@netlify/agent-runner-cli 1.170.0-local-ui-preview.0 → 1.170.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 +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
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:fz},xGe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},AGe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:xGe};import{Buffer as RGe}from"buffer";var rle=(t,e)=>t?void 0:CGe.bind(void 0,e),CGe=function*(t,e){if(typeof e!="string"&&!yr(e)&&!RGe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},nle=(t,e)=>t?IGe.bind(void 0,e):PGe.bind(void 0,e),IGe=function*(t,e){ile(t,e),yield e},PGe=function*(t,e){if(ile(t,e),typeof e!="string"&&!yr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},ile=(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 OGe}from"buffer";import{StringDecoder as NGe}from"string_decoder";var H0=(t,e,r)=>{if(r)return;if(t)return{transform:kGe.bind(void 0,new TextEncoder)};let n=new NGe(e);return{transform:MGe.bind(void 0,n),final:$Ge.bind(void 0,n)}},kGe=function*(t,e){OGe.isBuffer(e)?yield ka(e):typeof e=="string"?yield t.encode(e):yield e},MGe=function*(t,e){yield yr(e)?t.write(e):e},$Ge=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as ole}from"util";var hz=ole(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),W0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=LGe}=e[r];for await(let i of n(t))yield*W0(i,e,r+1)},sle=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*DGe(r,Number(e),t)},DGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*W0(n,r,e+1)},ale=ole(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),LGe=function*(t){yield t};var mz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},cle=(t,e)=>[...e.flatMap(r=>[...dd(r,t,0)]),...WS(t)],dd=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=FGe}=e[r];for(let i of n(t))yield*dd(i,e,r+1)},WS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*UGe(r,Number(e),t)},UGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*dd(n,r,e+1)},FGe=function*(t){yield t};var gz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=ule(t,s,o),l=ud(e),u=ud(r),d=l?hz.bind(void 0,W0,a):mz.bind(void 0,dd),f=l||u?hz.bind(void 0,sle,a):mz.bind(void 0,WS),p=l||u?ale.bind(void 0,a):void 0;return{stream:new zGe({writableObjectMode:n,writableHighWaterMark:lle(n),readableObjectMode:i,readableHighWaterMark:lle(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},Y0=(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=ule(s,r,a);t=cle(c,t)}return t},ule=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:rle(n,a)},H0(r,s,n),G0(r,o,n,c),{transform:t,final:e},{transform:nle(i,a)},tle({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var dle=(t,e)=>{for(let r of jGe(t))BGe(t,r,e)},jGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),BGe=(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 ${rl[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>qGe(a,n));r.input=LS(s)},qGe=(t,e)=>{let r=Y0(t,e,"utf8",!0);return VGe(r),LS(r)},VGe=t=>{let e=t.find(r=>typeof r!="string"&&!yr(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 YGe,appendFileSync as KGe}from"fs";var K0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&rh(r,n)&&!_i.has(e)&&GGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&HGe.has(o))||t.every(({type:i})=>Hi.has(i))),GGe=t=>t===1||t===2,HGe=new Set(["pipe","overlapped"]),fle=async(t,e,r,n)=>{for await(let i of t)WGe(e)||hle(i,r,n)},ple=(t,e,r)=>{for(let n of t)hle(n,e,r)},WGe=t=>t._readableState.pipes.length>0,hle=(t,e,r)=>{let n=l0(t);Ts({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var mle=({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)=>ZGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},ZGe=({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=gce(t,o,d),p=ka(f),{stdioItems:h,objectMode:m}=e[r],g=JGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=XGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});QGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?b:void 0;try{return n.error===void 0&&eHe(_,h,i),T}catch(S){return n.error=S,T}},JGe=(t,e,r,n)=>{try{return Y0(t,e,r,!1)}catch(i){return n.error=i,t}},XGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:LS(t)};let s=Poe(t,r);return n[o]?{serializedResult:s,finalResult:pz(s,!i[o],e)}:{serializedResult:s}},QGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!K0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=pz(t,!1,s);try{ple(a,e,n)}catch(c){r.error??=c}},eHe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>q0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?KGe(n,t):(r.add(o),YGe(n,t))}};var gle=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Da(e,r,"all")]:Array.isArray(e)?[Da(t,r,"all"),...e]:yr(t)&&yr(e)?bF([t,e]):`${t}${e}`};import{once as _z}from"events";var _le=async(t,e)=>{let[r,n]=await tHe(t);return e.isForcefullyTerminated??=!1,[r,n]},tHe=async t=>{let[e,r]=await Promise.allSettled([_z(t,"spawn"),_z(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?yle(t):r.value},yle=async t=>{try{return await _z(t,"exit")}catch{return yle(t)}},Sle=async t=>{let[e,r]=await t;if(!rHe(e,r)&&yz(e,r))throw new No;return[e,r]},rHe=(t,e)=>t===void 0&&e===void 0,yz=(t,e)=>t!==0||e!==null;var Ele=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=nHe(t,e,r),s=o?.code==="ETIMEDOUT",a=mce(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},nHe=(t,e,r)=>t!==void 0?t:yz(e,r)?new No:void 0;var vle=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=oHe(t,e,r),d=cHe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return fh(d,c,l)},oHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=d0(t,e,r),a=sHe(r),{file:c,commandArguments:l,options:u}=O0(t,e,a);aHe(u);let d=Jce(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},sHe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,aHe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Z0("ipcInput"),t&&Z0("ipc: true"),r&&Z0("detached: true"),n&&Z0("cancelSignal")},Z0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},cHe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=lHe({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}=Ele(c,r),{output:h,error:m=l}=mle({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>Da(b,r,T)),_=Da(gle(h,r),r,"all");return dHe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},lHe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{dle(o,r);let a=uHe(r);return iHe(...N0(t,e,a))}catch(a){return dh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},uHe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:F0(e)}),dHe=({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?z0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):HS({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 X6e}from"events";import{spawn as Q6e}from"child_process";import Ale from"process";import{once as Sz,on as fHe}from"events";var ble=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(oh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:x0(t)}),pHe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),pHe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{v0(e,i);let o=tl(t,e,r),s=new AbortController;try{return await Promise.race([hHe(o,n,s),mHe(o,r,s),gHe(o,r,s)])}catch(a){throw sh(t),a}finally{s.abort(),b0(e,i)}},hHe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await Sz(t,"message",{signal:r});return n}for await(let[n]of fHe(t,"message",{signal:r}))if(e(n))return n},mHe=async(t,e,{signal:r})=>{await Sz(t,"disconnect",{signal:r}),cae(e)},gHe=async(t,e,{signal:r})=>{let[n]=await Sz(t,"strict:error",{signal:r});throw y0(n,e)};import{once as wle,on as _He}from"events";var xle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>Ez({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),Ez=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{oh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:x0(t)}),v0(e,o);let s=tl(t,e,r),a=new AbortController,c={};return yHe(t,s,a),SHe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),EHe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},yHe=async(t,e,r)=>{try{await wle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},SHe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await wle(t,"strict:error",{signal:r.signal});n.error=y0(i,e),r.abort()}catch{}},EHe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of _He(r,"message",{signal:o.signal}))Tle(s),yield c}catch{Tle(s)}finally{o.abort(),b0(e,a),n||sh(t),i&&await t}},Tle=({error:t})=>{if(t)throw t};var Rle=(t,{ipc:e})=>{Object.assign(t,Ile(t,!1,e))},Cle=()=>{let t=Ale,e=!0,r=Ale.channel!==void 0;return{...Ile(t,e,r),getCancelSignal:$ae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Ile=(t,e,r)=>({sendMessage:I0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ble.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:xle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as vHe}from"child_process";import{PassThrough as bHe,Readable as THe,Writable as wHe,Duplex as xHe}from"stream";var Ple=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{uz(n);let a=new vHe;AHe(a,n),Object.assign(a,{readable:RHe,writable:CHe,duplex:IHe});let c=dh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=PHe(c,s,i);return{subprocess:a,promise:l}},AHe=(t,e)=>{let r=YS(),n=YS(),i=YS(),o=Array.from({length:e.length-3},YS),s=YS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},YS=()=>{let t=new bHe;return t.end(),t},RHe=()=>new THe({read(){}}),CHe=()=>new wHe({write(){}}),IHe=()=>new xHe({read(){},write(){}}),PHe=async(t,e,r)=>fh(t,e,r);import{createReadStream as Ole,createWriteStream as Nle}from"fs";import{Buffer as OHe}from"buffer";import{Readable as KS,Writable as NHe,Duplex as kHe}from"stream";var Mle=(t,e)=>V0(MHe,t,e,!1),ZS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${rl[t]}.`)},kle={fileNumber:ZS,generator:gz,asyncGenerator:gz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:kHe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},MHe={input:{...kle,fileUrl:({value:t})=>({stream:Ole(t)}),filePath:({value:{file:t}})=>({stream:Ole(t)}),webStream:({value:t})=>({stream:KS.fromWeb(t)}),iterable:({value:t})=>({stream:KS.from(t)}),asyncIterable:({value:t})=>({stream:KS.from(t)}),string:({value:t})=>({stream:KS.from(t)}),uint8Array:({value:t})=>({stream:KS.from(OHe.from(t))})},output:{...kle,fileUrl:({value:t})=>({stream:Nle(t)}),filePath:({value:{file:t,append:e}})=>({stream:Nle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:NHe.fromWeb(t)}),iterable:ZS,asyncIterable:ZS,string:ZS,uint8Array:ZS}};import{on as $He,once as $le}from"events";import{PassThrough as DHe,getDefaultHighWaterMark as LHe}from"stream";import{finished as Ule}from"stream/promises";function fd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)bz(i);let e=t.some(({readableObjectMode:i})=>i),r=UHe(t,e),n=new vz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var UHe=(t,e)=>{if(t.length===0)return LHe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},vz=class extends DHe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(bz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=FHe(this,this.#e,this.#o);let r=BHe({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(bz(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)}},FHe=async(t,e,r)=>{J0(t,Dle);let n=new AbortController;try{await Promise.race([zHe(t,n),jHe(t,e,r,n)])}finally{n.abort(),J0(t,-Dle)}},zHe=async(t,{signal:e})=>{try{await Ule(t,{signal:e,cleanup:!0})}catch(r){throw Fle(t,r),r}},jHe=async(t,e,r,{signal:n})=>{for await(let[i]of $He(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},bz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},BHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{J0(t,Lle);let a=new AbortController;try{await Promise.race([qHe(o,e,a),VHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),GHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),J0(t,-Lle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?Tz(t):HHe(t))},qHe=async(t,e,{signal:r})=>{try{await t,r.aborted||Tz(e)}catch(n){r.aborted||Fle(e,n)}},VHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Ule(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;zle(s)?i.add(e):jle(t,s)}},GHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await $le(t,i,{signal:o}),!t.readable)return $le(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},HHe=t=>{t.writable&&t.end()},Fle=(t,e)=>{zle(e)?Tz(t):jle(t,e)},zle=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Tz=t=>{(t.readable||t.writable)&&t.destroy()},jle=(t,e)=>{t.destroyed||(t.once("error",WHe),t.destroy(e))},WHe=()=>{},J0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Dle=2,Lle=1;import{finished as Ble}from"stream/promises";var hh=(t,e)=>{t.pipe(e),YHe(t,e),KHe(t,e)},YHe=async(t,e)=>{if(!(Oo(t)||Oo(e))){try{await Ble(t,{cleanup:!0,readable:!0,writable:!1})}catch{}wz(e)}},wz=t=>{t.writable&&t.end()},KHe=async(t,e)=>{if(!(Oo(t)||Oo(e))){try{await Ble(e,{cleanup:!0,readable:!1,writable:!0})}catch{}xz(t)}},xz=t=>{t.readable&&t.destroy()};var qle=(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})=>Hi.has(c)))ZHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Hi.has(c)))XHe({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]:fd(o);hh(s,i)}},ZHe=(t,e,r,n)=>{r==="output"?hh(t.stdio[n],e):hh(e,t.stdio[n]);let i=JHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},JHe=["stdin","stdout","stderr"],XHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;QHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},QHe=(t,{signal:e})=>{Oo(t)&&cd(t,e6e,e)},e6e=2;import{addAbortListener as n6e}from"events";var pd=[];pd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&pd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&pd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var X0=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",Az=Symbol.for("signal-exit emitter"),Rz=globalThis,t6e=Object.defineProperty.bind(Object),Cz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Rz[Az])return Rz[Az];t6e(Rz,Az,{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}},Q0=class{},r6e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Iz=class extends Q0{onExit(){return()=>{}}load(){}unload(){}},Pz=class extends Q0{#e=Oz.platform==="win32"?"SIGINT":"SIGHUP";#r=new Cz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of pd)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(!X0(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 pd)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,pd.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 X0(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"&&X0(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)}},Oz=globalThis.process,{onExit:Vle,load:JUt,unload:XUt}=r6e(X0(Oz)?new Pz(Oz):new Iz);var Gle=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Vle(()=>{t.kill()});n6e(n,()=>{i()})};var Wle=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=u0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=i6e(r,n,i),{sourceStream:d,sourceError:f}=s6e(t,l),{options:p,fileDescriptors:h}=xs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},i6e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=o6e(t,e,...r),a=E0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},o6e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Hle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||EF(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]=e0(r,...n);return{destination:e(Hle)(i,o,s),pipeOptions:s}}if(xs.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}`)},Hle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),s6e=(t,e)=>{try{return{sourceStream:ah(t,e)}}catch(r){return{sourceError:r}}};var Kle=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=a6e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw Nz({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},a6e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return xz(t),n;if(e!==void 0)return wz(r),e},Nz=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>dh({error:t,command:Yle,escapedCommand:Yle,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Yle="source.pipe(destination)";var Zle=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 c6e}from"stream/promises";var Jle=(t,e,r)=>{let n=eC.has(e)?u6e(t,e):l6e(t,e);return cd(t,f6e,r.signal),cd(e,p6e,r.signal),d6e(e),n},l6e=(t,e)=>{let r=fd([t]);return hh(r,e),eC.set(e,r),r},u6e=(t,e)=>{let r=eC.get(e);return r.add(t),r},d6e=async t=>{try{await c6e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}eC.delete(t)},eC=new WeakMap,f6e=2,p6e=1;import{aborted as h6e}from"util";var Xle=(t,e)=>t===void 0?[]:[m6e(t,e)],m6e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await h6e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw Nz({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var tC=(t,...e)=>{if(sr(e[0]))return tC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Wle(t,...e),i=g6e({...n,destination:r});return i.pipe=tC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},g6e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=_6e(t,i);Kle({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Jle(e,o,d);return await Promise.race([Zle(u),...Xle(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},_6e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as w6e}from"timers/promises";import{on as y6e}from"events";import{getDefaultHighWaterMark as S6e}from"stream";var rC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return E6e(e,s),eue({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},E6e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},kz=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;v6e(e,s,t);let a=t.readableObjectMode&&!o;return eue({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},v6e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},eue=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=y6e(t,"data",{signal:e.signal,highWaterMark:Qle,highWatermark:Qle});return b6e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},Mz=S6e(!0),Qle=Mz,b6e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=T6e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*dd(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*WS(a)}},T6e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[H0(t,r,!e),G0(t,i,!n,{})].filter(Boolean);var tue=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=x6e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([A6e(t),d]);return}let f=dz(c,r),p=kz({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([R6e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},x6e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!K0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=kz({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await fle(a,t,r,o)},A6e=async t=>{await w6e(),t.readableFlowing===null&&t.resume()},R6e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await D0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await L0(r,{maxBuffer:o})):await uh(r,{maxBuffer:o})}catch(a){return rue(fce({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},$z=async t=>{try{return await t}catch(e){return rue(e)}},rue=({bufferedData:t})=>Coe(t)?new Uint8Array(t):t;import{finished as C6e}from"stream/promises";var JS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=I6e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],C6e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||N6e(a,e,r,n)}finally{s.abort()}},I6e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&P6e(t,r,n),n},P6e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{O6e(e,r),n.call(t,...i)}},O6e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},N6e=(t,e,r,n)=>{if(!k6e(t,e,r,n))throw t},k6e=(t,e,r,n=!0)=>r.propagating?nue(t)||nC(t):(r.propagating=!0,Dz(r,e)===n?nue(t):nC(t)),Dz=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",nC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",nue=t=>t?.code==="EPIPE";var iue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>Lz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Lz=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=JS(t,e,l);if(Dz(l,e)){await u;return}let[d]=await Promise.all([tue({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 oue=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?fd([t,e].filter(Boolean)):void 0,sue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Lz({...M6e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:$6e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),M6e=({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}},$6e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as D6e}from"events";var aue=t=>rh(t,"ipc"),cue=(t,e)=>{let r=l0(t);Ts({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var lue=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=aue(o),a=Ma(e,"ipc"),c=Ma(r,"ipc");for await(let l of Ez({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(pce(t,i,c),i.push(l)),s&&cue(l,o);return i},uue=async(t,e)=>(await Promise.allSettled([t]),e);var due=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 b=_le(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=iue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=sue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),P=[],R=lue({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),O=L6e(m,t,T),M=U6e(h,T);try{return await Promise.race([Promise.all([{},Sle(b),Promise.all(S),x,R,Gae(t,d),...O,...M]),g,F6e(t,_),...zae(t,o,f,_),...aae({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Uae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(U){return f.terminationReason??="other",Promise.all([{error:U},b,Promise.all(S.map(v=>$z(v))),$z(x),uue(R,P),Promise.allSettled(O),Promise.allSettled(M)])}},L6e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:JS(n,i,r)),U6e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Mo(o,{checkOpen:!1})&&!Oo(o)).map(({type:i,value:o,stream:s=o})=>JS(s,n,e,{isSameDirection:Hi.has(i),stopOnExit:i==="native"}))),F6e=async(t,{signal:e})=>{let[r]=await D6e(t,"error",{signal:e});throw r};var fue=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),XS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ws();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},mh=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 z6e}from"stream";import{callbackify as j6e}from"util";import{finished as pue}from"stream/promises";var Uz=async t=>{if(t!==void 0)try{await Fz(t)}catch{}},hue=async t=>{if(t!==void 0)try{await zz(t)}catch{}},Fz=async t=>{await pue(t,{cleanup:!0,readable:!1,writable:!0})},zz=async t=>{await pue(t,{cleanup:!0,readable:!0,writable:!1})},iC=async(t,e)=>{if(await t,e)throw e},oC=(t,e,r)=>{r&&!nC(r)?t.destroy(r):e&&t.destroy()};var mue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_i.has(r),{subprocessStdout:a,waitReadableDestroy:c}=jz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Bz(a,s),{read:f,onStdoutDataDone:p}=qz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new z6e({read:f,destroy:j6e(Gz.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Vz({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},jz=(t,e,r)=>{let n=ah(t,e),i=XS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Bz=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:Mz},qz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ws(),s=rC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){B6e(this,s,o)},onStdoutDataDone:o}},B6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Vz=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await zz(t),await n,await Uz(i),await e,r.readable&&r.push(null)}catch(o){await Uz(i),gue(r,o)}},Gz=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await mh(r,e)&&(gue(t,n),await iC(e,n))},gue=(t,e)=>{oC(t,t.readable,e)};import{Writable as q6e}from"stream";import{callbackify as _ue}from"util";var yue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Hz(t,r,e),s=new q6e({...Wz(n,t,i),destroy:_ue(Kz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Yz(n,s),s},Hz=(t,e,r)=>{let n=E0(t,e),i=XS(r,n,"writableFinal"),o=XS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Wz=(t,e,r)=>({write:V6e.bind(void 0,t),final:_ue(G6e.bind(void 0,t,e,r))}),V6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},G6e=async(t,e,r)=>{await mh(r,e)&&(t.writable&&t.end(),await e)},Yz=async(t,e,r)=>{try{await Fz(t),e.writable&&e.end()}catch(n){await hue(r),Sue(e,n)}},Kz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await mh(r,e),await mh(n,e)&&(Sue(t,i),await iC(e,i))},Sue=(t,e)=>{oC(t,t.writable,e)};import{Duplex as H6e}from"stream";import{callbackify as W6e}from"util";var Eue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_i.has(r),{subprocessStdout:c,waitReadableDestroy:l}=jz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Hz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Bz(c,a),{read:g,onStdoutDataDone:_}=qz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new H6e({read:g,...Wz(u,t,d),destroy:W6e(Y6e.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 Vz({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),Yz(u,b,c),b},Y6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([Gz({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Kz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Zz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_i.has(e),s=ah(t,r),a=rC({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return K6e(a,s,t)},K6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var vue=(t,{encoding:e})=>{let r=fue();t.readable=mue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=yue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Eue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Zz.bind(void 0,t,e),t[Symbol.asyncIterator]=Zz.bind(void 0,t,e,{})};var bue=(t,e)=>{for(let[r,n]of J6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Z6e=(async()=>{})().constructor.prototype,J6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Z6e,t)]);var Tue=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=e3e(t,e,r),{subprocess:f,promise:p}=r3e({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}),bue(f,p),xs.set(f,{options:u,fileDescriptors:d}),f},e3e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=d0(t,e,r),{file:a,commandArguments:c,options:l}=O0(t,e,r),u=t3e(l),d=Mle(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},t3e=({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}},r3e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=Q6e(...N0(t,e,r))}catch(h){return Ple({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;X6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];qle(c,a,l),Gle(c,r,l);let d={},f=ws();c.kill=oae.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=oue(c,r),vue(c,r),Rle(c,r);let p=n3e({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}},n3e=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 due({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((S,x)=>Da(S,e,x)),b=Da(m,e,"all"),T=i3e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return fh(T,n,e)},i3e=({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?HS({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 As,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):z0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var sC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,o3e(n,t[n],i)]));return{...t,...r}},o3e=(t,e,r)=>s3e.has(t)&&sr(e)&&sr(r)?{...e,...r}:r,s3e=new Set(["env",...AF]);var nl=(t,e,r,n)=>{let i=(s,a,c)=>nl(s,a,r,c),o=(...s)=>a3e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},a3e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(sr(o))return i(t,sC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=c3e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?vle(a,c,l):Tue(a,c,l,i)},c3e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Moe(e)?$oe(e,r):[e,...r],[s,a,c]=e0(...o),l=sC(sC(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 wue=({file:t,commandArguments:e})=>Aue(t,e),xue=({file:t,commandArguments:e})=>({...Aue(t,e),isSync:!0}),Aue=(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]=l3e(t);return{file:r,commandArguments:n}},l3e=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(u3e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},u3e=/ +/g;var Rue=(t,e,r)=>{t.sync=e(d3e,r),t.s=t.sync},Cue=({options:t})=>Iue(t),d3e=({options:t})=>({...Iue(t),isSync:!0}),Iue=t=>({options:{...f3e(t),...t}}),f3e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Pue={preferLocal:!0};var Oue=nl(()=>({})),jjt=nl(()=>({isSync:!0})),Nue=nl(wue),Bjt=nl(xue),qjt=nl(Bae),Vjt=nl(Cue,{},Pue,Rue),{sendMessage:Gjt,getOneMessage:Hjt,getEachMessage:Wjt,getCancelSignal:Yjt}=Cle();var kue=!1,Mue=()=>{kue=!0},Cs=()=>kue;var QS=null,$ue=t=>(QS&&QS.destroy(),QS=new $o({totalAllowedTime:t}),QS),Due=()=>QS;var $o=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&&Cs())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 jR({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}),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 Lue={name:"@netlify/agent-runner-cli",type:"module",version:"1.170.0-local-ui-preview.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.128.0","@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 g3e=h3e(import.meta.url),_3e=La.dirname(g3e),y3e=m3e(import.meta.url),gh=le("shell"),Jz=new Set,Uue={preferLocal:!0},$t=(t,e,r)=>{let[n,i]=S3e(e,r),o={...Uue,...i},s=Oue(t,n,o);zue(s,o),que(s);let a=r?.idleTimeout;return a&&a>0&&Bue(s,a),s},Fue=(t,e)=>{let r={...Uue,...e},n=Nue(t,r);return zue(n,r),que(n),e?.idleTimeout&&e.idleTimeout>0&&Bue(n,e.idleTimeout),n},S3e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},zue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Is.env.NETLIFY_LOCAL_QUIET==="true")return;if(Is.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new CS).pipe(Is.stdout),t.stderr?.pipe(new CS).pipe(Is.stderr);return}t.stdout?.pipe(Is.stdout),t.stderr?.pipe(Is.stderr)},Xz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Is.kill(-t.pid,e),gh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return gh.error("Error killing process:",r),!1}},jue=t=>Xz(t,"SIGKILL"),Bue=(t,e)=>{let r=null,n=()=>{gh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Xz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(gh.log(`Force killing idle process ${t.pid}`),jue(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)},que=t=>{Jz.add(t);let e=Due();if(e){let r=e.onTimesUp(()=>{gh.log(`Global timer expired, killing process ${t.pid}`),Xz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(gh.log(`Force killing process ${t.pid} after timeout`),jue(t))},5e3)});t.on("exit",()=>{Jz.delete(t),r()}),t.on("error",()=>{Jz.delete(t),r()})}};function cC(t,e){return!!Do(t,e)}function Do(t,e){if(!Is.env.NETLIFY_LOCAL_MODE)try{let i=y3e.resolve(Lue.name),o=La.dirname(i);for(;o!==La.dirname(o);){let s=La.dirname(o);if(La.basename(s)==="node_modules"){let a=La.join(s,".bin",e);if(aC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Is.env.NODE_PATH){let i=La.join(Is.env.NODE_PATH,".bin",e);if(aC.existsSync(i))return i}let r=La.join(t,"node_modules",".bin",e);if(aC.existsSync(r))return r;let n=La.join(_3e,"..","node_modules",".bin",e);if(aC.existsSync(n))return n}var Vue=le("repo"),Kue="runner-diffs-",Zue=t=>`${Kue}${t}-`,Jue=async t=>{let e=Yue.tmpdir(),r;try{r=await lC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Kue)&&!n.startsWith(Zue(t))).map(n=>lC.rm(uC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Zn=(t,e={})=>$t("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),dC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Vue.info("Getting runner diffs");let n=await T3e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=x3e(o);await A3e(h,r)}Vue.info("Changes after processing"),await ej(r);let s=await tj(o,r);if(await Qz(s,r),i=await w3e(r),!i)return{hasChanges:!1,ignored:s};await Zn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await lC.mkdtemp(uC.join(Yue.tmpdir(),Zue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=uC.join(a,g);await Zn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await lC.stat(b);return{path:b,size:S}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Wue(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 Hue(d,h)||(f=h)}await Wue(r),oe.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Hue(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},Gue=async t=>{let e=E3e("sha256");for await(let r of v3e(t))e.update(r);return e.digest("hex")},Hue=async(t,e)=>t.size===e.size&&await Gue(t.path)===await Gue(e.path),Wue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Zn(["reset","--soft","HEAD~1"],{cwd:t})},Qz=async(t=[],e=process.cwd())=>{await Zn(["add",".",...t],{cwd:e})},ej=async(t=process.cwd())=>{let e=await Zn(["status","-s"],{cwd:t});return String(e.stdout??"")},Xue=/.. (.+)?\.log$/,b3e=[Xue],T3e=async(t=process.cwd())=>{let e=await ej(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
144
|
+
if (condition) { yield value; }`)};import{Buffer as OGe}from"buffer";import{StringDecoder as NGe}from"string_decoder";var H0=(t,e,r)=>{if(r)return;if(t)return{transform:kGe.bind(void 0,new TextEncoder)};let n=new NGe(e);return{transform:MGe.bind(void 0,n),final:$Ge.bind(void 0,n)}},kGe=function*(t,e){OGe.isBuffer(e)?yield ka(e):typeof e=="string"?yield t.encode(e):yield e},MGe=function*(t,e){yield yr(e)?t.write(e):e},$Ge=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as ole}from"util";var hz=ole(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),W0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=LGe}=e[r];for await(let i of n(t))yield*W0(i,e,r+1)},sle=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*DGe(r,Number(e),t)},DGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*W0(n,r,e+1)},ale=ole(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),LGe=function*(t){yield t};var mz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},cle=(t,e)=>[...e.flatMap(r=>[...dd(r,t,0)]),...WS(t)],dd=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=FGe}=e[r];for(let i of n(t))yield*dd(i,e,r+1)},WS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*UGe(r,Number(e),t)},UGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*dd(n,r,e+1)},FGe=function*(t){yield t};var gz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=ule(t,s,o),l=ud(e),u=ud(r),d=l?hz.bind(void 0,W0,a):mz.bind(void 0,dd),f=l||u?hz.bind(void 0,sle,a):mz.bind(void 0,WS),p=l||u?ale.bind(void 0,a):void 0;return{stream:new zGe({writableObjectMode:n,writableHighWaterMark:lle(n),readableObjectMode:i,readableHighWaterMark:lle(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},Y0=(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=ule(s,r,a);t=cle(c,t)}return t},ule=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:rle(n,a)},H0(r,s,n),G0(r,o,n,c),{transform:t,final:e},{transform:nle(i,a)},tle({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var dle=(t,e)=>{for(let r of jGe(t))BGe(t,r,e)},jGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),BGe=(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 ${rl[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>qGe(a,n));r.input=LS(s)},qGe=(t,e)=>{let r=Y0(t,e,"utf8",!0);return VGe(r),LS(r)},VGe=t=>{let e=t.find(r=>typeof r!="string"&&!yr(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 YGe,appendFileSync as KGe}from"fs";var K0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&rh(r,n)&&!_i.has(e)&&GGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&HGe.has(o))||t.every(({type:i})=>Hi.has(i))),GGe=t=>t===1||t===2,HGe=new Set(["pipe","overlapped"]),fle=async(t,e,r,n)=>{for await(let i of t)WGe(e)||hle(i,r,n)},ple=(t,e,r)=>{for(let n of t)hle(n,e,r)},WGe=t=>t._readableState.pipes.length>0,hle=(t,e,r)=>{let n=l0(t);Ts({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var mle=({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)=>ZGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},ZGe=({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=gce(t,o,d),p=ka(f),{stdioItems:h,objectMode:m}=e[r],g=JGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=XGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});QGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?b:void 0;try{return n.error===void 0&&eHe(_,h,i),T}catch(S){return n.error=S,T}},JGe=(t,e,r,n)=>{try{return Y0(t,e,r,!1)}catch(i){return n.error=i,t}},XGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:LS(t)};let s=Poe(t,r);return n[o]?{serializedResult:s,finalResult:pz(s,!i[o],e)}:{serializedResult:s}},QGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!K0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=pz(t,!1,s);try{ple(a,e,n)}catch(c){r.error??=c}},eHe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>q0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?KGe(n,t):(r.add(o),YGe(n,t))}};var gle=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Da(e,r,"all")]:Array.isArray(e)?[Da(t,r,"all"),...e]:yr(t)&&yr(e)?bF([t,e]):`${t}${e}`};import{once as _z}from"events";var _le=async(t,e)=>{let[r,n]=await tHe(t);return e.isForcefullyTerminated??=!1,[r,n]},tHe=async t=>{let[e,r]=await Promise.allSettled([_z(t,"spawn"),_z(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?yle(t):r.value},yle=async t=>{try{return await _z(t,"exit")}catch{return yle(t)}},Sle=async t=>{let[e,r]=await t;if(!rHe(e,r)&&yz(e,r))throw new No;return[e,r]},rHe=(t,e)=>t===void 0&&e===void 0,yz=(t,e)=>t!==0||e!==null;var Ele=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=nHe(t,e,r),s=o?.code==="ETIMEDOUT",a=mce(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},nHe=(t,e,r)=>t!==void 0?t:yz(e,r)?new No:void 0;var vle=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=oHe(t,e,r),d=cHe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return fh(d,c,l)},oHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=d0(t,e,r),a=sHe(r),{file:c,commandArguments:l,options:u}=O0(t,e,a);aHe(u);let d=Jce(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},sHe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,aHe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Z0("ipcInput"),t&&Z0("ipc: true"),r&&Z0("detached: true"),n&&Z0("cancelSignal")},Z0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},cHe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=lHe({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}=Ele(c,r),{output:h,error:m=l}=mle({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>Da(b,r,T)),_=Da(gle(h,r),r,"all");return dHe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},lHe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{dle(o,r);let a=uHe(r);return iHe(...N0(t,e,a))}catch(a){return dh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},uHe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:F0(e)}),dHe=({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?z0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):HS({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 X6e}from"events";import{spawn as Q6e}from"child_process";import Ale from"process";import{once as Sz,on as fHe}from"events";var ble=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(oh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:x0(t)}),pHe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),pHe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{v0(e,i);let o=tl(t,e,r),s=new AbortController;try{return await Promise.race([hHe(o,n,s),mHe(o,r,s),gHe(o,r,s)])}catch(a){throw sh(t),a}finally{s.abort(),b0(e,i)}},hHe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await Sz(t,"message",{signal:r});return n}for await(let[n]of fHe(t,"message",{signal:r}))if(e(n))return n},mHe=async(t,e,{signal:r})=>{await Sz(t,"disconnect",{signal:r}),cae(e)},gHe=async(t,e,{signal:r})=>{let[n]=await Sz(t,"strict:error",{signal:r});throw y0(n,e)};import{once as wle,on as _He}from"events";var xle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>Ez({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),Ez=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{oh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:x0(t)}),v0(e,o);let s=tl(t,e,r),a=new AbortController,c={};return yHe(t,s,a),SHe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),EHe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},yHe=async(t,e,r)=>{try{await wle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},SHe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await wle(t,"strict:error",{signal:r.signal});n.error=y0(i,e),r.abort()}catch{}},EHe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of _He(r,"message",{signal:o.signal}))Tle(s),yield c}catch{Tle(s)}finally{o.abort(),b0(e,a),n||sh(t),i&&await t}},Tle=({error:t})=>{if(t)throw t};var Rle=(t,{ipc:e})=>{Object.assign(t,Ile(t,!1,e))},Cle=()=>{let t=Ale,e=!0,r=Ale.channel!==void 0;return{...Ile(t,e,r),getCancelSignal:$ae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Ile=(t,e,r)=>({sendMessage:I0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ble.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:xle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as vHe}from"child_process";import{PassThrough as bHe,Readable as THe,Writable as wHe,Duplex as xHe}from"stream";var Ple=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{uz(n);let a=new vHe;AHe(a,n),Object.assign(a,{readable:RHe,writable:CHe,duplex:IHe});let c=dh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=PHe(c,s,i);return{subprocess:a,promise:l}},AHe=(t,e)=>{let r=YS(),n=YS(),i=YS(),o=Array.from({length:e.length-3},YS),s=YS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},YS=()=>{let t=new bHe;return t.end(),t},RHe=()=>new THe({read(){}}),CHe=()=>new wHe({write(){}}),IHe=()=>new xHe({read(){},write(){}}),PHe=async(t,e,r)=>fh(t,e,r);import{createReadStream as Ole,createWriteStream as Nle}from"fs";import{Buffer as OHe}from"buffer";import{Readable as KS,Writable as NHe,Duplex as kHe}from"stream";var Mle=(t,e)=>V0(MHe,t,e,!1),ZS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${rl[t]}.`)},kle={fileNumber:ZS,generator:gz,asyncGenerator:gz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:kHe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},MHe={input:{...kle,fileUrl:({value:t})=>({stream:Ole(t)}),filePath:({value:{file:t}})=>({stream:Ole(t)}),webStream:({value:t})=>({stream:KS.fromWeb(t)}),iterable:({value:t})=>({stream:KS.from(t)}),asyncIterable:({value:t})=>({stream:KS.from(t)}),string:({value:t})=>({stream:KS.from(t)}),uint8Array:({value:t})=>({stream:KS.from(OHe.from(t))})},output:{...kle,fileUrl:({value:t})=>({stream:Nle(t)}),filePath:({value:{file:t,append:e}})=>({stream:Nle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:NHe.fromWeb(t)}),iterable:ZS,asyncIterable:ZS,string:ZS,uint8Array:ZS}};import{on as $He,once as $le}from"events";import{PassThrough as DHe,getDefaultHighWaterMark as LHe}from"stream";import{finished as Ule}from"stream/promises";function fd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)bz(i);let e=t.some(({readableObjectMode:i})=>i),r=UHe(t,e),n=new vz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var UHe=(t,e)=>{if(t.length===0)return LHe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},vz=class extends DHe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(bz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=FHe(this,this.#e,this.#o);let r=BHe({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(bz(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)}},FHe=async(t,e,r)=>{J0(t,Dle);let n=new AbortController;try{await Promise.race([zHe(t,n),jHe(t,e,r,n)])}finally{n.abort(),J0(t,-Dle)}},zHe=async(t,{signal:e})=>{try{await Ule(t,{signal:e,cleanup:!0})}catch(r){throw Fle(t,r),r}},jHe=async(t,e,r,{signal:n})=>{for await(let[i]of $He(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},bz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},BHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{J0(t,Lle);let a=new AbortController;try{await Promise.race([qHe(o,e,a),VHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),GHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),J0(t,-Lle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?Tz(t):HHe(t))},qHe=async(t,e,{signal:r})=>{try{await t,r.aborted||Tz(e)}catch(n){r.aborted||Fle(e,n)}},VHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Ule(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;zle(s)?i.add(e):jle(t,s)}},GHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await $le(t,i,{signal:o}),!t.readable)return $le(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},HHe=t=>{t.writable&&t.end()},Fle=(t,e)=>{zle(e)?Tz(t):jle(t,e)},zle=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Tz=t=>{(t.readable||t.writable)&&t.destroy()},jle=(t,e)=>{t.destroyed||(t.once("error",WHe),t.destroy(e))},WHe=()=>{},J0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Dle=2,Lle=1;import{finished as Ble}from"stream/promises";var hh=(t,e)=>{t.pipe(e),YHe(t,e),KHe(t,e)},YHe=async(t,e)=>{if(!(Oo(t)||Oo(e))){try{await Ble(t,{cleanup:!0,readable:!0,writable:!1})}catch{}wz(e)}},wz=t=>{t.writable&&t.end()},KHe=async(t,e)=>{if(!(Oo(t)||Oo(e))){try{await Ble(e,{cleanup:!0,readable:!1,writable:!0})}catch{}xz(t)}},xz=t=>{t.readable&&t.destroy()};var qle=(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})=>Hi.has(c)))ZHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Hi.has(c)))XHe({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]:fd(o);hh(s,i)}},ZHe=(t,e,r,n)=>{r==="output"?hh(t.stdio[n],e):hh(e,t.stdio[n]);let i=JHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},JHe=["stdin","stdout","stderr"],XHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;QHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},QHe=(t,{signal:e})=>{Oo(t)&&cd(t,e6e,e)},e6e=2;import{addAbortListener as n6e}from"events";var pd=[];pd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&pd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&pd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var X0=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",Az=Symbol.for("signal-exit emitter"),Rz=globalThis,t6e=Object.defineProperty.bind(Object),Cz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Rz[Az])return Rz[Az];t6e(Rz,Az,{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}},Q0=class{},r6e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Iz=class extends Q0{onExit(){return()=>{}}load(){}unload(){}},Pz=class extends Q0{#e=Oz.platform==="win32"?"SIGINT":"SIGHUP";#r=new Cz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of pd)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(!X0(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 pd)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,pd.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 X0(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"&&X0(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)}},Oz=globalThis.process,{onExit:Vle,load:JUt,unload:XUt}=r6e(X0(Oz)?new Pz(Oz):new Iz);var Gle=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Vle(()=>{t.kill()});n6e(n,()=>{i()})};var Wle=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=u0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=i6e(r,n,i),{sourceStream:d,sourceError:f}=s6e(t,l),{options:p,fileDescriptors:h}=xs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},i6e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=o6e(t,e,...r),a=E0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},o6e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Hle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||EF(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]=e0(r,...n);return{destination:e(Hle)(i,o,s),pipeOptions:s}}if(xs.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}`)},Hle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),s6e=(t,e)=>{try{return{sourceStream:ah(t,e)}}catch(r){return{sourceError:r}}};var Kle=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=a6e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw Nz({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},a6e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return xz(t),n;if(e!==void 0)return wz(r),e},Nz=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>dh({error:t,command:Yle,escapedCommand:Yle,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Yle="source.pipe(destination)";var Zle=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 c6e}from"stream/promises";var Jle=(t,e,r)=>{let n=eC.has(e)?u6e(t,e):l6e(t,e);return cd(t,f6e,r.signal),cd(e,p6e,r.signal),d6e(e),n},l6e=(t,e)=>{let r=fd([t]);return hh(r,e),eC.set(e,r),r},u6e=(t,e)=>{let r=eC.get(e);return r.add(t),r},d6e=async t=>{try{await c6e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}eC.delete(t)},eC=new WeakMap,f6e=2,p6e=1;import{aborted as h6e}from"util";var Xle=(t,e)=>t===void 0?[]:[m6e(t,e)],m6e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await h6e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw Nz({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var tC=(t,...e)=>{if(sr(e[0]))return tC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Wle(t,...e),i=g6e({...n,destination:r});return i.pipe=tC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},g6e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=_6e(t,i);Kle({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Jle(e,o,d);return await Promise.race([Zle(u),...Xle(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},_6e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as w6e}from"timers/promises";import{on as y6e}from"events";import{getDefaultHighWaterMark as S6e}from"stream";var rC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return E6e(e,s),eue({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},E6e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},kz=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;v6e(e,s,t);let a=t.readableObjectMode&&!o;return eue({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},v6e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},eue=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=y6e(t,"data",{signal:e.signal,highWaterMark:Qle,highWatermark:Qle});return b6e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},Mz=S6e(!0),Qle=Mz,b6e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=T6e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*dd(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*WS(a)}},T6e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[H0(t,r,!e),G0(t,i,!n,{})].filter(Boolean);var tue=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=x6e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([A6e(t),d]);return}let f=dz(c,r),p=kz({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([R6e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},x6e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!K0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=kz({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await fle(a,t,r,o)},A6e=async t=>{await w6e(),t.readableFlowing===null&&t.resume()},R6e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await D0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await L0(r,{maxBuffer:o})):await uh(r,{maxBuffer:o})}catch(a){return rue(fce({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},$z=async t=>{try{return await t}catch(e){return rue(e)}},rue=({bufferedData:t})=>Coe(t)?new Uint8Array(t):t;import{finished as C6e}from"stream/promises";var JS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=I6e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],C6e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||N6e(a,e,r,n)}finally{s.abort()}},I6e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&P6e(t,r,n),n},P6e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{O6e(e,r),n.call(t,...i)}},O6e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},N6e=(t,e,r,n)=>{if(!k6e(t,e,r,n))throw t},k6e=(t,e,r,n=!0)=>r.propagating?nue(t)||nC(t):(r.propagating=!0,Dz(r,e)===n?nue(t):nC(t)),Dz=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",nC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",nue=t=>t?.code==="EPIPE";var iue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>Lz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Lz=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=JS(t,e,l);if(Dz(l,e)){await u;return}let[d]=await Promise.all([tue({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 oue=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?fd([t,e].filter(Boolean)):void 0,sue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Lz({...M6e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:$6e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),M6e=({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}},$6e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as D6e}from"events";var aue=t=>rh(t,"ipc"),cue=(t,e)=>{let r=l0(t);Ts({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var lue=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=aue(o),a=Ma(e,"ipc"),c=Ma(r,"ipc");for await(let l of Ez({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(pce(t,i,c),i.push(l)),s&&cue(l,o);return i},uue=async(t,e)=>(await Promise.allSettled([t]),e);var due=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 b=_le(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=iue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=sue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),P=[],R=lue({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),O=L6e(m,t,T),M=U6e(h,T);try{return await Promise.race([Promise.all([{},Sle(b),Promise.all(S),x,R,Gae(t,d),...O,...M]),g,F6e(t,_),...zae(t,o,f,_),...aae({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Uae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(U){return f.terminationReason??="other",Promise.all([{error:U},b,Promise.all(S.map(v=>$z(v))),$z(x),uue(R,P),Promise.allSettled(O),Promise.allSettled(M)])}},L6e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:JS(n,i,r)),U6e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Mo(o,{checkOpen:!1})&&!Oo(o)).map(({type:i,value:o,stream:s=o})=>JS(s,n,e,{isSameDirection:Hi.has(i),stopOnExit:i==="native"}))),F6e=async(t,{signal:e})=>{let[r]=await D6e(t,"error",{signal:e});throw r};var fue=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),XS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ws();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},mh=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 z6e}from"stream";import{callbackify as j6e}from"util";import{finished as pue}from"stream/promises";var Uz=async t=>{if(t!==void 0)try{await Fz(t)}catch{}},hue=async t=>{if(t!==void 0)try{await zz(t)}catch{}},Fz=async t=>{await pue(t,{cleanup:!0,readable:!1,writable:!0})},zz=async t=>{await pue(t,{cleanup:!0,readable:!0,writable:!1})},iC=async(t,e)=>{if(await t,e)throw e},oC=(t,e,r)=>{r&&!nC(r)?t.destroy(r):e&&t.destroy()};var mue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_i.has(r),{subprocessStdout:a,waitReadableDestroy:c}=jz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Bz(a,s),{read:f,onStdoutDataDone:p}=qz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new z6e({read:f,destroy:j6e(Gz.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Vz({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},jz=(t,e,r)=>{let n=ah(t,e),i=XS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Bz=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:Mz},qz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ws(),s=rC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){B6e(this,s,o)},onStdoutDataDone:o}},B6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Vz=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await zz(t),await n,await Uz(i),await e,r.readable&&r.push(null)}catch(o){await Uz(i),gue(r,o)}},Gz=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await mh(r,e)&&(gue(t,n),await iC(e,n))},gue=(t,e)=>{oC(t,t.readable,e)};import{Writable as q6e}from"stream";import{callbackify as _ue}from"util";var yue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Hz(t,r,e),s=new q6e({...Wz(n,t,i),destroy:_ue(Kz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Yz(n,s),s},Hz=(t,e,r)=>{let n=E0(t,e),i=XS(r,n,"writableFinal"),o=XS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Wz=(t,e,r)=>({write:V6e.bind(void 0,t),final:_ue(G6e.bind(void 0,t,e,r))}),V6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},G6e=async(t,e,r)=>{await mh(r,e)&&(t.writable&&t.end(),await e)},Yz=async(t,e,r)=>{try{await Fz(t),e.writable&&e.end()}catch(n){await hue(r),Sue(e,n)}},Kz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await mh(r,e),await mh(n,e)&&(Sue(t,i),await iC(e,i))},Sue=(t,e)=>{oC(t,t.writable,e)};import{Duplex as H6e}from"stream";import{callbackify as W6e}from"util";var Eue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_i.has(r),{subprocessStdout:c,waitReadableDestroy:l}=jz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Hz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Bz(c,a),{read:g,onStdoutDataDone:_}=qz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new H6e({read:g,...Wz(u,t,d),destroy:W6e(Y6e.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 Vz({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),Yz(u,b,c),b},Y6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([Gz({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Kz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Zz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_i.has(e),s=ah(t,r),a=rC({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return K6e(a,s,t)},K6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var vue=(t,{encoding:e})=>{let r=fue();t.readable=mue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=yue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Eue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Zz.bind(void 0,t,e),t[Symbol.asyncIterator]=Zz.bind(void 0,t,e,{})};var bue=(t,e)=>{for(let[r,n]of J6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Z6e=(async()=>{})().constructor.prototype,J6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Z6e,t)]);var Tue=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=e3e(t,e,r),{subprocess:f,promise:p}=r3e({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}),bue(f,p),xs.set(f,{options:u,fileDescriptors:d}),f},e3e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=d0(t,e,r),{file:a,commandArguments:c,options:l}=O0(t,e,r),u=t3e(l),d=Mle(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},t3e=({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}},r3e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=Q6e(...N0(t,e,r))}catch(h){return Ple({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;X6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];qle(c,a,l),Gle(c,r,l);let d={},f=ws();c.kill=oae.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=oue(c,r),vue(c,r),Rle(c,r);let p=n3e({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}},n3e=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 due({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((S,x)=>Da(S,e,x)),b=Da(m,e,"all"),T=i3e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return fh(T,n,e)},i3e=({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?HS({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 As,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):z0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var sC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,o3e(n,t[n],i)]));return{...t,...r}},o3e=(t,e,r)=>s3e.has(t)&&sr(e)&&sr(r)?{...e,...r}:r,s3e=new Set(["env",...AF]);var nl=(t,e,r,n)=>{let i=(s,a,c)=>nl(s,a,r,c),o=(...s)=>a3e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},a3e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(sr(o))return i(t,sC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=c3e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?vle(a,c,l):Tue(a,c,l,i)},c3e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Moe(e)?$oe(e,r):[e,...r],[s,a,c]=e0(...o),l=sC(sC(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 wue=({file:t,commandArguments:e})=>Aue(t,e),xue=({file:t,commandArguments:e})=>({...Aue(t,e),isSync:!0}),Aue=(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]=l3e(t);return{file:r,commandArguments:n}},l3e=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(u3e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},u3e=/ +/g;var Rue=(t,e,r)=>{t.sync=e(d3e,r),t.s=t.sync},Cue=({options:t})=>Iue(t),d3e=({options:t})=>({...Iue(t),isSync:!0}),Iue=t=>({options:{...f3e(t),...t}}),f3e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Pue={preferLocal:!0};var Oue=nl(()=>({})),jjt=nl(()=>({isSync:!0})),Nue=nl(wue),Bjt=nl(xue),qjt=nl(Bae),Vjt=nl(Cue,{},Pue,Rue),{sendMessage:Gjt,getOneMessage:Hjt,getEachMessage:Wjt,getCancelSignal:Yjt}=Cle();var kue=!1,Mue=()=>{kue=!0},Cs=()=>kue;var QS=null,$ue=t=>(QS&&QS.destroy(),QS=new $o({totalAllowedTime:t}),QS),Due=()=>QS;var $o=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&&Cs())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 jR({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}),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 Lue={name:"@netlify/agent-runner-cli",type:"module",version:"1.170.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 g3e=h3e(import.meta.url),_3e=La.dirname(g3e),y3e=m3e(import.meta.url),gh=le("shell"),Jz=new Set,Uue={preferLocal:!0},$t=(t,e,r)=>{let[n,i]=S3e(e,r),o={...Uue,...i},s=Oue(t,n,o);zue(s,o),que(s);let a=r?.idleTimeout;return a&&a>0&&Bue(s,a),s},Fue=(t,e)=>{let r={...Uue,...e},n=Nue(t,r);return zue(n,r),que(n),e?.idleTimeout&&e.idleTimeout>0&&Bue(n,e.idleTimeout),n},S3e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},zue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Is.env.NETLIFY_LOCAL_QUIET==="true")return;if(Is.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new CS).pipe(Is.stdout),t.stderr?.pipe(new CS).pipe(Is.stderr);return}t.stdout?.pipe(Is.stdout),t.stderr?.pipe(Is.stderr)},Xz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Is.kill(-t.pid,e),gh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return gh.error("Error killing process:",r),!1}},jue=t=>Xz(t,"SIGKILL"),Bue=(t,e)=>{let r=null,n=()=>{gh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Xz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(gh.log(`Force killing idle process ${t.pid}`),jue(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)},que=t=>{Jz.add(t);let e=Due();if(e){let r=e.onTimesUp(()=>{gh.log(`Global timer expired, killing process ${t.pid}`),Xz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(gh.log(`Force killing process ${t.pid} after timeout`),jue(t))},5e3)});t.on("exit",()=>{Jz.delete(t),r()}),t.on("error",()=>{Jz.delete(t),r()})}};function cC(t,e){return!!Do(t,e)}function Do(t,e){if(!Is.env.NETLIFY_LOCAL_MODE)try{let i=y3e.resolve(Lue.name),o=La.dirname(i);for(;o!==La.dirname(o);){let s=La.dirname(o);if(La.basename(s)==="node_modules"){let a=La.join(s,".bin",e);if(aC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Is.env.NODE_PATH){let i=La.join(Is.env.NODE_PATH,".bin",e);if(aC.existsSync(i))return i}let r=La.join(t,"node_modules",".bin",e);if(aC.existsSync(r))return r;let n=La.join(_3e,"..","node_modules",".bin",e);if(aC.existsSync(n))return n}var Vue=le("repo"),Kue="runner-diffs-",Zue=t=>`${Kue}${t}-`,Jue=async t=>{let e=Yue.tmpdir(),r;try{r=await lC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Kue)&&!n.startsWith(Zue(t))).map(n=>lC.rm(uC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Zn=(t,e={})=>$t("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),dC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Vue.info("Getting runner diffs");let n=await T3e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=x3e(o);await A3e(h,r)}Vue.info("Changes after processing"),await ej(r);let s=await tj(o,r);if(await Qz(s,r),i=await w3e(r),!i)return{hasChanges:!1,ignored:s};await Zn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await lC.mkdtemp(uC.join(Yue.tmpdir(),Zue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=uC.join(a,g);await Zn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await lC.stat(b);return{path:b,size:S}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Wue(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 Hue(d,h)||(f=h)}await Wue(r),oe.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Hue(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},Gue=async t=>{let e=E3e("sha256");for await(let r of v3e(t))e.update(r);return e.digest("hex")},Hue=async(t,e)=>t.size===e.size&&await Gue(t.path)===await Gue(e.path),Wue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Zn(["reset","--soft","HEAD~1"],{cwd:t})},Qz=async(t=[],e=process.cwd())=>{await Zn(["add",".",...t],{cwd:e})},ej=async(t=process.cwd())=>{let e=await Zn(["status","-s"],{cwd:t});return String(e.stdout??"")},Xue=/.. (.+)?\.log$/,b3e=[Xue],T3e=async(t=process.cwd())=>{let e=await ej(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
145
145
|
`).filter(i=>b3e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},w3e=async(t=process.cwd())=>{try{return await Zn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},eE=async(t=process.cwd())=>{let{stdout:e}=await Zn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Que=async(t=process.cwd())=>{let{stdout:e}=await Zn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},tj=async(t,e=process.cwd())=>{t||=await ej(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}${uC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Xue)?.[1];o&&n.push(`:!${o}.log`)}),n},ede=async(t=process.cwd())=>{await Zn(["reset","--hard","HEAD"],{cwd:t})},tde=async(t=process.cwd())=>{let e=await Zn(["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))},x3e=t=>{let e=t.split(`
|
package/dist/bin.js
CHANGED
|
@@ -621,7 +621,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
621
621
|
`,LF:`
|
|
622
622
|
`,concatBytes:aY},BTt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},VTt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:BTt};import{Buffer as HTt}from"buffer";var YRe=(t,e)=>t?void 0:GTt.bind(void 0,e),GTt=function*(t,e){if(typeof e!="string"&&!Zr(e)&&!HTt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},KRe=(t,e)=>t?WTt.bind(void 0,e):YTt.bind(void 0,e),WTt=function*(t,e){JRe(t,e),yield e},YTt=function*(t,e){if(JRe(t,e),typeof e!="string"&&!Zr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},JRe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
623
623
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
624
|
-
if (condition) { yield value; }`)};import{Buffer as KTt}from"buffer";import{StringDecoder as JTt}from"string_decoder";var XN=(t,e,r)=>{if(r)return;if(t)return{transform:ZTt.bind(void 0,new TextEncoder)};let n=new JTt(e);return{transform:XTt.bind(void 0,n),final:QTt.bind(void 0,n)}},ZTt=function*(t,e){KTt.isBuffer(e)?yield Xc(e):typeof e=="string"?yield t.encode(e):yield e},XTt=function*(t,e){yield Zr(e)?t.write(e):e},QTt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as ZRe}from"util";var lY=ZRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),QN=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=twt}=e[r];for await(let i of n(t))yield*QN(i,e,r+1)},XRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ewt(r,Number(e),t)},ewt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*QN(n,r,e+1)},QRe=ZRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),twt=function*(t){yield t};var uY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},e0e=(t,e)=>[...e.flatMap(r=>[...vp(r,t,0)]),...qT(t)],vp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=nwt}=e[r];for(let i of n(t))yield*vp(i,e,r+1)},qT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*rwt(r,Number(e),t)},rwt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*vp(n,r,e+1)},nwt=function*(t){yield t};var dY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=r0e(t,o,s),l=Ep(e),u=Ep(r),d=l?lY.bind(void 0,QN,a):uY.bind(void 0,vp),f=l||u?lY.bind(void 0,XRe,a):uY.bind(void 0,qT),p=l||u?QRe.bind(void 0,a):void 0;return{stream:new iwt({writableObjectMode:n,writableHighWaterMark:t0e(n),readableObjectMode:i,readableHighWaterMark:t0e(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},ek=(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=r0e(o,r,a);t=e0e(c,t)}return t},r0e=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:YRe(n,a)},XN(r,o,n),ZN(r,s,n,c),{transform:t,final:e},{transform:KRe(i,a)},WRe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var n0e=(t,e)=>{for(let r of swt(t))owt(t,r,e)},swt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),owt=(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 ${nd[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>awt(a,n));r.input=NT(o)},awt=(t,e)=>{let r=ek(t,e,"utf8",!0);return cwt(r),NT(r)},cwt=t=>{let e=t.find(r=>typeof r!="string"&&!Zr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as fwt,appendFileSync as pwt}from"fs";var tk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&v_(r,n)&&!ls.has(e)&&lwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&uwt.has(s))||t.every(({type:i})=>Gs.has(i))),lwt=t=>t===1||t===2,uwt=new Set(["pipe","overlapped"]),i0e=async(t,e,r,n)=>{for await(let i of t)dwt(e)||o0e(i,r,n)},s0e=(t,e,r)=>{for(let n of t)o0e(n,e,r)},dwt=t=>t._readableState.pipes.length>0,o0e=(t,e,r)=>{let n=mN(t);Ca({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var a0e=({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)=>hwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},hwt=({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=cRe(t,s,d),p=Xc(f),{stdioItems:h,objectMode:m}=e[r],_=mwt([p],h,c,n),{serializedResult:y,finalResult:v=y}=gwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});_wt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&ywt(y,h,i),S}catch(g){return n.error=g,S}},mwt=(t,e,r,n)=>{try{return ek(t,e,r,!1)}catch(i){return n.error=i,t}},gwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:NT(t)};let o=bbe(t,r);return n[s]?{serializedResult:o,finalResult:cY(o,!i[s],e)}:{serializedResult:o}},_wt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!tk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=cY(t,!1,o);try{s0e(a,e,n)}catch(c){r.error??=c}},ywt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>KN.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?pwt(n,t):(r.add(s),fwt(n,t))}};var c0e=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,tl(e,r,"all")]:Array.isArray(e)?[tl(t,r,"all"),...e]:Zr(t)&&Zr(e)?_W([t,e]):`${t}${e}`};import{once as fY}from"events";var l0e=async(t,e)=>{let[r,n]=await Swt(t);return e.isForcefullyTerminated??=!1,[r,n]},Swt=async t=>{let[e,r]=await Promise.allSettled([fY(t,"spawn"),fY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?u0e(t):r.value},u0e=async t=>{try{return await fY(t,"exit")}catch{return u0e(t)}},d0e=async t=>{let[e,r]=await t;if(!Ewt(e,r)&&pY(e,r))throw new Ao;return[e,r]},Ewt=(t,e)=>t===void 0&&e===void 0,pY=(t,e)=>t!==0||e!==null;var f0e=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=vwt(t,e,r),o=s?.code==="ETIMEDOUT",a=aRe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},vwt=(t,e,r)=>t!==void 0?t:pY(e,r)?new Ao:void 0;var p0e=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Twt(t,e,r),d=Awt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return O_(d,c,l)},Twt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),a=wwt(r),{file:c,commandArguments:l,options:u}=MN(t,e,a);Rwt(u);let d=BRe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},wwt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Rwt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&rk("ipcInput"),t&&rk("ipc: true"),r&&rk("detached: true"),n&&rk("cancelSignal")},rk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Awt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=xwt({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}=f0e(c,r),{output:h,error:m=l}=a0e({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>tl(v,r,S)),y=tl(c0e(h,r),r,"all");return Iwt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},xwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{n0e(s,r);let a=Pwt(r);return bwt(...UN(t,e,a))}catch(a){return C_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Pwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:HN(e)}),Iwt=({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?GN({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):zT({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 g0t}from"events";import{spawn as _0t}from"child_process";import y0e from"process";import{once as hY,on as Cwt}from"events";var h0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(w_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),Owt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Owt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{xN(e,i);let s=rd(t,e,r),o=new AbortController;try{return await Promise.race([Nwt(s,n,o),kwt(s,r,o),$wt(s,r,o)])}catch(a){throw R_(t),a}finally{o.abort(),PN(e,i)}},Nwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await hY(t,"message",{signal:r});return n}for await(let[n]of Cwt(t,"message",{signal:r}))if(e(n))return n},kwt=async(t,e,{signal:r})=>{await hY(t,"disconnect",{signal:r}),ewe(e)},$wt=async(t,e,{signal:r})=>{let[n]=await hY(t,"strict:error",{signal:r});throw wN(n,e)};import{once as g0e,on as Lwt}from"events";var _0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>mY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),mY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{w_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),xN(e,s);let o=rd(t,e,r),a=new AbortController,c={};return Dwt(t,o,a),Mwt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Uwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Dwt=async(t,e,r)=>{try{await g0e(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Mwt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await g0e(t,"strict:error",{signal:r.signal});n.error=wN(i,e),r.abort()}catch{}},Uwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Lwt(r,"message",{signal:s.signal}))m0e(o),yield c}catch{m0e(o)}finally{s.abort(),PN(e,a),n||R_(t),i&&await t}},m0e=({error:t})=>{if(t)throw t};var S0e=(t,{ipc:e})=>{Object.assign(t,v0e(t,!1,e))},E0e=()=>{let t=y0e,e=!0,r=y0e.channel!==void 0;return{...v0e(t,e,r),getCancelSignal:xwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},v0e=(t,e,r)=>({sendMessage:LN.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:h0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:_0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Fwt}from"child_process";import{PassThrough as jwt,Readable as zwt,Writable as qwt,Duplex as Bwt}from"stream";var b0e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{sY(n);let a=new Fwt;Vwt(a,n),Object.assign(a,{readable:Hwt,writable:Gwt,duplex:Wwt});let c=C_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Ywt(c,o,i);return{subprocess:a,promise:l}},Vwt=(t,e)=>{let r=BT(),n=BT(),i=BT(),s=Array.from({length:e.length-3},BT),o=BT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},BT=()=>{let t=new jwt;return t.end(),t},Hwt=()=>new zwt({read(){}}),Gwt=()=>new qwt({write(){}}),Wwt=()=>new Bwt({read(){},write(){}}),Ywt=async(t,e,r)=>O_(t,e,r);import{createReadStream as T0e,createWriteStream as w0e}from"fs";import{Buffer as Kwt}from"buffer";import{Readable as VT,Writable as Jwt,Duplex as Zwt}from"stream";var A0e=(t,e)=>JN(Xwt,t,e,!1),HT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${nd[t]}.`)},R0e={fileNumber:HT,generator:dY,asyncGenerator:dY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Zwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Xwt={input:{...R0e,fileUrl:({value:t})=>({stream:T0e(t)}),filePath:({value:{file:t}})=>({stream:T0e(t)}),webStream:({value:t})=>({stream:VT.fromWeb(t)}),iterable:({value:t})=>({stream:VT.from(t)}),asyncIterable:({value:t})=>({stream:VT.from(t)}),string:({value:t})=>({stream:VT.from(t)}),uint8Array:({value:t})=>({stream:VT.from(Kwt.from(t))})},output:{...R0e,fileUrl:({value:t})=>({stream:w0e(t)}),filePath:({value:{file:t,append:e}})=>({stream:w0e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Jwt.fromWeb(t)}),iterable:HT,asyncIterable:HT,string:HT,uint8Array:HT}};import{on as Qwt,once as x0e}from"events";import{PassThrough as eRt,getDefaultHighWaterMark as tRt}from"stream";import{finished as C0e}from"stream/promises";function bp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)_Y(i);let e=t.some(({readableObjectMode:i})=>i),r=rRt(t,e),n=new gY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var rRt=(t,e)=>{if(t.length===0)return tRt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},gY=class extends eRt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(_Y(e),this.#e.has(e))return;this.#e.add(e),this.#n??=nRt(this,this.#e,this.#s);let r=oRt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(_Y(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},nRt=async(t,e,r)=>{nk(t,P0e);let n=new AbortController;try{await Promise.race([iRt(t,n),sRt(t,e,r,n)])}finally{n.abort(),nk(t,-P0e)}},iRt=async(t,{signal:e})=>{try{await C0e(t,{signal:e,cleanup:!0})}catch(r){throw O0e(t,r),r}},sRt=async(t,e,r,{signal:n})=>{for await(let[i]of Qwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},_Y=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},oRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{nk(t,I0e);let a=new AbortController;try{await Promise.race([aRt(s,e,a),cRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),lRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),nk(t,-I0e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?yY(t):uRt(t))},aRt=async(t,e,{signal:r})=>{try{await t,r.aborted||yY(e)}catch(n){r.aborted||O0e(e,n)}},cRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await C0e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;N0e(o)?i.add(e):k0e(t,o)}},lRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await x0e(t,i,{signal:s}),!t.readable)return x0e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},uRt=t=>{t.writable&&t.end()},O0e=(t,e)=>{N0e(e)?yY(t):k0e(t,e)},N0e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yY=t=>{(t.readable||t.writable)&&t.destroy()},k0e=(t,e)=>{t.destroyed||(t.once("error",dRt),t.destroy(e))},dRt=()=>{},nk=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},P0e=2,I0e=1;import{finished as $0e}from"stream/promises";var k_=(t,e)=>{t.pipe(e),fRt(t,e),pRt(t,e)},fRt=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await $0e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}SY(e)}},SY=t=>{t.writable&&t.end()},pRt=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await $0e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}EY(t)}},EY=t=>{t.readable&&t.destroy()};var L0e=(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})=>Gs.has(c)))hRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Gs.has(c)))gRt({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]:bp(s);k_(o,i)}},hRt=(t,e,r,n)=>{r==="output"?k_(t.stdio[n],e):k_(e,t.stdio[n]);let i=mRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},mRt=["stdin","stdout","stderr"],gRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;_Rt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},_Rt=(t,{signal:e})=>{Ro(t)&&yp(t,yRt,e)},yRt=2;import{addAbortListener as vRt}from"events";var Tp=[];Tp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Tp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Tp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ik=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",vY=Symbol.for("signal-exit emitter"),bY=globalThis,SRt=Object.defineProperty.bind(Object),TY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(bY[vY])return bY[vY];SRt(bY,vY,{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}},sk=class{},ERt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),wY=class extends sk{onExit(){return()=>{}}load(){}unload(){}},RY=class extends sk{#e=AY.platform==="win32"?"SIGINT":"SIGHUP";#r=new TY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Tp)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!ik(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Tp)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Tp.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return ik(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"&&ik(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)}},AY=globalThis.process,{onExit:D0e,load:l_r,unload:u_r}=ERt(ik(AY)?new RY(AY):new wY);var M0e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=D0e(()=>{t.kill()});vRt(n,()=>{i()})};var F0e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=gN(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=bRt(r,n,i),{sourceStream:d,sourceError:f}=wRt(t,l),{options:p,fileDescriptors:h}=Na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},bRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=TRt(t,e,...r),a=AN(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},TRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(U0e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||mW(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]=oN(r,...n);return{destination:e(U0e)(i,s,o),pipeOptions:o}}if(Na.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}`)},U0e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),wRt=(t,e)=>{try{return{sourceStream:A_(t,e)}}catch(r){return{sourceError:r}}};var z0e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=RRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw xY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},RRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return EY(t),n;if(e!==void 0)return SY(r),e},xY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>C_({error:t,command:j0e,escapedCommand:j0e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),j0e="source.pipe(destination)";var q0e=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 ARt}from"stream/promises";var B0e=(t,e,r)=>{let n=ok.has(e)?PRt(t,e):xRt(t,e);return yp(t,CRt,r.signal),yp(e,ORt,r.signal),IRt(e),n},xRt=(t,e)=>{let r=bp([t]);return k_(r,e),ok.set(e,r),r},PRt=(t,e)=>{let r=ok.get(e);return r.add(t),r},IRt=async t=>{try{await ARt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ok.delete(t)},ok=new WeakMap,CRt=2,ORt=1;import{aborted as NRt}from"util";var V0e=(t,e)=>t===void 0?[]:[kRt(t,e)],kRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await NRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw xY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ak=(t,...e)=>{if(Lr(e[0]))return ak.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=F0e(t,...e),i=$Rt({...n,destination:r});return i.pipe=ak.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},$Rt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=LRt(t,i);z0e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=B0e(e,s,d);return await Promise.race([q0e(u),...V0e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},LRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as qRt}from"timers/promises";import{on as DRt}from"events";import{getDefaultHighWaterMark as MRt}from"stream";var ck=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return URt(e,o),G0e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},URt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},PY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;FRt(e,o,t);let a=t.readableObjectMode&&!s;return G0e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},FRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},G0e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=DRt(t,"data",{signal:e.signal,highWaterMark:H0e,highWatermark:H0e});return jRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},IY=MRt(!0),H0e=IY,jRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=zRt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*vp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*qT(a)}},zRt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[XN(t,r,!e),ZN(t,i,!n,{})].filter(Boolean);var W0e=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=BRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([VRt(t),d]);return}let f=oY(c,r),p=PY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([HRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},BRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!tk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=PY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await i0e(a,t,r,s)},VRt=async t=>{await qRt(),t.readableFlowing===null&&t.resume()},HRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qN(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await BN(r,{maxBuffer:s})):await I_(r,{maxBuffer:s})}catch(a){return Y0e(iRe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},CY=async t=>{try{return await t}catch(e){return Y0e(e)}},Y0e=({bufferedData:t})=>Ebe(t)?new Uint8Array(t):t;import{finished as GRt}from"stream/promises";var GT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=WRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],GRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||JRt(a,e,r,n)}finally{o.abort()}},WRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&YRt(t,r,n),n},YRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{KRt(e,r),n.call(t,...i)}},KRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},JRt=(t,e,r,n)=>{if(!ZRt(t,e,r,n))throw t},ZRt=(t,e,r,n=!0)=>r.propagating?K0e(t)||lk(t):(r.propagating=!0,OY(r,e)===n?K0e(t):lk(t)),OY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",lk=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",K0e=t=>t?.code==="EPIPE";var J0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>NY({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),NY=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=GT(t,e,l);if(OY(l,e)){await u;return}let[d]=await Promise.all([W0e({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 Z0e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?bp([t,e].filter(Boolean)):void 0,X0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>NY({...XRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:QRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),XRt=({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}},QRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as e0t}from"events";var Q0e=t=>v_(t,"ipc"),eAe=(t,e)=>{let r=mN(t);Ca({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var tAe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Q0e(s),a=Qc(e,"ipc"),c=Qc(r,"ipc");for await(let l of mY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(sRe(t,i,c),i.push(l)),o&&eAe(l,s);return i},rAe=async(t,e)=>(await Promise.allSettled([t]),e);var nAe=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 v=l0e(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=J0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),R=X0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),x=[],w=tAe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),b=t0t(m,t,S),I=r0t(h,S);try{return await Promise.race([Promise.all([{},d0e(v),Promise.all(g),R,w,Mwe(t,d),...b,...I]),_,n0t(t,y),...Nwe(t,s,f,y),...QTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Cwe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(N){return f.terminationReason??="other",Promise.all([{error:N},v,Promise.all(g.map(A=>CY(A))),CY(R),rAe(w,x),Promise.allSettled(b),Promise.allSettled(I)])}},t0t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:GT(n,i,r)),r0t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Po(s,{checkOpen:!1})&&!Ro(s)).map(({type:i,value:s,stream:o=s})=>GT(o,n,e,{isSameDirection:Gs.has(i),stopOnExit:i==="native"}))),n0t=async(t,{signal:e})=>{let[r]=await e0t(t,"error",{signal:e});throw r};var iAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),WT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Oa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},$_=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 i0t}from"stream";import{callbackify as s0t}from"util";import{finished as sAe}from"stream/promises";var kY=async t=>{if(t!==void 0)try{await $Y(t)}catch{}},oAe=async t=>{if(t!==void 0)try{await LY(t)}catch{}},$Y=async t=>{await sAe(t,{cleanup:!0,readable:!1,writable:!0})},LY=async t=>{await sAe(t,{cleanup:!0,readable:!0,writable:!1})},uk=async(t,e)=>{if(await t,e)throw e},dk=(t,e,r)=>{r&&!lk(r)?t.destroy(r):e&&t.destroy()};var aAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ls.has(r),{subprocessStdout:a,waitReadableDestroy:c}=DY(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=MY(a,o),{read:f,onStdoutDataDone:p}=UY({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new i0t({read:f,destroy:s0t(jY.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return FY({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},DY=(t,e,r)=>{let n=A_(t,e),i=WT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},MY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:IY},UY=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Oa(),o=ck({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){o0t(this,o,s)},onStdoutDataDone:s}},o0t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},FY=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await LY(t),await n,await kY(i),await e,r.readable&&r.push(null)}catch(s){await kY(i),cAe(r,s)}},jY=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await $_(r,e)&&(cAe(t,n),await uk(e,n))},cAe=(t,e)=>{dk(t,t.readable,e)};import{Writable as a0t}from"stream";import{callbackify as lAe}from"util";var uAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=zY(t,r,e),o=new a0t({...qY(n,t,i),destroy:lAe(VY.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return BY(n,o),o},zY=(t,e,r)=>{let n=AN(t,e),i=WT(r,n,"writableFinal"),s=WT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},qY=(t,e,r)=>({write:c0t.bind(void 0,t),final:lAe(l0t.bind(void 0,t,e,r))}),c0t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},l0t=async(t,e,r)=>{await $_(r,e)&&(t.writable&&t.end(),await e)},BY=async(t,e,r)=>{try{await $Y(t),e.writable&&e.end()}catch(n){await oAe(r),dAe(e,n)}},VY=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await $_(r,e),await $_(n,e)&&(dAe(t,i),await uk(e,i))},dAe=(t,e)=>{dk(t,t.writable,e)};import{Duplex as u0t}from"stream";import{callbackify as d0t}from"util";var fAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ls.has(r),{subprocessStdout:c,waitReadableDestroy:l}=DY(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=zY(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=MY(c,a),{read:_,onStdoutDataDone:y}=UY({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new u0t({read:_,...qY(u,t,d),destroy:d0t(f0t.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 FY({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),BY(u,v,c),v},f0t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([jY({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),VY({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var HY=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ls.has(e),o=A_(t,r),a=ck({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return p0t(a,o,t)},p0t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var pAe=(t,{encoding:e})=>{let r=iAe();t.readable=aAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=uAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=fAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=HY.bind(void 0,t,e),t[Symbol.asyncIterator]=HY.bind(void 0,t,e,{})};var hAe=(t,e)=>{for(let[r,n]of m0t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},h0t=(async()=>{})().constructor.prototype,m0t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(h0t,t)]);var mAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=y0t(t,e,r),{subprocess:f,promise:p}=E0t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ak.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),hAe(f,p),Na.set(f,{options:u,fileDescriptors:d}),f},y0t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),{file:a,commandArguments:c,options:l}=MN(t,e,r),u=S0t(l),d=A0e(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},S0t=({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}},E0t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=_0t(...UN(t,e,r))}catch(h){return b0e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;g0t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];L0e(c,a,l),M0e(c,r,l);let d={},f=Oa();c.kill=ZTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Z0e(c,r),pAe(c,r),S0e(c,r);let p=v0t({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}},v0t=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 nAe({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,R)=>tl(g,e,R)),v=tl(m,e,"all"),S=b0t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return O_(S,n,e)},b0t=({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?zT({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 ka,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):GN({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var fk=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,T0t(n,t[n],i)]));return{...t,...r}},T0t=(t,e,r)=>w0t.has(t)&&Lr(e)&&Lr(r)?{...e,...r}:r,w0t=new Set(["env",...vW]);var id=(t,e,r,n)=>{let i=(o,a,c)=>id(o,a,r,c),s=(...o)=>R0t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},R0t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Lr(s))return i(t,fk(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=A0t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?p0e(a,c,l):mAe(a,c,l,i)},A0t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Abe(e)?xbe(e,r):[e,...r],[o,a,c]=oN(...s),l=fk(fk(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 gAe=({file:t,commandArguments:e})=>yAe(t,e),_Ae=({file:t,commandArguments:e})=>({...yAe(t,e),isSync:!0}),yAe=(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]=x0t(t);return{file:r,commandArguments:n}},x0t=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(P0t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},P0t=/ +/g;var SAe=(t,e,r)=>{t.sync=e(I0t,r),t.s=t.sync},EAe=({options:t})=>vAe(t),I0t=({options:t})=>({...vAe(t),isSync:!0}),vAe=t=>({options:{...C0t(t),...t}}),C0t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},bAe={preferLocal:!0};var TAe=id(()=>({})),QSr=id(()=>({isSync:!0})),wAe=id(gAe),eEr=id(_Ae),tEr=id($we),rEr=id(EAe,{},bAe,SAe),{sendMessage:nEr,getOneMessage:iEr,getEachMessage:sEr,getCancelSignal:oEr}=E0e();import{Transform as O0t}from"stream";var N0t=["NETLIFY_AI_GATEWAY_KEY"];function k0t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...N0t])]}function $0t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function L0t(){let e=k0t().map(r=>process.env[r]).filter(r=>!(!r||$0t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Bi(t){if(typeof t!="string")return t;let e=L0t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(D0t(n),"g");r=r.replace(i,"******")}),r}function D0t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var YT=class extends O0t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Bi(i);n(null,s)}},pk=Symbol("maskedWrite");function RAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[pk]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Bi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stdout.write=r}if(!process.stderr.write[pk]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Bi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stderr.write=r}}}var AAe=!1,xAe=()=>{AAe=!0},Vi=()=>AAe;var KT=null,PAe=t=>(KT&&KT.destroy(),KT=new Io({totalAllowedTime:t}),KT),IAe=()=>KT;var Io=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&&Vi())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 tN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{de.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 CAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.170.0-local-ui-preview.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.128.0","@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 j0t=U0t(import.meta.url),z0t=rl.dirname(j0t),q0t=F0t(import.meta.url),L_=fe("shell"),GY=new Set,OAe={preferLocal:!0},pr=(t,e,r)=>{let[n,i]=B0t(e,r),s={...OAe,...i},o=TAe(t,n,s);kAe(o,s),DAe(o);let a=r?.idleTimeout;return a&&a>0&&LAe(o,a),o},NAe=(t,e)=>{let r={...OAe,...e},n=wAe(t,r);return kAe(n,r),DAe(n),e?.idleTimeout&&e.idleTimeout>0&&LAe(n,e.idleTimeout),n},B0t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},kAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||La.env.NETLIFY_LOCAL_QUIET==="true")return;if(La.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new YT).pipe(La.stdout),t.stderr?.pipe(new YT).pipe(La.stderr);return}t.stdout?.pipe(La.stdout),t.stderr?.pipe(La.stderr)},WY=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(La.kill(-t.pid,e),L_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return L_.error("Error killing process:",r),!1}},$Ae=t=>WY(t,"SIGKILL"),LAe=(t,e)=>{let r=null,n=()=>{L_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),WY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(L_.log(`Force killing idle process ${t.pid}`),$Ae(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},DAe=t=>{GY.add(t);let e=IAe();if(e){let r=e.onTimesUp(()=>{L_.log(`Global timer expired, killing process ${t.pid}`),WY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(L_.log(`Force killing process ${t.pid} after timeout`),$Ae(t))},5e3)});t.on("exit",()=>{GY.delete(t),r()}),t.on("error",()=>{GY.delete(t),r()})}};function Da(t,e){if(!La.env.NETLIFY_LOCAL_MODE)try{let i=q0t.resolve(CAe.name),s=rl.dirname(i);for(;s!==rl.dirname(s);){let o=rl.dirname(s);if(rl.basename(o)==="node_modules"){let a=rl.join(o,".bin",e);if(hk.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(La.env.NODE_PATH){let i=rl.join(La.env.NODE_PATH,".bin",e);if(hk.existsSync(i))return i}let r=rl.join(t,"node_modules",".bin",e);if(hk.existsSync(r))return r;let n=rl.join(z0t,"..","node_modules",".bin",e);if(hk.existsSync(n))return n}import MM from"process";import{fileURLToPath as _Ft}from"url";import{createRequire as yFt}from"module";import WR from"path";import{readFileSync as SFt}from"fs";var V0t="__netlify__getTracer",H0t="__netlify__shutdownTracers",xt=(t,e)=>globalThis[V0t]?.(t,e),MAe=async()=>globalThis[H0t]?.();function JT(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 dFt}from"timers/promises";Le();import Gxt from"process";Le();var mAt=(t,e)=>{e.recordException(t),e.setStatus({code:ri.ERROR})};var sl=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}=Cxe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>Oxe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Cxe(r,n,i),c=this._tracer.startSpan(e,s,o);return Oxe(c,s,a)}};function Cxe(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??tr.active(),{opts:n,ctx:i,fn:s}}function Oxe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:mAt,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)}}Le();var q_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var xK=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=zxe(e),n._asyncAttributesPending=e.filter(([i,s])=>q_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(q_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=zxe(this._rawAttributes),this._schemaUrl=gAt(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,q_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ae.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(q_(n)){ae.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=_At(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function PK(t,e){return xK.FromAttributeList(Object.entries(t),e)}function zxe(t){return t.map(([e,r])=>q_(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function gAt(t){if(typeof t=="string"||t===void 0)return t;ae.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function _At(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;ae.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Le();var cw=class{emit(e){}enabled(){return!1}},qxe=new cw;var lw=Symbol.for("io.opentelemetry.js.api.logs"),B_=globalThis;function Bxe(t,e,r){return n=>n===t?e:r}var IK=1;var CK=class{getLogger(e,r,n){return new cw}},Mk=new CK;var Uk=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):qxe}};var uw=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new Uk(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Mk}_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 Fk=class t{constructor(){this._proxyLoggerProvider=new uw}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return B_[lw]?this.getLoggerProvider():(B_[lw]=Bxe(IK,e,Mk),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=B_[lw])===null||e===void 0?void 0:e.call(B_,IK))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete B_[lw],this._proxyLoggerProvider=new uw}};var Vxe=Fk.getInstance();function Hxe(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 Gxe(t){t.forEach(e=>e.disable())}function OK(t){let e=t.tracerProvider||Mt.getTracerProvider(),r=t.meterProvider||aw.getMeterProvider(),n=t.loggerProvider||Vxe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Hxe(i,e,r,n),()=>{Gxe(i)}}Le();var yAt=ln("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Wxe(t){return t.getValue(yAt)===!0}var V_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(V_||(V_={}));Le();var NK="[_0-9a-z-*/]",SAt=`[a-z]${NK}{0,255}`,EAt=`[a-z0-9]${NK}{0,240}@[a-z]${NK}{0,13}`,vAt=new RegExp(`^(?:${SAt}|${EAt})$`),bAt=/^[ -~]{0,255}[!-~]$/,TAt=/,|=/;function kK(t){return vAt.test(t)}function $K(t){return bAt.test(t)&&!TAt.test(t)}var wAt=32,Yxe=512,Kxe=",",Jxe="=",jk=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!kK(e)||!$K(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>Yxe)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=Kxe+e),e=`${n[0]}${Jxe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(Kxe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Jxe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!kK(a)||!$K(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>Yxe)&&(r.set(a,c),n=l,r.size>=wAt))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 zk="traceparent",qk="tracestate",RAt="00",AAt="(?!ff)[\\da-f]{2}",xAt="(?![0]{32})[\\da-f]{32}",PAt="(?![0]{16})[\\da-f]{16}",IAt="[\\da-f]{2}",CAt=new RegExp(`^\\s?(${AAt})-(${xAt})-(${PAt})-(${IAt})(-.*)?\\s?$`);function Zxe(t){let e=CAt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ad=class{inject(e,r,n){let i=Mt.getSpanContext(e);if(!i||Wxe(e)||!Hi(i))return;let s=`${RAt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Pr.NONE).toString(16)}`;n.set(r,zk,s),i.traceState&&n.set(r,qk,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,zk);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=Zxe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,qk);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new jk(typeof c=="string"?c:void 0)}return Mt.setSpanContext(e,o)}fields(){return[zk,qk]}};var Bk=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 dw=class{_isCalled=!1;_deferred=new Bk;_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 $$=Wn(S5(),1);Le();var kCe=t=>{throw TypeError(t)},T5=(t,e,r)=>e.has(t)||kCe("Cannot "+r),k$=(t,e,r)=>(T5(t,e,"read from private field"),r?r.call(t):e.get(t)),E5=(t,e,r)=>e.has(t)?kCe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),CCe=(t,e,r,n)=>(T5(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Hxt=(t,e,r)=>(T5(t,e,"access private method"),r),OCe="__netlify__getTracer",Wxt="__netlify__shutdownTracers",Yxt="__nfOTLPTrace",Aw,xw,b5,$Ce,Kxt=class{constructor(){E5(this,b5),E5(this,Aw),E5(this,xw),CCe(this,Aw,new dw(Hxt(this,b5,$Ce),this)),CCe(this,xw,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(k$(this,xw).debug(`export ${t.length.toString()} spans`),k$(this,Aw).isCalled){e({code:V_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Yxt,JSON.stringify(Jxt(t))),e({code:V_.SUCCESS})}shutdown(){return k$(this,Aw).call()}};Aw=new WeakMap;xw=new WeakMap;b5=new WeakSet;$Ce=function(){return k$(this,xw).debug("Shutting down"),Promise.resolve()};function Jxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:N$(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||Co.SERVER,startTimeUnixNano:v5(e.startTime),endTimeUnixNano:v5(e.endTime),attributes:N$(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:v5(n.time),attributes:N$(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:N$(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function N$(t){return Object.keys(t).map(e=>LCe(e,t[e]))}function LCe(t,e){return{key:t,value:DCe(e)}}function DCe(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(DCe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>LCe(r,n))}}:{}}function v5(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var NCe={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"}},MCe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,OCe))return;let e=Gxt.version.slice(1),r=PK({"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??[Zxt()],i=new $$.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ad});let s=t.instrumentations??[];OK({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,OCe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new sl(Mt.getTracer(a,c)):new sl(Mt.getTracer(NCe.name,NCe.version))}}),Object.defineProperty(globalThis,Wxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Zxt=()=>new $$.SimpleSpanProcessor(new Kxt);Le();var Pw=Wn(S5(),1);Le();import*as L$ from"diagnostics_channel";var UCe=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?ri.ERROR:ri.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 sl?t:new sl(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){L$.subscribe(t,e);let r=()=>L$.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:Co.CLIENT},tr.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:ri.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 cUe=Wn(oUe(),1);var LM=fe("tracing"),aUe=8e3,fFt=5e3,GR=async(t=fFt)=>{try{await Promise.race([MAe(),dFt(t)])}catch(e){LM.warn("Failed to flush tracers on shutdown",e)}},lUe=async(t,e,r)=>{if(!xt()){let n=[new Pw.SimpleSpanProcessor(new wX),new Pw.SimpleSpanProcessor(new cUe.OTLPTraceExporter({url:r.exporterUrl}))];await MCe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new UCe({skipHeaders:!0})]})}return r.traceparent?(vi.setGlobalPropagator(new ad),vi.extract(tr.active(),{traceparent:r.traceparent,isRemote:!0})):tr.active()};function ir(t,e,r){return LM.log(`\u23F3 TRACE: ${e} starting...`),JT(t,e,r)}var wX=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(", ")}]`:"";LM.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&LM.log(` \u274C Error: ${e.status.message}`)}};function RX(){return tt().captureLlmContentEnabled}function uUe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function DM(t,e,r){let n={role:t,parts:[{type:"text",content:Bi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var pFt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]);function dUe(t,e,r,n){if(!t.length)return;let i=xt();if(!i)return;let s=RX(),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&&pFt.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>aUe?`${a.message.slice(0,aUe)}\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":Bi(_)}:{"gen_ai.output.messages":DM("assistant",_)}:{}}}).end(u)})}import{readdir as hFt,rm as mFt}from"fs/promises";import{join as gFt}from"path";async function fUe(t,e=[]){let n=(await hFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>mFt(gFt(t,i),{recursive:!0,force:!0})))}var lh=({mode:t,sessionCreditLimit:e})=>t==="create"&&e!=null&&e<=300;var AX=t=>{if(!lh(t))return"default";let e=tt();return e.createAskFirstEnabled&&e.questionsEnabled?"ask_first":e.creditWrapUpEnabled?"budget_constrained":"default"},pUe=t=>{let e=AX(t);return{budget_eligible:lh(t),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var EFt=WR.dirname(_Ft(import.meta.url)),hUe=yFt(import.meta.url),vFt=WR.resolve(EFt,"scripts/scaffold.js"),bFt="scripts/scaffold.js",TFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,xX=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},wFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),RFt=t=>{let e=xX(t);return e==="node"||e.endsWith("/node")},Il=t=>{if(typeof t!="string")return!1;let e=t.match(TFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&wFt(xX(e[r]));)r+=1;if(r>=e.length||!RFt(e[r]))return!1;let n=e[r+1];return n?xX(n).includes(bFt):!1},uh=fe("create_stage"),PX="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.",AFt=`${PX}
|
|
624
|
+
if (condition) { yield value; }`)};import{Buffer as KTt}from"buffer";import{StringDecoder as JTt}from"string_decoder";var XN=(t,e,r)=>{if(r)return;if(t)return{transform:ZTt.bind(void 0,new TextEncoder)};let n=new JTt(e);return{transform:XTt.bind(void 0,n),final:QTt.bind(void 0,n)}},ZTt=function*(t,e){KTt.isBuffer(e)?yield Xc(e):typeof e=="string"?yield t.encode(e):yield e},XTt=function*(t,e){yield Zr(e)?t.write(e):e},QTt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as ZRe}from"util";var lY=ZRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),QN=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=twt}=e[r];for await(let i of n(t))yield*QN(i,e,r+1)},XRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ewt(r,Number(e),t)},ewt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*QN(n,r,e+1)},QRe=ZRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),twt=function*(t){yield t};var uY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},e0e=(t,e)=>[...e.flatMap(r=>[...vp(r,t,0)]),...qT(t)],vp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=nwt}=e[r];for(let i of n(t))yield*vp(i,e,r+1)},qT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*rwt(r,Number(e),t)},rwt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*vp(n,r,e+1)},nwt=function*(t){yield t};var dY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=r0e(t,o,s),l=Ep(e),u=Ep(r),d=l?lY.bind(void 0,QN,a):uY.bind(void 0,vp),f=l||u?lY.bind(void 0,XRe,a):uY.bind(void 0,qT),p=l||u?QRe.bind(void 0,a):void 0;return{stream:new iwt({writableObjectMode:n,writableHighWaterMark:t0e(n),readableObjectMode:i,readableHighWaterMark:t0e(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},ek=(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=r0e(o,r,a);t=e0e(c,t)}return t},r0e=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:YRe(n,a)},XN(r,o,n),ZN(r,s,n,c),{transform:t,final:e},{transform:KRe(i,a)},WRe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var n0e=(t,e)=>{for(let r of swt(t))owt(t,r,e)},swt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),owt=(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 ${nd[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>awt(a,n));r.input=NT(o)},awt=(t,e)=>{let r=ek(t,e,"utf8",!0);return cwt(r),NT(r)},cwt=t=>{let e=t.find(r=>typeof r!="string"&&!Zr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as fwt,appendFileSync as pwt}from"fs";var tk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&v_(r,n)&&!ls.has(e)&&lwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&uwt.has(s))||t.every(({type:i})=>Gs.has(i))),lwt=t=>t===1||t===2,uwt=new Set(["pipe","overlapped"]),i0e=async(t,e,r,n)=>{for await(let i of t)dwt(e)||o0e(i,r,n)},s0e=(t,e,r)=>{for(let n of t)o0e(n,e,r)},dwt=t=>t._readableState.pipes.length>0,o0e=(t,e,r)=>{let n=mN(t);Ca({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var a0e=({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)=>hwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},hwt=({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=cRe(t,s,d),p=Xc(f),{stdioItems:h,objectMode:m}=e[r],_=mwt([p],h,c,n),{serializedResult:y,finalResult:v=y}=gwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});_wt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&ywt(y,h,i),S}catch(g){return n.error=g,S}},mwt=(t,e,r,n)=>{try{return ek(t,e,r,!1)}catch(i){return n.error=i,t}},gwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:NT(t)};let o=bbe(t,r);return n[s]?{serializedResult:o,finalResult:cY(o,!i[s],e)}:{serializedResult:o}},_wt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!tk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=cY(t,!1,o);try{s0e(a,e,n)}catch(c){r.error??=c}},ywt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>KN.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?pwt(n,t):(r.add(s),fwt(n,t))}};var c0e=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,tl(e,r,"all")]:Array.isArray(e)?[tl(t,r,"all"),...e]:Zr(t)&&Zr(e)?_W([t,e]):`${t}${e}`};import{once as fY}from"events";var l0e=async(t,e)=>{let[r,n]=await Swt(t);return e.isForcefullyTerminated??=!1,[r,n]},Swt=async t=>{let[e,r]=await Promise.allSettled([fY(t,"spawn"),fY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?u0e(t):r.value},u0e=async t=>{try{return await fY(t,"exit")}catch{return u0e(t)}},d0e=async t=>{let[e,r]=await t;if(!Ewt(e,r)&&pY(e,r))throw new Ao;return[e,r]},Ewt=(t,e)=>t===void 0&&e===void 0,pY=(t,e)=>t!==0||e!==null;var f0e=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=vwt(t,e,r),o=s?.code==="ETIMEDOUT",a=aRe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},vwt=(t,e,r)=>t!==void 0?t:pY(e,r)?new Ao:void 0;var p0e=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Twt(t,e,r),d=Awt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return O_(d,c,l)},Twt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),a=wwt(r),{file:c,commandArguments:l,options:u}=MN(t,e,a);Rwt(u);let d=BRe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},wwt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Rwt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&rk("ipcInput"),t&&rk("ipc: true"),r&&rk("detached: true"),n&&rk("cancelSignal")},rk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Awt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=xwt({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}=f0e(c,r),{output:h,error:m=l}=a0e({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>tl(v,r,S)),y=tl(c0e(h,r),r,"all");return Iwt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},xwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{n0e(s,r);let a=Pwt(r);return bwt(...UN(t,e,a))}catch(a){return C_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Pwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:HN(e)}),Iwt=({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?GN({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):zT({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 g0t}from"events";import{spawn as _0t}from"child_process";import y0e from"process";import{once as hY,on as Cwt}from"events";var h0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(w_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),Owt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Owt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{xN(e,i);let s=rd(t,e,r),o=new AbortController;try{return await Promise.race([Nwt(s,n,o),kwt(s,r,o),$wt(s,r,o)])}catch(a){throw R_(t),a}finally{o.abort(),PN(e,i)}},Nwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await hY(t,"message",{signal:r});return n}for await(let[n]of Cwt(t,"message",{signal:r}))if(e(n))return n},kwt=async(t,e,{signal:r})=>{await hY(t,"disconnect",{signal:r}),ewe(e)},$wt=async(t,e,{signal:r})=>{let[n]=await hY(t,"strict:error",{signal:r});throw wN(n,e)};import{once as g0e,on as Lwt}from"events";var _0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>mY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),mY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{w_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),xN(e,s);let o=rd(t,e,r),a=new AbortController,c={};return Dwt(t,o,a),Mwt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Uwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Dwt=async(t,e,r)=>{try{await g0e(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Mwt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await g0e(t,"strict:error",{signal:r.signal});n.error=wN(i,e),r.abort()}catch{}},Uwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Lwt(r,"message",{signal:s.signal}))m0e(o),yield c}catch{m0e(o)}finally{s.abort(),PN(e,a),n||R_(t),i&&await t}},m0e=({error:t})=>{if(t)throw t};var S0e=(t,{ipc:e})=>{Object.assign(t,v0e(t,!1,e))},E0e=()=>{let t=y0e,e=!0,r=y0e.channel!==void 0;return{...v0e(t,e,r),getCancelSignal:xwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},v0e=(t,e,r)=>({sendMessage:LN.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:h0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:_0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Fwt}from"child_process";import{PassThrough as jwt,Readable as zwt,Writable as qwt,Duplex as Bwt}from"stream";var b0e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{sY(n);let a=new Fwt;Vwt(a,n),Object.assign(a,{readable:Hwt,writable:Gwt,duplex:Wwt});let c=C_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Ywt(c,o,i);return{subprocess:a,promise:l}},Vwt=(t,e)=>{let r=BT(),n=BT(),i=BT(),s=Array.from({length:e.length-3},BT),o=BT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},BT=()=>{let t=new jwt;return t.end(),t},Hwt=()=>new zwt({read(){}}),Gwt=()=>new qwt({write(){}}),Wwt=()=>new Bwt({read(){},write(){}}),Ywt=async(t,e,r)=>O_(t,e,r);import{createReadStream as T0e,createWriteStream as w0e}from"fs";import{Buffer as Kwt}from"buffer";import{Readable as VT,Writable as Jwt,Duplex as Zwt}from"stream";var A0e=(t,e)=>JN(Xwt,t,e,!1),HT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${nd[t]}.`)},R0e={fileNumber:HT,generator:dY,asyncGenerator:dY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Zwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Xwt={input:{...R0e,fileUrl:({value:t})=>({stream:T0e(t)}),filePath:({value:{file:t}})=>({stream:T0e(t)}),webStream:({value:t})=>({stream:VT.fromWeb(t)}),iterable:({value:t})=>({stream:VT.from(t)}),asyncIterable:({value:t})=>({stream:VT.from(t)}),string:({value:t})=>({stream:VT.from(t)}),uint8Array:({value:t})=>({stream:VT.from(Kwt.from(t))})},output:{...R0e,fileUrl:({value:t})=>({stream:w0e(t)}),filePath:({value:{file:t,append:e}})=>({stream:w0e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Jwt.fromWeb(t)}),iterable:HT,asyncIterable:HT,string:HT,uint8Array:HT}};import{on as Qwt,once as x0e}from"events";import{PassThrough as eRt,getDefaultHighWaterMark as tRt}from"stream";import{finished as C0e}from"stream/promises";function bp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)_Y(i);let e=t.some(({readableObjectMode:i})=>i),r=rRt(t,e),n=new gY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var rRt=(t,e)=>{if(t.length===0)return tRt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},gY=class extends eRt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(_Y(e),this.#e.has(e))return;this.#e.add(e),this.#n??=nRt(this,this.#e,this.#s);let r=oRt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(_Y(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},nRt=async(t,e,r)=>{nk(t,P0e);let n=new AbortController;try{await Promise.race([iRt(t,n),sRt(t,e,r,n)])}finally{n.abort(),nk(t,-P0e)}},iRt=async(t,{signal:e})=>{try{await C0e(t,{signal:e,cleanup:!0})}catch(r){throw O0e(t,r),r}},sRt=async(t,e,r,{signal:n})=>{for await(let[i]of Qwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},_Y=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},oRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{nk(t,I0e);let a=new AbortController;try{await Promise.race([aRt(s,e,a),cRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),lRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),nk(t,-I0e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?yY(t):uRt(t))},aRt=async(t,e,{signal:r})=>{try{await t,r.aborted||yY(e)}catch(n){r.aborted||O0e(e,n)}},cRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await C0e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;N0e(o)?i.add(e):k0e(t,o)}},lRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await x0e(t,i,{signal:s}),!t.readable)return x0e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},uRt=t=>{t.writable&&t.end()},O0e=(t,e)=>{N0e(e)?yY(t):k0e(t,e)},N0e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yY=t=>{(t.readable||t.writable)&&t.destroy()},k0e=(t,e)=>{t.destroyed||(t.once("error",dRt),t.destroy(e))},dRt=()=>{},nk=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},P0e=2,I0e=1;import{finished as $0e}from"stream/promises";var k_=(t,e)=>{t.pipe(e),fRt(t,e),pRt(t,e)},fRt=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await $0e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}SY(e)}},SY=t=>{t.writable&&t.end()},pRt=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await $0e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}EY(t)}},EY=t=>{t.readable&&t.destroy()};var L0e=(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})=>Gs.has(c)))hRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Gs.has(c)))gRt({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]:bp(s);k_(o,i)}},hRt=(t,e,r,n)=>{r==="output"?k_(t.stdio[n],e):k_(e,t.stdio[n]);let i=mRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},mRt=["stdin","stdout","stderr"],gRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;_Rt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},_Rt=(t,{signal:e})=>{Ro(t)&&yp(t,yRt,e)},yRt=2;import{addAbortListener as vRt}from"events";var Tp=[];Tp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Tp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Tp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ik=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",vY=Symbol.for("signal-exit emitter"),bY=globalThis,SRt=Object.defineProperty.bind(Object),TY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(bY[vY])return bY[vY];SRt(bY,vY,{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}},sk=class{},ERt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),wY=class extends sk{onExit(){return()=>{}}load(){}unload(){}},RY=class extends sk{#e=AY.platform==="win32"?"SIGINT":"SIGHUP";#r=new TY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Tp)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!ik(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Tp)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Tp.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return ik(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"&&ik(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)}},AY=globalThis.process,{onExit:D0e,load:l_r,unload:u_r}=ERt(ik(AY)?new RY(AY):new wY);var M0e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=D0e(()=>{t.kill()});vRt(n,()=>{i()})};var F0e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=gN(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=bRt(r,n,i),{sourceStream:d,sourceError:f}=wRt(t,l),{options:p,fileDescriptors:h}=Na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},bRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=TRt(t,e,...r),a=AN(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},TRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(U0e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||mW(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]=oN(r,...n);return{destination:e(U0e)(i,s,o),pipeOptions:o}}if(Na.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}`)},U0e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),wRt=(t,e)=>{try{return{sourceStream:A_(t,e)}}catch(r){return{sourceError:r}}};var z0e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=RRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw xY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},RRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return EY(t),n;if(e!==void 0)return SY(r),e},xY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>C_({error:t,command:j0e,escapedCommand:j0e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),j0e="source.pipe(destination)";var q0e=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 ARt}from"stream/promises";var B0e=(t,e,r)=>{let n=ok.has(e)?PRt(t,e):xRt(t,e);return yp(t,CRt,r.signal),yp(e,ORt,r.signal),IRt(e),n},xRt=(t,e)=>{let r=bp([t]);return k_(r,e),ok.set(e,r),r},PRt=(t,e)=>{let r=ok.get(e);return r.add(t),r},IRt=async t=>{try{await ARt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ok.delete(t)},ok=new WeakMap,CRt=2,ORt=1;import{aborted as NRt}from"util";var V0e=(t,e)=>t===void 0?[]:[kRt(t,e)],kRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await NRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw xY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ak=(t,...e)=>{if(Lr(e[0]))return ak.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=F0e(t,...e),i=$Rt({...n,destination:r});return i.pipe=ak.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},$Rt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=LRt(t,i);z0e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=B0e(e,s,d);return await Promise.race([q0e(u),...V0e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},LRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as qRt}from"timers/promises";import{on as DRt}from"events";import{getDefaultHighWaterMark as MRt}from"stream";var ck=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return URt(e,o),G0e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},URt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},PY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;FRt(e,o,t);let a=t.readableObjectMode&&!s;return G0e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},FRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},G0e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=DRt(t,"data",{signal:e.signal,highWaterMark:H0e,highWatermark:H0e});return jRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},IY=MRt(!0),H0e=IY,jRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=zRt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*vp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*qT(a)}},zRt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[XN(t,r,!e),ZN(t,i,!n,{})].filter(Boolean);var W0e=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=BRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([VRt(t),d]);return}let f=oY(c,r),p=PY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([HRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},BRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!tk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=PY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await i0e(a,t,r,s)},VRt=async t=>{await qRt(),t.readableFlowing===null&&t.resume()},HRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qN(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await BN(r,{maxBuffer:s})):await I_(r,{maxBuffer:s})}catch(a){return Y0e(iRe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},CY=async t=>{try{return await t}catch(e){return Y0e(e)}},Y0e=({bufferedData:t})=>Ebe(t)?new Uint8Array(t):t;import{finished as GRt}from"stream/promises";var GT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=WRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],GRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||JRt(a,e,r,n)}finally{o.abort()}},WRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&YRt(t,r,n),n},YRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{KRt(e,r),n.call(t,...i)}},KRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},JRt=(t,e,r,n)=>{if(!ZRt(t,e,r,n))throw t},ZRt=(t,e,r,n=!0)=>r.propagating?K0e(t)||lk(t):(r.propagating=!0,OY(r,e)===n?K0e(t):lk(t)),OY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",lk=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",K0e=t=>t?.code==="EPIPE";var J0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>NY({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),NY=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=GT(t,e,l);if(OY(l,e)){await u;return}let[d]=await Promise.all([W0e({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 Z0e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?bp([t,e].filter(Boolean)):void 0,X0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>NY({...XRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:QRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),XRt=({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}},QRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as e0t}from"events";var Q0e=t=>v_(t,"ipc"),eAe=(t,e)=>{let r=mN(t);Ca({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var tAe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Q0e(s),a=Qc(e,"ipc"),c=Qc(r,"ipc");for await(let l of mY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(sRe(t,i,c),i.push(l)),o&&eAe(l,s);return i},rAe=async(t,e)=>(await Promise.allSettled([t]),e);var nAe=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 v=l0e(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=J0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),R=X0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),x=[],w=tAe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),b=t0t(m,t,S),I=r0t(h,S);try{return await Promise.race([Promise.all([{},d0e(v),Promise.all(g),R,w,Mwe(t,d),...b,...I]),_,n0t(t,y),...Nwe(t,s,f,y),...QTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Cwe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(N){return f.terminationReason??="other",Promise.all([{error:N},v,Promise.all(g.map(A=>CY(A))),CY(R),rAe(w,x),Promise.allSettled(b),Promise.allSettled(I)])}},t0t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:GT(n,i,r)),r0t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Po(s,{checkOpen:!1})&&!Ro(s)).map(({type:i,value:s,stream:o=s})=>GT(o,n,e,{isSameDirection:Gs.has(i),stopOnExit:i==="native"}))),n0t=async(t,{signal:e})=>{let[r]=await e0t(t,"error",{signal:e});throw r};var iAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),WT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Oa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},$_=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 i0t}from"stream";import{callbackify as s0t}from"util";import{finished as sAe}from"stream/promises";var kY=async t=>{if(t!==void 0)try{await $Y(t)}catch{}},oAe=async t=>{if(t!==void 0)try{await LY(t)}catch{}},$Y=async t=>{await sAe(t,{cleanup:!0,readable:!1,writable:!0})},LY=async t=>{await sAe(t,{cleanup:!0,readable:!0,writable:!1})},uk=async(t,e)=>{if(await t,e)throw e},dk=(t,e,r)=>{r&&!lk(r)?t.destroy(r):e&&t.destroy()};var aAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ls.has(r),{subprocessStdout:a,waitReadableDestroy:c}=DY(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=MY(a,o),{read:f,onStdoutDataDone:p}=UY({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new i0t({read:f,destroy:s0t(jY.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return FY({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},DY=(t,e,r)=>{let n=A_(t,e),i=WT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},MY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:IY},UY=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Oa(),o=ck({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){o0t(this,o,s)},onStdoutDataDone:s}},o0t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},FY=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await LY(t),await n,await kY(i),await e,r.readable&&r.push(null)}catch(s){await kY(i),cAe(r,s)}},jY=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await $_(r,e)&&(cAe(t,n),await uk(e,n))},cAe=(t,e)=>{dk(t,t.readable,e)};import{Writable as a0t}from"stream";import{callbackify as lAe}from"util";var uAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=zY(t,r,e),o=new a0t({...qY(n,t,i),destroy:lAe(VY.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return BY(n,o),o},zY=(t,e,r)=>{let n=AN(t,e),i=WT(r,n,"writableFinal"),s=WT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},qY=(t,e,r)=>({write:c0t.bind(void 0,t),final:lAe(l0t.bind(void 0,t,e,r))}),c0t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},l0t=async(t,e,r)=>{await $_(r,e)&&(t.writable&&t.end(),await e)},BY=async(t,e,r)=>{try{await $Y(t),e.writable&&e.end()}catch(n){await oAe(r),dAe(e,n)}},VY=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await $_(r,e),await $_(n,e)&&(dAe(t,i),await uk(e,i))},dAe=(t,e)=>{dk(t,t.writable,e)};import{Duplex as u0t}from"stream";import{callbackify as d0t}from"util";var fAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ls.has(r),{subprocessStdout:c,waitReadableDestroy:l}=DY(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=zY(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=MY(c,a),{read:_,onStdoutDataDone:y}=UY({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new u0t({read:_,...qY(u,t,d),destroy:d0t(f0t.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 FY({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),BY(u,v,c),v},f0t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([jY({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),VY({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var HY=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ls.has(e),o=A_(t,r),a=ck({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return p0t(a,o,t)},p0t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var pAe=(t,{encoding:e})=>{let r=iAe();t.readable=aAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=uAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=fAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=HY.bind(void 0,t,e),t[Symbol.asyncIterator]=HY.bind(void 0,t,e,{})};var hAe=(t,e)=>{for(let[r,n]of m0t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},h0t=(async()=>{})().constructor.prototype,m0t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(h0t,t)]);var mAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=y0t(t,e,r),{subprocess:f,promise:p}=E0t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ak.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),hAe(f,p),Na.set(f,{options:u,fileDescriptors:d}),f},y0t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),{file:a,commandArguments:c,options:l}=MN(t,e,r),u=S0t(l),d=A0e(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},S0t=({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}},E0t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=_0t(...UN(t,e,r))}catch(h){return b0e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;g0t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];L0e(c,a,l),M0e(c,r,l);let d={},f=Oa();c.kill=ZTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Z0e(c,r),pAe(c,r),S0e(c,r);let p=v0t({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}},v0t=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 nAe({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,R)=>tl(g,e,R)),v=tl(m,e,"all"),S=b0t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return O_(S,n,e)},b0t=({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?zT({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 ka,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):GN({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var fk=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,T0t(n,t[n],i)]));return{...t,...r}},T0t=(t,e,r)=>w0t.has(t)&&Lr(e)&&Lr(r)?{...e,...r}:r,w0t=new Set(["env",...vW]);var id=(t,e,r,n)=>{let i=(o,a,c)=>id(o,a,r,c),s=(...o)=>R0t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},R0t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Lr(s))return i(t,fk(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=A0t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?p0e(a,c,l):mAe(a,c,l,i)},A0t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Abe(e)?xbe(e,r):[e,...r],[o,a,c]=oN(...s),l=fk(fk(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 gAe=({file:t,commandArguments:e})=>yAe(t,e),_Ae=({file:t,commandArguments:e})=>({...yAe(t,e),isSync:!0}),yAe=(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]=x0t(t);return{file:r,commandArguments:n}},x0t=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(P0t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},P0t=/ +/g;var SAe=(t,e,r)=>{t.sync=e(I0t,r),t.s=t.sync},EAe=({options:t})=>vAe(t),I0t=({options:t})=>({...vAe(t),isSync:!0}),vAe=t=>({options:{...C0t(t),...t}}),C0t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},bAe={preferLocal:!0};var TAe=id(()=>({})),QSr=id(()=>({isSync:!0})),wAe=id(gAe),eEr=id(_Ae),tEr=id($we),rEr=id(EAe,{},bAe,SAe),{sendMessage:nEr,getOneMessage:iEr,getEachMessage:sEr,getCancelSignal:oEr}=E0e();import{Transform as O0t}from"stream";var N0t=["NETLIFY_AI_GATEWAY_KEY"];function k0t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...N0t])]}function $0t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function L0t(){let e=k0t().map(r=>process.env[r]).filter(r=>!(!r||$0t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Bi(t){if(typeof t!="string")return t;let e=L0t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(D0t(n),"g");r=r.replace(i,"******")}),r}function D0t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var YT=class extends O0t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Bi(i);n(null,s)}},pk=Symbol("maskedWrite");function RAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[pk]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Bi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stdout.write=r}if(!process.stderr.write[pk]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Bi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stderr.write=r}}}var AAe=!1,xAe=()=>{AAe=!0},Vi=()=>AAe;var KT=null,PAe=t=>(KT&&KT.destroy(),KT=new Io({totalAllowedTime:t}),KT),IAe=()=>KT;var Io=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&&Vi())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 tN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{de.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 CAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.170.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 j0t=U0t(import.meta.url),z0t=rl.dirname(j0t),q0t=F0t(import.meta.url),L_=fe("shell"),GY=new Set,OAe={preferLocal:!0},pr=(t,e,r)=>{let[n,i]=B0t(e,r),s={...OAe,...i},o=TAe(t,n,s);kAe(o,s),DAe(o);let a=r?.idleTimeout;return a&&a>0&&LAe(o,a),o},NAe=(t,e)=>{let r={...OAe,...e},n=wAe(t,r);return kAe(n,r),DAe(n),e?.idleTimeout&&e.idleTimeout>0&&LAe(n,e.idleTimeout),n},B0t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},kAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||La.env.NETLIFY_LOCAL_QUIET==="true")return;if(La.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new YT).pipe(La.stdout),t.stderr?.pipe(new YT).pipe(La.stderr);return}t.stdout?.pipe(La.stdout),t.stderr?.pipe(La.stderr)},WY=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(La.kill(-t.pid,e),L_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return L_.error("Error killing process:",r),!1}},$Ae=t=>WY(t,"SIGKILL"),LAe=(t,e)=>{let r=null,n=()=>{L_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),WY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(L_.log(`Force killing idle process ${t.pid}`),$Ae(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},DAe=t=>{GY.add(t);let e=IAe();if(e){let r=e.onTimesUp(()=>{L_.log(`Global timer expired, killing process ${t.pid}`),WY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(L_.log(`Force killing process ${t.pid} after timeout`),$Ae(t))},5e3)});t.on("exit",()=>{GY.delete(t),r()}),t.on("error",()=>{GY.delete(t),r()})}};function Da(t,e){if(!La.env.NETLIFY_LOCAL_MODE)try{let i=q0t.resolve(CAe.name),s=rl.dirname(i);for(;s!==rl.dirname(s);){let o=rl.dirname(s);if(rl.basename(o)==="node_modules"){let a=rl.join(o,".bin",e);if(hk.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(La.env.NODE_PATH){let i=rl.join(La.env.NODE_PATH,".bin",e);if(hk.existsSync(i))return i}let r=rl.join(t,"node_modules",".bin",e);if(hk.existsSync(r))return r;let n=rl.join(z0t,"..","node_modules",".bin",e);if(hk.existsSync(n))return n}import MM from"process";import{fileURLToPath as _Ft}from"url";import{createRequire as yFt}from"module";import WR from"path";import{readFileSync as SFt}from"fs";var V0t="__netlify__getTracer",H0t="__netlify__shutdownTracers",xt=(t,e)=>globalThis[V0t]?.(t,e),MAe=async()=>globalThis[H0t]?.();function JT(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 dFt}from"timers/promises";Le();import Gxt from"process";Le();var mAt=(t,e)=>{e.recordException(t),e.setStatus({code:ri.ERROR})};var sl=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}=Cxe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>Oxe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Cxe(r,n,i),c=this._tracer.startSpan(e,s,o);return Oxe(c,s,a)}};function Cxe(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??tr.active(),{opts:n,ctx:i,fn:s}}function Oxe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:mAt,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)}}Le();var q_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var xK=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=zxe(e),n._asyncAttributesPending=e.filter(([i,s])=>q_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(q_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=zxe(this._rawAttributes),this._schemaUrl=gAt(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,q_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ae.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(q_(n)){ae.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=_At(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function PK(t,e){return xK.FromAttributeList(Object.entries(t),e)}function zxe(t){return t.map(([e,r])=>q_(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function gAt(t){if(typeof t=="string"||t===void 0)return t;ae.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function _At(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;ae.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Le();var cw=class{emit(e){}enabled(){return!1}},qxe=new cw;var lw=Symbol.for("io.opentelemetry.js.api.logs"),B_=globalThis;function Bxe(t,e,r){return n=>n===t?e:r}var IK=1;var CK=class{getLogger(e,r,n){return new cw}},Mk=new CK;var Uk=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):qxe}};var uw=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new Uk(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Mk}_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 Fk=class t{constructor(){this._proxyLoggerProvider=new uw}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return B_[lw]?this.getLoggerProvider():(B_[lw]=Bxe(IK,e,Mk),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=B_[lw])===null||e===void 0?void 0:e.call(B_,IK))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete B_[lw],this._proxyLoggerProvider=new uw}};var Vxe=Fk.getInstance();function Hxe(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 Gxe(t){t.forEach(e=>e.disable())}function OK(t){let e=t.tracerProvider||Mt.getTracerProvider(),r=t.meterProvider||aw.getMeterProvider(),n=t.loggerProvider||Vxe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Hxe(i,e,r,n),()=>{Gxe(i)}}Le();var yAt=ln("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Wxe(t){return t.getValue(yAt)===!0}var V_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(V_||(V_={}));Le();var NK="[_0-9a-z-*/]",SAt=`[a-z]${NK}{0,255}`,EAt=`[a-z0-9]${NK}{0,240}@[a-z]${NK}{0,13}`,vAt=new RegExp(`^(?:${SAt}|${EAt})$`),bAt=/^[ -~]{0,255}[!-~]$/,TAt=/,|=/;function kK(t){return vAt.test(t)}function $K(t){return bAt.test(t)&&!TAt.test(t)}var wAt=32,Yxe=512,Kxe=",",Jxe="=",jk=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!kK(e)||!$K(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>Yxe)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=Kxe+e),e=`${n[0]}${Jxe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(Kxe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Jxe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!kK(a)||!$K(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>Yxe)&&(r.set(a,c),n=l,r.size>=wAt))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 zk="traceparent",qk="tracestate",RAt="00",AAt="(?!ff)[\\da-f]{2}",xAt="(?![0]{32})[\\da-f]{32}",PAt="(?![0]{16})[\\da-f]{16}",IAt="[\\da-f]{2}",CAt=new RegExp(`^\\s?(${AAt})-(${xAt})-(${PAt})-(${IAt})(-.*)?\\s?$`);function Zxe(t){let e=CAt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ad=class{inject(e,r,n){let i=Mt.getSpanContext(e);if(!i||Wxe(e)||!Hi(i))return;let s=`${RAt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Pr.NONE).toString(16)}`;n.set(r,zk,s),i.traceState&&n.set(r,qk,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,zk);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=Zxe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,qk);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new jk(typeof c=="string"?c:void 0)}return Mt.setSpanContext(e,o)}fields(){return[zk,qk]}};var Bk=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 dw=class{_isCalled=!1;_deferred=new Bk;_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 $$=Wn(S5(),1);Le();var kCe=t=>{throw TypeError(t)},T5=(t,e,r)=>e.has(t)||kCe("Cannot "+r),k$=(t,e,r)=>(T5(t,e,"read from private field"),r?r.call(t):e.get(t)),E5=(t,e,r)=>e.has(t)?kCe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),CCe=(t,e,r,n)=>(T5(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Hxt=(t,e,r)=>(T5(t,e,"access private method"),r),OCe="__netlify__getTracer",Wxt="__netlify__shutdownTracers",Yxt="__nfOTLPTrace",Aw,xw,b5,$Ce,Kxt=class{constructor(){E5(this,b5),E5(this,Aw),E5(this,xw),CCe(this,Aw,new dw(Hxt(this,b5,$Ce),this)),CCe(this,xw,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(k$(this,xw).debug(`export ${t.length.toString()} spans`),k$(this,Aw).isCalled){e({code:V_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Yxt,JSON.stringify(Jxt(t))),e({code:V_.SUCCESS})}shutdown(){return k$(this,Aw).call()}};Aw=new WeakMap;xw=new WeakMap;b5=new WeakSet;$Ce=function(){return k$(this,xw).debug("Shutting down"),Promise.resolve()};function Jxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:N$(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||Co.SERVER,startTimeUnixNano:v5(e.startTime),endTimeUnixNano:v5(e.endTime),attributes:N$(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:v5(n.time),attributes:N$(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:N$(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function N$(t){return Object.keys(t).map(e=>LCe(e,t[e]))}function LCe(t,e){return{key:t,value:DCe(e)}}function DCe(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(DCe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>LCe(r,n))}}:{}}function v5(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var NCe={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"}},MCe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,OCe))return;let e=Gxt.version.slice(1),r=PK({"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??[Zxt()],i=new $$.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ad});let s=t.instrumentations??[];OK({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,OCe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new sl(Mt.getTracer(a,c)):new sl(Mt.getTracer(NCe.name,NCe.version))}}),Object.defineProperty(globalThis,Wxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Zxt=()=>new $$.SimpleSpanProcessor(new Kxt);Le();var Pw=Wn(S5(),1);Le();import*as L$ from"diagnostics_channel";var UCe=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?ri.ERROR:ri.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 sl?t:new sl(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){L$.subscribe(t,e);let r=()=>L$.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:Co.CLIENT},tr.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:ri.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 cUe=Wn(oUe(),1);var LM=fe("tracing"),aUe=8e3,fFt=5e3,GR=async(t=fFt)=>{try{await Promise.race([MAe(),dFt(t)])}catch(e){LM.warn("Failed to flush tracers on shutdown",e)}},lUe=async(t,e,r)=>{if(!xt()){let n=[new Pw.SimpleSpanProcessor(new wX),new Pw.SimpleSpanProcessor(new cUe.OTLPTraceExporter({url:r.exporterUrl}))];await MCe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new UCe({skipHeaders:!0})]})}return r.traceparent?(vi.setGlobalPropagator(new ad),vi.extract(tr.active(),{traceparent:r.traceparent,isRemote:!0})):tr.active()};function ir(t,e,r){return LM.log(`\u23F3 TRACE: ${e} starting...`),JT(t,e,r)}var wX=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(", ")}]`:"";LM.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&LM.log(` \u274C Error: ${e.status.message}`)}};function RX(){return tt().captureLlmContentEnabled}function uUe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function DM(t,e,r){let n={role:t,parts:[{type:"text",content:Bi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var pFt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]);function dUe(t,e,r,n){if(!t.length)return;let i=xt();if(!i)return;let s=RX(),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&&pFt.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>aUe?`${a.message.slice(0,aUe)}\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":Bi(_)}:{"gen_ai.output.messages":DM("assistant",_)}:{}}}).end(u)})}import{readdir as hFt,rm as mFt}from"fs/promises";import{join as gFt}from"path";async function fUe(t,e=[]){let n=(await hFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>mFt(gFt(t,i),{recursive:!0,force:!0})))}var lh=({mode:t,sessionCreditLimit:e})=>t==="create"&&e!=null&&e<=300;var AX=t=>{if(!lh(t))return"default";let e=tt();return e.createAskFirstEnabled&&e.questionsEnabled?"ask_first":e.creditWrapUpEnabled?"budget_constrained":"default"},pUe=t=>{let e=AX(t);return{budget_eligible:lh(t),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var EFt=WR.dirname(_Ft(import.meta.url)),hUe=yFt(import.meta.url),vFt=WR.resolve(EFt,"scripts/scaffold.js"),bFt="scripts/scaffold.js",TFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,xX=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},wFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),RFt=t=>{let e=xX(t);return e==="node"||e.endsWith("/node")},Il=t=>{if(typeof t!="string")return!1;let e=t.match(TFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&wFt(xX(e[r]));)r+=1;if(r>=e.length||!RFt(e[r]))return!1;let n=e[r+1];return n?xX(n).includes(bFt):!1},uh=fe("create_stage"),PX="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.",AFt=`${PX}
|
|
625
625
|
|
|
626
626
|
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.`,xFt=`${PX}
|
|
627
627
|
|
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:QF},XVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},QVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:XVe};import{Buffer as eGe}from"buffer";var Lce=(t,e)=>t?void 0:tGe.bind(void 0,e),tGe=function*(t,e){if(typeof e!="string"&&!yr(e)&&!eGe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Uce=(t,e)=>t?rGe.bind(void 0,e):nGe.bind(void 0,e),rGe=function*(t,e){Fce(t,e),yield e},nGe=function*(t,e){if(Fce(t,e),typeof e!="string"&&!yr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Fce=(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 iGe}from"buffer";import{StringDecoder as oGe}from"string_decoder";var L0=(t,e,r)=>{if(r)return;if(t)return{transform:sGe.bind(void 0,new TextEncoder)};let n=new oGe(e);return{transform:aGe.bind(void 0,n),final:cGe.bind(void 0,n)}},sGe=function*(t,e){iGe.isBuffer(e)?yield Ca(e):typeof e=="string"?yield t.encode(e):yield e},aGe=function*(t,e){yield yr(e)?t.write(e):e},cGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as zce}from"util";var tz=zce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),U0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=uGe}=e[r];for await(let i of n(t))yield*U0(i,e,r+1)},jce=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*lGe(r,Number(e),t)},lGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*U0(n,r,e+1)},Bce=zce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),uGe=function*(t){yield t};var rz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},qce=(t,e)=>[...e.flatMap(r=>[...sd(r,t,0)]),...jS(t)],sd=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=fGe}=e[r];for(let i of n(t))yield*sd(i,e,r+1)},jS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*dGe(r,Number(e),t)},dGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*sd(n,r,e+1)},fGe=function*(t){yield t};var nz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Gce(t,s,o),l=od(e),u=od(r),d=l?tz.bind(void 0,U0,a):rz.bind(void 0,sd),f=l||u?tz.bind(void 0,jce,a):rz.bind(void 0,jS),p=l||u?Bce.bind(void 0,a):void 0;return{stream:new pGe({writableObjectMode:n,writableHighWaterMark:Vce(n),readableObjectMode:i,readableHighWaterMark:Vce(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},F0=(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=Gce(s,r,a);t=qce(c,t)}return t},Gce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Lce(n,a)},L0(r,s,n),D0(r,o,n,c),{transform:t,final:e},{transform:Uce(i,a)},Dce({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Hce=(t,e)=>{for(let r of hGe(t))mGe(t,r,e)},hGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),mGe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Jc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>gGe(a,n));r.input=OS(s)},gGe=(t,e)=>{let r=F0(t,e,"utf8",!0);return _Ge(r),OS(r)},_Ge=t=>{let e=t.find(r=>typeof r!="string"&&!yr(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 vGe,appendFileSync as bGe}from"fs";var z0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Zp(r,n)&&!hi.has(e)&&yGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&SGe.has(o))||t.every(({type:i})=>qi.has(i))),yGe=t=>t===1||t===2,SGe=new Set(["pipe","overlapped"]),Wce=async(t,e,r,n)=>{for await(let i of t)EGe(e)||Kce(i,r,n)},Yce=(t,e,r)=>{for(let n of t)Kce(n,e,r)},EGe=t=>t._readableState.pipes.length>0,Kce=(t,e,r)=>{let n=e0(t);ys({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Zce=({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)=>TGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},TGe=({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=Jae(t,o,d),p=Ca(f),{stdioItems:h,objectMode:m}=e[r],g=wGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=xGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});AGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?b:void 0;try{return n.error===void 0&&RGe(_,h,i),T}catch(v){return n.error=v,T}},wGe=(t,e,r,n)=>{try{return F0(t,e,r,!1)}catch(i){return n.error=i,t}},xGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:OS(t)};let s=doe(t,r);return n[o]?{serializedResult:s,finalResult:ez(s,!i[o],e)}:{serializedResult:s}},AGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!z0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=ez(t,!1,s);try{Yce(a,e,n)}catch(c){r.error??=c}},RGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>M0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?bGe(n,t):(r.add(o),vGe(n,t))}};var Jce=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Oa(e,r,"all")]:Array.isArray(e)?[Oa(t,r,"all"),...e]:yr(t)&&yr(e)?lF([t,e]):`${t}${e}`};import{once as iz}from"events";var Xce=async(t,e)=>{let[r,n]=await CGe(t);return e.isForcefullyTerminated??=!1,[r,n]},CGe=async t=>{let[e,r]=await Promise.allSettled([iz(t,"spawn"),iz(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Qce(t):r.value},Qce=async t=>{try{return await iz(t,"exit")}catch{return Qce(t)}},ele=async t=>{let[e,r]=await t;if(!IGe(e,r)&&oz(e,r))throw new Co;return[e,r]},IGe=(t,e)=>t===void 0&&e===void 0,oz=(t,e)=>t!==0||e!==null;var tle=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=PGe(t,e,r),s=o?.code==="ETIMEDOUT",a=Zae(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},PGe=(t,e,r)=>t!==void 0?t:oz(e,r)?new Co:void 0;var rle=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=NGe(t,e,r),d=$Ge({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return sh(d,c,l)},NGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=r0(t,e,r),a=kGe(r),{file:c,commandArguments:l,options:u}=b0(t,e,a);MGe(u);let d=Nce(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},kGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,MGe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&j0("ipcInput"),t&&j0("ipc: true"),r&&j0("detached: true"),n&&j0("cancelSignal")},j0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},$Ge=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=DGe({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}=tle(c,r),{output:h,error:m=l}=Zce({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>Oa(b,r,T)),_=Oa(Jce(h,r),r,"all");return UGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},DGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Hce(o,r);let a=LGe(r);return OGe(...T0(t,e,a))}catch(a){return oh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},LGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:P0(e)}),UGe=({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?O0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):zS({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 x6e}from"events";import{spawn as A6e}from"child_process";import ale from"process";import{once as sz,on as FGe}from"events";var nle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Qp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:g0(t)}),zGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),zGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{f0(e,i);let o=Zc(t,e,r),s=new AbortController;try{return await Promise.race([jGe(o,n,s),BGe(o,r,s),qGe(o,r,s)])}catch(a){throw eh(t),a}finally{s.abort(),p0(e,i)}},jGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await sz(t,"message",{signal:r});return n}for await(let[n]of FGe(t,"message",{signal:r}))if(e(n))return n},BGe=async(t,e,{signal:r})=>{await sz(t,"disconnect",{signal:r}),qse(e)},qGe=async(t,e,{signal:r})=>{let[n]=await sz(t,"strict:error",{signal:r});throw l0(n,e)};import{once as ole,on as VGe}from"events";var sle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>az({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),az=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Qp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:g0(t)}),f0(e,o);let s=Zc(t,e,r),a=new AbortController,c={};return GGe(t,s,a),HGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),WGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},GGe=async(t,e,r)=>{try{await ole(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},HGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ole(t,"strict:error",{signal:r.signal});n.error=l0(i,e),r.abort()}catch{}},WGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of VGe(r,"message",{signal:o.signal}))ile(s),yield c}catch{ile(s)}finally{o.abort(),p0(e,a),n||eh(t),i&&await t}},ile=({error:t})=>{if(t)throw t};var cle=(t,{ipc:e})=>{Object.assign(t,ule(t,!1,e))},lle=()=>{let t=ale,e=!0,r=ale.channel!==void 0;return{...ule(t,e,r),getCancelSignal:gae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ule=(t,e,r)=>({sendMessage:E0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:nle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:sle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as YGe}from"child_process";import{PassThrough as KGe,Readable as ZGe,Writable as JGe,Duplex as XGe}from"stream";var dle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{JF(n);let a=new YGe;QGe(a,n),Object.assign(a,{readable:eHe,writable:tHe,duplex:rHe});let c=oh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=nHe(c,s,i);return{subprocess:a,promise:l}},QGe=(t,e)=>{let r=BS(),n=BS(),i=BS(),o=Array.from({length:e.length-3},BS),s=BS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},BS=()=>{let t=new KGe;return t.end(),t},eHe=()=>new ZGe({read(){}}),tHe=()=>new JGe({write(){}}),rHe=()=>new XGe({read(){},write(){}}),nHe=async(t,e,r)=>sh(t,e,r);import{createReadStream as fle,createWriteStream as ple}from"fs";import{Buffer as iHe}from"buffer";import{Readable as qS,Writable as oHe,Duplex as sHe}from"stream";var mle=(t,e)=>$0(aHe,t,e,!1),VS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Jc[t]}.`)},hle={fileNumber:VS,generator:nz,asyncGenerator:nz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:sHe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},aHe={input:{...hle,fileUrl:({value:t})=>({stream:fle(t)}),filePath:({value:{file:t}})=>({stream:fle(t)}),webStream:({value:t})=>({stream:qS.fromWeb(t)}),iterable:({value:t})=>({stream:qS.from(t)}),asyncIterable:({value:t})=>({stream:qS.from(t)}),string:({value:t})=>({stream:qS.from(t)}),uint8Array:({value:t})=>({stream:qS.from(iHe.from(t))})},output:{...hle,fileUrl:({value:t})=>({stream:ple(t)}),filePath:({value:{file:t,append:e}})=>({stream:ple(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:oHe.fromWeb(t)}),iterable:VS,asyncIterable:VS,string:VS,uint8Array:VS}};import{on as cHe,once as gle}from"events";import{PassThrough as lHe,getDefaultHighWaterMark as uHe}from"stream";import{finished as Sle}from"stream/promises";function ad(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)lz(i);let e=t.some(({readableObjectMode:i})=>i),r=dHe(t,e),n=new cz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var dHe=(t,e)=>{if(t.length===0)return uHe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},cz=class extends lHe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(lz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=fHe(this,this.#e,this.#o);let r=mHe({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(lz(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)}},fHe=async(t,e,r)=>{B0(t,_le);let n=new AbortController;try{await Promise.race([pHe(t,n),hHe(t,e,r,n)])}finally{n.abort(),B0(t,-_le)}},pHe=async(t,{signal:e})=>{try{await Sle(t,{signal:e,cleanup:!0})}catch(r){throw Ele(t,r),r}},hHe=async(t,e,r,{signal:n})=>{for await(let[i]of cHe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},lz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},mHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{B0(t,yle);let a=new AbortController;try{await Promise.race([gHe(o,e,a),_He({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),yHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),B0(t,-yle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?uz(t):SHe(t))},gHe=async(t,e,{signal:r})=>{try{await t,r.aborted||uz(e)}catch(n){r.aborted||Ele(e,n)}},_He=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Sle(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;vle(s)?i.add(e):ble(t,s)}},yHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await gle(t,i,{signal:o}),!t.readable)return gle(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},SHe=t=>{t.writable&&t.end()},Ele=(t,e)=>{vle(e)?uz(t):ble(t,e)},vle=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",uz=t=>{(t.readable||t.writable)&&t.destroy()},ble=(t,e)=>{t.destroyed||(t.once("error",EHe),t.destroy(e))},EHe=()=>{},B0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},_le=2,yle=1;import{finished as Tle}from"stream/promises";var ch=(t,e)=>{t.pipe(e),vHe(t,e),bHe(t,e)},vHe=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await Tle(t,{cleanup:!0,readable:!0,writable:!1})}catch{}dz(e)}},dz=t=>{t.writable&&t.end()},bHe=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await Tle(e,{cleanup:!0,readable:!1,writable:!0})}catch{}fz(t)}},fz=t=>{t.readable&&t.destroy()};var wle=(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)))THe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!qi.has(c)))xHe({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);ch(s,i)}},THe=(t,e,r,n)=>{r==="output"?ch(t.stdio[n],e):ch(e,t.stdio[n]);let i=wHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},wHe=["stdin","stdout","stderr"],xHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;AHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},AHe=(t,{signal:e})=>{Ro(t)&&nd(t,RHe,e)},RHe=2;import{addAbortListener as PHe}from"events";var cd=[];cd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&cd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&cd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var q0=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",pz=Symbol.for("signal-exit emitter"),hz=globalThis,CHe=Object.defineProperty.bind(Object),mz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(hz[pz])return hz[pz];CHe(hz,pz,{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}},V0=class{},IHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),gz=class extends V0{onExit(){return()=>{}}load(){}unload(){}},_z=class extends V0{#e=yz.platform==="win32"?"SIGINT":"SIGHUP";#r=new mz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of cd)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(!q0(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 cd)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,cd.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 q0(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"&&q0(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)}},yz=globalThis.process,{onExit:xle,load:CUt,unload:IUt}=IHe(q0(yz)?new _z(yz):new gz);var Ale=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=xle(()=>{t.kill()});PHe(n,()=>{i()})};var Cle=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=t0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=OHe(r,n,i),{sourceStream:d,sourceError:f}=kHe(t,l),{options:p,fileDescriptors:h}=Es.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},OHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=NHe(t,e,...r),a=d0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},NHe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Rle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||aF(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]=GR(r,...n);return{destination:e(Rle)(i,o,s),pipeOptions:s}}if(Es.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}`)},Rle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),kHe=(t,e)=>{try{return{sourceStream:th(t,e)}}catch(r){return{sourceError:r}}};var Ple=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=MHe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw Sz({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},MHe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return fz(t),n;if(e!==void 0)return dz(r),e},Sz=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>oh({error:t,command:Ile,escapedCommand:Ile,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Ile="source.pipe(destination)";var Ole=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 $He}from"stream/promises";var Nle=(t,e,r)=>{let n=G0.has(e)?LHe(t,e):DHe(t,e);return nd(t,FHe,r.signal),nd(e,zHe,r.signal),UHe(e),n},DHe=(t,e)=>{let r=ad([t]);return ch(r,e),G0.set(e,r),r},LHe=(t,e)=>{let r=G0.get(e);return r.add(t),r},UHe=async t=>{try{await $He(t,{cleanup:!0,readable:!1,writable:!0})}catch{}G0.delete(t)},G0=new WeakMap,FHe=2,zHe=1;import{aborted as jHe}from"util";var kle=(t,e)=>t===void 0?[]:[BHe(t,e)],BHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await jHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw Sz({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var H0=(t,...e)=>{if(sr(e[0]))return H0.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Cle(t,...e),i=qHe({...n,destination:r});return i.pipe=H0.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},qHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=VHe(t,i);Ple({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Nle(e,o,d);return await Promise.race([Ole(u),...kle(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},VHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as JHe}from"timers/promises";import{on as GHe}from"events";import{getDefaultHighWaterMark as HHe}from"stream";var W0=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return WHe(e,s),$le({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},WHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Ez=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;YHe(e,s,t);let a=t.readableObjectMode&&!o;return $le({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},YHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},$le=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=GHe(t,"data",{signal:e.signal,highWaterMark:Mle,highWatermark:Mle});return KHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},vz=HHe(!0),Mle=vz,KHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=ZHe({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*jS(a)}},ZHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[L0(t,r,!e),D0(t,i,!n,{})].filter(Boolean);var Dle=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=XHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([QHe(t),d]);return}let f=XF(c,r),p=Ez({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([e6e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},XHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!z0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=Ez({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Wce(a,t,r,o)},QHe=async t=>{await JHe(),t.readableFlowing===null&&t.resume()},e6e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await R0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await C0(r,{maxBuffer:o})):await ih(r,{maxBuffer:o})}catch(a){return Lle(Wae({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},bz=async t=>{try{return await t}catch(e){return Lle(e)}},Lle=({bufferedData:t})=>loe(t)?new Uint8Array(t):t;import{finished as t6e}from"stream/promises";var GS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=r6e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],t6e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||o6e(a,e,r,n)}finally{s.abort()}},r6e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&n6e(t,r,n),n},n6e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{i6e(e,r),n.call(t,...i)}},i6e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},o6e=(t,e,r,n)=>{if(!s6e(t,e,r,n))throw t},s6e=(t,e,r,n=!0)=>r.propagating?Ule(t)||Y0(t):(r.propagating=!0,Tz(r,e)===n?Ule(t):Y0(t)),Tz=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Y0=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ule=t=>t?.code==="EPIPE";var Fle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>wz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),wz=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=GS(t,e,l);if(Tz(l,e)){await u;return}let[d]=await Promise.all([Dle({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 zle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?ad([t,e].filter(Boolean)):void 0,jle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>wz({...a6e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:c6e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),a6e=({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}},c6e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as l6e}from"events";var Ble=t=>Zp(t,"ipc"),qle=(t,e)=>{let r=e0(t);ys({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Vle=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ble(o),a=Ia(e,"ipc"),c=Ia(r,"ipc");for await(let l of az({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Yae(t,i,c),i.push(l)),s&&qle(l,o);return i},Gle=async(t,e)=>(await Promise.allSettled([t]),e);var Hle=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 b=Xce(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=Fle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=jle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),O=[],I=Vle({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),N=u6e(m,t,T),D=d6e(h,T);try{return await Promise.race([Promise.all([{},ele(b),Promise.all(v),x,I,Aae(t,d),...N,...D]),g,f6e(t,_),...vae(t,o,f,_),...Bse({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Sae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(z){return f.terminationReason??="other",Promise.all([{error:z},b,Promise.all(v.map(E=>bz(E))),bz(x),Gle(I,O),Promise.allSettled(N),Promise.allSettled(D)])}},u6e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:GS(n,i,r)),d6e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Po(o,{checkOpen:!1})&&!Ro(o)).map(({type:i,value:o,stream:s=o})=>GS(s,n,e,{isSameDirection:qi.has(i),stopOnExit:i==="native"}))),f6e=async(t,{signal:e})=>{let[r]=await l6e(t,"error",{signal:e});throw r};var Wle=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),HS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Ss();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},lh=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 p6e}from"stream";import{callbackify as h6e}from"util";import{finished as Yle}from"stream/promises";var xz=async t=>{if(t!==void 0)try{await Az(t)}catch{}},Kle=async t=>{if(t!==void 0)try{await Rz(t)}catch{}},Az=async t=>{await Yle(t,{cleanup:!0,readable:!1,writable:!0})},Rz=async t=>{await Yle(t,{cleanup:!0,readable:!0,writable:!1})},K0=async(t,e)=>{if(await t,e)throw e},Z0=(t,e,r)=>{r&&!Y0(r)?t.destroy(r):e&&t.destroy()};var Zle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||hi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Cz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Iz(a,s),{read:f,onStdoutDataDone:p}=Pz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new p6e({read:f,destroy:h6e(Nz.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Oz({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Cz=(t,e,r)=>{let n=th(t,e),i=HS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Iz=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:vz},Pz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Ss(),s=W0({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){m6e(this,s,o)},onStdoutDataDone:o}},m6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Oz=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Rz(t),await n,await xz(i),await e,r.readable&&r.push(null)}catch(o){await xz(i),Jle(r,o)}},Nz=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await lh(r,e)&&(Jle(t,n),await K0(e,n))},Jle=(t,e)=>{Z0(t,t.readable,e)};import{Writable as g6e}from"stream";import{callbackify as Xle}from"util";var Qle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=kz(t,r,e),s=new g6e({...Mz(n,t,i),destroy:Xle(Dz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return $z(n,s),s},kz=(t,e,r)=>{let n=d0(t,e),i=HS(r,n,"writableFinal"),o=HS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Mz=(t,e,r)=>({write:_6e.bind(void 0,t),final:Xle(y6e.bind(void 0,t,e,r))}),_6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},y6e=async(t,e,r)=>{await lh(r,e)&&(t.writable&&t.end(),await e)},$z=async(t,e,r)=>{try{await Az(t),e.writable&&e.end()}catch(n){await Kle(r),eue(e,n)}},Dz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await lh(r,e),await lh(n,e)&&(eue(t,i),await K0(e,i))},eue=(t,e)=>{Z0(t,t.writable,e)};import{Duplex as S6e}from"stream";import{callbackify as E6e}from"util";var tue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||hi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Cz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=kz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Iz(c,a),{read:g,onStdoutDataDone:_}=Pz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new S6e({read:g,...Mz(u,t,d),destroy:E6e(v6e.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 Oz({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),$z(u,b,c),b},v6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([Nz({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Dz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Lz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||hi.has(e),s=th(t,r),a=W0({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return b6e(a,s,t)},b6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var rue=(t,{encoding:e})=>{let r=Wle();t.readable=Zle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Qle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=tue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Lz.bind(void 0,t,e),t[Symbol.asyncIterator]=Lz.bind(void 0,t,e,{})};var nue=(t,e)=>{for(let[r,n]of w6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},T6e=(async()=>{})().constructor.prototype,w6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(T6e,t)]);var iue=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=R6e(t,e,r),{subprocess:f,promise:p}=I6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=H0.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),nue(f,p),Es.set(f,{options:u,fileDescriptors:d}),f},R6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=r0(t,e,r),{file:a,commandArguments:c,options:l}=b0(t,e,r),u=C6e(l),d=mle(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},C6e=({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}},I6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=A6e(...T0(t,e,r))}catch(h){return dle({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;x6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];wle(c,a,l),Ale(c,r,l);let d={},f=Ss();c.kill=zse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=zle(c,r),rue(c,r),cle(c,r);let p=P6e({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}},P6e=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 Hle({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((v,x)=>Oa(v,e,x)),b=Oa(m,e,"all"),T=O6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return sh(T,n,e)},O6e=({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?zS({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 vs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):O0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var J0=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,N6e(n,t[n],i)]));return{...t,...r}},N6e=(t,e,r)=>k6e.has(t)&&sr(e)&&sr(r)?{...e,...r}:r,k6e=new Set(["env",...pF]);var Xc=(t,e,r,n)=>{let i=(s,a,c)=>Xc(s,a,r,c),o=(...s)=>M6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},M6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(sr(o))return i(t,J0(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=$6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?rle(a,c,l):iue(a,c,l,i)},$6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=moe(e)?goe(e,r):[e,...r],[s,a,c]=GR(...o),l=J0(J0(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 oue=({file:t,commandArguments:e})=>aue(t,e),sue=({file:t,commandArguments:e})=>({...aue(t,e),isSync:!0}),aue=(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]=D6e(t);return{file:r,commandArguments:n}},D6e=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(L6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},L6e=/ +/g;var cue=(t,e,r)=>{t.sync=e(U6e,r),t.s=t.sync},lue=({options:t})=>uue(t),U6e=({options:t})=>({...uue(t),isSync:!0}),uue=t=>({options:{...F6e(t),...t}}),F6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},due={preferLocal:!0};var fue=Xc(()=>({})),yjt=Xc(()=>({isSync:!0})),pue=Xc(oue),Sjt=Xc(sue),Ejt=Xc(Tae),vjt=Xc(lue,{},due,cue),{sendMessage:bjt,getOneMessage:Tjt,getEachMessage:wjt,getCancelSignal:xjt}=lle();var hue=!1,mue=()=>{hue=!0},Ts=()=>hue;var WS=null,gue=t=>(WS&&WS.destroy(),WS=new Oo({totalAllowedTime:t}),WS),_ue=()=>WS;var Oo=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&&Ts())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 kR({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}),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 yue={name:"@netlify/agent-runner-cli",type:"module",version:"1.170.0-local-ui-preview.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.128.0","@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 q6e=j6e(import.meta.url),V6e=Na.dirname(q6e),G6e=B6e(import.meta.url),uh=le("shell"),Uz=new Set,Sue={preferLocal:!0},Bt=(t,e,r)=>{let[n,i]=H6e(e,r),o={...Sue,...i},s=fue(t,n,o);vue(s,o),wue(s);let a=r?.idleTimeout;return a&&a>0&&Tue(s,a),s},Eue=(t,e)=>{let r={...Sue,...e},n=pue(t,r);return vue(n,r),wue(n),e?.idleTimeout&&e.idleTimeout>0&&Tue(n,e.idleTimeout),n},H6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},vue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ws.env.NETLIFY_LOCAL_QUIET==="true")return;if(ws.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new bS).pipe(ws.stdout),t.stderr?.pipe(new bS).pipe(ws.stderr);return}t.stdout?.pipe(ws.stdout),t.stderr?.pipe(ws.stderr)},Fz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ws.kill(-t.pid,e),uh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return uh.error("Error killing process:",r),!1}},bue=t=>Fz(t,"SIGKILL"),Tue=(t,e)=>{let r=null,n=()=>{uh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Fz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(uh.log(`Force killing idle process ${t.pid}`),bue(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)},wue=t=>{Uz.add(t);let e=_ue();if(e){let r=e.onTimesUp(()=>{uh.log(`Global timer expired, killing process ${t.pid}`),Fz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(uh.log(`Force killing process ${t.pid} after timeout`),bue(t))},5e3)});t.on("exit",()=>{Uz.delete(t),r()}),t.on("error",()=>{Uz.delete(t),r()})}};function xs(t,e){if(!ws.env.NETLIFY_LOCAL_MODE)try{let i=G6e.resolve(yue.name),o=Na.dirname(i);for(;o!==Na.dirname(o);){let s=Na.dirname(o);if(Na.basename(s)==="node_modules"){let a=Na.join(s,".bin",e);if(X0.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ws.env.NODE_PATH){let i=Na.join(ws.env.NODE_PATH,".bin",e);if(X0.existsSync(i))return i}let r=Na.join(t,"node_modules",".bin",e);if(X0.existsSync(r))return r;let n=Na.join(V6e,"..","node_modules",".bin",e);if(X0.existsSync(n))return n}var xue=le("repo"),Pue="runner-diffs-",Oue=t=>`${Pue}${t}-`,Nue=async t=>{let e=Iue.tmpdir(),r;try{r=await Q0.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Pue)&&!n.startsWith(Oue(t))).map(n=>Q0.rm(eC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Wn=(t,e={})=>Bt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),tC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{xue.info("Getting runner diffs");let n=await Z6e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=X6e(o);await Q6e(h,r)}xue.info("Changes after processing"),await jz(r);let s=await qz(o,r);if(await zz(s,r),i=await J6e(r),!i)return{hasChanges:!1,ignored:s};await Wn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Q0.mkdtemp(eC.join(Iue.tmpdir(),Oue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=eC.join(a,g);await Wn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:v}=await Q0.stat(b);return{path:b,size:v}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Cue(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 Rue(d,h)||(f=h)}await Cue(r),oe.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Rue(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},Aue=async t=>{let e=W6e("sha256");for await(let r of Y6e(t))e.update(r);return e.digest("hex")},Rue=async(t,e)=>t.size===e.size&&await Aue(t.path)===await Aue(e.path),Cue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Wn(["reset","--soft","HEAD~1"],{cwd:t})},zz=async(t=[],e=process.cwd())=>{await Wn(["add",".",...t],{cwd:e})},jz=async(t=process.cwd())=>{let e=await Wn(["status","-s"],{cwd:t});return String(e.stdout??"")},kue=/.. (.+)?\.log$/,K6e=[kue],Z6e=async(t=process.cwd())=>{let e=await jz(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
143
|
+
if (condition) { yield value; }`)};import{Buffer as iGe}from"buffer";import{StringDecoder as oGe}from"string_decoder";var L0=(t,e,r)=>{if(r)return;if(t)return{transform:sGe.bind(void 0,new TextEncoder)};let n=new oGe(e);return{transform:aGe.bind(void 0,n),final:cGe.bind(void 0,n)}},sGe=function*(t,e){iGe.isBuffer(e)?yield Ca(e):typeof e=="string"?yield t.encode(e):yield e},aGe=function*(t,e){yield yr(e)?t.write(e):e},cGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as zce}from"util";var tz=zce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),U0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=uGe}=e[r];for await(let i of n(t))yield*U0(i,e,r+1)},jce=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*lGe(r,Number(e),t)},lGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*U0(n,r,e+1)},Bce=zce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),uGe=function*(t){yield t};var rz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},qce=(t,e)=>[...e.flatMap(r=>[...sd(r,t,0)]),...jS(t)],sd=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=fGe}=e[r];for(let i of n(t))yield*sd(i,e,r+1)},jS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*dGe(r,Number(e),t)},dGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*sd(n,r,e+1)},fGe=function*(t){yield t};var nz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Gce(t,s,o),l=od(e),u=od(r),d=l?tz.bind(void 0,U0,a):rz.bind(void 0,sd),f=l||u?tz.bind(void 0,jce,a):rz.bind(void 0,jS),p=l||u?Bce.bind(void 0,a):void 0;return{stream:new pGe({writableObjectMode:n,writableHighWaterMark:Vce(n),readableObjectMode:i,readableHighWaterMark:Vce(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},F0=(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=Gce(s,r,a);t=qce(c,t)}return t},Gce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Lce(n,a)},L0(r,s,n),D0(r,o,n,c),{transform:t,final:e},{transform:Uce(i,a)},Dce({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Hce=(t,e)=>{for(let r of hGe(t))mGe(t,r,e)},hGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),mGe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Jc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>gGe(a,n));r.input=OS(s)},gGe=(t,e)=>{let r=F0(t,e,"utf8",!0);return _Ge(r),OS(r)},_Ge=t=>{let e=t.find(r=>typeof r!="string"&&!yr(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 vGe,appendFileSync as bGe}from"fs";var z0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Zp(r,n)&&!hi.has(e)&&yGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&SGe.has(o))||t.every(({type:i})=>qi.has(i))),yGe=t=>t===1||t===2,SGe=new Set(["pipe","overlapped"]),Wce=async(t,e,r,n)=>{for await(let i of t)EGe(e)||Kce(i,r,n)},Yce=(t,e,r)=>{for(let n of t)Kce(n,e,r)},EGe=t=>t._readableState.pipes.length>0,Kce=(t,e,r)=>{let n=e0(t);ys({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Zce=({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)=>TGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},TGe=({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=Jae(t,o,d),p=Ca(f),{stdioItems:h,objectMode:m}=e[r],g=wGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=xGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});AGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?b:void 0;try{return n.error===void 0&&RGe(_,h,i),T}catch(v){return n.error=v,T}},wGe=(t,e,r,n)=>{try{return F0(t,e,r,!1)}catch(i){return n.error=i,t}},xGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:OS(t)};let s=doe(t,r);return n[o]?{serializedResult:s,finalResult:ez(s,!i[o],e)}:{serializedResult:s}},AGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!z0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=ez(t,!1,s);try{Yce(a,e,n)}catch(c){r.error??=c}},RGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>M0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?bGe(n,t):(r.add(o),vGe(n,t))}};var Jce=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Oa(e,r,"all")]:Array.isArray(e)?[Oa(t,r,"all"),...e]:yr(t)&&yr(e)?lF([t,e]):`${t}${e}`};import{once as iz}from"events";var Xce=async(t,e)=>{let[r,n]=await CGe(t);return e.isForcefullyTerminated??=!1,[r,n]},CGe=async t=>{let[e,r]=await Promise.allSettled([iz(t,"spawn"),iz(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Qce(t):r.value},Qce=async t=>{try{return await iz(t,"exit")}catch{return Qce(t)}},ele=async t=>{let[e,r]=await t;if(!IGe(e,r)&&oz(e,r))throw new Co;return[e,r]},IGe=(t,e)=>t===void 0&&e===void 0,oz=(t,e)=>t!==0||e!==null;var tle=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=PGe(t,e,r),s=o?.code==="ETIMEDOUT",a=Zae(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},PGe=(t,e,r)=>t!==void 0?t:oz(e,r)?new Co:void 0;var rle=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=NGe(t,e,r),d=$Ge({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return sh(d,c,l)},NGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=r0(t,e,r),a=kGe(r),{file:c,commandArguments:l,options:u}=b0(t,e,a);MGe(u);let d=Nce(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},kGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,MGe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&j0("ipcInput"),t&&j0("ipc: true"),r&&j0("detached: true"),n&&j0("cancelSignal")},j0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},$Ge=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=DGe({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}=tle(c,r),{output:h,error:m=l}=Zce({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>Oa(b,r,T)),_=Oa(Jce(h,r),r,"all");return UGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},DGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Hce(o,r);let a=LGe(r);return OGe(...T0(t,e,a))}catch(a){return oh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},LGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:P0(e)}),UGe=({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?O0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):zS({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 x6e}from"events";import{spawn as A6e}from"child_process";import ale from"process";import{once as sz,on as FGe}from"events";var nle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Qp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:g0(t)}),zGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),zGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{f0(e,i);let o=Zc(t,e,r),s=new AbortController;try{return await Promise.race([jGe(o,n,s),BGe(o,r,s),qGe(o,r,s)])}catch(a){throw eh(t),a}finally{s.abort(),p0(e,i)}},jGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await sz(t,"message",{signal:r});return n}for await(let[n]of FGe(t,"message",{signal:r}))if(e(n))return n},BGe=async(t,e,{signal:r})=>{await sz(t,"disconnect",{signal:r}),qse(e)},qGe=async(t,e,{signal:r})=>{let[n]=await sz(t,"strict:error",{signal:r});throw l0(n,e)};import{once as ole,on as VGe}from"events";var sle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>az({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),az=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Qp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:g0(t)}),f0(e,o);let s=Zc(t,e,r),a=new AbortController,c={};return GGe(t,s,a),HGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),WGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},GGe=async(t,e,r)=>{try{await ole(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},HGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ole(t,"strict:error",{signal:r.signal});n.error=l0(i,e),r.abort()}catch{}},WGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of VGe(r,"message",{signal:o.signal}))ile(s),yield c}catch{ile(s)}finally{o.abort(),p0(e,a),n||eh(t),i&&await t}},ile=({error:t})=>{if(t)throw t};var cle=(t,{ipc:e})=>{Object.assign(t,ule(t,!1,e))},lle=()=>{let t=ale,e=!0,r=ale.channel!==void 0;return{...ule(t,e,r),getCancelSignal:gae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ule=(t,e,r)=>({sendMessage:E0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:nle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:sle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as YGe}from"child_process";import{PassThrough as KGe,Readable as ZGe,Writable as JGe,Duplex as XGe}from"stream";var dle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{JF(n);let a=new YGe;QGe(a,n),Object.assign(a,{readable:eHe,writable:tHe,duplex:rHe});let c=oh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=nHe(c,s,i);return{subprocess:a,promise:l}},QGe=(t,e)=>{let r=BS(),n=BS(),i=BS(),o=Array.from({length:e.length-3},BS),s=BS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},BS=()=>{let t=new KGe;return t.end(),t},eHe=()=>new ZGe({read(){}}),tHe=()=>new JGe({write(){}}),rHe=()=>new XGe({read(){},write(){}}),nHe=async(t,e,r)=>sh(t,e,r);import{createReadStream as fle,createWriteStream as ple}from"fs";import{Buffer as iHe}from"buffer";import{Readable as qS,Writable as oHe,Duplex as sHe}from"stream";var mle=(t,e)=>$0(aHe,t,e,!1),VS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Jc[t]}.`)},hle={fileNumber:VS,generator:nz,asyncGenerator:nz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:sHe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},aHe={input:{...hle,fileUrl:({value:t})=>({stream:fle(t)}),filePath:({value:{file:t}})=>({stream:fle(t)}),webStream:({value:t})=>({stream:qS.fromWeb(t)}),iterable:({value:t})=>({stream:qS.from(t)}),asyncIterable:({value:t})=>({stream:qS.from(t)}),string:({value:t})=>({stream:qS.from(t)}),uint8Array:({value:t})=>({stream:qS.from(iHe.from(t))})},output:{...hle,fileUrl:({value:t})=>({stream:ple(t)}),filePath:({value:{file:t,append:e}})=>({stream:ple(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:oHe.fromWeb(t)}),iterable:VS,asyncIterable:VS,string:VS,uint8Array:VS}};import{on as cHe,once as gle}from"events";import{PassThrough as lHe,getDefaultHighWaterMark as uHe}from"stream";import{finished as Sle}from"stream/promises";function ad(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)lz(i);let e=t.some(({readableObjectMode:i})=>i),r=dHe(t,e),n=new cz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var dHe=(t,e)=>{if(t.length===0)return uHe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},cz=class extends lHe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(lz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=fHe(this,this.#e,this.#o);let r=mHe({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(lz(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)}},fHe=async(t,e,r)=>{B0(t,_le);let n=new AbortController;try{await Promise.race([pHe(t,n),hHe(t,e,r,n)])}finally{n.abort(),B0(t,-_le)}},pHe=async(t,{signal:e})=>{try{await Sle(t,{signal:e,cleanup:!0})}catch(r){throw Ele(t,r),r}},hHe=async(t,e,r,{signal:n})=>{for await(let[i]of cHe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},lz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},mHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{B0(t,yle);let a=new AbortController;try{await Promise.race([gHe(o,e,a),_He({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),yHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),B0(t,-yle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?uz(t):SHe(t))},gHe=async(t,e,{signal:r})=>{try{await t,r.aborted||uz(e)}catch(n){r.aborted||Ele(e,n)}},_He=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Sle(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;vle(s)?i.add(e):ble(t,s)}},yHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await gle(t,i,{signal:o}),!t.readable)return gle(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},SHe=t=>{t.writable&&t.end()},Ele=(t,e)=>{vle(e)?uz(t):ble(t,e)},vle=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",uz=t=>{(t.readable||t.writable)&&t.destroy()},ble=(t,e)=>{t.destroyed||(t.once("error",EHe),t.destroy(e))},EHe=()=>{},B0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},_le=2,yle=1;import{finished as Tle}from"stream/promises";var ch=(t,e)=>{t.pipe(e),vHe(t,e),bHe(t,e)},vHe=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await Tle(t,{cleanup:!0,readable:!0,writable:!1})}catch{}dz(e)}},dz=t=>{t.writable&&t.end()},bHe=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await Tle(e,{cleanup:!0,readable:!1,writable:!0})}catch{}fz(t)}},fz=t=>{t.readable&&t.destroy()};var wle=(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)))THe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!qi.has(c)))xHe({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);ch(s,i)}},THe=(t,e,r,n)=>{r==="output"?ch(t.stdio[n],e):ch(e,t.stdio[n]);let i=wHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},wHe=["stdin","stdout","stderr"],xHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;AHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},AHe=(t,{signal:e})=>{Ro(t)&&nd(t,RHe,e)},RHe=2;import{addAbortListener as PHe}from"events";var cd=[];cd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&cd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&cd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var q0=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",pz=Symbol.for("signal-exit emitter"),hz=globalThis,CHe=Object.defineProperty.bind(Object),mz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(hz[pz])return hz[pz];CHe(hz,pz,{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}},V0=class{},IHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),gz=class extends V0{onExit(){return()=>{}}load(){}unload(){}},_z=class extends V0{#e=yz.platform==="win32"?"SIGINT":"SIGHUP";#r=new mz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of cd)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(!q0(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 cd)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,cd.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 q0(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"&&q0(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)}},yz=globalThis.process,{onExit:xle,load:CUt,unload:IUt}=IHe(q0(yz)?new _z(yz):new gz);var Ale=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=xle(()=>{t.kill()});PHe(n,()=>{i()})};var Cle=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=t0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=OHe(r,n,i),{sourceStream:d,sourceError:f}=kHe(t,l),{options:p,fileDescriptors:h}=Es.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},OHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=NHe(t,e,...r),a=d0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},NHe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Rle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||aF(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]=GR(r,...n);return{destination:e(Rle)(i,o,s),pipeOptions:s}}if(Es.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}`)},Rle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),kHe=(t,e)=>{try{return{sourceStream:th(t,e)}}catch(r){return{sourceError:r}}};var Ple=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=MHe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw Sz({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},MHe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return fz(t),n;if(e!==void 0)return dz(r),e},Sz=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>oh({error:t,command:Ile,escapedCommand:Ile,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Ile="source.pipe(destination)";var Ole=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 $He}from"stream/promises";var Nle=(t,e,r)=>{let n=G0.has(e)?LHe(t,e):DHe(t,e);return nd(t,FHe,r.signal),nd(e,zHe,r.signal),UHe(e),n},DHe=(t,e)=>{let r=ad([t]);return ch(r,e),G0.set(e,r),r},LHe=(t,e)=>{let r=G0.get(e);return r.add(t),r},UHe=async t=>{try{await $He(t,{cleanup:!0,readable:!1,writable:!0})}catch{}G0.delete(t)},G0=new WeakMap,FHe=2,zHe=1;import{aborted as jHe}from"util";var kle=(t,e)=>t===void 0?[]:[BHe(t,e)],BHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await jHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw Sz({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var H0=(t,...e)=>{if(sr(e[0]))return H0.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Cle(t,...e),i=qHe({...n,destination:r});return i.pipe=H0.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},qHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=VHe(t,i);Ple({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Nle(e,o,d);return await Promise.race([Ole(u),...kle(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},VHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as JHe}from"timers/promises";import{on as GHe}from"events";import{getDefaultHighWaterMark as HHe}from"stream";var W0=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return WHe(e,s),$le({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},WHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Ez=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;YHe(e,s,t);let a=t.readableObjectMode&&!o;return $le({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},YHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},$le=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=GHe(t,"data",{signal:e.signal,highWaterMark:Mle,highWatermark:Mle});return KHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},vz=HHe(!0),Mle=vz,KHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=ZHe({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*jS(a)}},ZHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[L0(t,r,!e),D0(t,i,!n,{})].filter(Boolean);var Dle=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=XHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([QHe(t),d]);return}let f=XF(c,r),p=Ez({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([e6e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},XHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!z0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=Ez({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Wce(a,t,r,o)},QHe=async t=>{await JHe(),t.readableFlowing===null&&t.resume()},e6e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await R0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await C0(r,{maxBuffer:o})):await ih(r,{maxBuffer:o})}catch(a){return Lle(Wae({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},bz=async t=>{try{return await t}catch(e){return Lle(e)}},Lle=({bufferedData:t})=>loe(t)?new Uint8Array(t):t;import{finished as t6e}from"stream/promises";var GS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=r6e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],t6e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||o6e(a,e,r,n)}finally{s.abort()}},r6e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&n6e(t,r,n),n},n6e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{i6e(e,r),n.call(t,...i)}},i6e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},o6e=(t,e,r,n)=>{if(!s6e(t,e,r,n))throw t},s6e=(t,e,r,n=!0)=>r.propagating?Ule(t)||Y0(t):(r.propagating=!0,Tz(r,e)===n?Ule(t):Y0(t)),Tz=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Y0=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ule=t=>t?.code==="EPIPE";var Fle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>wz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),wz=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=GS(t,e,l);if(Tz(l,e)){await u;return}let[d]=await Promise.all([Dle({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 zle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?ad([t,e].filter(Boolean)):void 0,jle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>wz({...a6e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:c6e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),a6e=({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}},c6e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as l6e}from"events";var Ble=t=>Zp(t,"ipc"),qle=(t,e)=>{let r=e0(t);ys({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Vle=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ble(o),a=Ia(e,"ipc"),c=Ia(r,"ipc");for await(let l of az({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Yae(t,i,c),i.push(l)),s&&qle(l,o);return i},Gle=async(t,e)=>(await Promise.allSettled([t]),e);var Hle=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 b=Xce(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=Fle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=jle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),O=[],I=Vle({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),N=u6e(m,t,T),D=d6e(h,T);try{return await Promise.race([Promise.all([{},ele(b),Promise.all(v),x,I,Aae(t,d),...N,...D]),g,f6e(t,_),...vae(t,o,f,_),...Bse({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Sae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(z){return f.terminationReason??="other",Promise.all([{error:z},b,Promise.all(v.map(E=>bz(E))),bz(x),Gle(I,O),Promise.allSettled(N),Promise.allSettled(D)])}},u6e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:GS(n,i,r)),d6e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Po(o,{checkOpen:!1})&&!Ro(o)).map(({type:i,value:o,stream:s=o})=>GS(s,n,e,{isSameDirection:qi.has(i),stopOnExit:i==="native"}))),f6e=async(t,{signal:e})=>{let[r]=await l6e(t,"error",{signal:e});throw r};var Wle=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),HS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Ss();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},lh=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 p6e}from"stream";import{callbackify as h6e}from"util";import{finished as Yle}from"stream/promises";var xz=async t=>{if(t!==void 0)try{await Az(t)}catch{}},Kle=async t=>{if(t!==void 0)try{await Rz(t)}catch{}},Az=async t=>{await Yle(t,{cleanup:!0,readable:!1,writable:!0})},Rz=async t=>{await Yle(t,{cleanup:!0,readable:!0,writable:!1})},K0=async(t,e)=>{if(await t,e)throw e},Z0=(t,e,r)=>{r&&!Y0(r)?t.destroy(r):e&&t.destroy()};var Zle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||hi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Cz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Iz(a,s),{read:f,onStdoutDataDone:p}=Pz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new p6e({read:f,destroy:h6e(Nz.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Oz({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Cz=(t,e,r)=>{let n=th(t,e),i=HS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Iz=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:vz},Pz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Ss(),s=W0({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){m6e(this,s,o)},onStdoutDataDone:o}},m6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Oz=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Rz(t),await n,await xz(i),await e,r.readable&&r.push(null)}catch(o){await xz(i),Jle(r,o)}},Nz=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await lh(r,e)&&(Jle(t,n),await K0(e,n))},Jle=(t,e)=>{Z0(t,t.readable,e)};import{Writable as g6e}from"stream";import{callbackify as Xle}from"util";var Qle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=kz(t,r,e),s=new g6e({...Mz(n,t,i),destroy:Xle(Dz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return $z(n,s),s},kz=(t,e,r)=>{let n=d0(t,e),i=HS(r,n,"writableFinal"),o=HS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Mz=(t,e,r)=>({write:_6e.bind(void 0,t),final:Xle(y6e.bind(void 0,t,e,r))}),_6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},y6e=async(t,e,r)=>{await lh(r,e)&&(t.writable&&t.end(),await e)},$z=async(t,e,r)=>{try{await Az(t),e.writable&&e.end()}catch(n){await Kle(r),eue(e,n)}},Dz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await lh(r,e),await lh(n,e)&&(eue(t,i),await K0(e,i))},eue=(t,e)=>{Z0(t,t.writable,e)};import{Duplex as S6e}from"stream";import{callbackify as E6e}from"util";var tue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||hi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Cz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=kz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Iz(c,a),{read:g,onStdoutDataDone:_}=Pz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new S6e({read:g,...Mz(u,t,d),destroy:E6e(v6e.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 Oz({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),$z(u,b,c),b},v6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([Nz({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Dz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Lz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||hi.has(e),s=th(t,r),a=W0({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return b6e(a,s,t)},b6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var rue=(t,{encoding:e})=>{let r=Wle();t.readable=Zle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Qle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=tue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Lz.bind(void 0,t,e),t[Symbol.asyncIterator]=Lz.bind(void 0,t,e,{})};var nue=(t,e)=>{for(let[r,n]of w6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},T6e=(async()=>{})().constructor.prototype,w6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(T6e,t)]);var iue=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=R6e(t,e,r),{subprocess:f,promise:p}=I6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=H0.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),nue(f,p),Es.set(f,{options:u,fileDescriptors:d}),f},R6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=r0(t,e,r),{file:a,commandArguments:c,options:l}=b0(t,e,r),u=C6e(l),d=mle(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},C6e=({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}},I6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=A6e(...T0(t,e,r))}catch(h){return dle({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;x6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];wle(c,a,l),Ale(c,r,l);let d={},f=Ss();c.kill=zse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=zle(c,r),rue(c,r),cle(c,r);let p=P6e({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}},P6e=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 Hle({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((v,x)=>Oa(v,e,x)),b=Oa(m,e,"all"),T=O6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return sh(T,n,e)},O6e=({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?zS({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 vs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):O0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var J0=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,N6e(n,t[n],i)]));return{...t,...r}},N6e=(t,e,r)=>k6e.has(t)&&sr(e)&&sr(r)?{...e,...r}:r,k6e=new Set(["env",...pF]);var Xc=(t,e,r,n)=>{let i=(s,a,c)=>Xc(s,a,r,c),o=(...s)=>M6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},M6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(sr(o))return i(t,J0(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=$6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?rle(a,c,l):iue(a,c,l,i)},$6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=moe(e)?goe(e,r):[e,...r],[s,a,c]=GR(...o),l=J0(J0(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 oue=({file:t,commandArguments:e})=>aue(t,e),sue=({file:t,commandArguments:e})=>({...aue(t,e),isSync:!0}),aue=(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]=D6e(t);return{file:r,commandArguments:n}},D6e=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(L6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},L6e=/ +/g;var cue=(t,e,r)=>{t.sync=e(U6e,r),t.s=t.sync},lue=({options:t})=>uue(t),U6e=({options:t})=>({...uue(t),isSync:!0}),uue=t=>({options:{...F6e(t),...t}}),F6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},due={preferLocal:!0};var fue=Xc(()=>({})),yjt=Xc(()=>({isSync:!0})),pue=Xc(oue),Sjt=Xc(sue),Ejt=Xc(Tae),vjt=Xc(lue,{},due,cue),{sendMessage:bjt,getOneMessage:Tjt,getEachMessage:wjt,getCancelSignal:xjt}=lle();var hue=!1,mue=()=>{hue=!0},Ts=()=>hue;var WS=null,gue=t=>(WS&&WS.destroy(),WS=new Oo({totalAllowedTime:t}),WS),_ue=()=>WS;var Oo=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&&Ts())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 kR({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}),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 yue={name:"@netlify/agent-runner-cli",type:"module",version:"1.170.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 q6e=j6e(import.meta.url),V6e=Na.dirname(q6e),G6e=B6e(import.meta.url),uh=le("shell"),Uz=new Set,Sue={preferLocal:!0},Bt=(t,e,r)=>{let[n,i]=H6e(e,r),o={...Sue,...i},s=fue(t,n,o);vue(s,o),wue(s);let a=r?.idleTimeout;return a&&a>0&&Tue(s,a),s},Eue=(t,e)=>{let r={...Sue,...e},n=pue(t,r);return vue(n,r),wue(n),e?.idleTimeout&&e.idleTimeout>0&&Tue(n,e.idleTimeout),n},H6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},vue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ws.env.NETLIFY_LOCAL_QUIET==="true")return;if(ws.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new bS).pipe(ws.stdout),t.stderr?.pipe(new bS).pipe(ws.stderr);return}t.stdout?.pipe(ws.stdout),t.stderr?.pipe(ws.stderr)},Fz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ws.kill(-t.pid,e),uh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return uh.error("Error killing process:",r),!1}},bue=t=>Fz(t,"SIGKILL"),Tue=(t,e)=>{let r=null,n=()=>{uh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Fz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(uh.log(`Force killing idle process ${t.pid}`),bue(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)},wue=t=>{Uz.add(t);let e=_ue();if(e){let r=e.onTimesUp(()=>{uh.log(`Global timer expired, killing process ${t.pid}`),Fz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(uh.log(`Force killing process ${t.pid} after timeout`),bue(t))},5e3)});t.on("exit",()=>{Uz.delete(t),r()}),t.on("error",()=>{Uz.delete(t),r()})}};function xs(t,e){if(!ws.env.NETLIFY_LOCAL_MODE)try{let i=G6e.resolve(yue.name),o=Na.dirname(i);for(;o!==Na.dirname(o);){let s=Na.dirname(o);if(Na.basename(s)==="node_modules"){let a=Na.join(s,".bin",e);if(X0.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ws.env.NODE_PATH){let i=Na.join(ws.env.NODE_PATH,".bin",e);if(X0.existsSync(i))return i}let r=Na.join(t,"node_modules",".bin",e);if(X0.existsSync(r))return r;let n=Na.join(V6e,"..","node_modules",".bin",e);if(X0.existsSync(n))return n}var xue=le("repo"),Pue="runner-diffs-",Oue=t=>`${Pue}${t}-`,Nue=async t=>{let e=Iue.tmpdir(),r;try{r=await Q0.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Pue)&&!n.startsWith(Oue(t))).map(n=>Q0.rm(eC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Wn=(t,e={})=>Bt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),tC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{xue.info("Getting runner diffs");let n=await Z6e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=X6e(o);await Q6e(h,r)}xue.info("Changes after processing"),await jz(r);let s=await qz(o,r);if(await zz(s,r),i=await J6e(r),!i)return{hasChanges:!1,ignored:s};await Wn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Q0.mkdtemp(eC.join(Iue.tmpdir(),Oue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=eC.join(a,g);await Wn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:v}=await Q0.stat(b);return{path:b,size:v}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Cue(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 Rue(d,h)||(f=h)}await Cue(r),oe.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Rue(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},Aue=async t=>{let e=W6e("sha256");for await(let r of Y6e(t))e.update(r);return e.digest("hex")},Rue=async(t,e)=>t.size===e.size&&await Aue(t.path)===await Aue(e.path),Cue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Wn(["reset","--soft","HEAD~1"],{cwd:t})},zz=async(t=[],e=process.cwd())=>{await Wn(["add",".",...t],{cwd:e})},jz=async(t=process.cwd())=>{let e=await Wn(["status","-s"],{cwd:t});return String(e.stdout??"")},kue=/.. (.+)?\.log$/,K6e=[kue],Z6e=async(t=process.cwd())=>{let e=await jz(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
144
144
|
`).filter(i=>K6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},J6e=async(t=process.cwd())=>{try{return await Wn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},Bz=async(t=process.cwd())=>{let{stdout:e}=await Wn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Mue=async(t=process.cwd())=>{let{stdout:e}=await Wn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},qz=async(t,e=process.cwd())=>{t||=await jz(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}${eC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(kue)?.[1];o&&n.push(`:!${o}.log`)}),n},$ue=async(t=process.cwd())=>{await Wn(["reset","--hard","HEAD"],{cwd:t})},Due=async(t=process.cwd())=>{let e=await Wn(["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))},X6e=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.170.0
|
|
4
|
+
"version": "1.170.0",
|
|
5
5
|
"description": "CLI tool for running Netlify agents",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@netlify/database-proxy": "^0.2.1",
|
|
90
90
|
"@netlify/otel": "^6.0.6",
|
|
91
91
|
"@netlify/ts-cli": "^1.2.0",
|
|
92
|
-
"@openai/codex": "0.
|
|
92
|
+
"@openai/codex": "0.153.4",
|
|
93
93
|
"@opentelemetry/api": "^1.9.0",
|
|
94
94
|
"@opentelemetry/exporter-trace-otlp-grpc": "0.218.0",
|
|
95
95
|
"execa": "^9.6.1",
|