@netlify/agent-runner-cli 1.176.0-has-db-from-site.0 → 1.176.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin-local.js CHANGED
@@ -141,7 +141,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
141
141
  `,LF:`
142
142
  `,concatBytes:rj},S6e=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},E6e={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:S6e};import{Buffer as v6e}from"buffer";var bue=(t,e)=>t?void 0:b6e.bind(void 0,e),b6e=function*(t,e){if(typeof e!="string"&&!Tr(e)&&!v6e.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Tue=(t,e)=>t?T6e.bind(void 0,e):w6e.bind(void 0,e),T6e=function*(t,e){wue(t,e),yield e},w6e=function*(t,e){if(wue(t,e),typeof e!="string"&&!Tr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},wue=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
143
143
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
144
- if (condition) { yield value; }`)};import{Buffer as A6e}from"buffer";import{StringDecoder as x6e}from"string_decoder";var TC=(t,e,r)=>{if(r)return;if(t)return{transform:R6e.bind(void 0,new TextEncoder)};let n=new x6e(e);return{transform:C6e.bind(void 0,n),final:I6e.bind(void 0,n)}},R6e=function*(t,e){A6e.isBuffer(e)?yield za(e):typeof e=="string"?yield t.encode(e):yield e},C6e=function*(t,e){yield Tr(e)?t.write(e):e},I6e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Aue}from"util";var ij=Aue(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),wC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=O6e}=e[r];for await(let i of n(t))yield*wC(i,e,r+1)},xue=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*P6e(r,Number(e),t)},P6e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*wC(n,r,e+1)},Rue=Aue(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),O6e=function*(t){yield t};var oj=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Cue=(t,e)=>[...e.flatMap(r=>[...wd(r,t,0)]),...EE(t)],wd=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=k6e}=e[r];for(let i of n(t))yield*wd(i,e,r+1)},EE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*N6e(r,Number(e),t)},N6e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*wd(n,r,e+1)},k6e=function*(t){yield t};var sj=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Pue(t,s,o),l=Td(e),u=Td(r),d=l?ij.bind(void 0,wC,a):oj.bind(void 0,wd),f=l||u?ij.bind(void 0,xue,a):oj.bind(void 0,EE),p=l||u?Rue.bind(void 0,a):void 0;return{stream:new M6e({writableObjectMode:n,writableHighWaterMark:Iue(n),readableObjectMode:i,readableHighWaterMark:Iue(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},AC=(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=Pue(s,r,a);t=Cue(c,t)}return t},Pue=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:bue(n,a)},TC(r,s,n),bC(r,o,n,c),{transform:t,final:e},{transform:Tue(i,a)},vue({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Oue=(t,e)=>{for(let r of $6e(t))D6e(t,r,e)},$6e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),D6e=(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 ${fl[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>L6e(a,n));r.input=uE(s)},L6e=(t,e)=>{let r=AC(t,e,"utf8",!0);return U6e(r),uE(r)},U6e=t=>{let e=t.find(r=>typeof r!="string"&&!Tr(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 B6e,appendFileSync as q6e}from"fs";var xC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ah(r,n)&&!wi.has(e)&&F6e(n)&&(t.some(({type:i,value:o})=>i==="native"&&z6e.has(o))||t.every(({type:i})=>Qi.has(i))),F6e=t=>t===1||t===2,z6e=new Set(["pipe","overlapped"]),Nue=async(t,e,r,n)=>{for await(let i of t)j6e(e)||Mue(i,r,n)},kue=(t,e,r)=>{for(let n of t)Mue(n,e,r)},j6e=t=>t._readableState.pipes.length>0,Mue=(t,e,r)=>{let n=z0(t);Os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var $ue=({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)=>V6e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},V6e=({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=Dle(t,o,d),p=za(f),{stdioItems:h,objectMode:m}=e[r],g=G6e([p],h,c,n),{serializedResult:_,finalResult:v=_}=H6e({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});W6e({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?v:void 0;try{return n.error===void 0&&Y6e(_,h,i),w}catch(E){return n.error=E,w}},G6e=(t,e,r,n)=>{try{return AC(t,e,r,!1)}catch(i){return n.error=i,t}},H6e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:uE(t)};let s=Zse(t,r);return n[o]?{serializedResult:s,finalResult:nj(s,!i[o],e)}:{serializedResult:s}},W6e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!xC({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=nj(t,!1,s);try{kue(a,e,n)}catch(c){r.error??=c}},Y6e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>EC.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?q6e(n,t):(r.add(o),B6e(n,t))}};var Due=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,qa(e,r,"all")]:Array.isArray(e)?[qa(t,r,"all"),...e]:Tr(t)&&Tr(e)?fz([t,e]):`${t}${e}`};import{once as aj}from"events";var Lue=async(t,e)=>{let[r,n]=await K6e(t);return e.isForcefullyTerminated??=!1,[r,n]},K6e=async t=>{let[e,r]=await Promise.allSettled([aj(t,"spawn"),aj(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Uue(t):r.value},Uue=async t=>{try{return await aj(t,"exit")}catch{return Uue(t)}},Fue=async t=>{let[e,r]=await t;if(!Z6e(e,r)&&cj(e,r))throw new Uo;return[e,r]},Z6e=(t,e)=>t===void 0&&e===void 0,cj=(t,e)=>t!==0||e!==null;var zue=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=J6e(t,e,r),s=o?.code==="ETIMEDOUT",a=$le(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},J6e=(t,e,r)=>t!==void 0?t:cj(e,r)?new Uo:void 0;var jue=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Q6e(t,e,r),d=r3e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return $h(d,c,l)},Q6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=B0(t,e,r),a=e3e(r),{file:c,commandArguments:l,options:u}=cC(t,e,a);t3e(u);let d=_ue(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},e3e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,t3e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&RC("ipcInput"),t&&RC("ipc: true"),r&&RC("detached: true"),n&&RC("cancelSignal")},RC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},r3e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=n3e({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}=zue(c,r),{output:h,error:m=l}=$ue({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,w)=>qa(v,r,w)),_=qa(Due(h,r),r,"all");return o3e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},n3e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Oue(o,r);let a=i3e(r);return X6e(...lC(t,e,a))}catch(a){return Mh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},i3e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:gC(e)}),o3e=({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?_C({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):SE({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 HWe}from"events";import{spawn as WWe}from"child_process";import Hue from"process";import{once as lj,on as s3e}from"events";var Bue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Ch({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:rC(t)}),a3e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),a3e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{X0(e,i);let o=dl(t,e,r),s=new AbortController;try{return await Promise.race([c3e(o,n,s),l3e(o,r,s),u3e(o,r,s)])}catch(a){throw Ih(t),a}finally{s.abort(),Q0(e,i)}},c3e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await lj(t,"message",{signal:r});return n}for await(let[n]of s3e(t,"message",{signal:r}))if(e(n))return n},l3e=async(t,e,{signal:r})=>{await lj(t,"disconnect",{signal:r}),Cce(e)},u3e=async(t,e,{signal:r})=>{let[n]=await lj(t,"strict:error",{signal:r});throw K0(n,e)};import{once as Vue,on as d3e}from"events";var Gue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>uj({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),uj=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Ch({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:rC(t)}),X0(e,o);let s=dl(t,e,r),a=new AbortController,c={};return f3e(t,s,a),p3e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),h3e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},f3e=async(t,e,r)=>{try{await Vue(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},p3e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Vue(t,"strict:error",{signal:r.signal});n.error=K0(i,e),r.abort()}catch{}},h3e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of d3e(r,"message",{signal:o.signal}))que(s),yield c}catch{que(s)}finally{o.abort(),Q0(e,a),n||Ih(t),i&&await t}},que=({error:t})=>{if(t)throw t};var Wue=(t,{ipc:e})=>{Object.assign(t,Kue(t,!1,e))},Yue=()=>{let t=Hue,e=!0,r=Hue.channel!==void 0;return{...Kue(t,e,r),getCancelSignal:tle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Kue=(t,e,r)=>({sendMessage:sC.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Bue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Gue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as m3e}from"child_process";import{PassThrough as g3e,Readable as _3e,Writable as y3e,Duplex as S3e}from"stream";var Zue=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ej(n);let a=new m3e;E3e(a,n),Object.assign(a,{readable:v3e,writable:b3e,duplex:T3e});let c=Mh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=w3e(c,s,i);return{subprocess:a,promise:l}},E3e=(t,e)=>{let r=vE(),n=vE(),i=vE(),o=Array.from({length:e.length-3},vE),s=vE(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},vE=()=>{let t=new g3e;return t.end(),t},v3e=()=>new _3e({read(){}}),b3e=()=>new y3e({write(){}}),T3e=()=>new S3e({read(){},write(){}}),w3e=async(t,e,r)=>$h(t,e,r);import{createReadStream as Jue,createWriteStream as Xue}from"fs";import{Buffer as A3e}from"buffer";import{Readable as bE,Writable as x3e,Duplex as R3e}from"stream";var ede=(t,e)=>vC(C3e,t,e,!1),TE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${fl[t]}.`)},Que={fileNumber:TE,generator:sj,asyncGenerator:sj,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:R3e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},C3e={input:{...Que,fileUrl:({value:t})=>({stream:Jue(t)}),filePath:({value:{file:t}})=>({stream:Jue(t)}),webStream:({value:t})=>({stream:bE.fromWeb(t)}),iterable:({value:t})=>({stream:bE.from(t)}),asyncIterable:({value:t})=>({stream:bE.from(t)}),string:({value:t})=>({stream:bE.from(t)}),uint8Array:({value:t})=>({stream:bE.from(A3e.from(t))})},output:{...Que,fileUrl:({value:t})=>({stream:Xue(t)}),filePath:({value:{file:t,append:e}})=>({stream:Xue(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:x3e.fromWeb(t)}),iterable:TE,asyncIterable:TE,string:TE,uint8Array:TE}};import{on as I3e,once as tde}from"events";import{PassThrough as P3e,getDefaultHighWaterMark as O3e}from"stream";import{finished as ide}from"stream/promises";function Ad(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)fj(i);let e=t.some(({readableObjectMode:i})=>i),r=N3e(t,e),n=new dj({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var N3e=(t,e)=>{if(t.length===0)return O3e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},dj=class extends P3e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(fj(e),this.#e.has(e))return;this.#e.add(e),this.#n??=k3e(this,this.#e,this.#o);let r=D3e({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(fj(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)}},k3e=async(t,e,r)=>{CC(t,rde);let n=new AbortController;try{await Promise.race([M3e(t,n),$3e(t,e,r,n)])}finally{n.abort(),CC(t,-rde)}},M3e=async(t,{signal:e})=>{try{await ide(t,{signal:e,cleanup:!0})}catch(r){throw ode(t,r),r}},$3e=async(t,e,r,{signal:n})=>{for await(let[i]of I3e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},fj=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},D3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{CC(t,nde);let a=new AbortController;try{await Promise.race([L3e(o,e,a),U3e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),F3e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),CC(t,-nde)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?pj(t):z3e(t))},L3e=async(t,e,{signal:r})=>{try{await t,r.aborted||pj(e)}catch(n){r.aborted||ode(e,n)}},U3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await ide(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;sde(s)?i.add(e):ade(t,s)}},F3e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await tde(t,i,{signal:o}),!t.readable)return tde(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},z3e=t=>{t.writable&&t.end()},ode=(t,e)=>{sde(e)?pj(t):ade(t,e)},sde=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",pj=t=>{(t.readable||t.writable)&&t.destroy()},ade=(t,e)=>{t.destroyed||(t.once("error",j3e),t.destroy(e))},j3e=()=>{},CC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},rde=2,nde=1;import{finished as cde}from"stream/promises";var Lh=(t,e)=>{t.pipe(e),B3e(t,e),q3e(t,e)},B3e=async(t,e)=>{if(!(Lo(t)||Lo(e))){try{await cde(t,{cleanup:!0,readable:!0,writable:!1})}catch{}hj(e)}},hj=t=>{t.writable&&t.end()},q3e=async(t,e)=>{if(!(Lo(t)||Lo(e))){try{await cde(e,{cleanup:!0,readable:!1,writable:!0})}catch{}mj(t)}},mj=t=>{t.readable&&t.destroy()};var lde=(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})=>Qi.has(c)))V3e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qi.has(c)))H3e({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]:Ad(o);Lh(s,i)}},V3e=(t,e,r,n)=>{r==="output"?Lh(t.stdio[n],e):Lh(e,t.stdio[n]);let i=G3e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},G3e=["stdin","stdout","stderr"],H3e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;W3e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},W3e=(t,{signal:e})=>{Lo(t)&&vd(t,Y3e,e)},Y3e=2;import{addAbortListener as J3e}from"events";var xd=[];xd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&xd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&xd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var IC=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",gj=Symbol.for("signal-exit emitter"),_j=globalThis,K3e=Object.defineProperty.bind(Object),yj=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(_j[gj])return _j[gj];K3e(_j,gj,{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}},PC=class{},Z3e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Sj=class extends PC{onExit(){return()=>{}}load(){}unload(){}},Ej=class extends PC{#e=vj.platform==="win32"?"SIGINT":"SIGHUP";#r=new yj;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of xd)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(!IC(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 xd)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,xd.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 IC(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"&&IC(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)}},vj=globalThis.process,{onExit:ude,load:ljt,unload:ujt}=Z3e(IC(vj)?new Ej(vj):new Sj);var dde=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ude(()=>{t.kill()});J3e(n,()=>{i()})};var pde=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=j0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=X3e(r,n,i),{sourceStream:d,sourceError:f}=eWe(t,l),{options:p,fileDescriptors:h}=ks.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},X3e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Q3e(t,e,...r),a=J0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Q3e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(fde,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||uz(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]=O0(r,...n);return{destination:e(fde)(i,o,s),pipeOptions:s}}if(ks.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}`)},fde=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),eWe=(t,e)=>{try{return{sourceStream:Ph(t,e)}}catch(r){return{sourceError:r}}};var mde=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=tWe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw bj({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},tWe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return mj(t),n;if(e!==void 0)return hj(r),e},bj=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mh({error:t,command:hde,escapedCommand:hde,fileDescriptors:e,options:r,startTime:n,isSync:!1}),hde="source.pipe(destination)";var gde=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 rWe}from"stream/promises";var _de=(t,e,r)=>{let n=OC.has(e)?iWe(t,e):nWe(t,e);return vd(t,sWe,r.signal),vd(e,aWe,r.signal),oWe(e),n},nWe=(t,e)=>{let r=Ad([t]);return Lh(r,e),OC.set(e,r),r},iWe=(t,e)=>{let r=OC.get(e);return r.add(t),r},oWe=async t=>{try{await rWe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}OC.delete(t)},OC=new WeakMap,sWe=2,aWe=1;import{aborted as cWe}from"util";var yde=(t,e)=>t===void 0?[]:[lWe(t,e)],lWe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await cWe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw bj({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var NC=(t,...e)=>{if(lr(e[0]))return NC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=pde(t,...e),i=uWe({...n,destination:r});return i.pipe=NC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},uWe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=dWe(t,i);mde({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=_de(e,o,d);return await Promise.race([gde(u),...yde(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},dWe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as yWe}from"timers/promises";import{on as fWe}from"events";import{getDefaultHighWaterMark as pWe}from"stream";var kC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return hWe(e,s),Ede({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},hWe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Tj=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;mWe(e,s,t);let a=t.readableObjectMode&&!o;return Ede({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},mWe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Ede=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=fWe(t,"data",{signal:e.signal,highWaterMark:Sde,highWatermark:Sde});return gWe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},wj=pWe(!0),Sde=wj,gWe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=_We({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*wd(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*EE(a)}},_We=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[TC(t,r,!e),bC(t,i,!n,{})].filter(Boolean);var vde=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=SWe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([EWe(t),d]);return}let f=tj(c,r),p=Tj({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([vWe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},SWe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!xC({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=Tj({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Nue(a,t,r,o)},EWe=async t=>{await yWe(),t.readableFlowing===null&&t.resume()},vWe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await pC(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await hC(r,{maxBuffer:o})):await kh(r,{maxBuffer:o})}catch(a){return bde(Nle({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},Aj=async t=>{try{return await t}catch(e){return bde(e)}},bde=({bufferedData:t})=>Yse(t)?new Uint8Array(t):t;import{finished as bWe}from"stream/promises";var wE=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=TWe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],bWe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||xWe(a,e,r,n)}finally{s.abort()}},TWe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&wWe(t,r,n),n},wWe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{AWe(e,r),n.call(t,...i)}},AWe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},xWe=(t,e,r,n)=>{if(!RWe(t,e,r,n))throw t},RWe=(t,e,r,n=!0)=>r.propagating?Tde(t)||MC(t):(r.propagating=!0,xj(r,e)===n?Tde(t):MC(t)),xj=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",MC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Tde=t=>t?.code==="EPIPE";var wde=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>Rj({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Rj=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=wE(t,e,l);if(xj(l,e)){await u;return}let[d]=await Promise.all([vde({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 Ade=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ad([t,e].filter(Boolean)):void 0,xde=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Rj({...CWe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:IWe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),CWe=({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}},IWe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as PWe}from"events";var Rde=t=>Ah(t,"ipc"),Cde=(t,e)=>{let r=z0(t);Os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Ide=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Rde(o),a=ja(e,"ipc"),c=ja(r,"ipc");for await(let l of uj({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(kle(t,i,c),i.push(l)),s&&Cde(l,o);return i},Pde=async(t,e)=>(await Promise.allSettled([t]),e);var Ode=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 v=Lue(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},E=wde({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),T=xde({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),A=[],C=Ide({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),I=OWe(m,t,w),N=NWe(h,w);try{return await Promise.race([Promise.all([{},Fue(v),Promise.all(E),T,C,dle(t,d),...I,...N]),g,kWe(t,_),...sle(t,o,f,_),...Rce({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...ile({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},v,Promise.all(E.map(b=>Aj(b))),Aj(T),Pde(C,A),Promise.allSettled(I),Promise.allSettled(N)])}},OWe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:wE(n,i,r)),NWe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>zo(o,{checkOpen:!1})&&!Lo(o)).map(({type:i,value:o,stream:s=o})=>wE(s,n,e,{isSameDirection:Qi.has(i),stopOnExit:i==="native"}))),kWe=async(t,{signal:e})=>{let[r]=await PWe(t,"error",{signal:e});throw r};var Nde=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),AE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Ns();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Uh=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 MWe}from"stream";import{callbackify as $We}from"util";import{finished as kde}from"stream/promises";var Cj=async t=>{if(t!==void 0)try{await Ij(t)}catch{}},Mde=async t=>{if(t!==void 0)try{await Pj(t)}catch{}},Ij=async t=>{await kde(t,{cleanup:!0,readable:!1,writable:!0})},Pj=async t=>{await kde(t,{cleanup:!0,readable:!0,writable:!1})},$C=async(t,e)=>{if(await t,e)throw e},DC=(t,e,r)=>{r&&!MC(r)?t.destroy(r):e&&t.destroy()};var $de=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||wi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Oj(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Nj(a,s),{read:f,onStdoutDataDone:p}=kj({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new MWe({read:f,destroy:$We($j.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Mj({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Oj=(t,e,r)=>{let n=Ph(t,e),i=AE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Nj=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:wj},kj=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Ns(),s=kC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){DWe(this,s,o)},onStdoutDataDone:o}},DWe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Mj=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Pj(t),await n,await Cj(i),await e,r.readable&&r.push(null)}catch(o){await Cj(i),Dde(r,o)}},$j=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Uh(r,e)&&(Dde(t,n),await $C(e,n))},Dde=(t,e)=>{DC(t,t.readable,e)};import{Writable as LWe}from"stream";import{callbackify as Lde}from"util";var Ude=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Dj(t,r,e),s=new LWe({...Lj(n,t,i),destroy:Lde(Fj.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Uj(n,s),s},Dj=(t,e,r)=>{let n=J0(t,e),i=AE(r,n,"writableFinal"),o=AE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Lj=(t,e,r)=>({write:UWe.bind(void 0,t),final:Lde(FWe.bind(void 0,t,e,r))}),UWe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},FWe=async(t,e,r)=>{await Uh(r,e)&&(t.writable&&t.end(),await e)},Uj=async(t,e,r)=>{try{await Ij(t),e.writable&&e.end()}catch(n){await Mde(r),Fde(e,n)}},Fj=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Uh(r,e),await Uh(n,e)&&(Fde(t,i),await $C(e,i))},Fde=(t,e)=>{DC(t,t.writable,e)};import{Duplex as zWe}from"stream";import{callbackify as jWe}from"util";var zde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||wi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Oj(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Dj(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Nj(c,a),{read:g,onStdoutDataDone:_}=kj({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new zWe({read:g,...Lj(u,t,d),destroy:jWe(BWe.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 Mj({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:t,subprocessStdin:u}),Uj(u,v,c),v},BWe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([$j({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Fj({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var zj=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||wi.has(e),s=Ph(t,r),a=kC({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return qWe(a,s,t)},qWe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var jde=(t,{encoding:e})=>{let r=Nde();t.readable=$de.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Ude.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=zde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zj.bind(void 0,t,e),t[Symbol.asyncIterator]=zj.bind(void 0,t,e,{})};var Bde=(t,e)=>{for(let[r,n]of GWe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},VWe=(async()=>{})().constructor.prototype,GWe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(VWe,t)]);var qde=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=YWe(t,e,r),{subprocess:f,promise:p}=ZWe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=NC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Bde(f,p),ks.set(f,{options:u,fileDescriptors:d}),f},YWe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=B0(t,e,r),{file:a,commandArguments:c,options:l}=cC(t,e,r),u=KWe(l),d=ede(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},KWe=({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}},ZWe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=WWe(...lC(t,e,r))}catch(h){return Zue({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;HWe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];lde(c,a,l),dde(c,r,l);let d={},f=Ns();c.kill=Ace.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Ade(c,r),jde(c,r),Wue(c,r);let p=JWe({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}},JWe=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 Ode({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((E,T)=>qa(E,e,T)),v=qa(m,e,"all"),w=XWe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return $h(w,n,e)},XWe=({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?SE({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 Ms,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):_C({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var LC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,QWe(n,t[n],i)]));return{...t,...r}},QWe=(t,e,r)=>eYe.has(t)&&lr(e)&&lr(r)?{...e,...r}:r,eYe=new Set(["env",...gz]);var pl=(t,e,r,n)=>{let i=(s,a,c)=>pl(s,a,r,c),o=(...s)=>tYe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},tYe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(lr(o))return i(t,LC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=rYe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?jue(a,c,l):qde(a,c,l,i)},rYe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=eae(e)?tae(e,r):[e,...r],[s,a,c]=O0(...o),l=LC(LC(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 Vde=({file:t,commandArguments:e})=>Hde(t,e),Gde=({file:t,commandArguments:e})=>({...Hde(t,e),isSync:!0}),Hde=(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]=nYe(t);return{file:r,commandArguments:n}},nYe=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(iYe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},iYe=/ +/g;var Wde=(t,e,r)=>{t.sync=e(oYe,r),t.s=t.sync},Yde=({options:t})=>Kde(t),oYe=({options:t})=>({...Kde(t),isSync:!0}),Kde=t=>({options:{...sYe(t),...t}}),sYe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Zde={preferLocal:!0};var Jde=pl(()=>({})),Q2t=pl(()=>({isSync:!0})),Xde=pl(Vde),eqt=pl(Gde),tqt=pl(cle),rqt=pl(Yde,{},Zde,Wde),{sendMessage:nqt,getOneMessage:iqt,getEachMessage:oqt,getCancelSignal:sqt}=Yue();var Qde=!1,efe=()=>{Qde=!0},Ds=()=>Qde;var xE=null,tfe=t=>(xE&&xE.destroy(),xE=new jo({totalAllowedTime:t}),xE),rfe=()=>xE;var jo=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&&Ds())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 y0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Z.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 nfe={name:"@netlify/agent-runner-cli",type:"module",version:"1.176.0-has-db-from-site.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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.17.6","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@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.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var uYe=cYe(import.meta.url),dYe=Va.dirname(uYe),fYe=lYe(import.meta.url),Fh=oe("shell"),jj=new Set,ife={preferLocal:!0},Ft=(t,e,r)=>{let[n,i]=pYe(e,r),o={...ife,...i},s=Jde(t,n,o);sfe(s,o),lfe(s);let a=r?.idleTimeout;return a&&a>0&&cfe(s,a),s},ofe=(t,e)=>{let r={...ife,...e},n=Xde(t,r);return sfe(n,r),lfe(n),e?.idleTimeout&&e.idleTimeout>0&&cfe(n,e.idleTimeout),n},pYe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},sfe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ls.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ls.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new tE).pipe(Ls.stdout),t.stderr?.pipe(new tE).pipe(Ls.stderr);return}t.stdout?.pipe(Ls.stdout),t.stderr?.pipe(Ls.stderr)},Bj=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ls.kill(-t.pid,e),Fh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Fh.error("Error killing process:",r),!1}},afe=t=>Bj(t,"SIGKILL"),cfe=(t,e)=>{let r=null,n=()=>{Fh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Bj(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fh.log(`Force killing idle process ${t.pid}`),afe(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)},lfe=t=>{jj.add(t);let e=rfe();if(e){let r=e.onTimesUp(()=>{Fh.log(`Global timer expired, killing process ${t.pid}`),Bj(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fh.log(`Force killing process ${t.pid} after timeout`),afe(t))},5e3)});t.on("exit",()=>{jj.delete(t),r()}),t.on("error",()=>{jj.delete(t),r()})}};function FC(t,e){return!!Bo(t,e)}function Bo(t,e){if(!Ls.env.NETLIFY_LOCAL_MODE)try{let i=fYe.resolve(nfe.name),o=Va.dirname(i);for(;o!==Va.dirname(o);){let s=Va.dirname(o);if(Va.basename(s)==="node_modules"){let a=Va.join(s,".bin",e);if(UC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ls.env.NODE_PATH){let i=Va.join(Ls.env.NODE_PATH,".bin",e);if(UC.existsSync(i))return i}let r=Va.join(t,"node_modules",".bin",e);if(UC.existsSync(r))return r;let n=Va.join(dYe,"..","node_modules",".bin",e);if(UC.existsSync(n))return n}var ufe=oe("repo"),mfe="runner-diffs-",gfe=t=>`${mfe}${t}-`,_fe=async t=>{let e=hfe.tmpdir(),r;try{r=await zC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(mfe)&&!n.startsWith(gfe(t))).map(n=>zC.rm(jC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},gn=(t,e={})=>Ft("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),BC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{ufe.info("Getting runner diffs");let n=await _Ye(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=vYe(o);await bYe(h,r)}ufe.info("Changes after processing"),await Vj(r);let s=await Gj(o,r);if(await qj(s,r),i=await yYe(r),!i)return{hasChanges:!1,ignored:s};await gn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await zC.mkdtemp(jC.join(hfe.tmpdir(),gfe(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let v=jC.join(a,g);await gn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${v}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:E}=await zC.stat(v);return{path:v,size:E}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await pfe(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await ffe(d,h)||(f=h)}await pfe(r),Z.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await ffe(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},dfe=async t=>{let e=hYe("sha256");for await(let r of mYe(t))e.update(r);return e.digest("hex")},ffe=async(t,e)=>t.size===e.size&&await dfe(t.path)===await dfe(e.path),pfe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await gn(["reset","--soft","HEAD~1"],{cwd:t})},qj=async(t=[],e=process.cwd())=>{await gn(["add",".",...t],{cwd:e})},Vj=async(t=process.cwd())=>{let e=await gn(["status","-s"],{cwd:t});return String(e.stdout??"")},yfe=/.. (.+)?\.log$/,gYe=[yfe],_Ye=async(t=process.cwd())=>{let e=await Vj(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
144
+ if (condition) { yield value; }`)};import{Buffer as A6e}from"buffer";import{StringDecoder as x6e}from"string_decoder";var TC=(t,e,r)=>{if(r)return;if(t)return{transform:R6e.bind(void 0,new TextEncoder)};let n=new x6e(e);return{transform:C6e.bind(void 0,n),final:I6e.bind(void 0,n)}},R6e=function*(t,e){A6e.isBuffer(e)?yield za(e):typeof e=="string"?yield t.encode(e):yield e},C6e=function*(t,e){yield Tr(e)?t.write(e):e},I6e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Aue}from"util";var ij=Aue(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),wC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=O6e}=e[r];for await(let i of n(t))yield*wC(i,e,r+1)},xue=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*P6e(r,Number(e),t)},P6e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*wC(n,r,e+1)},Rue=Aue(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),O6e=function*(t){yield t};var oj=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Cue=(t,e)=>[...e.flatMap(r=>[...wd(r,t,0)]),...EE(t)],wd=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=k6e}=e[r];for(let i of n(t))yield*wd(i,e,r+1)},EE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*N6e(r,Number(e),t)},N6e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*wd(n,r,e+1)},k6e=function*(t){yield t};var sj=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Pue(t,s,o),l=Td(e),u=Td(r),d=l?ij.bind(void 0,wC,a):oj.bind(void 0,wd),f=l||u?ij.bind(void 0,xue,a):oj.bind(void 0,EE),p=l||u?Rue.bind(void 0,a):void 0;return{stream:new M6e({writableObjectMode:n,writableHighWaterMark:Iue(n),readableObjectMode:i,readableHighWaterMark:Iue(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},AC=(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=Pue(s,r,a);t=Cue(c,t)}return t},Pue=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:bue(n,a)},TC(r,s,n),bC(r,o,n,c),{transform:t,final:e},{transform:Tue(i,a)},vue({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Oue=(t,e)=>{for(let r of $6e(t))D6e(t,r,e)},$6e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),D6e=(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 ${fl[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>L6e(a,n));r.input=uE(s)},L6e=(t,e)=>{let r=AC(t,e,"utf8",!0);return U6e(r),uE(r)},U6e=t=>{let e=t.find(r=>typeof r!="string"&&!Tr(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 B6e,appendFileSync as q6e}from"fs";var xC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ah(r,n)&&!wi.has(e)&&F6e(n)&&(t.some(({type:i,value:o})=>i==="native"&&z6e.has(o))||t.every(({type:i})=>Qi.has(i))),F6e=t=>t===1||t===2,z6e=new Set(["pipe","overlapped"]),Nue=async(t,e,r,n)=>{for await(let i of t)j6e(e)||Mue(i,r,n)},kue=(t,e,r)=>{for(let n of t)Mue(n,e,r)},j6e=t=>t._readableState.pipes.length>0,Mue=(t,e,r)=>{let n=z0(t);Os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var $ue=({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)=>V6e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},V6e=({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=Dle(t,o,d),p=za(f),{stdioItems:h,objectMode:m}=e[r],g=G6e([p],h,c,n),{serializedResult:_,finalResult:v=_}=H6e({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});W6e({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?v:void 0;try{return n.error===void 0&&Y6e(_,h,i),w}catch(E){return n.error=E,w}},G6e=(t,e,r,n)=>{try{return AC(t,e,r,!1)}catch(i){return n.error=i,t}},H6e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:uE(t)};let s=Zse(t,r);return n[o]?{serializedResult:s,finalResult:nj(s,!i[o],e)}:{serializedResult:s}},W6e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!xC({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=nj(t,!1,s);try{kue(a,e,n)}catch(c){r.error??=c}},Y6e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>EC.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?q6e(n,t):(r.add(o),B6e(n,t))}};var Due=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,qa(e,r,"all")]:Array.isArray(e)?[qa(t,r,"all"),...e]:Tr(t)&&Tr(e)?fz([t,e]):`${t}${e}`};import{once as aj}from"events";var Lue=async(t,e)=>{let[r,n]=await K6e(t);return e.isForcefullyTerminated??=!1,[r,n]},K6e=async t=>{let[e,r]=await Promise.allSettled([aj(t,"spawn"),aj(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Uue(t):r.value},Uue=async t=>{try{return await aj(t,"exit")}catch{return Uue(t)}},Fue=async t=>{let[e,r]=await t;if(!Z6e(e,r)&&cj(e,r))throw new Uo;return[e,r]},Z6e=(t,e)=>t===void 0&&e===void 0,cj=(t,e)=>t!==0||e!==null;var zue=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=J6e(t,e,r),s=o?.code==="ETIMEDOUT",a=$le(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},J6e=(t,e,r)=>t!==void 0?t:cj(e,r)?new Uo:void 0;var jue=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Q6e(t,e,r),d=r3e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return $h(d,c,l)},Q6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=B0(t,e,r),a=e3e(r),{file:c,commandArguments:l,options:u}=cC(t,e,a);t3e(u);let d=_ue(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},e3e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,t3e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&RC("ipcInput"),t&&RC("ipc: true"),r&&RC("detached: true"),n&&RC("cancelSignal")},RC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},r3e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=n3e({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}=zue(c,r),{output:h,error:m=l}=$ue({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,w)=>qa(v,r,w)),_=qa(Due(h,r),r,"all");return o3e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},n3e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Oue(o,r);let a=i3e(r);return X6e(...lC(t,e,a))}catch(a){return Mh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},i3e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:gC(e)}),o3e=({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?_C({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):SE({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 HWe}from"events";import{spawn as WWe}from"child_process";import Hue from"process";import{once as lj,on as s3e}from"events";var Bue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Ch({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:rC(t)}),a3e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),a3e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{X0(e,i);let o=dl(t,e,r),s=new AbortController;try{return await Promise.race([c3e(o,n,s),l3e(o,r,s),u3e(o,r,s)])}catch(a){throw Ih(t),a}finally{s.abort(),Q0(e,i)}},c3e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await lj(t,"message",{signal:r});return n}for await(let[n]of s3e(t,"message",{signal:r}))if(e(n))return n},l3e=async(t,e,{signal:r})=>{await lj(t,"disconnect",{signal:r}),Cce(e)},u3e=async(t,e,{signal:r})=>{let[n]=await lj(t,"strict:error",{signal:r});throw K0(n,e)};import{once as Vue,on as d3e}from"events";var Gue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>uj({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),uj=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Ch({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:rC(t)}),X0(e,o);let s=dl(t,e,r),a=new AbortController,c={};return f3e(t,s,a),p3e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),h3e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},f3e=async(t,e,r)=>{try{await Vue(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},p3e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Vue(t,"strict:error",{signal:r.signal});n.error=K0(i,e),r.abort()}catch{}},h3e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of d3e(r,"message",{signal:o.signal}))que(s),yield c}catch{que(s)}finally{o.abort(),Q0(e,a),n||Ih(t),i&&await t}},que=({error:t})=>{if(t)throw t};var Wue=(t,{ipc:e})=>{Object.assign(t,Kue(t,!1,e))},Yue=()=>{let t=Hue,e=!0,r=Hue.channel!==void 0;return{...Kue(t,e,r),getCancelSignal:tle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Kue=(t,e,r)=>({sendMessage:sC.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Bue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Gue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as m3e}from"child_process";import{PassThrough as g3e,Readable as _3e,Writable as y3e,Duplex as S3e}from"stream";var Zue=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ej(n);let a=new m3e;E3e(a,n),Object.assign(a,{readable:v3e,writable:b3e,duplex:T3e});let c=Mh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=w3e(c,s,i);return{subprocess:a,promise:l}},E3e=(t,e)=>{let r=vE(),n=vE(),i=vE(),o=Array.from({length:e.length-3},vE),s=vE(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},vE=()=>{let t=new g3e;return t.end(),t},v3e=()=>new _3e({read(){}}),b3e=()=>new y3e({write(){}}),T3e=()=>new S3e({read(){},write(){}}),w3e=async(t,e,r)=>$h(t,e,r);import{createReadStream as Jue,createWriteStream as Xue}from"fs";import{Buffer as A3e}from"buffer";import{Readable as bE,Writable as x3e,Duplex as R3e}from"stream";var ede=(t,e)=>vC(C3e,t,e,!1),TE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${fl[t]}.`)},Que={fileNumber:TE,generator:sj,asyncGenerator:sj,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:R3e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},C3e={input:{...Que,fileUrl:({value:t})=>({stream:Jue(t)}),filePath:({value:{file:t}})=>({stream:Jue(t)}),webStream:({value:t})=>({stream:bE.fromWeb(t)}),iterable:({value:t})=>({stream:bE.from(t)}),asyncIterable:({value:t})=>({stream:bE.from(t)}),string:({value:t})=>({stream:bE.from(t)}),uint8Array:({value:t})=>({stream:bE.from(A3e.from(t))})},output:{...Que,fileUrl:({value:t})=>({stream:Xue(t)}),filePath:({value:{file:t,append:e}})=>({stream:Xue(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:x3e.fromWeb(t)}),iterable:TE,asyncIterable:TE,string:TE,uint8Array:TE}};import{on as I3e,once as tde}from"events";import{PassThrough as P3e,getDefaultHighWaterMark as O3e}from"stream";import{finished as ide}from"stream/promises";function Ad(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)fj(i);let e=t.some(({readableObjectMode:i})=>i),r=N3e(t,e),n=new dj({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var N3e=(t,e)=>{if(t.length===0)return O3e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},dj=class extends P3e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(fj(e),this.#e.has(e))return;this.#e.add(e),this.#n??=k3e(this,this.#e,this.#o);let r=D3e({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(fj(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)}},k3e=async(t,e,r)=>{CC(t,rde);let n=new AbortController;try{await Promise.race([M3e(t,n),$3e(t,e,r,n)])}finally{n.abort(),CC(t,-rde)}},M3e=async(t,{signal:e})=>{try{await ide(t,{signal:e,cleanup:!0})}catch(r){throw ode(t,r),r}},$3e=async(t,e,r,{signal:n})=>{for await(let[i]of I3e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},fj=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},D3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{CC(t,nde);let a=new AbortController;try{await Promise.race([L3e(o,e,a),U3e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),F3e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),CC(t,-nde)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?pj(t):z3e(t))},L3e=async(t,e,{signal:r})=>{try{await t,r.aborted||pj(e)}catch(n){r.aborted||ode(e,n)}},U3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await ide(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;sde(s)?i.add(e):ade(t,s)}},F3e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await tde(t,i,{signal:o}),!t.readable)return tde(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},z3e=t=>{t.writable&&t.end()},ode=(t,e)=>{sde(e)?pj(t):ade(t,e)},sde=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",pj=t=>{(t.readable||t.writable)&&t.destroy()},ade=(t,e)=>{t.destroyed||(t.once("error",j3e),t.destroy(e))},j3e=()=>{},CC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},rde=2,nde=1;import{finished as cde}from"stream/promises";var Lh=(t,e)=>{t.pipe(e),B3e(t,e),q3e(t,e)},B3e=async(t,e)=>{if(!(Lo(t)||Lo(e))){try{await cde(t,{cleanup:!0,readable:!0,writable:!1})}catch{}hj(e)}},hj=t=>{t.writable&&t.end()},q3e=async(t,e)=>{if(!(Lo(t)||Lo(e))){try{await cde(e,{cleanup:!0,readable:!1,writable:!0})}catch{}mj(t)}},mj=t=>{t.readable&&t.destroy()};var lde=(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})=>Qi.has(c)))V3e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qi.has(c)))H3e({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]:Ad(o);Lh(s,i)}},V3e=(t,e,r,n)=>{r==="output"?Lh(t.stdio[n],e):Lh(e,t.stdio[n]);let i=G3e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},G3e=["stdin","stdout","stderr"],H3e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;W3e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},W3e=(t,{signal:e})=>{Lo(t)&&vd(t,Y3e,e)},Y3e=2;import{addAbortListener as J3e}from"events";var xd=[];xd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&xd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&xd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var IC=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",gj=Symbol.for("signal-exit emitter"),_j=globalThis,K3e=Object.defineProperty.bind(Object),yj=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(_j[gj])return _j[gj];K3e(_j,gj,{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}},PC=class{},Z3e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Sj=class extends PC{onExit(){return()=>{}}load(){}unload(){}},Ej=class extends PC{#e=vj.platform==="win32"?"SIGINT":"SIGHUP";#r=new yj;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of xd)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(!IC(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 xd)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,xd.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 IC(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"&&IC(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)}},vj=globalThis.process,{onExit:ude,load:ljt,unload:ujt}=Z3e(IC(vj)?new Ej(vj):new Sj);var dde=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ude(()=>{t.kill()});J3e(n,()=>{i()})};var pde=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=j0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=X3e(r,n,i),{sourceStream:d,sourceError:f}=eWe(t,l),{options:p,fileDescriptors:h}=ks.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},X3e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Q3e(t,e,...r),a=J0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Q3e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(fde,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||uz(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]=O0(r,...n);return{destination:e(fde)(i,o,s),pipeOptions:s}}if(ks.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}`)},fde=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),eWe=(t,e)=>{try{return{sourceStream:Ph(t,e)}}catch(r){return{sourceError:r}}};var mde=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=tWe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw bj({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},tWe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return mj(t),n;if(e!==void 0)return hj(r),e},bj=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mh({error:t,command:hde,escapedCommand:hde,fileDescriptors:e,options:r,startTime:n,isSync:!1}),hde="source.pipe(destination)";var gde=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 rWe}from"stream/promises";var _de=(t,e,r)=>{let n=OC.has(e)?iWe(t,e):nWe(t,e);return vd(t,sWe,r.signal),vd(e,aWe,r.signal),oWe(e),n},nWe=(t,e)=>{let r=Ad([t]);return Lh(r,e),OC.set(e,r),r},iWe=(t,e)=>{let r=OC.get(e);return r.add(t),r},oWe=async t=>{try{await rWe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}OC.delete(t)},OC=new WeakMap,sWe=2,aWe=1;import{aborted as cWe}from"util";var yde=(t,e)=>t===void 0?[]:[lWe(t,e)],lWe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await cWe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw bj({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var NC=(t,...e)=>{if(lr(e[0]))return NC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=pde(t,...e),i=uWe({...n,destination:r});return i.pipe=NC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},uWe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=dWe(t,i);mde({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=_de(e,o,d);return await Promise.race([gde(u),...yde(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},dWe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as yWe}from"timers/promises";import{on as fWe}from"events";import{getDefaultHighWaterMark as pWe}from"stream";var kC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return hWe(e,s),Ede({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},hWe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Tj=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;mWe(e,s,t);let a=t.readableObjectMode&&!o;return Ede({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},mWe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Ede=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=fWe(t,"data",{signal:e.signal,highWaterMark:Sde,highWatermark:Sde});return gWe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},wj=pWe(!0),Sde=wj,gWe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=_We({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*wd(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*EE(a)}},_We=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[TC(t,r,!e),bC(t,i,!n,{})].filter(Boolean);var vde=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=SWe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([EWe(t),d]);return}let f=tj(c,r),p=Tj({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([vWe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},SWe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!xC({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=Tj({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Nue(a,t,r,o)},EWe=async t=>{await yWe(),t.readableFlowing===null&&t.resume()},vWe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await pC(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await hC(r,{maxBuffer:o})):await kh(r,{maxBuffer:o})}catch(a){return bde(Nle({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},Aj=async t=>{try{return await t}catch(e){return bde(e)}},bde=({bufferedData:t})=>Yse(t)?new Uint8Array(t):t;import{finished as bWe}from"stream/promises";var wE=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=TWe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],bWe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||xWe(a,e,r,n)}finally{s.abort()}},TWe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&wWe(t,r,n),n},wWe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{AWe(e,r),n.call(t,...i)}},AWe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},xWe=(t,e,r,n)=>{if(!RWe(t,e,r,n))throw t},RWe=(t,e,r,n=!0)=>r.propagating?Tde(t)||MC(t):(r.propagating=!0,xj(r,e)===n?Tde(t):MC(t)),xj=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",MC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Tde=t=>t?.code==="EPIPE";var wde=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>Rj({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Rj=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=wE(t,e,l);if(xj(l,e)){await u;return}let[d]=await Promise.all([vde({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 Ade=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ad([t,e].filter(Boolean)):void 0,xde=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Rj({...CWe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:IWe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),CWe=({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}},IWe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as PWe}from"events";var Rde=t=>Ah(t,"ipc"),Cde=(t,e)=>{let r=z0(t);Os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Ide=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Rde(o),a=ja(e,"ipc"),c=ja(r,"ipc");for await(let l of uj({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(kle(t,i,c),i.push(l)),s&&Cde(l,o);return i},Pde=async(t,e)=>(await Promise.allSettled([t]),e);var Ode=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 v=Lue(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},E=wde({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),T=xde({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),A=[],C=Ide({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),I=OWe(m,t,w),N=NWe(h,w);try{return await Promise.race([Promise.all([{},Fue(v),Promise.all(E),T,C,dle(t,d),...I,...N]),g,kWe(t,_),...sle(t,o,f,_),...Rce({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...ile({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},v,Promise.all(E.map(b=>Aj(b))),Aj(T),Pde(C,A),Promise.allSettled(I),Promise.allSettled(N)])}},OWe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:wE(n,i,r)),NWe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>zo(o,{checkOpen:!1})&&!Lo(o)).map(({type:i,value:o,stream:s=o})=>wE(s,n,e,{isSameDirection:Qi.has(i),stopOnExit:i==="native"}))),kWe=async(t,{signal:e})=>{let[r]=await PWe(t,"error",{signal:e});throw r};var Nde=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),AE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Ns();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Uh=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 MWe}from"stream";import{callbackify as $We}from"util";import{finished as kde}from"stream/promises";var Cj=async t=>{if(t!==void 0)try{await Ij(t)}catch{}},Mde=async t=>{if(t!==void 0)try{await Pj(t)}catch{}},Ij=async t=>{await kde(t,{cleanup:!0,readable:!1,writable:!0})},Pj=async t=>{await kde(t,{cleanup:!0,readable:!0,writable:!1})},$C=async(t,e)=>{if(await t,e)throw e},DC=(t,e,r)=>{r&&!MC(r)?t.destroy(r):e&&t.destroy()};var $de=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||wi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Oj(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Nj(a,s),{read:f,onStdoutDataDone:p}=kj({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new MWe({read:f,destroy:$We($j.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Mj({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Oj=(t,e,r)=>{let n=Ph(t,e),i=AE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Nj=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:wj},kj=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Ns(),s=kC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){DWe(this,s,o)},onStdoutDataDone:o}},DWe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Mj=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Pj(t),await n,await Cj(i),await e,r.readable&&r.push(null)}catch(o){await Cj(i),Dde(r,o)}},$j=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Uh(r,e)&&(Dde(t,n),await $C(e,n))},Dde=(t,e)=>{DC(t,t.readable,e)};import{Writable as LWe}from"stream";import{callbackify as Lde}from"util";var Ude=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Dj(t,r,e),s=new LWe({...Lj(n,t,i),destroy:Lde(Fj.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Uj(n,s),s},Dj=(t,e,r)=>{let n=J0(t,e),i=AE(r,n,"writableFinal"),o=AE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Lj=(t,e,r)=>({write:UWe.bind(void 0,t),final:Lde(FWe.bind(void 0,t,e,r))}),UWe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},FWe=async(t,e,r)=>{await Uh(r,e)&&(t.writable&&t.end(),await e)},Uj=async(t,e,r)=>{try{await Ij(t),e.writable&&e.end()}catch(n){await Mde(r),Fde(e,n)}},Fj=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Uh(r,e),await Uh(n,e)&&(Fde(t,i),await $C(e,i))},Fde=(t,e)=>{DC(t,t.writable,e)};import{Duplex as zWe}from"stream";import{callbackify as jWe}from"util";var zde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||wi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Oj(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Dj(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Nj(c,a),{read:g,onStdoutDataDone:_}=kj({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new zWe({read:g,...Lj(u,t,d),destroy:jWe(BWe.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 Mj({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:t,subprocessStdin:u}),Uj(u,v,c),v},BWe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([$j({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Fj({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var zj=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||wi.has(e),s=Ph(t,r),a=kC({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return qWe(a,s,t)},qWe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var jde=(t,{encoding:e})=>{let r=Nde();t.readable=$de.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Ude.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=zde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zj.bind(void 0,t,e),t[Symbol.asyncIterator]=zj.bind(void 0,t,e,{})};var Bde=(t,e)=>{for(let[r,n]of GWe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},VWe=(async()=>{})().constructor.prototype,GWe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(VWe,t)]);var qde=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=YWe(t,e,r),{subprocess:f,promise:p}=ZWe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=NC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Bde(f,p),ks.set(f,{options:u,fileDescriptors:d}),f},YWe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=B0(t,e,r),{file:a,commandArguments:c,options:l}=cC(t,e,r),u=KWe(l),d=ede(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},KWe=({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}},ZWe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=WWe(...lC(t,e,r))}catch(h){return Zue({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;HWe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];lde(c,a,l),dde(c,r,l);let d={},f=Ns();c.kill=Ace.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Ade(c,r),jde(c,r),Wue(c,r);let p=JWe({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}},JWe=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 Ode({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((E,T)=>qa(E,e,T)),v=qa(m,e,"all"),w=XWe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return $h(w,n,e)},XWe=({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?SE({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 Ms,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):_C({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var LC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,QWe(n,t[n],i)]));return{...t,...r}},QWe=(t,e,r)=>eYe.has(t)&&lr(e)&&lr(r)?{...e,...r}:r,eYe=new Set(["env",...gz]);var pl=(t,e,r,n)=>{let i=(s,a,c)=>pl(s,a,r,c),o=(...s)=>tYe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},tYe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(lr(o))return i(t,LC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=rYe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?jue(a,c,l):qde(a,c,l,i)},rYe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=eae(e)?tae(e,r):[e,...r],[s,a,c]=O0(...o),l=LC(LC(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 Vde=({file:t,commandArguments:e})=>Hde(t,e),Gde=({file:t,commandArguments:e})=>({...Hde(t,e),isSync:!0}),Hde=(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]=nYe(t);return{file:r,commandArguments:n}},nYe=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(iYe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},iYe=/ +/g;var Wde=(t,e,r)=>{t.sync=e(oYe,r),t.s=t.sync},Yde=({options:t})=>Kde(t),oYe=({options:t})=>({...Kde(t),isSync:!0}),Kde=t=>({options:{...sYe(t),...t}}),sYe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Zde={preferLocal:!0};var Jde=pl(()=>({})),Q2t=pl(()=>({isSync:!0})),Xde=pl(Vde),eqt=pl(Gde),tqt=pl(cle),rqt=pl(Yde,{},Zde,Wde),{sendMessage:nqt,getOneMessage:iqt,getEachMessage:oqt,getCancelSignal:sqt}=Yue();var Qde=!1,efe=()=>{Qde=!0},Ds=()=>Qde;var xE=null,tfe=t=>(xE&&xE.destroy(),xE=new jo({totalAllowedTime:t}),xE),rfe=()=>xE;var jo=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&&Ds())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 y0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Z.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 nfe={name:"@netlify/agent-runner-cli",type:"module",version:"1.176.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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.17.6","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@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.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var uYe=cYe(import.meta.url),dYe=Va.dirname(uYe),fYe=lYe(import.meta.url),Fh=oe("shell"),jj=new Set,ife={preferLocal:!0},Ft=(t,e,r)=>{let[n,i]=pYe(e,r),o={...ife,...i},s=Jde(t,n,o);sfe(s,o),lfe(s);let a=r?.idleTimeout;return a&&a>0&&cfe(s,a),s},ofe=(t,e)=>{let r={...ife,...e},n=Xde(t,r);return sfe(n,r),lfe(n),e?.idleTimeout&&e.idleTimeout>0&&cfe(n,e.idleTimeout),n},pYe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},sfe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ls.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ls.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new tE).pipe(Ls.stdout),t.stderr?.pipe(new tE).pipe(Ls.stderr);return}t.stdout?.pipe(Ls.stdout),t.stderr?.pipe(Ls.stderr)},Bj=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ls.kill(-t.pid,e),Fh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Fh.error("Error killing process:",r),!1}},afe=t=>Bj(t,"SIGKILL"),cfe=(t,e)=>{let r=null,n=()=>{Fh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Bj(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fh.log(`Force killing idle process ${t.pid}`),afe(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)},lfe=t=>{jj.add(t);let e=rfe();if(e){let r=e.onTimesUp(()=>{Fh.log(`Global timer expired, killing process ${t.pid}`),Bj(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fh.log(`Force killing process ${t.pid} after timeout`),afe(t))},5e3)});t.on("exit",()=>{jj.delete(t),r()}),t.on("error",()=>{jj.delete(t),r()})}};function FC(t,e){return!!Bo(t,e)}function Bo(t,e){if(!Ls.env.NETLIFY_LOCAL_MODE)try{let i=fYe.resolve(nfe.name),o=Va.dirname(i);for(;o!==Va.dirname(o);){let s=Va.dirname(o);if(Va.basename(s)==="node_modules"){let a=Va.join(s,".bin",e);if(UC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ls.env.NODE_PATH){let i=Va.join(Ls.env.NODE_PATH,".bin",e);if(UC.existsSync(i))return i}let r=Va.join(t,"node_modules",".bin",e);if(UC.existsSync(r))return r;let n=Va.join(dYe,"..","node_modules",".bin",e);if(UC.existsSync(n))return n}var ufe=oe("repo"),mfe="runner-diffs-",gfe=t=>`${mfe}${t}-`,_fe=async t=>{let e=hfe.tmpdir(),r;try{r=await zC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(mfe)&&!n.startsWith(gfe(t))).map(n=>zC.rm(jC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},gn=(t,e={})=>Ft("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),BC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{ufe.info("Getting runner diffs");let n=await _Ye(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=vYe(o);await bYe(h,r)}ufe.info("Changes after processing"),await Vj(r);let s=await Gj(o,r);if(await qj(s,r),i=await yYe(r),!i)return{hasChanges:!1,ignored:s};await gn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await zC.mkdtemp(jC.join(hfe.tmpdir(),gfe(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let v=jC.join(a,g);await gn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${v}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:E}=await zC.stat(v);return{path:v,size:E}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await pfe(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await ffe(d,h)||(f=h)}await pfe(r),Z.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await ffe(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},dfe=async t=>{let e=hYe("sha256");for await(let r of mYe(t))e.update(r);return e.digest("hex")},ffe=async(t,e)=>t.size===e.size&&await dfe(t.path)===await dfe(e.path),pfe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await gn(["reset","--soft","HEAD~1"],{cwd:t})},qj=async(t=[],e=process.cwd())=>{await gn(["add",".",...t],{cwd:e})},Vj=async(t=process.cwd())=>{let e=await gn(["status","-s"],{cwd:t});return String(e.stdout??"")},yfe=/.. (.+)?\.log$/,gYe=[yfe],_Ye=async(t=process.cwd())=>{let e=await Vj(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
145
145
  `).filter(i=>gYe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},yYe=async(t=process.cwd())=>{try{return await gn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},RE=async(t=process.cwd())=>{let{stdout:e}=await gn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},SYe=1,EYe=async t=>{try{return await gn(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===SYe)return!1;throw e}},Sfe=async(t=process.cwd())=>{if(!await EYe(t))return!0;let{stdout:e}=await gn(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},Efe=async(t=process.cwd())=>{let{stdout:e}=await gn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},Gj=async(t,e=process.cwd())=>{t||=await Vj(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(`
146
146
  `).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${jC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(yfe)?.[1];o&&n.push(`:!${o}.log`)}),n},vfe=async(t=process.cwd())=>{await gn(["reset","--hard","HEAD"],{cwd:t})},bfe=async(t=process.cwd())=>{let e=await gn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
147
147
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},vYe=t=>{let e=t.split(`
package/dist/bin.js CHANGED
@@ -631,7 +631,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
631
631
  `,LF:`
632
632
  `,concatBytes:MK},zAt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},qAt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:zAt};import{Buffer as BAt}from"buffer";var mxe=(t,e)=>t?void 0:VAt.bind(void 0,e),VAt=function*(t,e){if(typeof e!="string"&&!nn(e)&&!BAt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},gxe=(t,e)=>t?HAt.bind(void 0,e):GAt.bind(void 0,e),HAt=function*(t,e){_xe(t,e),yield e},GAt=function*(t,e){if(_xe(t,e),typeof e!="string"&&!nn(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},_xe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
633
633
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
634
- if (condition) { yield value; }`)};import{Buffer as WAt}from"buffer";import{StringDecoder as YAt}from"string_decoder";var Yk=(t,e,r)=>{if(r)return;if(t)return{transform:KAt.bind(void 0,new TextEncoder)};let n=new YAt(e);return{transform:JAt.bind(void 0,n),final:ZAt.bind(void 0,n)}},KAt=function*(t,e){WAt.isBuffer(e)?yield cl(e):typeof e=="string"?yield t.encode(e):yield e},JAt=function*(t,e){yield nn(e)?t.write(e):e},ZAt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as yxe}from"util";var FK=yxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Kk=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QAt}=e[r];for await(let i of n(t))yield*Kk(i,e,r+1)},Sxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XAt(r,Number(e),t)},XAt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Kk(n,r,e+1)},Exe=yxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),QAt=function*(t){yield t};var jK=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},vxe=(t,e)=>[...e.flatMap(r=>[...zp(r,t,0)]),...zw(t)],zp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=txt}=e[r];for(let i of n(t))yield*zp(i,e,r+1)},zw=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ext(r,Number(e),t)},ext=function*(t,e,r){if(t!==void 0)for(let n of t())yield*zp(n,r,e+1)},txt=function*(t){yield t};var zK=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Txe(t,o,s),l=jp(e),u=jp(r),d=l?FK.bind(void 0,Kk,a):jK.bind(void 0,zp),f=l||u?FK.bind(void 0,Sxe,a):jK.bind(void 0,zw),p=l||u?Exe.bind(void 0,a):void 0;return{stream:new rxt({writableObjectMode:n,writableHighWaterMark:bxe(n),readableObjectMode:i,readableHighWaterMark:bxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},Jk=(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=Txe(o,r,a);t=vxe(c,t)}return t},Txe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:mxe(n,a)},Yk(r,o,n),Wk(r,s,n,c),{transform:t,final:e},{transform:gxe(i,a)},hxe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var wxe=(t,e)=>{for(let r of nxt(t))ixt(t,r,e)},nxt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),ixt=(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 ${pd[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>sxt(a,n));r.input=Ow(o)},sxt=(t,e)=>{let r=Jk(t,e,"utf8",!0);return oxt(r),Ow(r)},oxt=t=>{let e=t.find(r=>typeof r!="string"&&!nn(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 uxt,appendFileSync as dxt}from"fs";var Zk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Z_(r,n)&&!ys.has(e)&&axt(n)&&(t.some(({type:i,value:s})=>i==="native"&&cxt.has(s))||t.every(({type:i})=>to.has(i))),axt=t=>t===1||t===2,cxt=new Set(["pipe","overlapped"]),Rxe=async(t,e,r,n)=>{for await(let i of t)lxt(e)||xxe(i,r,n)},Axe=(t,e,r)=>{for(let n of t)xxe(n,e,r)},lxt=t=>t._readableState.pipes.length>0,xxe=(t,e,r)=>{let n=dk(t);La({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Cxe=({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)=>fxt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},fxt=({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=PAe(t,s,d),p=cl(f),{stdioItems:h,objectMode:m}=e[r],_=pxt([p],h,c,n),{serializedResult:y,finalResult:E=y}=hxt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});mxt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&gxt(y,h,i),S}catch(g){return n.error=g,S}},pxt=(t,e,r,n)=>{try{return Jk(t,e,r,!1)}catch(i){return n.error=i,t}},hxt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Ow(t)};let o=Bwe(t,r);return n[s]?{serializedResult:o,finalResult:UK(o,!i[s],e)}:{serializedResult:o}},mxt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!Zk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=UK(t,!1,o);try{Axe(a,e,n)}catch(c){r.error??=c}},gxt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>Hk.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?dxt(n,t):(r.add(s),uxt(n,t))}};var Pxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,dl(e,r,"all")]:Array.isArray(e)?[dl(t,r,"all"),...e]:nn(t)&&nn(e)?WY([t,e]):`${t}${e}`};import{once as qK}from"events";var Ixe=async(t,e)=>{let[r,n]=await _xt(t);return e.isForcefullyTerminated??=!1,[r,n]},_xt=async t=>{let[e,r]=await Promise.allSettled([qK(t,"spawn"),qK(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Oxe(t):r.value},Oxe=async t=>{try{return await qK(t,"exit")}catch{return Oxe(t)}},Nxe=async t=>{let[e,r]=await t;if(!yxt(e,r)&&BK(e,r))throw new $o;return[e,r]},yxt=(t,e)=>t===void 0&&e===void 0,BK=(t,e)=>t!==0||e!==null;var kxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Sxt(t,e,r),o=s?.code==="ETIMEDOUT",a=CAe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Sxt=(t,e,r)=>t!==void 0?t:BK(e,r)?new $o:void 0;var $xe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=vxt(t,e,r),d=wxt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return ay(d,c,l)},vxt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pk(t,e,r),a=bxt(r),{file:c,commandArguments:l,options:u}=kk(t,e,a);Txt(u);let d=uxe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},bxt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Txt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Xk("ipcInput"),t&&Xk("ipc: true"),r&&Xk("detached: true"),n&&Xk("cancelSignal")},Xk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},wxt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Rxt({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}=kxe(c,r),{output:h,error:m=l}=Cxe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,S)=>dl(E,r,S)),y=dl(Pxe(h,r),r,"all");return xxt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Rxt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{wxe(s,r);let a=Axt(r);return Ext(...$k(t,e,a))}catch(a){return oy({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Axt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:zk(e)}),xxt=({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?qk({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):jw({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 hPt}from"events";import{spawn as mPt}from"child_process";import Fxe from"process";import{once as VK,on as Cxt}from"events";var Lxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(ey({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:xk(t)}),Pxt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Pxt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{Tk(e,i);let s=fd(t,e,r),o=new AbortController;try{return await Promise.race([Ixt(s,n,o),Oxt(s,r,o),Nxt(s,r,o)])}catch(a){throw ty(t),a}finally{o.abort(),wk(e,i)}},Ixt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await VK(t,"message",{signal:r});return n}for await(let[n]of Cxt(t,"message",{signal:r}))if(e(n))return n},Oxt=async(t,e,{signal:r})=>{await VK(t,"disconnect",{signal:r}),v0e(e)},Nxt=async(t,e,{signal:r})=>{let[n]=await VK(t,"strict:error",{signal:r});throw Ek(n,e)};import{once as Mxe,on as kxt}from"events";var Uxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>HK({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),HK=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{ey({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:xk(t)}),Tk(e,s);let o=fd(t,e,r),a=new AbortController,c={};return $xt(t,o,a),Lxt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Dxt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},$xt=async(t,e,r)=>{try{await Mxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Lxt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Mxe(t,"strict:error",{signal:r.signal});n.error=Ek(i,e),r.abort()}catch{}},Dxt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of kxt(r,"message",{signal:s.signal}))Dxe(o),yield c}catch{Dxe(o)}finally{s.abort(),wk(e,a),n||ty(t),i&&await t}},Dxe=({error:t})=>{if(t)throw t};var jxe=(t,{ipc:e})=>{Object.assign(t,qxe(t,!1,e))},zxe=()=>{let t=Fxe,e=!0,r=Fxe.channel!==void 0;return{...qxe(t,e,r),getCancelSignal:Y0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},qxe=(t,e,r)=>({sendMessage:Ok.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Lxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Uxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Mxt}from"child_process";import{PassThrough as Uxt,Readable as Fxt,Writable as jxt,Duplex as zxt}from"stream";var Bxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{LK(n);let a=new Mxt;qxt(a,n),Object.assign(a,{readable:Bxt,writable:Vxt,duplex:Hxt});let c=oy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Gxt(c,o,i);return{subprocess:a,promise:l}},qxt=(t,e)=>{let r=qw(),n=qw(),i=qw(),s=Array.from({length:e.length-3},qw),o=qw(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},qw=()=>{let t=new Uxt;return t.end(),t},Bxt=()=>new Fxt({read(){}}),Vxt=()=>new jxt({write(){}}),Hxt=()=>new zxt({read(){},write(){}}),Gxt=async(t,e,r)=>ay(t,e,r);import{createReadStream as Vxe,createWriteStream as Hxe}from"fs";import{Buffer as Wxt}from"buffer";import{Readable as Bw,Writable as Yxt,Duplex as Kxt}from"stream";var Wxe=(t,e)=>Gk(Jxt,t,e,!1),Vw=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Gxe={fileNumber:Vw,generator:zK,asyncGenerator:zK,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Kxt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Jxt={input:{...Gxe,fileUrl:({value:t})=>({stream:Vxe(t)}),filePath:({value:{file:t}})=>({stream:Vxe(t)}),webStream:({value:t})=>({stream:Bw.fromWeb(t)}),iterable:({value:t})=>({stream:Bw.from(t)}),asyncIterable:({value:t})=>({stream:Bw.from(t)}),string:({value:t})=>({stream:Bw.from(t)}),uint8Array:({value:t})=>({stream:Bw.from(Wxt.from(t))})},output:{...Gxe,fileUrl:({value:t})=>({stream:Hxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Hxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Yxt.fromWeb(t)}),iterable:Vw,asyncIterable:Vw,string:Vw,uint8Array:Vw}};import{on as Zxt,once as Yxe}from"events";import{PassThrough as Xxt,getDefaultHighWaterMark as Qxt}from"stream";import{finished as Zxe}from"stream/promises";function qp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)WK(i);let e=t.some(({readableObjectMode:i})=>i),r=eCt(t,e),n=new GK({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var eCt=(t,e)=>{if(t.length===0)return Qxt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},GK=class extends Xxt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(WK(e),this.#e.has(e))return;this.#e.add(e),this.#n??=tCt(this,this.#e,this.#s);let r=iCt({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(WK(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)}},tCt=async(t,e,r)=>{Qk(t,Kxe);let n=new AbortController;try{await Promise.race([rCt(t,n),nCt(t,e,r,n)])}finally{n.abort(),Qk(t,-Kxe)}},rCt=async(t,{signal:e})=>{try{await Zxe(t,{signal:e,cleanup:!0})}catch(r){throw Xxe(t,r),r}},nCt=async(t,e,r,{signal:n})=>{for await(let[i]of Zxt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},WK=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},iCt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{Qk(t,Jxe);let a=new AbortController;try{await Promise.race([sCt(s,e,a),oCt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),aCt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),Qk(t,-Jxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?YK(t):cCt(t))},sCt=async(t,e,{signal:r})=>{try{await t,r.aborted||YK(e)}catch(n){r.aborted||Xxe(e,n)}},oCt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Zxe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Qxe(o)?i.add(e):eCe(t,o)}},aCt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Yxe(t,i,{signal:s}),!t.readable)return Yxe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},cCt=t=>{t.writable&&t.end()},Xxe=(t,e)=>{Qxe(e)?YK(t):eCe(t,e)},Qxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",YK=t=>{(t.readable||t.writable)&&t.destroy()},eCe=(t,e)=>{t.destroyed||(t.once("error",lCt),t.destroy(e))},lCt=()=>{},Qk=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Kxe=2,Jxe=1;import{finished as tCe}from"stream/promises";var ly=(t,e)=>{t.pipe(e),uCt(t,e),dCt(t,e)},uCt=async(t,e)=>{if(!(ko(t)||ko(e))){try{await tCe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}KK(e)}},KK=t=>{t.writable&&t.end()},dCt=async(t,e)=>{if(!(ko(t)||ko(e))){try{await tCe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}JK(t)}},JK=t=>{t.readable&&t.destroy()};var rCe=(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})=>to.has(c)))fCt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!to.has(c)))hCt({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]:qp(s);ly(o,i)}},fCt=(t,e,r,n)=>{r==="output"?ly(t.stdio[n],e):ly(e,t.stdio[n]);let i=pCt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},pCt=["stdin","stdout","stderr"],hCt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;mCt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},mCt=(t,{signal:e})=>{ko(t)&&Up(t,gCt,e)},gCt=2;import{addAbortListener as SCt}from"events";var Bp=[];Bp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var e$=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",ZK=Symbol.for("signal-exit emitter"),XK=globalThis,_Ct=Object.defineProperty.bind(Object),QK=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(XK[ZK])return XK[ZK];_Ct(XK,ZK,{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}},t$=class{},yCt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),e5=class extends t${onExit(){return()=>{}}load(){}unload(){}},t5=class extends t${#e=r5.platform==="win32"?"SIGINT":"SIGHUP";#r=new QK;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Bp)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(!e$(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 Bp)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,Bp.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 e$(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"&&e$(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)}},r5=globalThis.process,{onExit:nCe,load:iwr,unload:swr}=yCt(e$(r5)?new t5(r5):new e5);var iCe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=nCe(()=>{t.kill()});SCt(n,()=>{i()})};var oCe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=fk(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=ECt(r,n,i),{sourceStream:d,sourceError:f}=bCt(t,l),{options:p,fileDescriptors:h}=Ma.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},ECt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=vCt(t,e,...r),a=bk(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},vCt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(sCe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||HY(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]=rk(r,...n);return{destination:e(sCe)(i,s,o),pipeOptions:o}}if(Ma.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}`)},sCe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),bCt=(t,e)=>{try{return{sourceStream:ry(t,e)}}catch(r){return{sourceError:r}}};var cCe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=TCt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw n5({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},TCt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return JK(t),n;if(e!==void 0)return KK(r),e},n5=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>oy({error:t,command:aCe,escapedCommand:aCe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),aCe="source.pipe(destination)";var lCe=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 wCt}from"stream/promises";var uCe=(t,e,r)=>{let n=r$.has(e)?ACt(t,e):RCt(t,e);return Up(t,CCt,r.signal),Up(e,PCt,r.signal),xCt(e),n},RCt=(t,e)=>{let r=qp([t]);return ly(r,e),r$.set(e,r),r},ACt=(t,e)=>{let r=r$.get(e);return r.add(t),r},xCt=async t=>{try{await wCt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}r$.delete(t)},r$=new WeakMap,CCt=2,PCt=1;import{aborted as ICt}from"util";var dCe=(t,e)=>t===void 0?[]:[OCt(t,e)],OCt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await ICt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw n5({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var n$=(t,...e)=>{if(zr(e[0]))return n$.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=oCe(t,...e),i=NCt({...n,destination:r});return i.pipe=n$.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},NCt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=kCt(t,i);cCe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=uCe(e,s,d);return await Promise.race([lCe(u),...dCe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},kCt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as jCt}from"timers/promises";import{on as $Ct}from"events";import{getDefaultHighWaterMark as LCt}from"stream";var i$=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return DCt(e,o),pCe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},DCt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},i5=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;MCt(e,o,t);let a=t.readableObjectMode&&!s;return pCe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},MCt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},pCe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=$Ct(t,"data",{signal:e.signal,highWaterMark:fCe,highWatermark:fCe});return UCt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},s5=LCt(!0),fCe=s5,UCt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=FCt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*zp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*zw(a)}},FCt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Yk(t,r,!e),Wk(t,i,!n,{})].filter(Boolean);var hCe=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=zCt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([qCt(t),d]);return}let f=DK(c,r),p=i5({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([BCt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},zCt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!Zk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=i5({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Rxe(a,t,r,s)},qCt=async t=>{await jCt(),t.readableFlowing===null&&t.resume()},BCt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await Uk(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await Fk(r,{maxBuffer:s})):await sy(r,{maxBuffer:s})}catch(a){return mCe(RAe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},o5=async t=>{try{return await t}catch(e){return mCe(e)}},mCe=({bufferedData:t})=>zwe(t)?new Uint8Array(t):t;import{finished as VCt}from"stream/promises";var Hw=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=HCt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],VCt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||YCt(a,e,r,n)}finally{o.abort()}},HCt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&GCt(t,r,n),n},GCt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{WCt(e,r),n.call(t,...i)}},WCt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},YCt=(t,e,r,n)=>{if(!KCt(t,e,r,n))throw t},KCt=(t,e,r,n=!0)=>r.propagating?gCe(t)||s$(t):(r.propagating=!0,a5(r,e)===n?gCe(t):s$(t)),a5=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",s$=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",gCe=t=>t?.code==="EPIPE";var _Ce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>c5({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),c5=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=Hw(t,e,l);if(a5(l,e)){await u;return}let[d]=await Promise.all([hCe({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 yCe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?qp([t,e].filter(Boolean)):void 0,SCe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>c5({...JCt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:ZCt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),JCt=({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}},ZCt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as XCt}from"events";var ECe=t=>Z_(t,"ipc"),vCe=(t,e)=>{let r=dk(t);La({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var bCe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=ECe(s),a=ll(e,"ipc"),c=ll(r,"ipc");for await(let l of HK({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(AAe(t,i,c),i.push(l)),o&&vCe(l,s);return i},TCe=async(t,e)=>(await Promise.allSettled([t]),e);var wCe=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:_,controller:y})=>{let E=Ixe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=_Ce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),T=SCe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),R=[],w=bCe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),b=QCt(m,t,S),C=ePt(h,S);try{return await Promise.race([Promise.all([{},Nxe(E),Promise.all(g),T,w,iAe(t,d),...b,...C]),_,tPt(t,y),...Q0e(t,s,f,y),...E0e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Z0e({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(N){return f.terminationReason??="other",Promise.all([{error:N},E,Promise.all(g.map(x=>o5(x))),o5(T),TCe(w,R),Promise.allSettled(b),Promise.allSettled(C)])}},QCt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Hw(n,i,r)),ePt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Do(s,{checkOpen:!1})&&!ko(s)).map(({type:i,value:s,stream:o=s})=>Hw(o,n,e,{isSameDirection:to.has(i),stopOnExit:i==="native"}))),tPt=async(t,{signal:e})=>{let[r]=await XCt(t,"error",{signal:e});throw r};var RCe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Gw=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Da();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},uy=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 rPt}from"stream";import{callbackify as nPt}from"util";import{finished as ACe}from"stream/promises";var l5=async t=>{if(t!==void 0)try{await u5(t)}catch{}},xCe=async t=>{if(t!==void 0)try{await d5(t)}catch{}},u5=async t=>{await ACe(t,{cleanup:!0,readable:!1,writable:!0})},d5=async t=>{await ACe(t,{cleanup:!0,readable:!0,writable:!1})},o$=async(t,e)=>{if(await t,e)throw e},a$=(t,e,r)=>{r&&!s$(r)?t.destroy(r):e&&t.destroy()};var CCe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ys.has(r),{subprocessStdout:a,waitReadableDestroy:c}=f5(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=p5(a,o),{read:f,onStdoutDataDone:p}=h5({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new rPt({read:f,destroy:nPt(g5.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return m5({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},f5=(t,e,r)=>{let n=ry(t,e),i=Gw(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},p5=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:s5},h5=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Da(),o=i$({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){iPt(this,o,s)},onStdoutDataDone:s}},iPt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},m5=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await d5(t),await n,await l5(i),await e,r.readable&&r.push(null)}catch(s){await l5(i),PCe(r,s)}},g5=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await uy(r,e)&&(PCe(t,n),await o$(e,n))},PCe=(t,e)=>{a$(t,t.readable,e)};import{Writable as sPt}from"stream";import{callbackify as ICe}from"util";var OCe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=_5(t,r,e),o=new sPt({...y5(n,t,i),destroy:ICe(E5.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return S5(n,o),o},_5=(t,e,r)=>{let n=bk(t,e),i=Gw(r,n,"writableFinal"),s=Gw(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},y5=(t,e,r)=>({write:oPt.bind(void 0,t),final:ICe(aPt.bind(void 0,t,e,r))}),oPt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},aPt=async(t,e,r)=>{await uy(r,e)&&(t.writable&&t.end(),await e)},S5=async(t,e,r)=>{try{await u5(t),e.writable&&e.end()}catch(n){await xCe(r),NCe(e,n)}},E5=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await uy(r,e),await uy(n,e)&&(NCe(t,i),await o$(e,i))},NCe=(t,e)=>{a$(t,t.writable,e)};import{Duplex as cPt}from"stream";import{callbackify as lPt}from"util";var kCe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ys.has(r),{subprocessStdout:c,waitReadableDestroy:l}=f5(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=_5(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=p5(c,a),{read:_,onStdoutDataDone:y}=h5({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new cPt({read:_,...y5(u,t,d),destroy:lPt(uPt.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 m5({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:u}),S5(u,E,c),E},uPt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([g5({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),E5({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var v5=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ys.has(e),o=ry(t,r),a=i$({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return dPt(a,o,t)},dPt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var $Ce=(t,{encoding:e})=>{let r=RCe();t.readable=CCe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=OCe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=kCe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=v5.bind(void 0,t,e),t[Symbol.asyncIterator]=v5.bind(void 0,t,e,{})};var LCe=(t,e)=>{for(let[r,n]of pPt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},fPt=(async()=>{})().constructor.prototype,pPt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(fPt,t)]);var DCe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=gPt(t,e,r),{subprocess:f,promise:p}=yPt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=n$.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),LCe(f,p),Ma.set(f,{options:u,fileDescriptors:d}),f},gPt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pk(t,e,r),{file:a,commandArguments:c,options:l}=kk(t,e,r),u=_Pt(l),d=Wxe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_Pt=({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}},yPt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=mPt(...$k(t,e,r))}catch(h){return Bxe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;hPt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];rCe(c,a,l),iCe(c,r,l);let d={},f=Da();c.kill=y0e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=yCe(c,r),$Ce(c,r),jxe(c,r);let p=SPt({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}},SPt=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,_]=await wCe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,T)=>dl(g,e,T)),E=dl(m,e,"all"),S=EPt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return ay(S,n,e)},EPt=({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?jw({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 Ua,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):qk({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var c$=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,vPt(n,t[n],i)]));return{...t,...r}},vPt=(t,e,r)=>bPt.has(t)&&zr(e)&&zr(r)?{...e,...r}:r,bPt=new Set(["env",...ZY]);var hd=(t,e,r,n)=>{let i=(o,a,c)=>hd(o,a,r,c),s=(...o)=>TPt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},TPt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(zr(s))return i(t,c$(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=wPt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?$xe(a,c,l):DCe(a,c,l,i)},wPt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Wwe(e)?Ywe(e,r):[e,...r],[o,a,c]=rk(...s),l=c$(c$(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 MCe=({file:t,commandArguments:e})=>FCe(t,e),UCe=({file:t,commandArguments:e})=>({...FCe(t,e),isSync:!0}),FCe=(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]=RPt(t);return{file:r,commandArguments:n}},RPt=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(APt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},APt=/ +/g;var jCe=(t,e,r)=>{t.sync=e(xPt,r),t.s=t.sync},zCe=({options:t})=>qCe(t),xPt=({options:t})=>({...qCe(t),isSync:!0}),qCe=t=>({options:{...CPt(t),...t}}),CPt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},BCe={preferLocal:!0};var VCe=hd(()=>({})),Y0r=hd(()=>({isSync:!0})),HCe=hd(MCe),K0r=hd(UCe),J0r=hd(tAe),Z0r=hd(zCe,{},BCe,jCe),{sendMessage:X0r,getOneMessage:Q0r,getEachMessage:eAr,getCancelSignal:tAr}=zxe();import{Transform as PPt}from"stream";var IPt=["NETLIFY_AI_GATEWAY_KEY"];function OPt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...IPt])]}function NPt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function kPt(){let e=OPt().map(r=>process.env[r]).filter(r=>!(!r||NPt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ji(t){if(typeof t!="string")return t;let e=kPt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp($Pt(n),"g");r=r.replace(i,"******")}),r}function $Pt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ww=class extends PPt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ji(i);n(null,s)}},l$=Symbol("maskedWrite");function GCe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[l$]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ji(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[l$]=!0,process.stdout.write=r}if(!process.stderr.write[l$]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ji(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[l$]=!0,process.stderr.write=r}}}var WCe=!1,YCe=()=>{WCe=!0},Zi=()=>WCe;var Yw=null,KCe=t=>(Yw&&Yw.destroy(),Yw=new Mo({totalAllowedTime:t}),Yw),JCe=()=>Yw;var Mo=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&&Zi())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 ZN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{oe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),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 ZCe={name:"@netlify/agent-runner-cli",type:"module",version:"1.176.0-has-db-from-site.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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.17.6","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@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.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var UPt=DPt(import.meta.url),FPt=fl.dirname(UPt),jPt=MPt(import.meta.url),dy=pe("shell"),b5=new Set,XCe={preferLocal:!0},gr=(t,e,r)=>{let[n,i]=zPt(e,r),s={...XCe,...i},o=VCe(t,n,s);ePe(o,s),nPe(o);let a=r?.idleTimeout;return a&&a>0&&rPe(o,a),o},QCe=(t,e)=>{let r={...XCe,...e},n=HCe(t,r);return ePe(n,r),nPe(n),e?.idleTimeout&&e.idleTimeout>0&&rPe(n,e.idleTimeout),n},zPt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ePe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ja.env.NETLIFY_LOCAL_QUIET==="true")return;if(ja.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Ww).pipe(ja.stdout),t.stderr?.pipe(new Ww).pipe(ja.stderr);return}t.stdout?.pipe(ja.stdout),t.stderr?.pipe(ja.stderr)},T5=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ja.kill(-t.pid,e),dy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return dy.error("Error killing process:",r),!1}},tPe=t=>T5(t,"SIGKILL"),rPe=(t,e)=>{let r=null,n=()=>{dy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),T5(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dy.log(`Force killing idle process ${t.pid}`),tPe(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)},nPe=t=>{b5.add(t);let e=JCe();if(e){let r=e.onTimesUp(()=>{dy.log(`Global timer expired, killing process ${t.pid}`),T5(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dy.log(`Force killing process ${t.pid} after timeout`),tPe(t))},5e3)});t.on("exit",()=>{b5.delete(t),r()}),t.on("error",()=>{b5.delete(t),r()})}};function za(t,e){if(!ja.env.NETLIFY_LOCAL_MODE)try{let i=jPt.resolve(ZCe.name),s=fl.dirname(i);for(;s!==fl.dirname(s);){let o=fl.dirname(s);if(fl.basename(o)==="node_modules"){let a=fl.join(o,".bin",e);if(u$.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(ja.env.NODE_PATH){let i=fl.join(ja.env.NODE_PATH,".bin",e);if(u$.existsSync(i))return i}let r=fl.join(t,"node_modules",".bin",e);if(u$.existsSync(r))return r;let n=fl.join(FPt,"..","node_modules",".bin",e);if(u$.existsSync(n))return n}import k1 from"process";import{fileURLToPath as g2t}from"url";import{createRequire as _2t}from"module";import G0 from"path";import{readFileSync as y2t}from"fs";var qPt="__netlify__getTracer",BPt="__netlify__shutdownTracers",Ot=(t,e)=>globalThis[qPt]?.(t,e),iPe=async()=>globalThis[BPt]?.();function Kw(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 l2t}from"timers/promises";ke();import VOt from"process";ke();var pIt=(t,e)=>{e.recordException(t),e.setStatus({code:ai.ERROR})};var ml=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}=ZPe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>XPe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=ZPe(r,n,i),c=this._tracer.startSpan(e,s,o);return XPe(c,s,a)}};function ZPe(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??nr.active(),{opts:n,ctx:i,fn:s}}function XPe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:pIt,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)}}ke();var yy=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var n9=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=cIe(e),n._asyncAttributesPending=e.filter(([i,s])=>yy(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(yy(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=cIe(this._rawAttributes),this._schemaUrl=hIt(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,yy(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&le.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(yy(n)){le.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=mIt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function i9(t,e){return n9.FromAttributeList(Object.entries(t),e)}function cIe(t){return t.map(([e,r])=>yy(r)?[e,r.catch(n=>{le.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function hIt(t){if(typeof t=="string"||t===void 0)return t;le.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function mIt(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;le.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}ke();var aR=class{emit(e){}enabled(){return!1}},lIe=new aR;var cR=Symbol.for("io.opentelemetry.js.api.logs"),Sy=globalThis;function uIe(t,e,r){return n=>n===t?e:r}var s9=1;var o9=class{getLogger(e,r,n){return new aR}},k$=new o9;var $$=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):lIe}};var lR=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new $$(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:k$}_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 L$=class t{constructor(){this._proxyLoggerProvider=new lR}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Sy[cR]?this.getLoggerProvider():(Sy[cR]=uIe(s9,e,k$),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Sy[cR])===null||e===void 0?void 0:e.call(Sy,s9))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Sy[cR],this._proxyLoggerProvider=new lR}};var dIe=L$.getInstance();function fIe(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 pIe(t){t.forEach(e=>e.disable())}function a9(t){let e=t.tracerProvider||qt.getTracerProvider(),r=t.meterProvider||oR.getMeterProvider(),n=t.loggerProvider||dIe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return fIe(i,e,r,n),()=>{pIe(i)}}ke();var gIt=mn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function hIe(t){return t.getValue(gIt)===!0}var Ey;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Ey||(Ey={}));ke();var c9="[_0-9a-z-*/]",_It=`[a-z]${c9}{0,255}`,yIt=`[a-z0-9]${c9}{0,240}@[a-z]${c9}{0,13}`,SIt=new RegExp(`^(?:${_It}|${yIt})$`),EIt=/^[ -~]{0,255}[!-~]$/,vIt=/,|=/;function l9(t){return SIt.test(t)}function u9(t){return EIt.test(t)&&!vIt.test(t)}var bIt=32,mIe=512,gIe=",",_Ie="=",D$=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!l9(e)||!u9(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>mIe)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=gIe+e),e=`${n[0]}${_Ie}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(gIe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(_Ie);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!l9(a)||!u9(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>mIe)&&(r.set(a,c),n=l,r.size>=bIt))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 M$="traceparent",U$="tracestate",TIt="00",wIt="(?!ff)[\\da-f]{2}",RIt="(?![0]{32})[\\da-f]{32}",AIt="(?![0]{16})[\\da-f]{16}",xIt="[\\da-f]{2}",CIt=new RegExp(`^\\s?(${wIt})-(${RIt})-(${AIt})-(${xIt})(-.*)?\\s?$`);function yIe(t){let e=CIt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var _d=class{inject(e,r,n){let i=qt.getSpanContext(e);if(!i||hIe(e)||!Xi(i))return;let s=`${TIt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Or.NONE).toString(16)}`;n.set(r,M$,s),i.traceState&&n.set(r,U$,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,M$);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=yIe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,U$);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new D$(typeof c=="string"?c:void 0)}return qt.setSpanContext(e,o)}fields(){return[M$,U$]}};var F$=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 uR=class{_isCalled=!1;_deferred=new F$;_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 IL=Cn(K9(),1);ke();var eke=t=>{throw TypeError(t)},Q9=(t,e,r)=>e.has(t)||eke("Cannot "+r),PL=(t,e,r)=>(Q9(t,e,"read from private field"),r?r.call(t):e.get(t)),J9=(t,e,r)=>e.has(t)?eke("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),ZNe=(t,e,r,n)=>(Q9(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),BOt=(t,e,r)=>(Q9(t,e,"access private method"),r),XNe="__netlify__getTracer",HOt="__netlify__shutdownTracers",GOt="__nfOTLPTrace",RR,AR,X9,tke,WOt=class{constructor(){J9(this,X9),J9(this,RR),J9(this,AR),ZNe(this,RR,new uR(BOt(this,X9,tke),this)),ZNe(this,AR,le.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(PL(this,AR).debug(`export ${t.length.toString()} spans`),PL(this,RR).isCalled){e({code:Ey.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(GOt,JSON.stringify(YOt(t))),e({code:Ey.SUCCESS})}shutdown(){return PL(this,RR).call()}};RR=new WeakMap;AR=new WeakMap;X9=new WeakSet;tke=function(){return PL(this,AR).debug("Shutting down"),Promise.resolve()};function YOt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:CL(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||Uo.SERVER,startTimeUnixNano:Z9(e.startTime),endTimeUnixNano:Z9(e.endTime),attributes:CL(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Z9(n.time),attributes:CL(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:CL(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function CL(t){return Object.keys(t).map(e=>rke(e,t[e]))}function rke(t,e){return{key:t,value:nke(e)}}function nke(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(nke)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>rke(r,n))}}:{}}function Z9(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var QNe={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"}},ike=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,XNe))return;let e=VOt.version.slice(1),r=i9({"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??[KOt()],i=new IL.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new _d});let s=t.instrumentations??[];a9({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,XNe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new ml(qt.getTracer(a,c)):new ml(qt.getTracer(QNe.name,QNe.version))}}),Object.defineProperty(globalThis,HOt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},KOt=()=>new IL.SimpleSpanProcessor(new WOt);ke();var xR=Cn(K9(),1);ke();import*as OL from"diagnostics_channel";var ske=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?ai.ERROR:ai.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 ml?t:new ml(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){OL.subscribe(t,e);let r=()=>OL.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:Uo.CLIENT},nr.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:ai.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 Pje=Cn(xje(),1);var O1=pe("tracing"),Cje=8e3,u2t=5e3,H0=async(t=u2t)=>{try{await Promise.race([iPe(),l2t(t)])}catch(e){O1.warn("Failed to flush tracers on shutdown",e)}},Ije=async(t,e,r)=>{if(!Ot()){let n=[new xR.SimpleSpanProcessor(new eQ),new xR.SimpleSpanProcessor(new Pje.OTLPTraceExporter({url:r.exporterUrl}))];await ike({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new ske({skipHeaders:!0})]})}return r.traceparent?(Pi.setGlobalPropagator(new _d),Pi.extract(nr.active(),{traceparent:r.traceparent,isRemote:!0})):nr.active()};function or(t,e,r){return O1.log(`\u23F3 TRACE: ${e} starting...`),Kw(t,e,r)}var eQ=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(", ")}]`:"";O1.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&O1.log(` \u274C Error: ${e.status.message}`)}};function tQ(){return Qe().captureLlmContentEnabled}function Oje(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function N1(t,e,r){let n={role:t,parts:[{type:"text",content:Ji(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var d2t=new Set([Q.Task,Q.RunCommand,Q.Explore,Q.FileRead,Q.FileWrite,Q.Notebook,Q.Web,Q.Todo,Q.Skill,Q.Tool,Q.Memorize,Q.Deployment,Q.SiteGeneration]);function Nje(t,e,r,n){if(!t.length)return;let i=Ot();if(!i)return;let s=tQ(),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&&d2t.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,_=a.message?a.message.length>Cje?`${a.message.slice(0,Cje)}\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&&_?d?{"gen_ai.tool.call.result":Ji(_)}:{"gen_ai.output.messages":N1("assistant",_)}:{}}}).end(u)})}import{readdir as f2t,rm as p2t}from"fs/promises";import{join as h2t}from"path";async function kje(t,e=[]){let n=(await f2t(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>p2t(h2t(t,i),{recursive:!0,force:!0})))}var m2t=300,Ph=t=>Qe().budgetCreditThresholds[t.mode]?.[t.runner]??m2t,Ih=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var rQ=t=>{let e=Ph(t);if(!Ih(t,e))return"default";let r=Qe();return r.createAskFirstEnabled&&r.questionsEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},$je=t=>{let e=rQ(t),r=Ph(t);return{budget_eligible:Ih(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var S2t=G0.dirname(g2t(import.meta.url)),Lje=_2t(import.meta.url),E2t=G0.resolve(S2t,"scripts/scaffold.js"),v2t="scripts/scaffold.js",b2t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,nQ=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},T2t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),w2t=t=>{let e=nQ(t);return e==="node"||e.endsWith("/node")},Fl=t=>{if(typeof t!="string")return!1;let e=t.match(b2t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&T2t(nQ(e[r]));)r+=1;if(r>=e.length||!w2t(e[r]))return!1;let n=e[r+1];return n?nQ(n).includes(v2t):!1},Oh=pe("create_stage"),iQ="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.",R2t=`${iQ}
634
+ if (condition) { yield value; }`)};import{Buffer as WAt}from"buffer";import{StringDecoder as YAt}from"string_decoder";var Yk=(t,e,r)=>{if(r)return;if(t)return{transform:KAt.bind(void 0,new TextEncoder)};let n=new YAt(e);return{transform:JAt.bind(void 0,n),final:ZAt.bind(void 0,n)}},KAt=function*(t,e){WAt.isBuffer(e)?yield cl(e):typeof e=="string"?yield t.encode(e):yield e},JAt=function*(t,e){yield nn(e)?t.write(e):e},ZAt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as yxe}from"util";var FK=yxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Kk=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QAt}=e[r];for await(let i of n(t))yield*Kk(i,e,r+1)},Sxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XAt(r,Number(e),t)},XAt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Kk(n,r,e+1)},Exe=yxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),QAt=function*(t){yield t};var jK=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},vxe=(t,e)=>[...e.flatMap(r=>[...zp(r,t,0)]),...zw(t)],zp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=txt}=e[r];for(let i of n(t))yield*zp(i,e,r+1)},zw=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ext(r,Number(e),t)},ext=function*(t,e,r){if(t!==void 0)for(let n of t())yield*zp(n,r,e+1)},txt=function*(t){yield t};var zK=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Txe(t,o,s),l=jp(e),u=jp(r),d=l?FK.bind(void 0,Kk,a):jK.bind(void 0,zp),f=l||u?FK.bind(void 0,Sxe,a):jK.bind(void 0,zw),p=l||u?Exe.bind(void 0,a):void 0;return{stream:new rxt({writableObjectMode:n,writableHighWaterMark:bxe(n),readableObjectMode:i,readableHighWaterMark:bxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},Jk=(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=Txe(o,r,a);t=vxe(c,t)}return t},Txe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:mxe(n,a)},Yk(r,o,n),Wk(r,s,n,c),{transform:t,final:e},{transform:gxe(i,a)},hxe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var wxe=(t,e)=>{for(let r of nxt(t))ixt(t,r,e)},nxt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),ixt=(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 ${pd[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>sxt(a,n));r.input=Ow(o)},sxt=(t,e)=>{let r=Jk(t,e,"utf8",!0);return oxt(r),Ow(r)},oxt=t=>{let e=t.find(r=>typeof r!="string"&&!nn(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 uxt,appendFileSync as dxt}from"fs";var Zk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Z_(r,n)&&!ys.has(e)&&axt(n)&&(t.some(({type:i,value:s})=>i==="native"&&cxt.has(s))||t.every(({type:i})=>to.has(i))),axt=t=>t===1||t===2,cxt=new Set(["pipe","overlapped"]),Rxe=async(t,e,r,n)=>{for await(let i of t)lxt(e)||xxe(i,r,n)},Axe=(t,e,r)=>{for(let n of t)xxe(n,e,r)},lxt=t=>t._readableState.pipes.length>0,xxe=(t,e,r)=>{let n=dk(t);La({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Cxe=({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)=>fxt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},fxt=({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=PAe(t,s,d),p=cl(f),{stdioItems:h,objectMode:m}=e[r],_=pxt([p],h,c,n),{serializedResult:y,finalResult:E=y}=hxt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});mxt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&gxt(y,h,i),S}catch(g){return n.error=g,S}},pxt=(t,e,r,n)=>{try{return Jk(t,e,r,!1)}catch(i){return n.error=i,t}},hxt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Ow(t)};let o=Bwe(t,r);return n[s]?{serializedResult:o,finalResult:UK(o,!i[s],e)}:{serializedResult:o}},mxt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!Zk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=UK(t,!1,o);try{Axe(a,e,n)}catch(c){r.error??=c}},gxt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>Hk.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?dxt(n,t):(r.add(s),uxt(n,t))}};var Pxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,dl(e,r,"all")]:Array.isArray(e)?[dl(t,r,"all"),...e]:nn(t)&&nn(e)?WY([t,e]):`${t}${e}`};import{once as qK}from"events";var Ixe=async(t,e)=>{let[r,n]=await _xt(t);return e.isForcefullyTerminated??=!1,[r,n]},_xt=async t=>{let[e,r]=await Promise.allSettled([qK(t,"spawn"),qK(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Oxe(t):r.value},Oxe=async t=>{try{return await qK(t,"exit")}catch{return Oxe(t)}},Nxe=async t=>{let[e,r]=await t;if(!yxt(e,r)&&BK(e,r))throw new $o;return[e,r]},yxt=(t,e)=>t===void 0&&e===void 0,BK=(t,e)=>t!==0||e!==null;var kxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Sxt(t,e,r),o=s?.code==="ETIMEDOUT",a=CAe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Sxt=(t,e,r)=>t!==void 0?t:BK(e,r)?new $o:void 0;var $xe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=vxt(t,e,r),d=wxt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return ay(d,c,l)},vxt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pk(t,e,r),a=bxt(r),{file:c,commandArguments:l,options:u}=kk(t,e,a);Txt(u);let d=uxe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},bxt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Txt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Xk("ipcInput"),t&&Xk("ipc: true"),r&&Xk("detached: true"),n&&Xk("cancelSignal")},Xk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},wxt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Rxt({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}=kxe(c,r),{output:h,error:m=l}=Cxe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,S)=>dl(E,r,S)),y=dl(Pxe(h,r),r,"all");return xxt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Rxt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{wxe(s,r);let a=Axt(r);return Ext(...$k(t,e,a))}catch(a){return oy({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Axt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:zk(e)}),xxt=({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?qk({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):jw({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 hPt}from"events";import{spawn as mPt}from"child_process";import Fxe from"process";import{once as VK,on as Cxt}from"events";var Lxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(ey({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:xk(t)}),Pxt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Pxt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{Tk(e,i);let s=fd(t,e,r),o=new AbortController;try{return await Promise.race([Ixt(s,n,o),Oxt(s,r,o),Nxt(s,r,o)])}catch(a){throw ty(t),a}finally{o.abort(),wk(e,i)}},Ixt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await VK(t,"message",{signal:r});return n}for await(let[n]of Cxt(t,"message",{signal:r}))if(e(n))return n},Oxt=async(t,e,{signal:r})=>{await VK(t,"disconnect",{signal:r}),v0e(e)},Nxt=async(t,e,{signal:r})=>{let[n]=await VK(t,"strict:error",{signal:r});throw Ek(n,e)};import{once as Mxe,on as kxt}from"events";var Uxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>HK({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),HK=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{ey({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:xk(t)}),Tk(e,s);let o=fd(t,e,r),a=new AbortController,c={};return $xt(t,o,a),Lxt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Dxt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},$xt=async(t,e,r)=>{try{await Mxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Lxt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Mxe(t,"strict:error",{signal:r.signal});n.error=Ek(i,e),r.abort()}catch{}},Dxt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of kxt(r,"message",{signal:s.signal}))Dxe(o),yield c}catch{Dxe(o)}finally{s.abort(),wk(e,a),n||ty(t),i&&await t}},Dxe=({error:t})=>{if(t)throw t};var jxe=(t,{ipc:e})=>{Object.assign(t,qxe(t,!1,e))},zxe=()=>{let t=Fxe,e=!0,r=Fxe.channel!==void 0;return{...qxe(t,e,r),getCancelSignal:Y0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},qxe=(t,e,r)=>({sendMessage:Ok.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Lxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Uxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Mxt}from"child_process";import{PassThrough as Uxt,Readable as Fxt,Writable as jxt,Duplex as zxt}from"stream";var Bxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{LK(n);let a=new Mxt;qxt(a,n),Object.assign(a,{readable:Bxt,writable:Vxt,duplex:Hxt});let c=oy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Gxt(c,o,i);return{subprocess:a,promise:l}},qxt=(t,e)=>{let r=qw(),n=qw(),i=qw(),s=Array.from({length:e.length-3},qw),o=qw(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},qw=()=>{let t=new Uxt;return t.end(),t},Bxt=()=>new Fxt({read(){}}),Vxt=()=>new jxt({write(){}}),Hxt=()=>new zxt({read(){},write(){}}),Gxt=async(t,e,r)=>ay(t,e,r);import{createReadStream as Vxe,createWriteStream as Hxe}from"fs";import{Buffer as Wxt}from"buffer";import{Readable as Bw,Writable as Yxt,Duplex as Kxt}from"stream";var Wxe=(t,e)=>Gk(Jxt,t,e,!1),Vw=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Gxe={fileNumber:Vw,generator:zK,asyncGenerator:zK,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Kxt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Jxt={input:{...Gxe,fileUrl:({value:t})=>({stream:Vxe(t)}),filePath:({value:{file:t}})=>({stream:Vxe(t)}),webStream:({value:t})=>({stream:Bw.fromWeb(t)}),iterable:({value:t})=>({stream:Bw.from(t)}),asyncIterable:({value:t})=>({stream:Bw.from(t)}),string:({value:t})=>({stream:Bw.from(t)}),uint8Array:({value:t})=>({stream:Bw.from(Wxt.from(t))})},output:{...Gxe,fileUrl:({value:t})=>({stream:Hxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Hxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Yxt.fromWeb(t)}),iterable:Vw,asyncIterable:Vw,string:Vw,uint8Array:Vw}};import{on as Zxt,once as Yxe}from"events";import{PassThrough as Xxt,getDefaultHighWaterMark as Qxt}from"stream";import{finished as Zxe}from"stream/promises";function qp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)WK(i);let e=t.some(({readableObjectMode:i})=>i),r=eCt(t,e),n=new GK({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var eCt=(t,e)=>{if(t.length===0)return Qxt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},GK=class extends Xxt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(WK(e),this.#e.has(e))return;this.#e.add(e),this.#n??=tCt(this,this.#e,this.#s);let r=iCt({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(WK(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)}},tCt=async(t,e,r)=>{Qk(t,Kxe);let n=new AbortController;try{await Promise.race([rCt(t,n),nCt(t,e,r,n)])}finally{n.abort(),Qk(t,-Kxe)}},rCt=async(t,{signal:e})=>{try{await Zxe(t,{signal:e,cleanup:!0})}catch(r){throw Xxe(t,r),r}},nCt=async(t,e,r,{signal:n})=>{for await(let[i]of Zxt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},WK=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},iCt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{Qk(t,Jxe);let a=new AbortController;try{await Promise.race([sCt(s,e,a),oCt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),aCt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),Qk(t,-Jxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?YK(t):cCt(t))},sCt=async(t,e,{signal:r})=>{try{await t,r.aborted||YK(e)}catch(n){r.aborted||Xxe(e,n)}},oCt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Zxe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Qxe(o)?i.add(e):eCe(t,o)}},aCt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Yxe(t,i,{signal:s}),!t.readable)return Yxe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},cCt=t=>{t.writable&&t.end()},Xxe=(t,e)=>{Qxe(e)?YK(t):eCe(t,e)},Qxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",YK=t=>{(t.readable||t.writable)&&t.destroy()},eCe=(t,e)=>{t.destroyed||(t.once("error",lCt),t.destroy(e))},lCt=()=>{},Qk=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Kxe=2,Jxe=1;import{finished as tCe}from"stream/promises";var ly=(t,e)=>{t.pipe(e),uCt(t,e),dCt(t,e)},uCt=async(t,e)=>{if(!(ko(t)||ko(e))){try{await tCe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}KK(e)}},KK=t=>{t.writable&&t.end()},dCt=async(t,e)=>{if(!(ko(t)||ko(e))){try{await tCe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}JK(t)}},JK=t=>{t.readable&&t.destroy()};var rCe=(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})=>to.has(c)))fCt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!to.has(c)))hCt({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]:qp(s);ly(o,i)}},fCt=(t,e,r,n)=>{r==="output"?ly(t.stdio[n],e):ly(e,t.stdio[n]);let i=pCt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},pCt=["stdin","stdout","stderr"],hCt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;mCt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},mCt=(t,{signal:e})=>{ko(t)&&Up(t,gCt,e)},gCt=2;import{addAbortListener as SCt}from"events";var Bp=[];Bp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var e$=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",ZK=Symbol.for("signal-exit emitter"),XK=globalThis,_Ct=Object.defineProperty.bind(Object),QK=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(XK[ZK])return XK[ZK];_Ct(XK,ZK,{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}},t$=class{},yCt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),e5=class extends t${onExit(){return()=>{}}load(){}unload(){}},t5=class extends t${#e=r5.platform==="win32"?"SIGINT":"SIGHUP";#r=new QK;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Bp)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(!e$(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 Bp)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,Bp.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 e$(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"&&e$(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)}},r5=globalThis.process,{onExit:nCe,load:iwr,unload:swr}=yCt(e$(r5)?new t5(r5):new e5);var iCe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=nCe(()=>{t.kill()});SCt(n,()=>{i()})};var oCe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=fk(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=ECt(r,n,i),{sourceStream:d,sourceError:f}=bCt(t,l),{options:p,fileDescriptors:h}=Ma.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},ECt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=vCt(t,e,...r),a=bk(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},vCt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(sCe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||HY(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]=rk(r,...n);return{destination:e(sCe)(i,s,o),pipeOptions:o}}if(Ma.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}`)},sCe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),bCt=(t,e)=>{try{return{sourceStream:ry(t,e)}}catch(r){return{sourceError:r}}};var cCe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=TCt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw n5({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},TCt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return JK(t),n;if(e!==void 0)return KK(r),e},n5=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>oy({error:t,command:aCe,escapedCommand:aCe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),aCe="source.pipe(destination)";var lCe=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 wCt}from"stream/promises";var uCe=(t,e,r)=>{let n=r$.has(e)?ACt(t,e):RCt(t,e);return Up(t,CCt,r.signal),Up(e,PCt,r.signal),xCt(e),n},RCt=(t,e)=>{let r=qp([t]);return ly(r,e),r$.set(e,r),r},ACt=(t,e)=>{let r=r$.get(e);return r.add(t),r},xCt=async t=>{try{await wCt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}r$.delete(t)},r$=new WeakMap,CCt=2,PCt=1;import{aborted as ICt}from"util";var dCe=(t,e)=>t===void 0?[]:[OCt(t,e)],OCt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await ICt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw n5({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var n$=(t,...e)=>{if(zr(e[0]))return n$.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=oCe(t,...e),i=NCt({...n,destination:r});return i.pipe=n$.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},NCt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=kCt(t,i);cCe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=uCe(e,s,d);return await Promise.race([lCe(u),...dCe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},kCt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as jCt}from"timers/promises";import{on as $Ct}from"events";import{getDefaultHighWaterMark as LCt}from"stream";var i$=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return DCt(e,o),pCe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},DCt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},i5=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;MCt(e,o,t);let a=t.readableObjectMode&&!s;return pCe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},MCt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},pCe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=$Ct(t,"data",{signal:e.signal,highWaterMark:fCe,highWatermark:fCe});return UCt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},s5=LCt(!0),fCe=s5,UCt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=FCt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*zp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*zw(a)}},FCt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Yk(t,r,!e),Wk(t,i,!n,{})].filter(Boolean);var hCe=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=zCt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([qCt(t),d]);return}let f=DK(c,r),p=i5({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([BCt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},zCt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!Zk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=i5({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Rxe(a,t,r,s)},qCt=async t=>{await jCt(),t.readableFlowing===null&&t.resume()},BCt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await Uk(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await Fk(r,{maxBuffer:s})):await sy(r,{maxBuffer:s})}catch(a){return mCe(RAe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},o5=async t=>{try{return await t}catch(e){return mCe(e)}},mCe=({bufferedData:t})=>zwe(t)?new Uint8Array(t):t;import{finished as VCt}from"stream/promises";var Hw=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=HCt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],VCt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||YCt(a,e,r,n)}finally{o.abort()}},HCt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&GCt(t,r,n),n},GCt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{WCt(e,r),n.call(t,...i)}},WCt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},YCt=(t,e,r,n)=>{if(!KCt(t,e,r,n))throw t},KCt=(t,e,r,n=!0)=>r.propagating?gCe(t)||s$(t):(r.propagating=!0,a5(r,e)===n?gCe(t):s$(t)),a5=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",s$=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",gCe=t=>t?.code==="EPIPE";var _Ce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>c5({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),c5=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=Hw(t,e,l);if(a5(l,e)){await u;return}let[d]=await Promise.all([hCe({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 yCe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?qp([t,e].filter(Boolean)):void 0,SCe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>c5({...JCt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:ZCt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),JCt=({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}},ZCt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as XCt}from"events";var ECe=t=>Z_(t,"ipc"),vCe=(t,e)=>{let r=dk(t);La({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var bCe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=ECe(s),a=ll(e,"ipc"),c=ll(r,"ipc");for await(let l of HK({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(AAe(t,i,c),i.push(l)),o&&vCe(l,s);return i},TCe=async(t,e)=>(await Promise.allSettled([t]),e);var wCe=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:_,controller:y})=>{let E=Ixe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=_Ce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),T=SCe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),R=[],w=bCe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),b=QCt(m,t,S),C=ePt(h,S);try{return await Promise.race([Promise.all([{},Nxe(E),Promise.all(g),T,w,iAe(t,d),...b,...C]),_,tPt(t,y),...Q0e(t,s,f,y),...E0e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Z0e({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(N){return f.terminationReason??="other",Promise.all([{error:N},E,Promise.all(g.map(x=>o5(x))),o5(T),TCe(w,R),Promise.allSettled(b),Promise.allSettled(C)])}},QCt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Hw(n,i,r)),ePt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Do(s,{checkOpen:!1})&&!ko(s)).map(({type:i,value:s,stream:o=s})=>Hw(o,n,e,{isSameDirection:to.has(i),stopOnExit:i==="native"}))),tPt=async(t,{signal:e})=>{let[r]=await XCt(t,"error",{signal:e});throw r};var RCe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Gw=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Da();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},uy=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 rPt}from"stream";import{callbackify as nPt}from"util";import{finished as ACe}from"stream/promises";var l5=async t=>{if(t!==void 0)try{await u5(t)}catch{}},xCe=async t=>{if(t!==void 0)try{await d5(t)}catch{}},u5=async t=>{await ACe(t,{cleanup:!0,readable:!1,writable:!0})},d5=async t=>{await ACe(t,{cleanup:!0,readable:!0,writable:!1})},o$=async(t,e)=>{if(await t,e)throw e},a$=(t,e,r)=>{r&&!s$(r)?t.destroy(r):e&&t.destroy()};var CCe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ys.has(r),{subprocessStdout:a,waitReadableDestroy:c}=f5(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=p5(a,o),{read:f,onStdoutDataDone:p}=h5({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new rPt({read:f,destroy:nPt(g5.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return m5({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},f5=(t,e,r)=>{let n=ry(t,e),i=Gw(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},p5=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:s5},h5=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Da(),o=i$({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){iPt(this,o,s)},onStdoutDataDone:s}},iPt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},m5=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await d5(t),await n,await l5(i),await e,r.readable&&r.push(null)}catch(s){await l5(i),PCe(r,s)}},g5=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await uy(r,e)&&(PCe(t,n),await o$(e,n))},PCe=(t,e)=>{a$(t,t.readable,e)};import{Writable as sPt}from"stream";import{callbackify as ICe}from"util";var OCe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=_5(t,r,e),o=new sPt({...y5(n,t,i),destroy:ICe(E5.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return S5(n,o),o},_5=(t,e,r)=>{let n=bk(t,e),i=Gw(r,n,"writableFinal"),s=Gw(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},y5=(t,e,r)=>({write:oPt.bind(void 0,t),final:ICe(aPt.bind(void 0,t,e,r))}),oPt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},aPt=async(t,e,r)=>{await uy(r,e)&&(t.writable&&t.end(),await e)},S5=async(t,e,r)=>{try{await u5(t),e.writable&&e.end()}catch(n){await xCe(r),NCe(e,n)}},E5=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await uy(r,e),await uy(n,e)&&(NCe(t,i),await o$(e,i))},NCe=(t,e)=>{a$(t,t.writable,e)};import{Duplex as cPt}from"stream";import{callbackify as lPt}from"util";var kCe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ys.has(r),{subprocessStdout:c,waitReadableDestroy:l}=f5(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=_5(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=p5(c,a),{read:_,onStdoutDataDone:y}=h5({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new cPt({read:_,...y5(u,t,d),destroy:lPt(uPt.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 m5({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:u}),S5(u,E,c),E},uPt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([g5({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),E5({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var v5=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ys.has(e),o=ry(t,r),a=i$({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return dPt(a,o,t)},dPt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var $Ce=(t,{encoding:e})=>{let r=RCe();t.readable=CCe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=OCe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=kCe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=v5.bind(void 0,t,e),t[Symbol.asyncIterator]=v5.bind(void 0,t,e,{})};var LCe=(t,e)=>{for(let[r,n]of pPt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},fPt=(async()=>{})().constructor.prototype,pPt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(fPt,t)]);var DCe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=gPt(t,e,r),{subprocess:f,promise:p}=yPt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=n$.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),LCe(f,p),Ma.set(f,{options:u,fileDescriptors:d}),f},gPt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pk(t,e,r),{file:a,commandArguments:c,options:l}=kk(t,e,r),u=_Pt(l),d=Wxe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_Pt=({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}},yPt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=mPt(...$k(t,e,r))}catch(h){return Bxe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;hPt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];rCe(c,a,l),iCe(c,r,l);let d={},f=Da();c.kill=y0e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=yCe(c,r),$Ce(c,r),jxe(c,r);let p=SPt({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}},SPt=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,_]=await wCe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,T)=>dl(g,e,T)),E=dl(m,e,"all"),S=EPt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return ay(S,n,e)},EPt=({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?jw({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 Ua,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):qk({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var c$=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,vPt(n,t[n],i)]));return{...t,...r}},vPt=(t,e,r)=>bPt.has(t)&&zr(e)&&zr(r)?{...e,...r}:r,bPt=new Set(["env",...ZY]);var hd=(t,e,r,n)=>{let i=(o,a,c)=>hd(o,a,r,c),s=(...o)=>TPt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},TPt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(zr(s))return i(t,c$(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=wPt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?$xe(a,c,l):DCe(a,c,l,i)},wPt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Wwe(e)?Ywe(e,r):[e,...r],[o,a,c]=rk(...s),l=c$(c$(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 MCe=({file:t,commandArguments:e})=>FCe(t,e),UCe=({file:t,commandArguments:e})=>({...FCe(t,e),isSync:!0}),FCe=(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]=RPt(t);return{file:r,commandArguments:n}},RPt=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(APt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},APt=/ +/g;var jCe=(t,e,r)=>{t.sync=e(xPt,r),t.s=t.sync},zCe=({options:t})=>qCe(t),xPt=({options:t})=>({...qCe(t),isSync:!0}),qCe=t=>({options:{...CPt(t),...t}}),CPt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},BCe={preferLocal:!0};var VCe=hd(()=>({})),Y0r=hd(()=>({isSync:!0})),HCe=hd(MCe),K0r=hd(UCe),J0r=hd(tAe),Z0r=hd(zCe,{},BCe,jCe),{sendMessage:X0r,getOneMessage:Q0r,getEachMessage:eAr,getCancelSignal:tAr}=zxe();import{Transform as PPt}from"stream";var IPt=["NETLIFY_AI_GATEWAY_KEY"];function OPt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...IPt])]}function NPt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function kPt(){let e=OPt().map(r=>process.env[r]).filter(r=>!(!r||NPt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ji(t){if(typeof t!="string")return t;let e=kPt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp($Pt(n),"g");r=r.replace(i,"******")}),r}function $Pt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ww=class extends PPt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ji(i);n(null,s)}},l$=Symbol("maskedWrite");function GCe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[l$]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ji(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[l$]=!0,process.stdout.write=r}if(!process.stderr.write[l$]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ji(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[l$]=!0,process.stderr.write=r}}}var WCe=!1,YCe=()=>{WCe=!0},Zi=()=>WCe;var Yw=null,KCe=t=>(Yw&&Yw.destroy(),Yw=new Mo({totalAllowedTime:t}),Yw),JCe=()=>Yw;var Mo=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&&Zi())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 ZN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{oe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),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 ZCe={name:"@netlify/agent-runner-cli",type:"module",version:"1.176.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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.17.6","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@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.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var UPt=DPt(import.meta.url),FPt=fl.dirname(UPt),jPt=MPt(import.meta.url),dy=pe("shell"),b5=new Set,XCe={preferLocal:!0},gr=(t,e,r)=>{let[n,i]=zPt(e,r),s={...XCe,...i},o=VCe(t,n,s);ePe(o,s),nPe(o);let a=r?.idleTimeout;return a&&a>0&&rPe(o,a),o},QCe=(t,e)=>{let r={...XCe,...e},n=HCe(t,r);return ePe(n,r),nPe(n),e?.idleTimeout&&e.idleTimeout>0&&rPe(n,e.idleTimeout),n},zPt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ePe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ja.env.NETLIFY_LOCAL_QUIET==="true")return;if(ja.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Ww).pipe(ja.stdout),t.stderr?.pipe(new Ww).pipe(ja.stderr);return}t.stdout?.pipe(ja.stdout),t.stderr?.pipe(ja.stderr)},T5=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ja.kill(-t.pid,e),dy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return dy.error("Error killing process:",r),!1}},tPe=t=>T5(t,"SIGKILL"),rPe=(t,e)=>{let r=null,n=()=>{dy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),T5(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dy.log(`Force killing idle process ${t.pid}`),tPe(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)},nPe=t=>{b5.add(t);let e=JCe();if(e){let r=e.onTimesUp(()=>{dy.log(`Global timer expired, killing process ${t.pid}`),T5(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dy.log(`Force killing process ${t.pid} after timeout`),tPe(t))},5e3)});t.on("exit",()=>{b5.delete(t),r()}),t.on("error",()=>{b5.delete(t),r()})}};function za(t,e){if(!ja.env.NETLIFY_LOCAL_MODE)try{let i=jPt.resolve(ZCe.name),s=fl.dirname(i);for(;s!==fl.dirname(s);){let o=fl.dirname(s);if(fl.basename(o)==="node_modules"){let a=fl.join(o,".bin",e);if(u$.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(ja.env.NODE_PATH){let i=fl.join(ja.env.NODE_PATH,".bin",e);if(u$.existsSync(i))return i}let r=fl.join(t,"node_modules",".bin",e);if(u$.existsSync(r))return r;let n=fl.join(FPt,"..","node_modules",".bin",e);if(u$.existsSync(n))return n}import k1 from"process";import{fileURLToPath as g2t}from"url";import{createRequire as _2t}from"module";import G0 from"path";import{readFileSync as y2t}from"fs";var qPt="__netlify__getTracer",BPt="__netlify__shutdownTracers",Ot=(t,e)=>globalThis[qPt]?.(t,e),iPe=async()=>globalThis[BPt]?.();function Kw(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 l2t}from"timers/promises";ke();import VOt from"process";ke();var pIt=(t,e)=>{e.recordException(t),e.setStatus({code:ai.ERROR})};var ml=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}=ZPe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>XPe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=ZPe(r,n,i),c=this._tracer.startSpan(e,s,o);return XPe(c,s,a)}};function ZPe(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??nr.active(),{opts:n,ctx:i,fn:s}}function XPe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:pIt,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)}}ke();var yy=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var n9=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=cIe(e),n._asyncAttributesPending=e.filter(([i,s])=>yy(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(yy(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=cIe(this._rawAttributes),this._schemaUrl=hIt(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,yy(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&le.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(yy(n)){le.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=mIt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function i9(t,e){return n9.FromAttributeList(Object.entries(t),e)}function cIe(t){return t.map(([e,r])=>yy(r)?[e,r.catch(n=>{le.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function hIt(t){if(typeof t=="string"||t===void 0)return t;le.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function mIt(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;le.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}ke();var aR=class{emit(e){}enabled(){return!1}},lIe=new aR;var cR=Symbol.for("io.opentelemetry.js.api.logs"),Sy=globalThis;function uIe(t,e,r){return n=>n===t?e:r}var s9=1;var o9=class{getLogger(e,r,n){return new aR}},k$=new o9;var $$=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):lIe}};var lR=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new $$(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:k$}_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 L$=class t{constructor(){this._proxyLoggerProvider=new lR}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Sy[cR]?this.getLoggerProvider():(Sy[cR]=uIe(s9,e,k$),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Sy[cR])===null||e===void 0?void 0:e.call(Sy,s9))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Sy[cR],this._proxyLoggerProvider=new lR}};var dIe=L$.getInstance();function fIe(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 pIe(t){t.forEach(e=>e.disable())}function a9(t){let e=t.tracerProvider||qt.getTracerProvider(),r=t.meterProvider||oR.getMeterProvider(),n=t.loggerProvider||dIe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return fIe(i,e,r,n),()=>{pIe(i)}}ke();var gIt=mn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function hIe(t){return t.getValue(gIt)===!0}var Ey;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Ey||(Ey={}));ke();var c9="[_0-9a-z-*/]",_It=`[a-z]${c9}{0,255}`,yIt=`[a-z0-9]${c9}{0,240}@[a-z]${c9}{0,13}`,SIt=new RegExp(`^(?:${_It}|${yIt})$`),EIt=/^[ -~]{0,255}[!-~]$/,vIt=/,|=/;function l9(t){return SIt.test(t)}function u9(t){return EIt.test(t)&&!vIt.test(t)}var bIt=32,mIe=512,gIe=",",_Ie="=",D$=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!l9(e)||!u9(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>mIe)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=gIe+e),e=`${n[0]}${_Ie}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(gIe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(_Ie);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!l9(a)||!u9(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>mIe)&&(r.set(a,c),n=l,r.size>=bIt))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 M$="traceparent",U$="tracestate",TIt="00",wIt="(?!ff)[\\da-f]{2}",RIt="(?![0]{32})[\\da-f]{32}",AIt="(?![0]{16})[\\da-f]{16}",xIt="[\\da-f]{2}",CIt=new RegExp(`^\\s?(${wIt})-(${RIt})-(${AIt})-(${xIt})(-.*)?\\s?$`);function yIe(t){let e=CIt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var _d=class{inject(e,r,n){let i=qt.getSpanContext(e);if(!i||hIe(e)||!Xi(i))return;let s=`${TIt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Or.NONE).toString(16)}`;n.set(r,M$,s),i.traceState&&n.set(r,U$,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,M$);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=yIe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,U$);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new D$(typeof c=="string"?c:void 0)}return qt.setSpanContext(e,o)}fields(){return[M$,U$]}};var F$=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 uR=class{_isCalled=!1;_deferred=new F$;_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 IL=Cn(K9(),1);ke();var eke=t=>{throw TypeError(t)},Q9=(t,e,r)=>e.has(t)||eke("Cannot "+r),PL=(t,e,r)=>(Q9(t,e,"read from private field"),r?r.call(t):e.get(t)),J9=(t,e,r)=>e.has(t)?eke("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),ZNe=(t,e,r,n)=>(Q9(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),BOt=(t,e,r)=>(Q9(t,e,"access private method"),r),XNe="__netlify__getTracer",HOt="__netlify__shutdownTracers",GOt="__nfOTLPTrace",RR,AR,X9,tke,WOt=class{constructor(){J9(this,X9),J9(this,RR),J9(this,AR),ZNe(this,RR,new uR(BOt(this,X9,tke),this)),ZNe(this,AR,le.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(PL(this,AR).debug(`export ${t.length.toString()} spans`),PL(this,RR).isCalled){e({code:Ey.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(GOt,JSON.stringify(YOt(t))),e({code:Ey.SUCCESS})}shutdown(){return PL(this,RR).call()}};RR=new WeakMap;AR=new WeakMap;X9=new WeakSet;tke=function(){return PL(this,AR).debug("Shutting down"),Promise.resolve()};function YOt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:CL(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||Uo.SERVER,startTimeUnixNano:Z9(e.startTime),endTimeUnixNano:Z9(e.endTime),attributes:CL(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Z9(n.time),attributes:CL(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:CL(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function CL(t){return Object.keys(t).map(e=>rke(e,t[e]))}function rke(t,e){return{key:t,value:nke(e)}}function nke(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(nke)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>rke(r,n))}}:{}}function Z9(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var QNe={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"}},ike=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,XNe))return;let e=VOt.version.slice(1),r=i9({"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??[KOt()],i=new IL.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new _d});let s=t.instrumentations??[];a9({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,XNe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new ml(qt.getTracer(a,c)):new ml(qt.getTracer(QNe.name,QNe.version))}}),Object.defineProperty(globalThis,HOt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},KOt=()=>new IL.SimpleSpanProcessor(new WOt);ke();var xR=Cn(K9(),1);ke();import*as OL from"diagnostics_channel";var ske=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?ai.ERROR:ai.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 ml?t:new ml(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){OL.subscribe(t,e);let r=()=>OL.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:Uo.CLIENT},nr.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:ai.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 Pje=Cn(xje(),1);var O1=pe("tracing"),Cje=8e3,u2t=5e3,H0=async(t=u2t)=>{try{await Promise.race([iPe(),l2t(t)])}catch(e){O1.warn("Failed to flush tracers on shutdown",e)}},Ije=async(t,e,r)=>{if(!Ot()){let n=[new xR.SimpleSpanProcessor(new eQ),new xR.SimpleSpanProcessor(new Pje.OTLPTraceExporter({url:r.exporterUrl}))];await ike({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new ske({skipHeaders:!0})]})}return r.traceparent?(Pi.setGlobalPropagator(new _d),Pi.extract(nr.active(),{traceparent:r.traceparent,isRemote:!0})):nr.active()};function or(t,e,r){return O1.log(`\u23F3 TRACE: ${e} starting...`),Kw(t,e,r)}var eQ=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(", ")}]`:"";O1.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&O1.log(` \u274C Error: ${e.status.message}`)}};function tQ(){return Qe().captureLlmContentEnabled}function Oje(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function N1(t,e,r){let n={role:t,parts:[{type:"text",content:Ji(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var d2t=new Set([Q.Task,Q.RunCommand,Q.Explore,Q.FileRead,Q.FileWrite,Q.Notebook,Q.Web,Q.Todo,Q.Skill,Q.Tool,Q.Memorize,Q.Deployment,Q.SiteGeneration]);function Nje(t,e,r,n){if(!t.length)return;let i=Ot();if(!i)return;let s=tQ(),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&&d2t.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,_=a.message?a.message.length>Cje?`${a.message.slice(0,Cje)}\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&&_?d?{"gen_ai.tool.call.result":Ji(_)}:{"gen_ai.output.messages":N1("assistant",_)}:{}}}).end(u)})}import{readdir as f2t,rm as p2t}from"fs/promises";import{join as h2t}from"path";async function kje(t,e=[]){let n=(await f2t(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>p2t(h2t(t,i),{recursive:!0,force:!0})))}var m2t=300,Ph=t=>Qe().budgetCreditThresholds[t.mode]?.[t.runner]??m2t,Ih=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var rQ=t=>{let e=Ph(t);if(!Ih(t,e))return"default";let r=Qe();return r.createAskFirstEnabled&&r.questionsEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},$je=t=>{let e=rQ(t),r=Ph(t);return{budget_eligible:Ih(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var S2t=G0.dirname(g2t(import.meta.url)),Lje=_2t(import.meta.url),E2t=G0.resolve(S2t,"scripts/scaffold.js"),v2t="scripts/scaffold.js",b2t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,nQ=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},T2t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),w2t=t=>{let e=nQ(t);return e==="node"||e.endsWith("/node")},Fl=t=>{if(typeof t!="string")return!1;let e=t.match(b2t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&T2t(nQ(e[r]));)r+=1;if(r>=e.length||!w2t(e[r]))return!1;let n=e[r+1];return n?nQ(n).includes(v2t):!1},Oh=pe("create_stage"),iQ="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.",R2t=`${iQ}
635
635
 
636
636
  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.`,A2t=`${iQ}
637
637
 
package/dist/index.js CHANGED
@@ -140,7 +140,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
140
140
  `,LF:`
141
141
  `,concatBytes:qz},HHe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},WHe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:HHe};import{Buffer as YHe}from"buffer";var nue=(t,e)=>t?void 0:KHe.bind(void 0,e),KHe=function*(t,e){if(typeof e!="string"&&!Tr(e)&&!YHe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},iue=(t,e)=>t?ZHe.bind(void 0,e):JHe.bind(void 0,e),ZHe=function*(t,e){oue(t,e),yield e},JHe=function*(t,e){if(oue(t,e),typeof e!="string"&&!Tr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},oue=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
142
142
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
143
- if (condition) { yield value; }`)};import{Buffer as XHe}from"buffer";import{StringDecoder as QHe}from"string_decoder";var hC=(t,e,r)=>{if(r)return;if(t)return{transform:e6e.bind(void 0,new TextEncoder)};let n=new QHe(e);return{transform:t6e.bind(void 0,n),final:r6e.bind(void 0,n)}},e6e=function*(t,e){XHe.isBuffer(e)?yield $a(e):typeof e=="string"?yield t.encode(e):yield e},t6e=function*(t,e){yield Tr(e)?t.write(e):e},r6e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as sue}from"util";var Gz=sue(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),mC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=i6e}=e[r];for await(let i of n(t))yield*mC(i,e,r+1)},aue=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*n6e(r,Number(e),t)},n6e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*mC(n,r,e+1)},cue=sue(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),i6e=function*(t){yield t};var Hz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},lue=(t,e)=>[...e.flatMap(r=>[...Sd(r,t,0)]),...hE(t)],Sd=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=s6e}=e[r];for(let i of n(t))yield*Sd(i,e,r+1)},hE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*o6e(r,Number(e),t)},o6e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Sd(n,r,e+1)},s6e=function*(t){yield t};var Wz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=due(t,s,o),l=yd(e),u=yd(r),d=l?Gz.bind(void 0,mC,a):Hz.bind(void 0,Sd),f=l||u?Gz.bind(void 0,aue,a):Hz.bind(void 0,hE),p=l||u?cue.bind(void 0,a):void 0;return{stream:new a6e({writableObjectMode:n,writableHighWaterMark:uue(n),readableObjectMode:i,readableHighWaterMark:uue(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},gC=(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=due(s,r,a);t=lue(c,t)}return t},due=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:nue(n,a)},hC(r,s,n),pC(r,o,n,c),{transform:t,final:e},{transform:iue(i,a)},rue({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var fue=(t,e)=>{for(let r of c6e(t))l6e(t,r,e)},c6e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),l6e=(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 ${al[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>u6e(a,n));r.input=iE(s)},u6e=(t,e)=>{let r=gC(t,e,"utf8",!0);return d6e(r),iE(r)},d6e=t=>{let e=t.find(r=>typeof r!="string"&&!Tr(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 m6e,appendFileSync as g6e}from"fs";var _C=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sh(r,n)&&!vi.has(e)&&f6e(n)&&(t.some(({type:i,value:o})=>i==="native"&&p6e.has(o))||t.every(({type:i})=>Zi.has(i))),f6e=t=>t===1||t===2,p6e=new Set(["pipe","overlapped"]),pue=async(t,e,r,n)=>{for await(let i of t)h6e(e)||mue(i,r,n)},hue=(t,e,r)=>{for(let n of t)mue(n,e,r)},h6e=t=>t._readableState.pipes.length>0,mue=(t,e,r)=>{let n=O0(t);As({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var gue=({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)=>_6e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},_6e=({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=_le(t,o,d),p=$a(f),{stdioItems:h,objectMode:m}=e[r],g=y6e([p],h,c,n),{serializedResult:_,finalResult:E=_}=S6e({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});E6e({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let b=a[r]?E:void 0;try{return n.error===void 0&&v6e(_,h,i),b}catch(T){return n.error=T,b}},y6e=(t,e,r,n)=>{try{return gC(t,e,r,!1)}catch(i){return n.error=i,t}},S6e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:iE(t)};let s=Ose(t,r);return n[o]?{serializedResult:s,finalResult:Vz(s,!i[o],e)}:{serializedResult:s}},E6e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!_C({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=Vz(t,!1,s);try{hue(a,e,n)}catch(c){r.error??=c}},v6e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>dC.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?g6e(n,t):(r.add(o),m6e(n,t))}};var _ue=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ua(e,r,"all")]:Array.isArray(e)?[Ua(t,r,"all"),...e]:Tr(t)&&Tr(e)?QF([t,e]):`${t}${e}`};import{once as Yz}from"events";var yue=async(t,e)=>{let[r,n]=await b6e(t);return e.isForcefullyTerminated??=!1,[r,n]},b6e=async t=>{let[e,r]=await Promise.allSettled([Yz(t,"spawn"),Yz(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Sue(t):r.value},Sue=async t=>{try{return await Yz(t,"exit")}catch{return Sue(t)}},Eue=async t=>{let[e,r]=await t;if(!T6e(e,r)&&Kz(e,r))throw new Mo;return[e,r]},T6e=(t,e)=>t===void 0&&e===void 0,Kz=(t,e)=>t!==0||e!==null;var vue=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=w6e(t,e,r),s=o?.code==="ETIMEDOUT",a=gle(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},w6e=(t,e,r)=>t!==void 0?t:Kz(e,r)?new Mo:void 0;var bue=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=A6e(t,e,r),d=I6e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Ih(d,c,l)},A6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=k0(t,e,r),a=R6e(r),{file:c,commandArguments:l,options:u}=Q0(t,e,a);C6e(u);let d=Xle(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},R6e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,C6e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&yC("ipcInput"),t&&yC("ipc: true"),r&&yC("detached: true"),n&&yC("cancelSignal")},yC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},I6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=P6e({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}=vue(c,r),{output:h,error:m=l}=gue({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((E,b)=>Ua(E,r,b)),_=Ua(_ue(h,r),r,"all");return N6e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},P6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{fue(o,r);let a=O6e(r);return x6e(...eC(t,e,a))}catch(a){return Ch({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},O6e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:aC(e)}),N6e=({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?cC({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):pE({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 SWe}from"events";import{spawn as EWe}from"child_process";import Rue from"process";import{once as Zz,on as k6e}from"events";var Tue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(bh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:W0(t)}),M6e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),M6e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{q0(e,i);let o=sl(t,e,r),s=new AbortController;try{return await Promise.race([$6e(o,n,s),D6e(o,r,s),L6e(o,r,s)])}catch(a){throw Th(t),a}finally{s.abort(),V0(e,i)}},$6e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await Zz(t,"message",{signal:r});return n}for await(let[n]of k6e(t,"message",{signal:r}))if(e(n))return n},D6e=async(t,e,{signal:r})=>{await Zz(t,"disconnect",{signal:r}),lce(e)},L6e=async(t,e,{signal:r})=>{let[n]=await Zz(t,"strict:error",{signal:r});throw z0(n,e)};import{once as xue,on as U6e}from"events";var Aue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>Jz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),Jz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{bh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:W0(t)}),q0(e,o);let s=sl(t,e,r),a=new AbortController,c={};return F6e(t,s,a),z6e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),j6e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},F6e=async(t,e,r)=>{try{await xue(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},z6e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await xue(t,"strict:error",{signal:r.signal});n.error=z0(i,e),r.abort()}catch{}},j6e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of U6e(r,"message",{signal:o.signal}))wue(s),yield c}catch{wue(s)}finally{o.abort(),V0(e,a),n||Th(t),i&&await t}},wue=({error:t})=>{if(t)throw t};var Cue=(t,{ipc:e})=>{Object.assign(t,Pue(t,!1,e))},Iue=()=>{let t=Rue,e=!0,r=Rue.channel!==void 0;return{...Pue(t,e,r),getCancelSignal:Dce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Pue=(t,e,r)=>({sendMessage:J0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Tue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Aue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as B6e}from"child_process";import{PassThrough as q6e,Readable as V6e,Writable as G6e,Duplex as H6e}from"stream";var Oue=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{jz(n);let a=new B6e;W6e(a,n),Object.assign(a,{readable:Y6e,writable:K6e,duplex:Z6e});let c=Ch({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=J6e(c,s,i);return{subprocess:a,promise:l}},W6e=(t,e)=>{let r=mE(),n=mE(),i=mE(),o=Array.from({length:e.length-3},mE),s=mE(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},mE=()=>{let t=new q6e;return t.end(),t},Y6e=()=>new V6e({read(){}}),K6e=()=>new G6e({write(){}}),Z6e=()=>new H6e({read(){},write(){}}),J6e=async(t,e,r)=>Ih(t,e,r);import{createReadStream as Nue,createWriteStream as kue}from"fs";import{Buffer as X6e}from"buffer";import{Readable as gE,Writable as Q6e,Duplex as e3e}from"stream";var $ue=(t,e)=>fC(t3e,t,e,!1),_E=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${al[t]}.`)},Mue={fileNumber:_E,generator:Wz,asyncGenerator:Wz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:e3e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},t3e={input:{...Mue,fileUrl:({value:t})=>({stream:Nue(t)}),filePath:({value:{file:t}})=>({stream:Nue(t)}),webStream:({value:t})=>({stream:gE.fromWeb(t)}),iterable:({value:t})=>({stream:gE.from(t)}),asyncIterable:({value:t})=>({stream:gE.from(t)}),string:({value:t})=>({stream:gE.from(t)}),uint8Array:({value:t})=>({stream:gE.from(X6e.from(t))})},output:{...Mue,fileUrl:({value:t})=>({stream:kue(t)}),filePath:({value:{file:t,append:e}})=>({stream:kue(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Q6e.fromWeb(t)}),iterable:_E,asyncIterable:_E,string:_E,uint8Array:_E}};import{on as r3e,once as Due}from"events";import{PassThrough as n3e,getDefaultHighWaterMark as i3e}from"stream";import{finished as Fue}from"stream/promises";function Ed(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Qz(i);let e=t.some(({readableObjectMode:i})=>i),r=o3e(t,e),n=new Xz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var o3e=(t,e)=>{if(t.length===0)return i3e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},Xz=class extends n3e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(Qz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=s3e(this,this.#e,this.#o);let r=l3e({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(Qz(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)}},s3e=async(t,e,r)=>{SC(t,Lue);let n=new AbortController;try{await Promise.race([a3e(t,n),c3e(t,e,r,n)])}finally{n.abort(),SC(t,-Lue)}},a3e=async(t,{signal:e})=>{try{await Fue(t,{signal:e,cleanup:!0})}catch(r){throw zue(t,r),r}},c3e=async(t,e,r,{signal:n})=>{for await(let[i]of r3e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},Qz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},l3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{SC(t,Uue);let a=new AbortController;try{await Promise.race([u3e(o,e,a),d3e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),f3e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),SC(t,-Uue)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?ej(t):p3e(t))},u3e=async(t,e,{signal:r})=>{try{await t,r.aborted||ej(e)}catch(n){r.aborted||zue(e,n)}},d3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Fue(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;jue(s)?i.add(e):Bue(t,s)}},f3e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Due(t,i,{signal:o}),!t.readable)return Due(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},p3e=t=>{t.writable&&t.end()},zue=(t,e)=>{jue(e)?ej(t):Bue(t,e)},jue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",ej=t=>{(t.readable||t.writable)&&t.destroy()},Bue=(t,e)=>{t.destroyed||(t.once("error",h3e),t.destroy(e))},h3e=()=>{},SC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Lue=2,Uue=1;import{finished as que}from"stream/promises";var Oh=(t,e)=>{t.pipe(e),m3e(t,e),g3e(t,e)},m3e=async(t,e)=>{if(!(ko(t)||ko(e))){try{await que(t,{cleanup:!0,readable:!0,writable:!1})}catch{}tj(e)}},tj=t=>{t.writable&&t.end()},g3e=async(t,e)=>{if(!(ko(t)||ko(e))){try{await que(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rj(t)}},rj=t=>{t.readable&&t.destroy()};var Vue=(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})=>Zi.has(c)))_3e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zi.has(c)))S3e({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]:Ed(o);Oh(s,i)}},_3e=(t,e,r,n)=>{r==="output"?Oh(t.stdio[n],e):Oh(e,t.stdio[n]);let i=y3e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},y3e=["stdin","stdout","stderr"],S3e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;E3e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},E3e=(t,{signal:e})=>{ko(t)&&gd(t,v3e,e)},v3e=2;import{addAbortListener as w3e}from"events";var vd=[];vd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&vd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&vd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var EC=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",nj=Symbol.for("signal-exit emitter"),ij=globalThis,b3e=Object.defineProperty.bind(Object),oj=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ij[nj])return ij[nj];b3e(ij,nj,{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}},vC=class{},T3e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),sj=class extends vC{onExit(){return()=>{}}load(){}unload(){}},aj=class extends vC{#e=cj.platform==="win32"?"SIGINT":"SIGHUP";#r=new oj;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of vd)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(!EC(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 vd)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,vd.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 EC(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"&&EC(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)}},cj=globalThis.process,{onExit:Gue,load:zzt,unload:jzt}=T3e(EC(cj)?new aj(cj):new sj);var Hue=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Gue(()=>{t.kill()});w3e(n,()=>{i()})};var Yue=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=N0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=x3e(r,n,i),{sourceStream:d,sourceError:f}=R3e(t,l),{options:p,fileDescriptors:h}=Cs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},x3e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=A3e(t,e,...r),a=B0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},A3e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Wue,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||JF(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]=b0(r,...n);return{destination:e(Wue)(i,o,s),pipeOptions:s}}if(Cs.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}`)},Wue=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),R3e=(t,e)=>{try{return{sourceStream:wh(t,e)}}catch(r){return{sourceError:r}}};var Zue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=C3e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw lj({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},C3e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return rj(t),n;if(e!==void 0)return tj(r),e},lj=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Ch({error:t,command:Kue,escapedCommand:Kue,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Kue="source.pipe(destination)";var Jue=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 I3e}from"stream/promises";var Xue=(t,e,r)=>{let n=bC.has(e)?O3e(t,e):P3e(t,e);return gd(t,k3e,r.signal),gd(e,M3e,r.signal),N3e(e),n},P3e=(t,e)=>{let r=Ed([t]);return Oh(r,e),bC.set(e,r),r},O3e=(t,e)=>{let r=bC.get(e);return r.add(t),r},N3e=async t=>{try{await I3e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}bC.delete(t)},bC=new WeakMap,k3e=2,M3e=1;import{aborted as $3e}from"util";var Que=(t,e)=>t===void 0?[]:[D3e(t,e)],D3e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await $3e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw lj({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var TC=(t,...e)=>{if(lr(e[0]))return TC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Yue(t,...e),i=L3e({...n,destination:r});return i.pipe=TC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},L3e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=U3e(t,i);Zue({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Xue(e,o,d);return await Promise.race([Jue(u),...Que(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},U3e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as G3e}from"timers/promises";import{on as F3e}from"events";import{getDefaultHighWaterMark as z3e}from"stream";var wC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return j3e(e,s),tde({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},j3e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},uj=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;B3e(e,s,t);let a=t.readableObjectMode&&!o;return tde({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},B3e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},tde=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=F3e(t,"data",{signal:e.signal,highWaterMark:ede,highWatermark:ede});return q3e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},dj=z3e(!0),ede=dj,q3e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=V3e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Sd(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*hE(a)}},V3e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[hC(t,r,!e),pC(t,i,!n,{})].filter(Boolean);var rde=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=H3e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([W3e(t),d]);return}let f=Bz(c,r),p=uj({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([Y3e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},H3e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!_C({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=uj({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await pue(a,t,r,o)},W3e=async t=>{await G3e(),t.readableFlowing===null&&t.resume()},Y3e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await iC(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await oC(r,{maxBuffer:o})):await Rh(r,{maxBuffer:o})}catch(a){return nde(ple({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},fj=async t=>{try{return await t}catch(e){return nde(e)}},nde=({bufferedData:t})=>Ise(t)?new Uint8Array(t):t;import{finished as K3e}from"stream/promises";var yE=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=Z3e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],K3e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Q3e(a,e,r,n)}finally{s.abort()}},Z3e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&J3e(t,r,n),n},J3e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{X3e(e,r),n.call(t,...i)}},X3e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Q3e=(t,e,r,n)=>{if(!eWe(t,e,r,n))throw t},eWe=(t,e,r,n=!0)=>r.propagating?ide(t)||xC(t):(r.propagating=!0,pj(r,e)===n?ide(t):xC(t)),pj=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",xC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",ide=t=>t?.code==="EPIPE";var ode=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>hj({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),hj=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=yE(t,e,l);if(pj(l,e)){await u;return}let[d]=await Promise.all([rde({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 sde=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ed([t,e].filter(Boolean)):void 0,ade=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>hj({...tWe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:rWe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),tWe=({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}},rWe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as nWe}from"events";var cde=t=>Sh(t,"ipc"),lde=(t,e)=>{let r=O0(t);As({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ude=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=cde(o),a=Da(e,"ipc"),c=Da(r,"ipc");for await(let l of Jz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(hle(t,i,c),i.push(l)),s&&lde(l,o);return i},dde=async(t,e)=>(await Promise.allSettled([t]),e);var fde=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 E=yue(t,f),b={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},T=ode({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),w=ade({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),A=[],P=ude({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),C=iWe(m,t,b),M=oWe(h,b);try{return await Promise.race([Promise.all([{},Eue(E),Promise.all(T),w,P,Hce(t,d),...C,...M]),g,sWe(t,_),...jce(t,o,f,_),...cce({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Fce({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},E,Promise.all(T.map(v=>fj(v))),fj(w),dde(P,A),Promise.allSettled(C),Promise.allSettled(M)])}},iWe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:yE(n,i,r)),oWe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Do(o,{checkOpen:!1})&&!ko(o)).map(({type:i,value:o,stream:s=o})=>yE(s,n,e,{isSameDirection:Zi.has(i),stopOnExit:i==="native"}))),sWe=async(t,{signal:e})=>{let[r]=await nWe(t,"error",{signal:e});throw r};var pde=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),SE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Rs();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Nh=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 aWe}from"stream";import{callbackify as cWe}from"util";import{finished as hde}from"stream/promises";var mj=async t=>{if(t!==void 0)try{await gj(t)}catch{}},mde=async t=>{if(t!==void 0)try{await _j(t)}catch{}},gj=async t=>{await hde(t,{cleanup:!0,readable:!1,writable:!0})},_j=async t=>{await hde(t,{cleanup:!0,readable:!0,writable:!1})},AC=async(t,e)=>{if(await t,e)throw e},RC=(t,e,r)=>{r&&!xC(r)?t.destroy(r):e&&t.destroy()};var gde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||vi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=yj(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Sj(a,s),{read:f,onStdoutDataDone:p}=Ej({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new aWe({read:f,destroy:cWe(bj.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return vj({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},yj=(t,e,r)=>{let n=wh(t,e),i=SE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Sj=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:dj},Ej=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Rs(),s=wC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){lWe(this,s,o)},onStdoutDataDone:o}},lWe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},vj=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await _j(t),await n,await mj(i),await e,r.readable&&r.push(null)}catch(o){await mj(i),_de(r,o)}},bj=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Nh(r,e)&&(_de(t,n),await AC(e,n))},_de=(t,e)=>{RC(t,t.readable,e)};import{Writable as uWe}from"stream";import{callbackify as yde}from"util";var Sde=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Tj(t,r,e),s=new uWe({...wj(n,t,i),destroy:yde(Aj.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return xj(n,s),s},Tj=(t,e,r)=>{let n=B0(t,e),i=SE(r,n,"writableFinal"),o=SE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},wj=(t,e,r)=>({write:dWe.bind(void 0,t),final:yde(fWe.bind(void 0,t,e,r))}),dWe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},fWe=async(t,e,r)=>{await Nh(r,e)&&(t.writable&&t.end(),await e)},xj=async(t,e,r)=>{try{await gj(t),e.writable&&e.end()}catch(n){await mde(r),Ede(e,n)}},Aj=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Nh(r,e),await Nh(n,e)&&(Ede(t,i),await AC(e,i))},Ede=(t,e)=>{RC(t,t.writable,e)};import{Duplex as pWe}from"stream";import{callbackify as hWe}from"util";var vde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||vi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=yj(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Tj(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Sj(c,a),{read:g,onStdoutDataDone:_}=Ej({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),E=new pWe({read:g,...wj(u,t,d),destroy:hWe(mWe.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 vj({subprocessStdout:c,onStdoutDataDone:_,readable:E,subprocess:t,subprocessStdin:u}),xj(u,E,c),E},mWe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([bj({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Aj({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Rj=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||vi.has(e),s=wh(t,r),a=wC({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return gWe(a,s,t)},gWe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var bde=(t,{encoding:e})=>{let r=pde();t.readable=gde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Sde.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=vde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Rj.bind(void 0,t,e),t[Symbol.asyncIterator]=Rj.bind(void 0,t,e,{})};var Tde=(t,e)=>{for(let[r,n]of yWe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},_We=(async()=>{})().constructor.prototype,yWe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(_We,t)]);var wde=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=vWe(t,e,r),{subprocess:f,promise:p}=TWe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=TC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Tde(f,p),Cs.set(f,{options:u,fileDescriptors:d}),f},vWe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=k0(t,e,r),{file:a,commandArguments:c,options:l}=Q0(t,e,r),u=bWe(l),d=$ue(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},bWe=({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}},TWe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=EWe(...eC(t,e,r))}catch(h){return Oue({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;SWe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Vue(c,a,l),Hue(c,r,l);let d={},f=Rs();c.kill=sce.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=sde(c,r),bde(c,r),Cue(c,r);let p=wWe({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}},wWe=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 fde({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((T,w)=>Ua(T,e,w)),E=Ua(m,e,"all"),b=xWe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:E,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Ih(b,n,e)},xWe=({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?pE({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 Is,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):cC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var CC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,AWe(n,t[n],i)]));return{...t,...r}},AWe=(t,e,r)=>RWe.has(t)&&lr(e)&&lr(r)?{...e,...r}:r,RWe=new Set(["env",...nz]);var cl=(t,e,r,n)=>{let i=(s,a,c)=>cl(s,a,r,c),o=(...s)=>CWe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},CWe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(lr(o))return i(t,CC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=IWe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?bue(a,c,l):wde(a,c,l,i)},IWe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=$se(e)?Dse(e,r):[e,...r],[s,a,c]=b0(...o),l=CC(CC(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 xde=({file:t,commandArguments:e})=>Rde(t,e),Ade=({file:t,commandArguments:e})=>({...Rde(t,e),isSync:!0}),Rde=(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]=PWe(t);return{file:r,commandArguments:n}},PWe=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(OWe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},OWe=/ +/g;var Cde=(t,e,r)=>{t.sync=e(NWe,r),t.s=t.sync},Ide=({options:t})=>Pde(t),NWe=({options:t})=>({...Pde(t),isSync:!0}),Pde=t=>({options:{...kWe(t),...t}}),kWe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Ode={preferLocal:!0};var Nde=cl(()=>({})),P2t=cl(()=>({isSync:!0})),kde=cl(xde),O2t=cl(Ade),N2t=cl(qce),k2t=cl(Ide,{},Ode,Cde),{sendMessage:M2t,getOneMessage:$2t,getEachMessage:D2t,getCancelSignal:L2t}=Iue();var Mde=!1,$de=()=>{Mde=!0},Os=()=>Mde;var EE=null,Dde=t=>(EE&&EE.destroy(),EE=new Lo({totalAllowedTime:t}),EE),Lde=()=>EE;var Lo=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&&Os())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 u0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Z.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 Ude={name:"@netlify/agent-runner-cli",type:"module",version:"1.176.0-has-db-from-site.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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.17.6","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@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.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var LWe=$We(import.meta.url),UWe=Fa.dirname(LWe),FWe=DWe(import.meta.url),kh=ae("shell"),Cj=new Set,Fde={preferLocal:!0},Gt=(t,e,r)=>{let[n,i]=zWe(e,r),o={...Fde,...i},s=Nde(t,n,o);jde(s,o),Vde(s);let a=r?.idleTimeout;return a&&a>0&&qde(s,a),s},zde=(t,e)=>{let r={...Fde,...e},n=kde(t,r);return jde(n,r),Vde(n),e?.idleTimeout&&e.idleTimeout>0&&qde(n,e.idleTimeout),n},zWe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},jde=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ns.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ns.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new KS).pipe(Ns.stdout),t.stderr?.pipe(new KS).pipe(Ns.stderr);return}t.stdout?.pipe(Ns.stdout),t.stderr?.pipe(Ns.stderr)},Ij=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ns.kill(-t.pid,e),kh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return kh.error("Error killing process:",r),!1}},Bde=t=>Ij(t,"SIGKILL"),qde=(t,e)=>{let r=null,n=()=>{kh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Ij(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(kh.log(`Force killing idle process ${t.pid}`),Bde(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)},Vde=t=>{Cj.add(t);let e=Lde();if(e){let r=e.onTimesUp(()=>{kh.log(`Global timer expired, killing process ${t.pid}`),Ij(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(kh.log(`Force killing process ${t.pid} after timeout`),Bde(t))},5e3)});t.on("exit",()=>{Cj.delete(t),r()}),t.on("error",()=>{Cj.delete(t),r()})}};function ks(t,e){if(!Ns.env.NETLIFY_LOCAL_MODE)try{let i=FWe.resolve(Ude.name),o=Fa.dirname(i);for(;o!==Fa.dirname(o);){let s=Fa.dirname(o);if(Fa.basename(s)==="node_modules"){let a=Fa.join(s,".bin",e);if(IC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ns.env.NODE_PATH){let i=Fa.join(Ns.env.NODE_PATH,".bin",e);if(IC.existsSync(i))return i}let r=Fa.join(t,"node_modules",".bin",e);if(IC.existsSync(r))return r;let n=Fa.join(UWe,"..","node_modules",".bin",e);if(IC.existsSync(n))return n}var Gde=ae("repo"),Zde="runner-diffs-",Jde=t=>`${Zde}${t}-`,Xde=async t=>{let e=Kde.tmpdir(),r;try{r=await PC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Zde)&&!n.startsWith(Jde(t))).map(n=>PC.rm(OC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},hn=(t,e={})=>Gt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),NC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Gde.info("Getting runner diffs");let n=await VWe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=YWe(o);await KWe(h,r)}Gde.info("Changes after processing"),await Oj(r);let s=await kj(o,r);if(await Pj(s,r),i=await GWe(r),!i)return{hasChanges:!1,ignored:s};await hn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await PC.mkdtemp(OC.join(Kde.tmpdir(),Jde(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let E=OC.join(a,g);await hn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${E}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:T}=await PC.stat(E);return{path:E,size:T}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Yde(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await Wde(d,h)||(f=h)}await Yde(r),Z.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Wde(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},Hde=async t=>{let e=jWe("sha256");for await(let r of BWe(t))e.update(r);return e.digest("hex")},Wde=async(t,e)=>t.size===e.size&&await Hde(t.path)===await Hde(e.path),Yde=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await hn(["reset","--soft","HEAD~1"],{cwd:t})},Pj=async(t=[],e=process.cwd())=>{await hn(["add",".",...t],{cwd:e})},Oj=async(t=process.cwd())=>{let e=await hn(["status","-s"],{cwd:t});return String(e.stdout??"")},Qde=/.. (.+)?\.log$/,qWe=[Qde],VWe=async(t=process.cwd())=>{let e=await Oj(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
143
+ if (condition) { yield value; }`)};import{Buffer as XHe}from"buffer";import{StringDecoder as QHe}from"string_decoder";var hC=(t,e,r)=>{if(r)return;if(t)return{transform:e6e.bind(void 0,new TextEncoder)};let n=new QHe(e);return{transform:t6e.bind(void 0,n),final:r6e.bind(void 0,n)}},e6e=function*(t,e){XHe.isBuffer(e)?yield $a(e):typeof e=="string"?yield t.encode(e):yield e},t6e=function*(t,e){yield Tr(e)?t.write(e):e},r6e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as sue}from"util";var Gz=sue(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),mC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=i6e}=e[r];for await(let i of n(t))yield*mC(i,e,r+1)},aue=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*n6e(r,Number(e),t)},n6e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*mC(n,r,e+1)},cue=sue(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),i6e=function*(t){yield t};var Hz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},lue=(t,e)=>[...e.flatMap(r=>[...Sd(r,t,0)]),...hE(t)],Sd=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=s6e}=e[r];for(let i of n(t))yield*Sd(i,e,r+1)},hE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*o6e(r,Number(e),t)},o6e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Sd(n,r,e+1)},s6e=function*(t){yield t};var Wz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=due(t,s,o),l=yd(e),u=yd(r),d=l?Gz.bind(void 0,mC,a):Hz.bind(void 0,Sd),f=l||u?Gz.bind(void 0,aue,a):Hz.bind(void 0,hE),p=l||u?cue.bind(void 0,a):void 0;return{stream:new a6e({writableObjectMode:n,writableHighWaterMark:uue(n),readableObjectMode:i,readableHighWaterMark:uue(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},gC=(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=due(s,r,a);t=lue(c,t)}return t},due=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:nue(n,a)},hC(r,s,n),pC(r,o,n,c),{transform:t,final:e},{transform:iue(i,a)},rue({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var fue=(t,e)=>{for(let r of c6e(t))l6e(t,r,e)},c6e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),l6e=(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 ${al[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>u6e(a,n));r.input=iE(s)},u6e=(t,e)=>{let r=gC(t,e,"utf8",!0);return d6e(r),iE(r)},d6e=t=>{let e=t.find(r=>typeof r!="string"&&!Tr(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 m6e,appendFileSync as g6e}from"fs";var _C=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sh(r,n)&&!vi.has(e)&&f6e(n)&&(t.some(({type:i,value:o})=>i==="native"&&p6e.has(o))||t.every(({type:i})=>Zi.has(i))),f6e=t=>t===1||t===2,p6e=new Set(["pipe","overlapped"]),pue=async(t,e,r,n)=>{for await(let i of t)h6e(e)||mue(i,r,n)},hue=(t,e,r)=>{for(let n of t)mue(n,e,r)},h6e=t=>t._readableState.pipes.length>0,mue=(t,e,r)=>{let n=O0(t);As({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var gue=({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)=>_6e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},_6e=({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=_le(t,o,d),p=$a(f),{stdioItems:h,objectMode:m}=e[r],g=y6e([p],h,c,n),{serializedResult:_,finalResult:E=_}=S6e({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});E6e({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let b=a[r]?E:void 0;try{return n.error===void 0&&v6e(_,h,i),b}catch(T){return n.error=T,b}},y6e=(t,e,r,n)=>{try{return gC(t,e,r,!1)}catch(i){return n.error=i,t}},S6e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:iE(t)};let s=Ose(t,r);return n[o]?{serializedResult:s,finalResult:Vz(s,!i[o],e)}:{serializedResult:s}},E6e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!_C({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=Vz(t,!1,s);try{hue(a,e,n)}catch(c){r.error??=c}},v6e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>dC.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?g6e(n,t):(r.add(o),m6e(n,t))}};var _ue=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ua(e,r,"all")]:Array.isArray(e)?[Ua(t,r,"all"),...e]:Tr(t)&&Tr(e)?QF([t,e]):`${t}${e}`};import{once as Yz}from"events";var yue=async(t,e)=>{let[r,n]=await b6e(t);return e.isForcefullyTerminated??=!1,[r,n]},b6e=async t=>{let[e,r]=await Promise.allSettled([Yz(t,"spawn"),Yz(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Sue(t):r.value},Sue=async t=>{try{return await Yz(t,"exit")}catch{return Sue(t)}},Eue=async t=>{let[e,r]=await t;if(!T6e(e,r)&&Kz(e,r))throw new Mo;return[e,r]},T6e=(t,e)=>t===void 0&&e===void 0,Kz=(t,e)=>t!==0||e!==null;var vue=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=w6e(t,e,r),s=o?.code==="ETIMEDOUT",a=gle(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},w6e=(t,e,r)=>t!==void 0?t:Kz(e,r)?new Mo:void 0;var bue=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=A6e(t,e,r),d=I6e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Ih(d,c,l)},A6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=k0(t,e,r),a=R6e(r),{file:c,commandArguments:l,options:u}=Q0(t,e,a);C6e(u);let d=Xle(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},R6e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,C6e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&yC("ipcInput"),t&&yC("ipc: true"),r&&yC("detached: true"),n&&yC("cancelSignal")},yC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},I6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=P6e({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}=vue(c,r),{output:h,error:m=l}=gue({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((E,b)=>Ua(E,r,b)),_=Ua(_ue(h,r),r,"all");return N6e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},P6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{fue(o,r);let a=O6e(r);return x6e(...eC(t,e,a))}catch(a){return Ch({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},O6e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:aC(e)}),N6e=({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?cC({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):pE({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 SWe}from"events";import{spawn as EWe}from"child_process";import Rue from"process";import{once as Zz,on as k6e}from"events";var Tue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(bh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:W0(t)}),M6e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),M6e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{q0(e,i);let o=sl(t,e,r),s=new AbortController;try{return await Promise.race([$6e(o,n,s),D6e(o,r,s),L6e(o,r,s)])}catch(a){throw Th(t),a}finally{s.abort(),V0(e,i)}},$6e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await Zz(t,"message",{signal:r});return n}for await(let[n]of k6e(t,"message",{signal:r}))if(e(n))return n},D6e=async(t,e,{signal:r})=>{await Zz(t,"disconnect",{signal:r}),lce(e)},L6e=async(t,e,{signal:r})=>{let[n]=await Zz(t,"strict:error",{signal:r});throw z0(n,e)};import{once as xue,on as U6e}from"events";var Aue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>Jz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),Jz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{bh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:W0(t)}),q0(e,o);let s=sl(t,e,r),a=new AbortController,c={};return F6e(t,s,a),z6e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),j6e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},F6e=async(t,e,r)=>{try{await xue(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},z6e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await xue(t,"strict:error",{signal:r.signal});n.error=z0(i,e),r.abort()}catch{}},j6e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of U6e(r,"message",{signal:o.signal}))wue(s),yield c}catch{wue(s)}finally{o.abort(),V0(e,a),n||Th(t),i&&await t}},wue=({error:t})=>{if(t)throw t};var Cue=(t,{ipc:e})=>{Object.assign(t,Pue(t,!1,e))},Iue=()=>{let t=Rue,e=!0,r=Rue.channel!==void 0;return{...Pue(t,e,r),getCancelSignal:Dce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Pue=(t,e,r)=>({sendMessage:J0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Tue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Aue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as B6e}from"child_process";import{PassThrough as q6e,Readable as V6e,Writable as G6e,Duplex as H6e}from"stream";var Oue=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{jz(n);let a=new B6e;W6e(a,n),Object.assign(a,{readable:Y6e,writable:K6e,duplex:Z6e});let c=Ch({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=J6e(c,s,i);return{subprocess:a,promise:l}},W6e=(t,e)=>{let r=mE(),n=mE(),i=mE(),o=Array.from({length:e.length-3},mE),s=mE(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},mE=()=>{let t=new q6e;return t.end(),t},Y6e=()=>new V6e({read(){}}),K6e=()=>new G6e({write(){}}),Z6e=()=>new H6e({read(){},write(){}}),J6e=async(t,e,r)=>Ih(t,e,r);import{createReadStream as Nue,createWriteStream as kue}from"fs";import{Buffer as X6e}from"buffer";import{Readable as gE,Writable as Q6e,Duplex as e3e}from"stream";var $ue=(t,e)=>fC(t3e,t,e,!1),_E=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${al[t]}.`)},Mue={fileNumber:_E,generator:Wz,asyncGenerator:Wz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:e3e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},t3e={input:{...Mue,fileUrl:({value:t})=>({stream:Nue(t)}),filePath:({value:{file:t}})=>({stream:Nue(t)}),webStream:({value:t})=>({stream:gE.fromWeb(t)}),iterable:({value:t})=>({stream:gE.from(t)}),asyncIterable:({value:t})=>({stream:gE.from(t)}),string:({value:t})=>({stream:gE.from(t)}),uint8Array:({value:t})=>({stream:gE.from(X6e.from(t))})},output:{...Mue,fileUrl:({value:t})=>({stream:kue(t)}),filePath:({value:{file:t,append:e}})=>({stream:kue(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Q6e.fromWeb(t)}),iterable:_E,asyncIterable:_E,string:_E,uint8Array:_E}};import{on as r3e,once as Due}from"events";import{PassThrough as n3e,getDefaultHighWaterMark as i3e}from"stream";import{finished as Fue}from"stream/promises";function Ed(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Qz(i);let e=t.some(({readableObjectMode:i})=>i),r=o3e(t,e),n=new Xz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var o3e=(t,e)=>{if(t.length===0)return i3e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},Xz=class extends n3e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(Qz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=s3e(this,this.#e,this.#o);let r=l3e({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(Qz(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)}},s3e=async(t,e,r)=>{SC(t,Lue);let n=new AbortController;try{await Promise.race([a3e(t,n),c3e(t,e,r,n)])}finally{n.abort(),SC(t,-Lue)}},a3e=async(t,{signal:e})=>{try{await Fue(t,{signal:e,cleanup:!0})}catch(r){throw zue(t,r),r}},c3e=async(t,e,r,{signal:n})=>{for await(let[i]of r3e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},Qz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},l3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{SC(t,Uue);let a=new AbortController;try{await Promise.race([u3e(o,e,a),d3e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),f3e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),SC(t,-Uue)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?ej(t):p3e(t))},u3e=async(t,e,{signal:r})=>{try{await t,r.aborted||ej(e)}catch(n){r.aborted||zue(e,n)}},d3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Fue(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;jue(s)?i.add(e):Bue(t,s)}},f3e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Due(t,i,{signal:o}),!t.readable)return Due(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},p3e=t=>{t.writable&&t.end()},zue=(t,e)=>{jue(e)?ej(t):Bue(t,e)},jue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",ej=t=>{(t.readable||t.writable)&&t.destroy()},Bue=(t,e)=>{t.destroyed||(t.once("error",h3e),t.destroy(e))},h3e=()=>{},SC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Lue=2,Uue=1;import{finished as que}from"stream/promises";var Oh=(t,e)=>{t.pipe(e),m3e(t,e),g3e(t,e)},m3e=async(t,e)=>{if(!(ko(t)||ko(e))){try{await que(t,{cleanup:!0,readable:!0,writable:!1})}catch{}tj(e)}},tj=t=>{t.writable&&t.end()},g3e=async(t,e)=>{if(!(ko(t)||ko(e))){try{await que(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rj(t)}},rj=t=>{t.readable&&t.destroy()};var Vue=(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})=>Zi.has(c)))_3e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zi.has(c)))S3e({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]:Ed(o);Oh(s,i)}},_3e=(t,e,r,n)=>{r==="output"?Oh(t.stdio[n],e):Oh(e,t.stdio[n]);let i=y3e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},y3e=["stdin","stdout","stderr"],S3e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;E3e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},E3e=(t,{signal:e})=>{ko(t)&&gd(t,v3e,e)},v3e=2;import{addAbortListener as w3e}from"events";var vd=[];vd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&vd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&vd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var EC=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",nj=Symbol.for("signal-exit emitter"),ij=globalThis,b3e=Object.defineProperty.bind(Object),oj=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ij[nj])return ij[nj];b3e(ij,nj,{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}},vC=class{},T3e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),sj=class extends vC{onExit(){return()=>{}}load(){}unload(){}},aj=class extends vC{#e=cj.platform==="win32"?"SIGINT":"SIGHUP";#r=new oj;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of vd)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(!EC(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 vd)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,vd.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 EC(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"&&EC(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)}},cj=globalThis.process,{onExit:Gue,load:zzt,unload:jzt}=T3e(EC(cj)?new aj(cj):new sj);var Hue=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Gue(()=>{t.kill()});w3e(n,()=>{i()})};var Yue=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=N0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=x3e(r,n,i),{sourceStream:d,sourceError:f}=R3e(t,l),{options:p,fileDescriptors:h}=Cs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},x3e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=A3e(t,e,...r),a=B0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},A3e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Wue,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||JF(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]=b0(r,...n);return{destination:e(Wue)(i,o,s),pipeOptions:s}}if(Cs.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}`)},Wue=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),R3e=(t,e)=>{try{return{sourceStream:wh(t,e)}}catch(r){return{sourceError:r}}};var Zue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=C3e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw lj({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},C3e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return rj(t),n;if(e!==void 0)return tj(r),e},lj=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Ch({error:t,command:Kue,escapedCommand:Kue,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Kue="source.pipe(destination)";var Jue=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 I3e}from"stream/promises";var Xue=(t,e,r)=>{let n=bC.has(e)?O3e(t,e):P3e(t,e);return gd(t,k3e,r.signal),gd(e,M3e,r.signal),N3e(e),n},P3e=(t,e)=>{let r=Ed([t]);return Oh(r,e),bC.set(e,r),r},O3e=(t,e)=>{let r=bC.get(e);return r.add(t),r},N3e=async t=>{try{await I3e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}bC.delete(t)},bC=new WeakMap,k3e=2,M3e=1;import{aborted as $3e}from"util";var Que=(t,e)=>t===void 0?[]:[D3e(t,e)],D3e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await $3e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw lj({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var TC=(t,...e)=>{if(lr(e[0]))return TC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Yue(t,...e),i=L3e({...n,destination:r});return i.pipe=TC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},L3e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=U3e(t,i);Zue({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Xue(e,o,d);return await Promise.race([Jue(u),...Que(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},U3e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as G3e}from"timers/promises";import{on as F3e}from"events";import{getDefaultHighWaterMark as z3e}from"stream";var wC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return j3e(e,s),tde({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},j3e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},uj=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;B3e(e,s,t);let a=t.readableObjectMode&&!o;return tde({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},B3e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},tde=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=F3e(t,"data",{signal:e.signal,highWaterMark:ede,highWatermark:ede});return q3e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},dj=z3e(!0),ede=dj,q3e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=V3e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Sd(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*hE(a)}},V3e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[hC(t,r,!e),pC(t,i,!n,{})].filter(Boolean);var rde=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=H3e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([W3e(t),d]);return}let f=Bz(c,r),p=uj({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([Y3e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},H3e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!_C({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=uj({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await pue(a,t,r,o)},W3e=async t=>{await G3e(),t.readableFlowing===null&&t.resume()},Y3e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await iC(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await oC(r,{maxBuffer:o})):await Rh(r,{maxBuffer:o})}catch(a){return nde(ple({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},fj=async t=>{try{return await t}catch(e){return nde(e)}},nde=({bufferedData:t})=>Ise(t)?new Uint8Array(t):t;import{finished as K3e}from"stream/promises";var yE=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=Z3e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],K3e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Q3e(a,e,r,n)}finally{s.abort()}},Z3e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&J3e(t,r,n),n},J3e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{X3e(e,r),n.call(t,...i)}},X3e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Q3e=(t,e,r,n)=>{if(!eWe(t,e,r,n))throw t},eWe=(t,e,r,n=!0)=>r.propagating?ide(t)||xC(t):(r.propagating=!0,pj(r,e)===n?ide(t):xC(t)),pj=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",xC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",ide=t=>t?.code==="EPIPE";var ode=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>hj({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),hj=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=yE(t,e,l);if(pj(l,e)){await u;return}let[d]=await Promise.all([rde({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 sde=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ed([t,e].filter(Boolean)):void 0,ade=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>hj({...tWe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:rWe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),tWe=({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}},rWe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as nWe}from"events";var cde=t=>Sh(t,"ipc"),lde=(t,e)=>{let r=O0(t);As({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ude=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=cde(o),a=Da(e,"ipc"),c=Da(r,"ipc");for await(let l of Jz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(hle(t,i,c),i.push(l)),s&&lde(l,o);return i},dde=async(t,e)=>(await Promise.allSettled([t]),e);var fde=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 E=yue(t,f),b={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},T=ode({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),w=ade({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),A=[],P=ude({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),C=iWe(m,t,b),M=oWe(h,b);try{return await Promise.race([Promise.all([{},Eue(E),Promise.all(T),w,P,Hce(t,d),...C,...M]),g,sWe(t,_),...jce(t,o,f,_),...cce({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Fce({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},E,Promise.all(T.map(v=>fj(v))),fj(w),dde(P,A),Promise.allSettled(C),Promise.allSettled(M)])}},iWe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:yE(n,i,r)),oWe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Do(o,{checkOpen:!1})&&!ko(o)).map(({type:i,value:o,stream:s=o})=>yE(s,n,e,{isSameDirection:Zi.has(i),stopOnExit:i==="native"}))),sWe=async(t,{signal:e})=>{let[r]=await nWe(t,"error",{signal:e});throw r};var pde=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),SE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Rs();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Nh=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 aWe}from"stream";import{callbackify as cWe}from"util";import{finished as hde}from"stream/promises";var mj=async t=>{if(t!==void 0)try{await gj(t)}catch{}},mde=async t=>{if(t!==void 0)try{await _j(t)}catch{}},gj=async t=>{await hde(t,{cleanup:!0,readable:!1,writable:!0})},_j=async t=>{await hde(t,{cleanup:!0,readable:!0,writable:!1})},AC=async(t,e)=>{if(await t,e)throw e},RC=(t,e,r)=>{r&&!xC(r)?t.destroy(r):e&&t.destroy()};var gde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||vi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=yj(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Sj(a,s),{read:f,onStdoutDataDone:p}=Ej({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new aWe({read:f,destroy:cWe(bj.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return vj({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},yj=(t,e,r)=>{let n=wh(t,e),i=SE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Sj=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:dj},Ej=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Rs(),s=wC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){lWe(this,s,o)},onStdoutDataDone:o}},lWe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},vj=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await _j(t),await n,await mj(i),await e,r.readable&&r.push(null)}catch(o){await mj(i),_de(r,o)}},bj=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Nh(r,e)&&(_de(t,n),await AC(e,n))},_de=(t,e)=>{RC(t,t.readable,e)};import{Writable as uWe}from"stream";import{callbackify as yde}from"util";var Sde=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Tj(t,r,e),s=new uWe({...wj(n,t,i),destroy:yde(Aj.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return xj(n,s),s},Tj=(t,e,r)=>{let n=B0(t,e),i=SE(r,n,"writableFinal"),o=SE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},wj=(t,e,r)=>({write:dWe.bind(void 0,t),final:yde(fWe.bind(void 0,t,e,r))}),dWe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},fWe=async(t,e,r)=>{await Nh(r,e)&&(t.writable&&t.end(),await e)},xj=async(t,e,r)=>{try{await gj(t),e.writable&&e.end()}catch(n){await mde(r),Ede(e,n)}},Aj=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Nh(r,e),await Nh(n,e)&&(Ede(t,i),await AC(e,i))},Ede=(t,e)=>{RC(t,t.writable,e)};import{Duplex as pWe}from"stream";import{callbackify as hWe}from"util";var vde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||vi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=yj(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Tj(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Sj(c,a),{read:g,onStdoutDataDone:_}=Ej({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),E=new pWe({read:g,...wj(u,t,d),destroy:hWe(mWe.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 vj({subprocessStdout:c,onStdoutDataDone:_,readable:E,subprocess:t,subprocessStdin:u}),xj(u,E,c),E},mWe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([bj({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Aj({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Rj=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||vi.has(e),s=wh(t,r),a=wC({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return gWe(a,s,t)},gWe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var bde=(t,{encoding:e})=>{let r=pde();t.readable=gde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Sde.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=vde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Rj.bind(void 0,t,e),t[Symbol.asyncIterator]=Rj.bind(void 0,t,e,{})};var Tde=(t,e)=>{for(let[r,n]of yWe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},_We=(async()=>{})().constructor.prototype,yWe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(_We,t)]);var wde=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=vWe(t,e,r),{subprocess:f,promise:p}=TWe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=TC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Tde(f,p),Cs.set(f,{options:u,fileDescriptors:d}),f},vWe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=k0(t,e,r),{file:a,commandArguments:c,options:l}=Q0(t,e,r),u=bWe(l),d=$ue(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},bWe=({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}},TWe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=EWe(...eC(t,e,r))}catch(h){return Oue({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;SWe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Vue(c,a,l),Hue(c,r,l);let d={},f=Rs();c.kill=sce.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=sde(c,r),bde(c,r),Cue(c,r);let p=wWe({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}},wWe=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 fde({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((T,w)=>Ua(T,e,w)),E=Ua(m,e,"all"),b=xWe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:E,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Ih(b,n,e)},xWe=({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?pE({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 Is,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):cC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var CC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,AWe(n,t[n],i)]));return{...t,...r}},AWe=(t,e,r)=>RWe.has(t)&&lr(e)&&lr(r)?{...e,...r}:r,RWe=new Set(["env",...nz]);var cl=(t,e,r,n)=>{let i=(s,a,c)=>cl(s,a,r,c),o=(...s)=>CWe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},CWe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(lr(o))return i(t,CC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=IWe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?bue(a,c,l):wde(a,c,l,i)},IWe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=$se(e)?Dse(e,r):[e,...r],[s,a,c]=b0(...o),l=CC(CC(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 xde=({file:t,commandArguments:e})=>Rde(t,e),Ade=({file:t,commandArguments:e})=>({...Rde(t,e),isSync:!0}),Rde=(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]=PWe(t);return{file:r,commandArguments:n}},PWe=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(OWe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},OWe=/ +/g;var Cde=(t,e,r)=>{t.sync=e(NWe,r),t.s=t.sync},Ide=({options:t})=>Pde(t),NWe=({options:t})=>({...Pde(t),isSync:!0}),Pde=t=>({options:{...kWe(t),...t}}),kWe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Ode={preferLocal:!0};var Nde=cl(()=>({})),P2t=cl(()=>({isSync:!0})),kde=cl(xde),O2t=cl(Ade),N2t=cl(qce),k2t=cl(Ide,{},Ode,Cde),{sendMessage:M2t,getOneMessage:$2t,getEachMessage:D2t,getCancelSignal:L2t}=Iue();var Mde=!1,$de=()=>{Mde=!0},Os=()=>Mde;var EE=null,Dde=t=>(EE&&EE.destroy(),EE=new Lo({totalAllowedTime:t}),EE),Lde=()=>EE;var Lo=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&&Os())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 u0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Z.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 Ude={name:"@netlify/agent-runner-cli",type:"module",version:"1.176.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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.17.6","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@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.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var LWe=$We(import.meta.url),UWe=Fa.dirname(LWe),FWe=DWe(import.meta.url),kh=ae("shell"),Cj=new Set,Fde={preferLocal:!0},Gt=(t,e,r)=>{let[n,i]=zWe(e,r),o={...Fde,...i},s=Nde(t,n,o);jde(s,o),Vde(s);let a=r?.idleTimeout;return a&&a>0&&qde(s,a),s},zde=(t,e)=>{let r={...Fde,...e},n=kde(t,r);return jde(n,r),Vde(n),e?.idleTimeout&&e.idleTimeout>0&&qde(n,e.idleTimeout),n},zWe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},jde=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ns.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ns.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new KS).pipe(Ns.stdout),t.stderr?.pipe(new KS).pipe(Ns.stderr);return}t.stdout?.pipe(Ns.stdout),t.stderr?.pipe(Ns.stderr)},Ij=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ns.kill(-t.pid,e),kh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return kh.error("Error killing process:",r),!1}},Bde=t=>Ij(t,"SIGKILL"),qde=(t,e)=>{let r=null,n=()=>{kh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Ij(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(kh.log(`Force killing idle process ${t.pid}`),Bde(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)},Vde=t=>{Cj.add(t);let e=Lde();if(e){let r=e.onTimesUp(()=>{kh.log(`Global timer expired, killing process ${t.pid}`),Ij(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(kh.log(`Force killing process ${t.pid} after timeout`),Bde(t))},5e3)});t.on("exit",()=>{Cj.delete(t),r()}),t.on("error",()=>{Cj.delete(t),r()})}};function ks(t,e){if(!Ns.env.NETLIFY_LOCAL_MODE)try{let i=FWe.resolve(Ude.name),o=Fa.dirname(i);for(;o!==Fa.dirname(o);){let s=Fa.dirname(o);if(Fa.basename(s)==="node_modules"){let a=Fa.join(s,".bin",e);if(IC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ns.env.NODE_PATH){let i=Fa.join(Ns.env.NODE_PATH,".bin",e);if(IC.existsSync(i))return i}let r=Fa.join(t,"node_modules",".bin",e);if(IC.existsSync(r))return r;let n=Fa.join(UWe,"..","node_modules",".bin",e);if(IC.existsSync(n))return n}var Gde=ae("repo"),Zde="runner-diffs-",Jde=t=>`${Zde}${t}-`,Xde=async t=>{let e=Kde.tmpdir(),r;try{r=await PC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Zde)&&!n.startsWith(Jde(t))).map(n=>PC.rm(OC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},hn=(t,e={})=>Gt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),NC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Gde.info("Getting runner diffs");let n=await VWe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=YWe(o);await KWe(h,r)}Gde.info("Changes after processing"),await Oj(r);let s=await kj(o,r);if(await Pj(s,r),i=await GWe(r),!i)return{hasChanges:!1,ignored:s};await hn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await PC.mkdtemp(OC.join(Kde.tmpdir(),Jde(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let E=OC.join(a,g);await hn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${E}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:T}=await PC.stat(E);return{path:E,size:T}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Yde(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await Wde(d,h)||(f=h)}await Yde(r),Z.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Wde(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},Hde=async t=>{let e=jWe("sha256");for await(let r of BWe(t))e.update(r);return e.digest("hex")},Wde=async(t,e)=>t.size===e.size&&await Hde(t.path)===await Hde(e.path),Yde=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await hn(["reset","--soft","HEAD~1"],{cwd:t})},Pj=async(t=[],e=process.cwd())=>{await hn(["add",".",...t],{cwd:e})},Oj=async(t=process.cwd())=>{let e=await hn(["status","-s"],{cwd:t});return String(e.stdout??"")},Qde=/.. (.+)?\.log$/,qWe=[Qde],VWe=async(t=process.cwd())=>{let e=await Oj(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
144
144
  `).filter(i=>qWe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},GWe=async(t=process.cwd())=>{try{return await hn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},Nj=async(t=process.cwd())=>{let{stdout:e}=await hn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},HWe=1,WWe=async t=>{try{return await hn(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===HWe)return!1;throw e}},efe=async(t=process.cwd())=>{if(!await WWe(t))return!0;let{stdout:e}=await hn(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},tfe=async(t=process.cwd())=>{let{stdout:e}=await hn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},kj=async(t,e=process.cwd())=>{t||=await Oj(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(`
145
145
  `).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${OC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Qde)?.[1];o&&n.push(`:!${o}.log`)}),n},rfe=async(t=process.cwd())=>{await hn(["reset","--hard","HEAD"],{cwd:t})},nfe=async(t=process.cwd())=>{let e=await hn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
146
146
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},YWe=t=>{let e=t.split(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/agent-runner-cli",
3
3
  "type": "module",
4
- "version": "1.176.0-has-db-from-site.0",
4
+ "version": "1.176.0",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",