@netlify/agent-runner-cli 1.187.0-count-api-reqs.0 → 1.188.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 +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -143,7 +143,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
143
143
|
`,LF:`
|
|
144
144
|
`,concatBytes:zU},fGe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},pGe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:fGe};import{Buffer as hGe}from"buffer";var Uae=(t,e)=>t?void 0:mGe.bind(void 0,e),mGe=function*(t,e){if(typeof e!="string"&&!dr(e)&&!hGe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Fae=(t,e)=>t?gGe.bind(void 0,e):_Ge.bind(void 0,e),gGe=function*(t,e){zae(t,e),yield e},_Ge=function*(t,e){if(zae(t,e),typeof e!="string"&&!dr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},zae=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
145
145
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
146
|
-
if (condition) { yield value; }`)};import{Buffer as yGe}from"buffer";import{StringDecoder as SGe}from"string_decoder";var MR=(t,e,r)=>{if(r)return;if(t)return{transform:EGe.bind(void 0,new TextEncoder)};let n=new SGe(e);return{transform:vGe.bind(void 0,n),final:TGe.bind(void 0,n)}},EGe=function*(t,e){yGe.isBuffer(e)?yield ha(e):typeof e=="string"?yield t.encode(e):yield e},vGe=function*(t,e){yield dr(e)?t.write(e):e},TGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as jae}from"util";var BU=jae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),DR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=wGe}=e[r];for await(let i of n(t))yield*DR(i,e,r+1)},Bae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*bGe(r,Number(e),t)},bGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*DR(n,r,e+1)},qae=jae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),wGe=function*(t){yield t};var qU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Vae=(t,e)=>[...e.flatMap(r=>[...zu(r,t,0)]),...Qy(t)],zu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=xGe}=e[r];for(let i of n(t))yield*zu(i,e,r+1)},Qy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*AGe(r,Number(e),t)},AGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*zu(n,r,e+1)},xGe=function*(t){yield t};var VU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Hae(t,s,o),l=Fu(e),u=Fu(r),d=l?BU.bind(void 0,DR,a):qU.bind(void 0,zu),f=l||u?BU.bind(void 0,Bae,a):qU.bind(void 0,Qy),p=l||u?qae.bind(void 0,a):void 0;return{stream:new RGe({writableObjectMode:n,writableHighWaterMark:Gae(n),readableObjectMode:i,readableHighWaterMark:Gae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},$R=(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=Hae(s,r,a);t=Vae(c,t)}return t},Hae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Uae(n,a)},MR(r,s,n),kR(r,o,n,c),{transform:t,final:e},{transform:Fae(i,a)},Lae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Wae=(t,e)=>{for(let r of CGe(t))IGe(t,r,e)},CGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),IGe=(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 ${Dc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>PGe(a,n));r.input=qy(s)},PGe=(t,e)=>{let r=$R(t,e,"utf8",!0);return OGe(r),qy(r)},OGe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(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 DGe,appendFileSync as $Ge}from"fs";var LR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&kp(r,n)&&!oi.has(e)&&NGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&kGe.has(o))||t.every(({type:i})=>ki.has(i))),NGe=t=>t===1||t===2,kGe=new Set(["pipe","overlapped"]),Yae=async(t,e,r,n)=>{for await(let i of t)MGe(e)||Zae(i,r,n)},Kae=(t,e,r)=>{for(let n of t)Zae(n,e,r)},MGe=t=>t._readableState.pipes.length>0,Zae=(t,e,r)=>{let n=Jx(t);ls({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Jae=({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)=>LGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},LGe=({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=Xse(t,o,d),p=ha(f),{stdioItems:h,objectMode:m}=e[r],g=UGe([p],h,c,n),{serializedResult:_,finalResult:T=_}=FGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});zGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?T:void 0;try{return n.error===void 0&&jGe(_,h,i),w}catch(v){return n.error=v,w}},UGe=(t,e,r,n)=>{try{return $R(t,e,r,!1)}catch(i){return n.error=i,t}},FGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qy(t)};let s=fie(t,r);return n[o]?{serializedResult:s,finalResult:jU(s,!i[o],e)}:{serializedResult:s}},zGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!LR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=jU(t,!1,s);try{Kae(a,e,n)}catch(c){r.error??=c}},jGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>OR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?$Ge(n,t):(r.add(o),DGe(n,t))}};var Xae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,_a(e,r,"all")]:Array.isArray(e)?[_a(t,r,"all"),...e]:dr(t)&&dr(e)?Z1([t,e]):`${t}${e}`};import{once as GU}from"events";var Qae=async(t,e)=>{let[r,n]=await BGe(t);return e.isForcefullyTerminated??=!1,[r,n]},BGe=async t=>{let[e,r]=await Promise.allSettled([GU(t,"spawn"),GU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?ece(t):r.value},ece=async t=>{try{return await GU(t,"exit")}catch{return ece(t)}},tce=async t=>{let[e,r]=await t;if(!qGe(e,r)&&HU(e,r))throw new ho;return[e,r]},qGe=(t,e)=>t===void 0&&e===void 0,HU=(t,e)=>t!==0||e!==null;var rce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=VGe(t,e,r),s=o?.code==="ETIMEDOUT",a=Jse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},VGe=(t,e,r)=>t!==void 0?t:HU(e,r)?new ho:void 0;var nce=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=HGe(t,e,r),d=KGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return qp(d,c,l)},HGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Qx(t,e,r),a=WGe(r),{file:c,commandArguments:l,options:u}=SR(t,e,a);YGe(u);let d=kae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},WGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,YGe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&UR("ipcInput"),t&&UR("ipc: true"),r&&UR("detached: true"),n&&UR("cancelSignal")},UR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},KGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=ZGe({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}=rce(c,r),{output:h,error:m=l}=Jae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((T,w)=>_a(T,r,w)),_=_a(Xae(h,r),r,"all");return XGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},ZGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Wae(o,r);let a=JGe(r);return GGe(...ER(t,e,a))}catch(a){return Bp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},JGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RR(e)}),XGe=({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?CR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Xy({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 FHe}from"events";import{spawn as zHe}from"child_process";import cce from"process";import{once as WU,on as QGe}from"events";var ice=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>($p({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:pR(t)}),e4e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),e4e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{lR(e,i);let o=Mc(t,e,r),s=new AbortController;try{return await Promise.race([t4e(o,n,s),r4e(o,r,s),n4e(o,r,s)])}catch(a){throw Lp(t),a}finally{s.abort(),uR(e,i)}},t4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await WU(t,"message",{signal:r});return n}for await(let[n]of QGe(t,"message",{signal:r}))if(e(n))return n},r4e=async(t,e,{signal:r})=>{await WU(t,"disconnect",{signal:r}),Voe(e)},n4e=async(t,e,{signal:r})=>{let[n]=await WU(t,"strict:error",{signal:r});throw sR(n,e)};import{once as sce,on as i4e}from"events";var ace=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>YU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),YU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{$p({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:pR(t)}),lR(e,o);let s=Mc(t,e,r),a=new AbortController,c={};return o4e(t,s,a),s4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),a4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},o4e=async(t,e,r)=>{try{await sce(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},s4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await sce(t,"strict:error",{signal:r.signal});n.error=sR(i,e),r.abort()}catch{}},a4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of i4e(r,"message",{signal:o.signal}))oce(s),yield c}catch{oce(s)}finally{o.abort(),uR(e,a),n||Lp(t),i&&await t}},oce=({error:t})=>{if(t)throw t};var lce=(t,{ipc:e})=>{Object.assign(t,dce(t,!1,e))},uce=()=>{let t=cce,e=!0,r=cce.channel!==void 0;return{...dce(t,e,r),getCancelSignal:_se.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},dce=(t,e,r)=>({sendMessage:_R.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ice.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ace.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as c4e}from"child_process";import{PassThrough as l4e,Readable as u4e,Writable as d4e,Duplex as f4e}from"stream";var fce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{UU(n);let a=new c4e;p4e(a,n),Object.assign(a,{readable:h4e,writable:m4e,duplex:g4e});let c=Bp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=_4e(c,s,i);return{subprocess:a,promise:l}},p4e=(t,e)=>{let r=eS(),n=eS(),i=eS(),o=Array.from({length:e.length-3},eS),s=eS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},eS=()=>{let t=new l4e;return t.end(),t},h4e=()=>new u4e({read(){}}),m4e=()=>new d4e({write(){}}),g4e=()=>new f4e({read(){},write(){}}),_4e=async(t,e,r)=>qp(t,e,r);import{createReadStream as pce,createWriteStream as hce}from"fs";import{Buffer as y4e}from"buffer";import{Readable as tS,Writable as S4e,Duplex as E4e}from"stream";var gce=(t,e)=>NR(v4e,t,e,!1),rS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Dc[t]}.`)},mce={fileNumber:rS,generator:VU,asyncGenerator:VU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:E4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},v4e={input:{...mce,fileUrl:({value:t})=>({stream:pce(t)}),filePath:({value:{file:t}})=>({stream:pce(t)}),webStream:({value:t})=>({stream:tS.fromWeb(t)}),iterable:({value:t})=>({stream:tS.from(t)}),asyncIterable:({value:t})=>({stream:tS.from(t)}),string:({value:t})=>({stream:tS.from(t)}),uint8Array:({value:t})=>({stream:tS.from(y4e.from(t))})},output:{...mce,fileUrl:({value:t})=>({stream:hce(t)}),filePath:({value:{file:t,append:e}})=>({stream:hce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:S4e.fromWeb(t)}),iterable:rS,asyncIterable:rS,string:rS,uint8Array:rS}};import{on as T4e,once as _ce}from"events";import{PassThrough as b4e,getDefaultHighWaterMark as w4e}from"stream";import{finished as Ece}from"stream/promises";function ju(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)ZU(i);let e=t.some(({readableObjectMode:i})=>i),r=A4e(t,e),n=new KU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var A4e=(t,e)=>{if(t.length===0)return w4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},KU=class extends b4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(ZU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=x4e(this,this.#e,this.#o);let r=I4e({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(ZU(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)}},x4e=async(t,e,r)=>{FR(t,yce);let n=new AbortController;try{await Promise.race([R4e(t,n),C4e(t,e,r,n)])}finally{n.abort(),FR(t,-yce)}},R4e=async(t,{signal:e})=>{try{await Ece(t,{signal:e,cleanup:!0})}catch(r){throw vce(t,r),r}},C4e=async(t,e,r,{signal:n})=>{for await(let[i]of T4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},ZU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},I4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{FR(t,Sce);let a=new AbortController;try{await Promise.race([P4e(o,e,a),O4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),N4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),FR(t,-Sce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?JU(t):k4e(t))},P4e=async(t,e,{signal:r})=>{try{await t,r.aborted||JU(e)}catch(n){r.aborted||vce(e,n)}},O4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Ece(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Tce(s)?i.add(e):bce(t,s)}},N4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await _ce(t,i,{signal:o}),!t.readable)return _ce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},k4e=t=>{t.writable&&t.end()},vce=(t,e)=>{Tce(e)?JU(t):bce(t,e)},Tce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",JU=t=>{(t.readable||t.writable)&&t.destroy()},bce=(t,e)=>{t.destroyed||(t.once("error",M4e),t.destroy(e))},M4e=()=>{},FR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},yce=2,Sce=1;import{finished as wce}from"stream/promises";var Gp=(t,e)=>{t.pipe(e),D4e(t,e),$4e(t,e)},D4e=async(t,e)=>{if(!(po(t)||po(e))){try{await wce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}XU(e)}},XU=t=>{t.writable&&t.end()},$4e=async(t,e)=>{if(!(po(t)||po(e))){try{await wce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}QU(t)}},QU=t=>{t.readable&&t.destroy()};var Ace=(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})=>ki.has(c)))L4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ki.has(c)))F4e({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]:ju(o);Gp(s,i)}},L4e=(t,e,r,n)=>{r==="output"?Gp(t.stdio[n],e):Gp(e,t.stdio[n]);let i=U4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},U4e=["stdin","stdout","stderr"],F4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;z4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},z4e=(t,{signal:e})=>{po(t)&&Lu(t,j4e,e)},j4e=2;import{addAbortListener as V4e}from"events";var Bu=[];Bu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var zR=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",eF=Symbol.for("signal-exit emitter"),tF=globalThis,B4e=Object.defineProperty.bind(Object),rF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(tF[eF])return tF[eF];B4e(tF,eF,{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}},jR=class{},q4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),nF=class extends jR{onExit(){return()=>{}}load(){}unload(){}},iF=class extends jR{#e=oF.platform==="win32"?"SIGINT":"SIGHUP";#r=new rF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Bu)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(!zR(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 Bu)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,Bu.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 zR(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"&&zR(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)}},oF=globalThis.process,{onExit:xce,load:y1t,unload:S1t}=q4e(zR(oF)?new iF(oF):new nF);var Rce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=xce(()=>{t.kill()});V4e(n,()=>{i()})};var Ice=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Xx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=G4e(r,n,i),{sourceStream:d,sourceError:f}=W4e(t,l),{options:p,fileDescriptors:h}=ds.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},G4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=H4e(t,e,...r),a=cR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},H4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Cce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||Y1(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]=Bx(r,...n);return{destination:e(Cce)(i,o,s),pipeOptions:s}}if(ds.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}`)},Cce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),W4e=(t,e)=>{try{return{sourceStream:Up(t,e)}}catch(r){return{sourceError:r}}};var Oce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Y4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw sF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Y4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return QU(t),n;if(e!==void 0)return XU(r),e},sF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Bp({error:t,command:Pce,escapedCommand:Pce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Pce="source.pipe(destination)";var Nce=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 K4e}from"stream/promises";var kce=(t,e,r)=>{let n=BR.has(e)?J4e(t,e):Z4e(t,e);return Lu(t,Q4e,r.signal),Lu(e,eHe,r.signal),X4e(e),n},Z4e=(t,e)=>{let r=ju([t]);return Gp(r,e),BR.set(e,r),r},J4e=(t,e)=>{let r=BR.get(e);return r.add(t),r},X4e=async t=>{try{await K4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}BR.delete(t)},BR=new WeakMap,Q4e=2,eHe=1;import{aborted as tHe}from"util";var Mce=(t,e)=>t===void 0?[]:[rHe(t,e)],rHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await tHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw sF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var qR=(t,...e)=>{if(Jt(e[0]))return qR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Ice(t,...e),i=nHe({...n,destination:r});return i.pipe=qR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},nHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=iHe(t,i);Oce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=kce(e,o,d);return await Promise.race([Nce(u),...Mce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},iHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as dHe}from"timers/promises";import{on as oHe}from"events";import{getDefaultHighWaterMark as sHe}from"stream";var VR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return aHe(e,s),$ce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},aHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},aF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;cHe(e,s,t);let a=t.readableObjectMode&&!o;return $ce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},cHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},$ce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=oHe(t,"data",{signal:e.signal,highWaterMark:Dce,highWatermark:Dce});return lHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},cF=sHe(!0),Dce=cF,lHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=uHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*zu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Qy(a)}},uHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[MR(t,r,!e),kR(t,i,!n,{})].filter(Boolean);var Lce=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=fHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([pHe(t),d]);return}let f=FU(c,r),p=aF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([hHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},fHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!LR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=aF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Yae(a,t,r,o)},pHe=async t=>{await dHe(),t.readableFlowing===null&&t.resume()},hHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await wR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await AR(r,{maxBuffer:o})):await jp(r,{maxBuffer:o})}catch(a){return Uce(Yse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},lF=async t=>{try{return await t}catch(e){return Uce(e)}},Uce=({bufferedData:t})=>uie(t)?new Uint8Array(t):t;import{finished as mHe}from"stream/promises";var nS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=gHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],mHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||SHe(a,e,r,n)}finally{s.abort()}},gHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&_He(t,r,n),n},_He=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{yHe(e,r),n.call(t,...i)}},yHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},SHe=(t,e,r,n)=>{if(!EHe(t,e,r,n))throw t},EHe=(t,e,r,n=!0)=>r.propagating?Fce(t)||GR(t):(r.propagating=!0,uF(r,e)===n?Fce(t):GR(t)),uF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",GR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Fce=t=>t?.code==="EPIPE";var zce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>dF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),dF=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=nS(t,e,l);if(uF(l,e)){await u;return}let[d]=await Promise.all([Lce({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 jce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?ju([t,e].filter(Boolean)):void 0,Bce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>dF({...vHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:THe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),vHe=({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}},THe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as bHe}from"events";var qce=t=>kp(t,"ipc"),Vce=(t,e)=>{let r=Jx(t);ls({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Gce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=qce(o),a=ma(e,"ipc"),c=ma(r,"ipc");for await(let l of YU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Kse(t,i,c),i.push(l)),s&&Vce(l,o);return i},Hce=async(t,e)=>(await Promise.allSettled([t]),e);var Wce=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 T=Qae(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},v=zce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),b=Bce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),A=[],R=Gce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),P=wHe(m,t,w),O=AHe(h,w);try{return await Promise.race([Promise.all([{},tce(T),Promise.all(v),b,R,Rse(t,d),...P,...O]),g,xHe(t,_),...Tse(t,o,f,_),...qoe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Ese({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},T,Promise.all(v.map(y=>lF(y))),lF(b),Hce(R,A),Promise.allSettled(P),Promise.allSettled(O)])}},wHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:nS(n,i,r)),AHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>go(o,{checkOpen:!1})&&!po(o)).map(({type:i,value:o,stream:s=o})=>nS(s,n,e,{isSameDirection:ki.has(i),stopOnExit:i==="native"}))),xHe=async(t,{signal:e})=>{let[r]=await bHe(t,"error",{signal:e});throw r};var Yce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),iS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=us();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Hp=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as RHe}from"stream";import{callbackify as CHe}from"util";import{finished as Kce}from"stream/promises";var fF=async t=>{if(t!==void 0)try{await pF(t)}catch{}},Zce=async t=>{if(t!==void 0)try{await hF(t)}catch{}},pF=async t=>{await Kce(t,{cleanup:!0,readable:!1,writable:!0})},hF=async t=>{await Kce(t,{cleanup:!0,readable:!0,writable:!1})},HR=async(t,e)=>{if(await t,e)throw e},WR=(t,e,r)=>{r&&!GR(r)?t.destroy(r):e&&t.destroy()};var Jce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||oi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=mF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=gF(a,s),{read:f,onStdoutDataDone:p}=_F({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new RHe({read:f,destroy:CHe(SF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return yF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},mF=(t,e,r)=>{let n=Up(t,e),i=iS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},gF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:cF},_F=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=us(),s=VR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){IHe(this,s,o)},onStdoutDataDone:o}},IHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},yF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await hF(t),await n,await fF(i),await e,r.readable&&r.push(null)}catch(o){await fF(i),Xce(r,o)}},SF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Hp(r,e)&&(Xce(t,n),await HR(e,n))},Xce=(t,e)=>{WR(t,t.readable,e)};import{Writable as PHe}from"stream";import{callbackify as Qce}from"util";var ele=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=EF(t,r,e),s=new PHe({...vF(n,t,i),destroy:Qce(bF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return TF(n,s),s},EF=(t,e,r)=>{let n=cR(t,e),i=iS(r,n,"writableFinal"),o=iS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},vF=(t,e,r)=>({write:OHe.bind(void 0,t),final:Qce(NHe.bind(void 0,t,e,r))}),OHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},NHe=async(t,e,r)=>{await Hp(r,e)&&(t.writable&&t.end(),await e)},TF=async(t,e,r)=>{try{await pF(t),e.writable&&e.end()}catch(n){await Zce(r),tle(e,n)}},bF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Hp(r,e),await Hp(n,e)&&(tle(t,i),await HR(e,i))},tle=(t,e)=>{WR(t,t.writable,e)};import{Duplex as kHe}from"stream";import{callbackify as MHe}from"util";var rle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||oi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=mF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=EF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=gF(c,a),{read:g,onStdoutDataDone:_}=_F({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new kHe({read:g,...vF(u,t,d),destroy:MHe(DHe.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 yF({subprocessStdout:c,onStdoutDataDone:_,readable:T,subprocess:t,subprocessStdin:u}),TF(u,T,c),T},DHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([SF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),bF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var wF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||oi.has(e),s=Up(t,r),a=VR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return $He(a,s,t)},$He=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var nle=(t,{encoding:e})=>{let r=Yce();t.readable=Jce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=ele.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=rle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=wF.bind(void 0,t,e),t[Symbol.asyncIterator]=wF.bind(void 0,t,e,{})};var ile=(t,e)=>{for(let[r,n]of UHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},LHe=(async()=>{})().constructor.prototype,UHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(LHe,t)]);var ole=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=jHe(t,e,r),{subprocess:f,promise:p}=qHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=qR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ile(f,p),ds.set(f,{options:u,fileDescriptors:d}),f},jHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Qx(t,e,r),{file:a,commandArguments:c,options:l}=SR(t,e,r),u=BHe(l),d=gce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},BHe=({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}},qHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=zHe(...ER(t,e,r))}catch(h){return fce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;FHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ace(c,a,l),Rce(c,r,l);let d={},f=us();c.kill=joe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=jce(c,r),nle(c,r),lce(c,r);let p=VHe({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}},VHe=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 Wce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((v,b)=>_a(v,e,b)),T=_a(m,e,"all"),w=GHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:T,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return qp(w,n,e)},GHe=({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?Xy({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 fs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):CR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var YR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,HHe(n,t[n],i)]));return{...t,...r}},HHe=(t,e,r)=>WHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,WHe=new Set(["env",...eU]);var $c=(t,e,r,n)=>{let i=(s,a,c)=>$c(s,a,r,c),o=(...s)=>YHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},YHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,YR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=KHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?nce(a,c,l):ole(a,c,l,i)},KHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=gie(e)?_ie(e,r):[e,...r],[s,a,c]=Bx(...o),l=YR(YR(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 sle=({file:t,commandArguments:e})=>cle(t,e),ale=({file:t,commandArguments:e})=>({...cle(t,e),isSync:!0}),cle=(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]=ZHe(t);return{file:r,commandArguments:n}},ZHe=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(JHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},JHe=/ +/g;var lle=(t,e,r)=>{t.sync=e(XHe,r),t.s=t.sync},ule=({options:t})=>dle(t),XHe=({options:t})=>({...dle(t),isSync:!0}),dle=t=>({options:{...QHe(t),...t}}),QHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},fle={preferLocal:!0};var ple=$c(()=>({})),czt=$c(()=>({isSync:!0})),hle=$c(sle),lzt=$c(ale),uzt=$c(wse),dzt=$c(ule,{},fle,lle),{sendMessage:fzt,getOneMessage:pzt,getEachMessage:hzt,getCancelSignal:mzt}=uce();var mle=!1,gle,e6e=t=>{gle??=t},_le=t=>{mle=!0,e6e(t)},si=()=>mle,Wp=()=>gle;var oS=null,yle=t=>(oS&&oS.destroy(),oS=new _o({totalAllowedTime:t}),oS),Sle=()=>oS;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&&si())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 Ox({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{V.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 Ele={name:"@netlify/agent-runner-cli",type:"module",version:"1.187.0-count-api-reqs.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.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.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.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var i6e=r6e(import.meta.url),o6e=ya.dirname(i6e),s6e=n6e(import.meta.url),Yp=ie("shell"),AF=new Set,vle={preferLocal:!0},It=(t,e,r)=>{let[n,i]=a6e(e,r),o={...vle,...i},s=ple(t,n,o);ble(s,o),xle(s);let a=r?.idleTimeout;return a&&a>0&&Ale(s,a),s},Tle=(t,e)=>{let r={...vle,...e},n=hle(t,r);return ble(n,r),xle(n),e?.idleTimeout&&e.idleTimeout>0&&Ale(n,e.idleTimeout),n},a6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ble=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||hs.env.NETLIFY_LOCAL_QUIET==="true")return;if(hs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new My).pipe(hs.stdout),t.stderr?.pipe(new My).pipe(hs.stderr);return}t.stdout?.pipe(hs.stdout),t.stderr?.pipe(hs.stderr)},xF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(hs.kill(-t.pid,e),Yp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Yp.error("Error killing process:",r),!1}},wle=t=>xF(t,"SIGKILL"),Ale=(t,e)=>{let r=null,n=()=>{Yp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),xF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yp.log(`Force killing idle process ${t.pid}`),wle(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)},xle=t=>{AF.add(t);let e=Sle();if(e){let r=e.onTimesUp(()=>{Yp.log(`Global timer expired, killing process ${t.pid}`),xF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yp.log(`Force killing process ${t.pid} after timeout`),wle(t))},5e3)});t.on("exit",()=>{AF.delete(t),r()}),t.on("error",()=>{AF.delete(t),r()})}};function ZR(t,e){return!!yo(t,e)}function yo(t,e){if(!hs.env.NETLIFY_LOCAL_MODE)try{let i=s6e.resolve(Ele.name),o=ya.dirname(i);for(;o!==ya.dirname(o);){let s=ya.dirname(o);if(ya.basename(s)==="node_modules"){let a=ya.join(s,".bin",e);if(KR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(hs.env.NODE_PATH){let i=ya.join(hs.env.NODE_PATH,".bin",e);if(KR.existsSync(i))return i}let r=ya.join(t,"node_modules",".bin",e);if(KR.existsSync(r))return r;let n=ya.join(o6e,"..","node_modules",".bin",e);if(KR.existsSync(n))return n}var Rle=ie("repo"),Ole="runner-diffs-",QR=t=>`${Ole}${t}-`,Nle=async t=>{let e=Ple.tmpdir(),r;try{r=await JR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Ole)&&!n.startsWith(QR(t))).map(n=>JR.rm(XR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>It("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),eC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Rle.info("Getting runner diffs");let n=await PF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=OF(o);await m6e(l,r)}Rle.info("Changes after processing"),await IF(r);let s=await aS(o,r);if(await CF(s,r),i=await f6e(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await JR.mkdtemp(XR.join(Ple.tmpdir(),QR(t.sessionId))),c=await RF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await u6e(r),c.hasChanges&&V.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},RF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=XR.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:T}=await JR.stat(g);return{path:g,size:T}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Ile(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Ile(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Cle=async t=>{let e=c6e("sha256");for await(let r of l6e(t))e.update(r);return e.digest("hex")},Ile=async(t,e)=>t.size===e.size&&await Cle(t.path)===await Cle(e.path),u6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},CF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},IF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},kle=/.. (.+)?\.log$/,d6e=[kle],PF=async(t=process.cwd())=>{let e=await IF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
146
|
+
if (condition) { yield value; }`)};import{Buffer as yGe}from"buffer";import{StringDecoder as SGe}from"string_decoder";var MR=(t,e,r)=>{if(r)return;if(t)return{transform:EGe.bind(void 0,new TextEncoder)};let n=new SGe(e);return{transform:vGe.bind(void 0,n),final:TGe.bind(void 0,n)}},EGe=function*(t,e){yGe.isBuffer(e)?yield ha(e):typeof e=="string"?yield t.encode(e):yield e},vGe=function*(t,e){yield dr(e)?t.write(e):e},TGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as jae}from"util";var BU=jae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),DR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=wGe}=e[r];for await(let i of n(t))yield*DR(i,e,r+1)},Bae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*bGe(r,Number(e),t)},bGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*DR(n,r,e+1)},qae=jae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),wGe=function*(t){yield t};var qU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Vae=(t,e)=>[...e.flatMap(r=>[...zu(r,t,0)]),...Qy(t)],zu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=xGe}=e[r];for(let i of n(t))yield*zu(i,e,r+1)},Qy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*AGe(r,Number(e),t)},AGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*zu(n,r,e+1)},xGe=function*(t){yield t};var VU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Hae(t,s,o),l=Fu(e),u=Fu(r),d=l?BU.bind(void 0,DR,a):qU.bind(void 0,zu),f=l||u?BU.bind(void 0,Bae,a):qU.bind(void 0,Qy),p=l||u?qae.bind(void 0,a):void 0;return{stream:new RGe({writableObjectMode:n,writableHighWaterMark:Gae(n),readableObjectMode:i,readableHighWaterMark:Gae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},$R=(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=Hae(s,r,a);t=Vae(c,t)}return t},Hae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Uae(n,a)},MR(r,s,n),kR(r,o,n,c),{transform:t,final:e},{transform:Fae(i,a)},Lae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Wae=(t,e)=>{for(let r of CGe(t))IGe(t,r,e)},CGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),IGe=(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 ${Dc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>PGe(a,n));r.input=qy(s)},PGe=(t,e)=>{let r=$R(t,e,"utf8",!0);return OGe(r),qy(r)},OGe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(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 DGe,appendFileSync as $Ge}from"fs";var LR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&kp(r,n)&&!oi.has(e)&&NGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&kGe.has(o))||t.every(({type:i})=>ki.has(i))),NGe=t=>t===1||t===2,kGe=new Set(["pipe","overlapped"]),Yae=async(t,e,r,n)=>{for await(let i of t)MGe(e)||Zae(i,r,n)},Kae=(t,e,r)=>{for(let n of t)Zae(n,e,r)},MGe=t=>t._readableState.pipes.length>0,Zae=(t,e,r)=>{let n=Jx(t);ls({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Jae=({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)=>LGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},LGe=({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=Xse(t,o,d),p=ha(f),{stdioItems:h,objectMode:m}=e[r],g=UGe([p],h,c,n),{serializedResult:_,finalResult:T=_}=FGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});zGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?T:void 0;try{return n.error===void 0&&jGe(_,h,i),w}catch(v){return n.error=v,w}},UGe=(t,e,r,n)=>{try{return $R(t,e,r,!1)}catch(i){return n.error=i,t}},FGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qy(t)};let s=fie(t,r);return n[o]?{serializedResult:s,finalResult:jU(s,!i[o],e)}:{serializedResult:s}},zGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!LR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=jU(t,!1,s);try{Kae(a,e,n)}catch(c){r.error??=c}},jGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>OR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?$Ge(n,t):(r.add(o),DGe(n,t))}};var Xae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,_a(e,r,"all")]:Array.isArray(e)?[_a(t,r,"all"),...e]:dr(t)&&dr(e)?Z1([t,e]):`${t}${e}`};import{once as GU}from"events";var Qae=async(t,e)=>{let[r,n]=await BGe(t);return e.isForcefullyTerminated??=!1,[r,n]},BGe=async t=>{let[e,r]=await Promise.allSettled([GU(t,"spawn"),GU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?ece(t):r.value},ece=async t=>{try{return await GU(t,"exit")}catch{return ece(t)}},tce=async t=>{let[e,r]=await t;if(!qGe(e,r)&&HU(e,r))throw new ho;return[e,r]},qGe=(t,e)=>t===void 0&&e===void 0,HU=(t,e)=>t!==0||e!==null;var rce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=VGe(t,e,r),s=o?.code==="ETIMEDOUT",a=Jse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},VGe=(t,e,r)=>t!==void 0?t:HU(e,r)?new ho:void 0;var nce=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=HGe(t,e,r),d=KGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return qp(d,c,l)},HGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Qx(t,e,r),a=WGe(r),{file:c,commandArguments:l,options:u}=SR(t,e,a);YGe(u);let d=kae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},WGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,YGe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&UR("ipcInput"),t&&UR("ipc: true"),r&&UR("detached: true"),n&&UR("cancelSignal")},UR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},KGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=ZGe({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}=rce(c,r),{output:h,error:m=l}=Jae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((T,w)=>_a(T,r,w)),_=_a(Xae(h,r),r,"all");return XGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},ZGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Wae(o,r);let a=JGe(r);return GGe(...ER(t,e,a))}catch(a){return Bp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},JGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RR(e)}),XGe=({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?CR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Xy({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 FHe}from"events";import{spawn as zHe}from"child_process";import cce from"process";import{once as WU,on as QGe}from"events";var ice=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>($p({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:pR(t)}),e4e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),e4e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{lR(e,i);let o=Mc(t,e,r),s=new AbortController;try{return await Promise.race([t4e(o,n,s),r4e(o,r,s),n4e(o,r,s)])}catch(a){throw Lp(t),a}finally{s.abort(),uR(e,i)}},t4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await WU(t,"message",{signal:r});return n}for await(let[n]of QGe(t,"message",{signal:r}))if(e(n))return n},r4e=async(t,e,{signal:r})=>{await WU(t,"disconnect",{signal:r}),Voe(e)},n4e=async(t,e,{signal:r})=>{let[n]=await WU(t,"strict:error",{signal:r});throw sR(n,e)};import{once as sce,on as i4e}from"events";var ace=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>YU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),YU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{$p({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:pR(t)}),lR(e,o);let s=Mc(t,e,r),a=new AbortController,c={};return o4e(t,s,a),s4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),a4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},o4e=async(t,e,r)=>{try{await sce(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},s4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await sce(t,"strict:error",{signal:r.signal});n.error=sR(i,e),r.abort()}catch{}},a4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of i4e(r,"message",{signal:o.signal}))oce(s),yield c}catch{oce(s)}finally{o.abort(),uR(e,a),n||Lp(t),i&&await t}},oce=({error:t})=>{if(t)throw t};var lce=(t,{ipc:e})=>{Object.assign(t,dce(t,!1,e))},uce=()=>{let t=cce,e=!0,r=cce.channel!==void 0;return{...dce(t,e,r),getCancelSignal:_se.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},dce=(t,e,r)=>({sendMessage:_R.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ice.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ace.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as c4e}from"child_process";import{PassThrough as l4e,Readable as u4e,Writable as d4e,Duplex as f4e}from"stream";var fce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{UU(n);let a=new c4e;p4e(a,n),Object.assign(a,{readable:h4e,writable:m4e,duplex:g4e});let c=Bp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=_4e(c,s,i);return{subprocess:a,promise:l}},p4e=(t,e)=>{let r=eS(),n=eS(),i=eS(),o=Array.from({length:e.length-3},eS),s=eS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},eS=()=>{let t=new l4e;return t.end(),t},h4e=()=>new u4e({read(){}}),m4e=()=>new d4e({write(){}}),g4e=()=>new f4e({read(){},write(){}}),_4e=async(t,e,r)=>qp(t,e,r);import{createReadStream as pce,createWriteStream as hce}from"fs";import{Buffer as y4e}from"buffer";import{Readable as tS,Writable as S4e,Duplex as E4e}from"stream";var gce=(t,e)=>NR(v4e,t,e,!1),rS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Dc[t]}.`)},mce={fileNumber:rS,generator:VU,asyncGenerator:VU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:E4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},v4e={input:{...mce,fileUrl:({value:t})=>({stream:pce(t)}),filePath:({value:{file:t}})=>({stream:pce(t)}),webStream:({value:t})=>({stream:tS.fromWeb(t)}),iterable:({value:t})=>({stream:tS.from(t)}),asyncIterable:({value:t})=>({stream:tS.from(t)}),string:({value:t})=>({stream:tS.from(t)}),uint8Array:({value:t})=>({stream:tS.from(y4e.from(t))})},output:{...mce,fileUrl:({value:t})=>({stream:hce(t)}),filePath:({value:{file:t,append:e}})=>({stream:hce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:S4e.fromWeb(t)}),iterable:rS,asyncIterable:rS,string:rS,uint8Array:rS}};import{on as T4e,once as _ce}from"events";import{PassThrough as b4e,getDefaultHighWaterMark as w4e}from"stream";import{finished as Ece}from"stream/promises";function ju(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)ZU(i);let e=t.some(({readableObjectMode:i})=>i),r=A4e(t,e),n=new KU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var A4e=(t,e)=>{if(t.length===0)return w4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},KU=class extends b4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(ZU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=x4e(this,this.#e,this.#o);let r=I4e({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(ZU(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)}},x4e=async(t,e,r)=>{FR(t,yce);let n=new AbortController;try{await Promise.race([R4e(t,n),C4e(t,e,r,n)])}finally{n.abort(),FR(t,-yce)}},R4e=async(t,{signal:e})=>{try{await Ece(t,{signal:e,cleanup:!0})}catch(r){throw vce(t,r),r}},C4e=async(t,e,r,{signal:n})=>{for await(let[i]of T4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},ZU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},I4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{FR(t,Sce);let a=new AbortController;try{await Promise.race([P4e(o,e,a),O4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),N4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),FR(t,-Sce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?JU(t):k4e(t))},P4e=async(t,e,{signal:r})=>{try{await t,r.aborted||JU(e)}catch(n){r.aborted||vce(e,n)}},O4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Ece(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Tce(s)?i.add(e):bce(t,s)}},N4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await _ce(t,i,{signal:o}),!t.readable)return _ce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},k4e=t=>{t.writable&&t.end()},vce=(t,e)=>{Tce(e)?JU(t):bce(t,e)},Tce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",JU=t=>{(t.readable||t.writable)&&t.destroy()},bce=(t,e)=>{t.destroyed||(t.once("error",M4e),t.destroy(e))},M4e=()=>{},FR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},yce=2,Sce=1;import{finished as wce}from"stream/promises";var Gp=(t,e)=>{t.pipe(e),D4e(t,e),$4e(t,e)},D4e=async(t,e)=>{if(!(po(t)||po(e))){try{await wce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}XU(e)}},XU=t=>{t.writable&&t.end()},$4e=async(t,e)=>{if(!(po(t)||po(e))){try{await wce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}QU(t)}},QU=t=>{t.readable&&t.destroy()};var Ace=(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})=>ki.has(c)))L4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ki.has(c)))F4e({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]:ju(o);Gp(s,i)}},L4e=(t,e,r,n)=>{r==="output"?Gp(t.stdio[n],e):Gp(e,t.stdio[n]);let i=U4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},U4e=["stdin","stdout","stderr"],F4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;z4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},z4e=(t,{signal:e})=>{po(t)&&Lu(t,j4e,e)},j4e=2;import{addAbortListener as V4e}from"events";var Bu=[];Bu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var zR=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",eF=Symbol.for("signal-exit emitter"),tF=globalThis,B4e=Object.defineProperty.bind(Object),rF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(tF[eF])return tF[eF];B4e(tF,eF,{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}},jR=class{},q4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),nF=class extends jR{onExit(){return()=>{}}load(){}unload(){}},iF=class extends jR{#e=oF.platform==="win32"?"SIGINT":"SIGHUP";#r=new rF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Bu)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(!zR(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 Bu)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,Bu.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 zR(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"&&zR(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)}},oF=globalThis.process,{onExit:xce,load:y1t,unload:S1t}=q4e(zR(oF)?new iF(oF):new nF);var Rce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=xce(()=>{t.kill()});V4e(n,()=>{i()})};var Ice=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Xx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=G4e(r,n,i),{sourceStream:d,sourceError:f}=W4e(t,l),{options:p,fileDescriptors:h}=ds.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},G4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=H4e(t,e,...r),a=cR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},H4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Cce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||Y1(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]=Bx(r,...n);return{destination:e(Cce)(i,o,s),pipeOptions:s}}if(ds.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}`)},Cce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),W4e=(t,e)=>{try{return{sourceStream:Up(t,e)}}catch(r){return{sourceError:r}}};var Oce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Y4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw sF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Y4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return QU(t),n;if(e!==void 0)return XU(r),e},sF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Bp({error:t,command:Pce,escapedCommand:Pce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Pce="source.pipe(destination)";var Nce=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 K4e}from"stream/promises";var kce=(t,e,r)=>{let n=BR.has(e)?J4e(t,e):Z4e(t,e);return Lu(t,Q4e,r.signal),Lu(e,eHe,r.signal),X4e(e),n},Z4e=(t,e)=>{let r=ju([t]);return Gp(r,e),BR.set(e,r),r},J4e=(t,e)=>{let r=BR.get(e);return r.add(t),r},X4e=async t=>{try{await K4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}BR.delete(t)},BR=new WeakMap,Q4e=2,eHe=1;import{aborted as tHe}from"util";var Mce=(t,e)=>t===void 0?[]:[rHe(t,e)],rHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await tHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw sF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var qR=(t,...e)=>{if(Jt(e[0]))return qR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Ice(t,...e),i=nHe({...n,destination:r});return i.pipe=qR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},nHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=iHe(t,i);Oce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=kce(e,o,d);return await Promise.race([Nce(u),...Mce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},iHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as dHe}from"timers/promises";import{on as oHe}from"events";import{getDefaultHighWaterMark as sHe}from"stream";var VR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return aHe(e,s),$ce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},aHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},aF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;cHe(e,s,t);let a=t.readableObjectMode&&!o;return $ce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},cHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},$ce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=oHe(t,"data",{signal:e.signal,highWaterMark:Dce,highWatermark:Dce});return lHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},cF=sHe(!0),Dce=cF,lHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=uHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*zu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Qy(a)}},uHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[MR(t,r,!e),kR(t,i,!n,{})].filter(Boolean);var Lce=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=fHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([pHe(t),d]);return}let f=FU(c,r),p=aF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([hHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},fHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!LR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=aF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Yae(a,t,r,o)},pHe=async t=>{await dHe(),t.readableFlowing===null&&t.resume()},hHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await wR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await AR(r,{maxBuffer:o})):await jp(r,{maxBuffer:o})}catch(a){return Uce(Yse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},lF=async t=>{try{return await t}catch(e){return Uce(e)}},Uce=({bufferedData:t})=>uie(t)?new Uint8Array(t):t;import{finished as mHe}from"stream/promises";var nS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=gHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],mHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||SHe(a,e,r,n)}finally{s.abort()}},gHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&_He(t,r,n),n},_He=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{yHe(e,r),n.call(t,...i)}},yHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},SHe=(t,e,r,n)=>{if(!EHe(t,e,r,n))throw t},EHe=(t,e,r,n=!0)=>r.propagating?Fce(t)||GR(t):(r.propagating=!0,uF(r,e)===n?Fce(t):GR(t)),uF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",GR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Fce=t=>t?.code==="EPIPE";var zce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>dF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),dF=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=nS(t,e,l);if(uF(l,e)){await u;return}let[d]=await Promise.all([Lce({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 jce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?ju([t,e].filter(Boolean)):void 0,Bce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>dF({...vHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:THe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),vHe=({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}},THe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as bHe}from"events";var qce=t=>kp(t,"ipc"),Vce=(t,e)=>{let r=Jx(t);ls({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Gce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=qce(o),a=ma(e,"ipc"),c=ma(r,"ipc");for await(let l of YU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Kse(t,i,c),i.push(l)),s&&Vce(l,o);return i},Hce=async(t,e)=>(await Promise.allSettled([t]),e);var Wce=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 T=Qae(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},v=zce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),b=Bce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),A=[],R=Gce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),P=wHe(m,t,w),O=AHe(h,w);try{return await Promise.race([Promise.all([{},tce(T),Promise.all(v),b,R,Rse(t,d),...P,...O]),g,xHe(t,_),...Tse(t,o,f,_),...qoe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Ese({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},T,Promise.all(v.map(y=>lF(y))),lF(b),Hce(R,A),Promise.allSettled(P),Promise.allSettled(O)])}},wHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:nS(n,i,r)),AHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>go(o,{checkOpen:!1})&&!po(o)).map(({type:i,value:o,stream:s=o})=>nS(s,n,e,{isSameDirection:ki.has(i),stopOnExit:i==="native"}))),xHe=async(t,{signal:e})=>{let[r]=await bHe(t,"error",{signal:e});throw r};var Yce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),iS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=us();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Hp=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as RHe}from"stream";import{callbackify as CHe}from"util";import{finished as Kce}from"stream/promises";var fF=async t=>{if(t!==void 0)try{await pF(t)}catch{}},Zce=async t=>{if(t!==void 0)try{await hF(t)}catch{}},pF=async t=>{await Kce(t,{cleanup:!0,readable:!1,writable:!0})},hF=async t=>{await Kce(t,{cleanup:!0,readable:!0,writable:!1})},HR=async(t,e)=>{if(await t,e)throw e},WR=(t,e,r)=>{r&&!GR(r)?t.destroy(r):e&&t.destroy()};var Jce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||oi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=mF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=gF(a,s),{read:f,onStdoutDataDone:p}=_F({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new RHe({read:f,destroy:CHe(SF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return yF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},mF=(t,e,r)=>{let n=Up(t,e),i=iS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},gF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:cF},_F=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=us(),s=VR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){IHe(this,s,o)},onStdoutDataDone:o}},IHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},yF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await hF(t),await n,await fF(i),await e,r.readable&&r.push(null)}catch(o){await fF(i),Xce(r,o)}},SF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Hp(r,e)&&(Xce(t,n),await HR(e,n))},Xce=(t,e)=>{WR(t,t.readable,e)};import{Writable as PHe}from"stream";import{callbackify as Qce}from"util";var ele=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=EF(t,r,e),s=new PHe({...vF(n,t,i),destroy:Qce(bF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return TF(n,s),s},EF=(t,e,r)=>{let n=cR(t,e),i=iS(r,n,"writableFinal"),o=iS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},vF=(t,e,r)=>({write:OHe.bind(void 0,t),final:Qce(NHe.bind(void 0,t,e,r))}),OHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},NHe=async(t,e,r)=>{await Hp(r,e)&&(t.writable&&t.end(),await e)},TF=async(t,e,r)=>{try{await pF(t),e.writable&&e.end()}catch(n){await Zce(r),tle(e,n)}},bF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Hp(r,e),await Hp(n,e)&&(tle(t,i),await HR(e,i))},tle=(t,e)=>{WR(t,t.writable,e)};import{Duplex as kHe}from"stream";import{callbackify as MHe}from"util";var rle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||oi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=mF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=EF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=gF(c,a),{read:g,onStdoutDataDone:_}=_F({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new kHe({read:g,...vF(u,t,d),destroy:MHe(DHe.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 yF({subprocessStdout:c,onStdoutDataDone:_,readable:T,subprocess:t,subprocessStdin:u}),TF(u,T,c),T},DHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([SF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),bF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var wF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||oi.has(e),s=Up(t,r),a=VR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return $He(a,s,t)},$He=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var nle=(t,{encoding:e})=>{let r=Yce();t.readable=Jce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=ele.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=rle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=wF.bind(void 0,t,e),t[Symbol.asyncIterator]=wF.bind(void 0,t,e,{})};var ile=(t,e)=>{for(let[r,n]of UHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},LHe=(async()=>{})().constructor.prototype,UHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(LHe,t)]);var ole=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=jHe(t,e,r),{subprocess:f,promise:p}=qHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=qR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ile(f,p),ds.set(f,{options:u,fileDescriptors:d}),f},jHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Qx(t,e,r),{file:a,commandArguments:c,options:l}=SR(t,e,r),u=BHe(l),d=gce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},BHe=({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}},qHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=zHe(...ER(t,e,r))}catch(h){return fce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;FHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ace(c,a,l),Rce(c,r,l);let d={},f=us();c.kill=joe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=jce(c,r),nle(c,r),lce(c,r);let p=VHe({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}},VHe=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 Wce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((v,b)=>_a(v,e,b)),T=_a(m,e,"all"),w=GHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:T,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return qp(w,n,e)},GHe=({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?Xy({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 fs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):CR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var YR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,HHe(n,t[n],i)]));return{...t,...r}},HHe=(t,e,r)=>WHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,WHe=new Set(["env",...eU]);var $c=(t,e,r,n)=>{let i=(s,a,c)=>$c(s,a,r,c),o=(...s)=>YHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},YHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,YR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=KHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?nce(a,c,l):ole(a,c,l,i)},KHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=gie(e)?_ie(e,r):[e,...r],[s,a,c]=Bx(...o),l=YR(YR(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 sle=({file:t,commandArguments:e})=>cle(t,e),ale=({file:t,commandArguments:e})=>({...cle(t,e),isSync:!0}),cle=(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]=ZHe(t);return{file:r,commandArguments:n}},ZHe=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(JHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},JHe=/ +/g;var lle=(t,e,r)=>{t.sync=e(XHe,r),t.s=t.sync},ule=({options:t})=>dle(t),XHe=({options:t})=>({...dle(t),isSync:!0}),dle=t=>({options:{...QHe(t),...t}}),QHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},fle={preferLocal:!0};var ple=$c(()=>({})),czt=$c(()=>({isSync:!0})),hle=$c(sle),lzt=$c(ale),uzt=$c(wse),dzt=$c(ule,{},fle,lle),{sendMessage:fzt,getOneMessage:pzt,getEachMessage:hzt,getCancelSignal:mzt}=uce();var mle=!1,gle,e6e=t=>{gle??=t},_le=t=>{mle=!0,e6e(t)},si=()=>mle,Wp=()=>gle;var oS=null,yle=t=>(oS&&oS.destroy(),oS=new _o({totalAllowedTime:t}),oS),Sle=()=>oS;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&&si())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 Ox({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{V.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 Ele={name:"@netlify/agent-runner-cli",type:"module",version:"1.188.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.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.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.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var i6e=r6e(import.meta.url),o6e=ya.dirname(i6e),s6e=n6e(import.meta.url),Yp=ie("shell"),AF=new Set,vle={preferLocal:!0},It=(t,e,r)=>{let[n,i]=a6e(e,r),o={...vle,...i},s=ple(t,n,o);ble(s,o),xle(s);let a=r?.idleTimeout;return a&&a>0&&Ale(s,a),s},Tle=(t,e)=>{let r={...vle,...e},n=hle(t,r);return ble(n,r),xle(n),e?.idleTimeout&&e.idleTimeout>0&&Ale(n,e.idleTimeout),n},a6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ble=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||hs.env.NETLIFY_LOCAL_QUIET==="true")return;if(hs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new My).pipe(hs.stdout),t.stderr?.pipe(new My).pipe(hs.stderr);return}t.stdout?.pipe(hs.stdout),t.stderr?.pipe(hs.stderr)},xF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(hs.kill(-t.pid,e),Yp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Yp.error("Error killing process:",r),!1}},wle=t=>xF(t,"SIGKILL"),Ale=(t,e)=>{let r=null,n=()=>{Yp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),xF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yp.log(`Force killing idle process ${t.pid}`),wle(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)},xle=t=>{AF.add(t);let e=Sle();if(e){let r=e.onTimesUp(()=>{Yp.log(`Global timer expired, killing process ${t.pid}`),xF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yp.log(`Force killing process ${t.pid} after timeout`),wle(t))},5e3)});t.on("exit",()=>{AF.delete(t),r()}),t.on("error",()=>{AF.delete(t),r()})}};function ZR(t,e){return!!yo(t,e)}function yo(t,e){if(!hs.env.NETLIFY_LOCAL_MODE)try{let i=s6e.resolve(Ele.name),o=ya.dirname(i);for(;o!==ya.dirname(o);){let s=ya.dirname(o);if(ya.basename(s)==="node_modules"){let a=ya.join(s,".bin",e);if(KR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(hs.env.NODE_PATH){let i=ya.join(hs.env.NODE_PATH,".bin",e);if(KR.existsSync(i))return i}let r=ya.join(t,"node_modules",".bin",e);if(KR.existsSync(r))return r;let n=ya.join(o6e,"..","node_modules",".bin",e);if(KR.existsSync(n))return n}var Rle=ie("repo"),Ole="runner-diffs-",QR=t=>`${Ole}${t}-`,Nle=async t=>{let e=Ple.tmpdir(),r;try{r=await JR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Ole)&&!n.startsWith(QR(t))).map(n=>JR.rm(XR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>It("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),eC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Rle.info("Getting runner diffs");let n=await PF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=OF(o);await m6e(l,r)}Rle.info("Changes after processing"),await IF(r);let s=await aS(o,r);if(await CF(s,r),i=await f6e(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await JR.mkdtemp(XR.join(Ple.tmpdir(),QR(t.sessionId))),c=await RF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await u6e(r),c.hasChanges&&V.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},RF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=XR.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:T}=await JR.stat(g);return{path:g,size:T}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Ile(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Ile(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Cle=async t=>{let e=c6e("sha256");for await(let r of l6e(t))e.update(r);return e.digest("hex")},Ile=async(t,e)=>t.size===e.size&&await Cle(t.path)===await Cle(e.path),u6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},CF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},IF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},kle=/.. (.+)?\.log$/,d6e=[kle],PF=async(t=process.cwd())=>{let e=await IF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
147
147
|
`).filter(i=>d6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},f6e=async(t=process.cwd())=>{try{return await Xt(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},sS=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},p6e=1,h6e=async t=>{try{return await Xt(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===p6e)return!1;throw e}},Mle=async(t=process.cwd())=>{if(!await h6e(t))return!0;let{stdout:e}=await Xt(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},Dle=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},aS=async(t,e=process.cwd())=>{t||=await IF(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
148
148
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${XR.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(kle)?.[1];o&&n.push(`:!${o}.log`)}),n},$le=async(t=process.cwd())=>{await Xt(["reset","--hard","HEAD"],{cwd:t})},Lle=async(t=process.cwd())=>{let e=await Xt(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
149
149
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},OF=t=>{let e=t.split(`
|
package/dist/bin.js
CHANGED
|
@@ -594,7 +594,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
594
594
|
`,LF:`
|
|
595
595
|
`,concatBytes:J3},Dbt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Mbt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Dbt};import{Buffer as Ubt}from"buffer";var qwe=(t,e)=>t?void 0:Fbt.bind(void 0,e),Fbt=function*(t,e){if(typeof e!="string"&&!Br(e)&&!Ubt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Bwe=(t,e)=>t?jbt.bind(void 0,e):zbt.bind(void 0,e),jbt=function*(t,e){Vwe(t,e),yield e},zbt=function*(t,e){if(Vwe(t,e),typeof e!="string"&&!Br(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Vwe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
596
596
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
597
|
-
if (condition) { yield value; }`)};import{Buffer as qbt}from"buffer";import{StringDecoder as Bbt}from"string_decoder";var NP=(t,e,r)=>{if(r)return;if(t)return{transform:Vbt.bind(void 0,new TextEncoder)};let n=new Bbt(e);return{transform:Hbt.bind(void 0,n),final:Gbt.bind(void 0,n)}},Vbt=function*(t,e){qbt.isBuffer(e)?yield Oc(e):typeof e=="string"?yield t.encode(e):yield e},Hbt=function*(t,e){yield Br(e)?t.write(e):e},Gbt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Hwe}from"util";var Q3=Hwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),kP=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Ybt}=e[r];for await(let i of n(t))yield*kP(i,e,r+1)},Gwe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Wbt(r,Number(e),t)},Wbt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*kP(n,r,e+1)},Wwe=Hwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Ybt=function*(t){yield t};var eW=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Ywe=(t,e)=>[...e.flatMap(r=>[...Wf(r,t,0)]),...KT(t)],Wf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Zbt}=e[r];for(let i of n(t))yield*Wf(i,e,r+1)},KT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kbt(r,Number(e),t)},Kbt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Wf(n,r,e+1)},Zbt=function*(t){yield t};var tW=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Zwe(t,o,s),l=Gf(e),u=Gf(r),d=l?Q3.bind(void 0,kP,a):eW.bind(void 0,Wf),f=l||u?Q3.bind(void 0,Gwe,a):eW.bind(void 0,KT),p=l||u?Wwe.bind(void 0,a):void 0;return{stream:new Jbt({writableObjectMode:n,writableHighWaterMark:Kwe(n),readableObjectMode:i,readableHighWaterMark:Kwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},$P=(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=Zwe(o,r,a);t=Ywe(c,t)}return t},Zwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:qwe(n,a)},NP(r,o,n),PP(r,s,n,c),{transform:t,final:e},{transform:Bwe(i,a)},zwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Jwe=(t,e)=>{for(let r of Xbt(t))Qbt(t,r,e)},Xbt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Qbt=(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 ${xu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>ewt(a,n));r.input=FT(o)},ewt=(t,e)=>{let r=$P(t,e,"utf8",!0);return twt(r),FT(r)},twt=t=>{let e=t.find(r=>typeof r!="string"&&!Br(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 swt,appendFileSync as owt}from"fs";var LP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&xg(r,n)&&!Ki.has(e)&&rwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&nwt.has(s))||t.every(({type:i})=>Os.has(i))),rwt=t=>t===1||t===2,nwt=new Set(["pipe","overlapped"]),Xwe=async(t,e,r,n)=>{for await(let i of t)iwt(e)||eRe(i,r,n)},Qwe=(t,e,r)=>{for(let n of t)eRe(n,e,r)},iwt=t=>t._readableState.pipes.length>0,eRe=(t,e,r)=>{let n=KO(t);la({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var tRe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>awt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},awt=({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=rwe(t,s,d),p=Oc(f),{stdioItems:h,objectMode:m}=e[r],_=cwt([p],h,c,n),{serializedResult:S,finalResult:v=S}=lwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?v:void 0;try{return n.error===void 0&&dwt(S,h,i),y}catch(g){return n.error=g,y}},cwt=(t,e,r,n)=>{try{return $P(t,e,r,!1)}catch(i){return n.error=i,t}},lwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:FT(t)};let o=gve(t,r);return n[s]?{serializedResult:o,finalResult:X3(o,!i[s],e)}:{serializedResult:o}},uwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!LP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=X3(t,!1,o);try{Qwe(a,e,n)}catch(c){r.error??=c}},dwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>IP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?owt(n,t):(r.add(s),swt(n,t))}};var rRe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,kc(e,r,"all")]:Array.isArray(e)?[kc(t,r,"all"),...e]:Br(t)&&Br(e)?a3([t,e]):`${t}${e}`};import{once as rW}from"events";var nRe=async(t,e)=>{let[r,n]=await fwt(t);return e.isForcefullyTerminated??=!1,[r,n]},fwt=async t=>{let[e,r]=await Promise.allSettled([rW(t,"spawn"),rW(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?iRe(t):r.value},iRe=async t=>{try{return await rW(t,"exit")}catch{return iRe(t)}},sRe=async t=>{let[e,r]=await t;if(!pwt(e,r)&&nW(e,r))throw new ao;return[e,r]},pwt=(t,e)=>t===void 0&&e===void 0,nW=(t,e)=>t!==0||e!==null;var oRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=hwt(t,e,r),o=s?.code==="ETIMEDOUT",a=twe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},hwt=(t,e,r)=>t!==void 0?t:nW(e,r)?new ao:void 0;var aRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gwt(t,e,r),d=Swt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Mg(d,c,l)},gwt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JO(t,e,r),a=_wt(r),{file:c,commandArguments:l,options:u}=_P(t,e,a);ywt(u);let d=Mwe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_wt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ywt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&DP("ipcInput"),t&&DP("ipc: true"),r&&DP("detached: true"),n&&DP("cancelSignal")},DP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Swt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Ewt({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}=oRe(c,r),{output:h,error:m=l}=tRe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,y)=>kc(v,r,y)),S=kc(rRe(h,r),r,"all");return Twt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},Ewt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Jwe(s,r);let a=vwt(r);return mwt(...yP(t,e,a))}catch(a){return Dg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},vwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RP(e)}),Twt=({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?AP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):YT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as lAt}from"events";import{spawn as uAt}from"child_process";import fRe from"process";import{once as iW,on as bwt}from"events";var cRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Og({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:dP(t)}),wwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),wwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{aP(e,i);let s=Au(t,e,r),o=new AbortController;try{return await Promise.race([Rwt(s,n,o),Awt(s,r,o),xwt(s,r,o)])}catch(a){throw Pg(t),a}finally{o.abort(),cP(e,i)}},Rwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await iW(t,"message",{signal:r});return n}for await(let[n]of bwt(t,"message",{signal:r}))if(e(n))return n},Awt=async(t,e,{signal:r})=>{await iW(t,"disconnect",{signal:r}),YTe(e)},xwt=async(t,e,{signal:r})=>{let[n]=await iW(t,"strict:error",{signal:r});throw iP(n,e)};import{once as uRe,on as Cwt}from"events";var dRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>sW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),sW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Og({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:dP(t)}),aP(e,s);let o=Au(t,e,r),a=new AbortController,c={};return Iwt(t,o,a),Owt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Pwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Iwt=async(t,e,r)=>{try{await uRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Owt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await uRe(t,"strict:error",{signal:r.signal});n.error=iP(i,e),r.abort()}catch{}},Pwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Cwt(r,"message",{signal:s.signal}))lRe(o),yield c}catch{lRe(o)}finally{s.abort(),cP(e,a),n||Pg(t),i&&await t}},lRe=({error:t})=>{if(t)throw t};var pRe=(t,{ipc:e})=>{Object.assign(t,mRe(t,!1,e))},hRe=()=>{let t=fRe,e=!0,r=fRe.channel!==void 0;return{...mRe(t,e,r),getCancelSignal:vbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},mRe=(t,e,r)=>({sendMessage:mP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:cRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:dRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Nwt}from"child_process";import{PassThrough as kwt,Readable as $wt,Writable as Lwt,Duplex as Dwt}from"stream";var gRe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{K3(n);let a=new Nwt;Mwt(a,n),Object.assign(a,{readable:Uwt,writable:Fwt,duplex:jwt});let c=Dg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=zwt(c,o,i);return{subprocess:a,promise:l}},Mwt=(t,e)=>{let r=ZT(),n=ZT(),i=ZT(),s=Array.from({length:e.length-3},ZT),o=ZT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},ZT=()=>{let t=new kwt;return t.end(),t},Uwt=()=>new $wt({read(){}}),Fwt=()=>new Lwt({write(){}}),jwt=()=>new Dwt({read(){},write(){}}),zwt=async(t,e,r)=>Mg(t,e,r);import{createReadStream as _Re,createWriteStream as yRe}from"fs";import{Buffer as qwt}from"buffer";import{Readable as JT,Writable as Bwt,Duplex as Vwt}from"stream";var ERe=(t,e)=>OP(Hwt,t,e,!1),XT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${xu[t]}.`)},SRe={fileNumber:XT,generator:tW,asyncGenerator:tW,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Vwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Hwt={input:{...SRe,fileUrl:({value:t})=>({stream:_Re(t)}),filePath:({value:{file:t}})=>({stream:_Re(t)}),webStream:({value:t})=>({stream:JT.fromWeb(t)}),iterable:({value:t})=>({stream:JT.from(t)}),asyncIterable:({value:t})=>({stream:JT.from(t)}),string:({value:t})=>({stream:JT.from(t)}),uint8Array:({value:t})=>({stream:JT.from(qwt.from(t))})},output:{...SRe,fileUrl:({value:t})=>({stream:yRe(t)}),filePath:({value:{file:t,append:e}})=>({stream:yRe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Bwt.fromWeb(t)}),iterable:XT,asyncIterable:XT,string:XT,uint8Array:XT}};import{on as Gwt,once as vRe}from"events";import{PassThrough as Wwt,getDefaultHighWaterMark as Ywt}from"stream";import{finished as wRe}from"stream/promises";function Yf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)aW(i);let e=t.some(({readableObjectMode:i})=>i),r=Kwt(t,e),n=new oW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Kwt=(t,e)=>{if(t.length===0)return Ywt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},oW=class extends Wwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(aW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Zwt(this,this.#e,this.#s);let r=Qwt({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(aW(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)}},Zwt=async(t,e,r)=>{MP(t,TRe);let n=new AbortController;try{await Promise.race([Jwt(t,n),Xwt(t,e,r,n)])}finally{n.abort(),MP(t,-TRe)}},Jwt=async(t,{signal:e})=>{try{await wRe(t,{signal:e,cleanup:!0})}catch(r){throw RRe(t,r),r}},Xwt=async(t,e,r,{signal:n})=>{for await(let[i]of Gwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},aW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Qwt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{MP(t,bRe);let a=new AbortController;try{await Promise.race([eRt(s,e,a),tRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),rRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),MP(t,-bRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?cW(t):nRt(t))},eRt=async(t,e,{signal:r})=>{try{await t,r.aborted||cW(e)}catch(n){r.aborted||RRe(e,n)}},tRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await wRe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;ARe(o)?i.add(e):xRe(t,o)}},rRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await vRe(t,i,{signal:s}),!t.readable)return vRe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},nRt=t=>{t.writable&&t.end()},RRe=(t,e)=>{ARe(e)?cW(t):xRe(t,e)},ARe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",cW=t=>{(t.readable||t.writable)&&t.destroy()},xRe=(t,e)=>{t.destroyed||(t.once("error",iRt),t.destroy(e))},iRt=()=>{},MP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},TRe=2,bRe=1;import{finished as CRe}from"stream/promises";var Fg=(t,e)=>{t.pipe(e),sRt(t,e),oRt(t,e)},sRt=async(t,e)=>{if(!(oo(t)||oo(e))){try{await CRe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}lW(e)}},lW=t=>{t.writable&&t.end()},oRt=async(t,e)=>{if(!(oo(t)||oo(e))){try{await CRe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}uW(t)}},uW=t=>{t.readable&&t.destroy()};var IRe=(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})=>Os.has(c)))aRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Os.has(c)))lRt({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]:Yf(s);Fg(o,i)}},aRt=(t,e,r,n)=>{r==="output"?Fg(t.stdio[n],e):Fg(e,t.stdio[n]);let i=cRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},cRt=["stdin","stdout","stderr"],lRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;uRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},uRt=(t,{signal:e})=>{oo(t)&&Vf(t,dRt,e)},dRt=2;import{addAbortListener as hRt}from"events";var Kf=[];Kf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Kf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Kf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var UP=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",dW=Symbol.for("signal-exit emitter"),fW=globalThis,fRt=Object.defineProperty.bind(Object),pW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(fW[dW])return fW[dW];fRt(fW,dW,{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}},FP=class{},pRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),hW=class extends FP{onExit(){return()=>{}}load(){}unload(){}},mW=class extends FP{#e=gW.platform==="win32"?"SIGINT":"SIGHUP";#r=new pW;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Kf)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(!UP(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 Kf)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,Kf.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 UP(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"&&UP(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)}},gW=globalThis.process,{onExit:ORe,load:Dmr,unload:Mmr}=pRt(UP(gW)?new mW(gW):new hW);var PRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ORe(()=>{t.kill()});hRt(n,()=>{i()})};var kRe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=ZO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mRt(r,n,i),{sourceStream:d,sourceError:f}=_Rt(t,l),{options:p,fileDescriptors:h}=da.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},mRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=gRt(t,e,...r),a=oP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},gRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(NRe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||s3(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]=jO(r,...n);return{destination:e(NRe)(i,s,o),pipeOptions:o}}if(da.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}`)},NRe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_Rt=(t,e)=>{try{return{sourceStream:Ng(t,e)}}catch(r){return{sourceError:r}}};var LRe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=yRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw _W({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},yRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return uW(t),n;if(e!==void 0)return lW(r),e},_W=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Dg({error:t,command:$Re,escapedCommand:$Re,fileDescriptors:e,options:r,startTime:n,isSync:!1}),$Re="source.pipe(destination)";var DRe=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 SRt}from"stream/promises";var MRe=(t,e,r)=>{let n=jP.has(e)?vRt(t,e):ERt(t,e);return Vf(t,bRt,r.signal),Vf(e,wRt,r.signal),TRt(e),n},ERt=(t,e)=>{let r=Yf([t]);return Fg(r,e),jP.set(e,r),r},vRt=(t,e)=>{let r=jP.get(e);return r.add(t),r},TRt=async t=>{try{await SRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jP.delete(t)},jP=new WeakMap,bRt=2,wRt=1;import{aborted as RRt}from"util";var URe=(t,e)=>t===void 0?[]:[ARt(t,e)],ARt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await RRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw _W({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var zP=(t,...e)=>{if(Cr(e[0]))return zP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=kRe(t,...e),i=xRt({...n,destination:r});return i.pipe=zP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},xRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=CRt(t,i);LRe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=MRe(e,s,d);return await Promise.race([DRe(u),...URe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},CRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as LRt}from"timers/promises";import{on as IRt}from"events";import{getDefaultHighWaterMark as ORt}from"stream";var qP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return PRt(e,o),jRe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},PRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},yW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;NRt(e,o,t);let a=t.readableObjectMode&&!s;return jRe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},NRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},jRe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=IRt(t,"data",{signal:e.signal,highWaterMark:FRe,highWatermark:FRe});return kRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},SW=ORt(!0),FRe=SW,kRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=$Rt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Wf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*KT(a)}},$Rt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NP(t,r,!e),PP(t,i,!n,{})].filter(Boolean);var zRe=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=DRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([MRt(t),d]);return}let f=Z3(c,r),p=yW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([URt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},DRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!LP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=yW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Xwe(a,t,r,s)},MRt=async t=>{await LRt(),t.readableFlowing===null&&t.resume()},URt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await TP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await bP(r,{maxBuffer:s})):await Lg(r,{maxBuffer:s})}catch(a){return qRe(Xbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},EW=async t=>{try{return await t}catch(e){return qRe(e)}},qRe=({bufferedData:t})=>hve(t)?new Uint8Array(t):t;import{finished as FRt}from"stream/promises";var QT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=jRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],FRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||BRt(a,e,r,n)}finally{o.abort()}},jRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&zRt(t,r,n),n},zRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qRt(e,r),n.call(t,...i)}},qRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},BRt=(t,e,r,n)=>{if(!VRt(t,e,r,n))throw t},VRt=(t,e,r,n=!0)=>r.propagating?BRe(t)||BP(t):(r.propagating=!0,vW(r,e)===n?BRe(t):BP(t)),vW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",BP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",BRe=t=>t?.code==="EPIPE";var VRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>TW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),TW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=QT(t,e,l);if(vW(l,e)){await u;return}let[d]=await Promise.all([zRe({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 HRe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Yf([t,e].filter(Boolean)):void 0,GRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>TW({...HRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:GRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),HRt=({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}},GRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as WRt}from"events";var WRe=t=>xg(t,"ipc"),YRe=(t,e)=>{let r=KO(t);la({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var KRe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=WRe(s),a=Pc(e,"ipc"),c=Pc(r,"ipc");for await(let l of sW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Qbe(t,i,c),i.push(l)),o&&YRe(l,s);return i},ZRe=async(t,e)=>(await Promise.allSettled([t]),e);var JRe=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:S})=>{let v=nRe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=VRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=GRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],R=KRe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=YRt(m,t,y),C=KRt(h,y);try{return await Promise.race([Promise.all([{},sRe(v),Promise.all(g),T,R,Pbe(t,d),...b,...C]),_,ZRt(t,S),...Abe(t,s,f,S),...WTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...wbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},v,Promise.all(g.map(A=>EW(A))),EW(T),ZRe(R,w),Promise.allSettled(b),Promise.allSettled(C)])}},YRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:QT(n,i,r)),KRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>lo(s,{checkOpen:!1})&&!oo(s)).map(({type:i,value:s,stream:o=s})=>QT(o,n,e,{isSameDirection:Os.has(i),stopOnExit:i==="native"}))),ZRt=async(t,{signal:e})=>{let[r]=await WRt(t,"error",{signal:e});throw r};var XRe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),eb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ua();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},jg=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 JRt}from"stream";import{callbackify as XRt}from"util";import{finished as QRe}from"stream/promises";var bW=async t=>{if(t!==void 0)try{await wW(t)}catch{}},eAe=async t=>{if(t!==void 0)try{await RW(t)}catch{}},wW=async t=>{await QRe(t,{cleanup:!0,readable:!1,writable:!0})},RW=async t=>{await QRe(t,{cleanup:!0,readable:!0,writable:!1})},VP=async(t,e)=>{if(await t,e)throw e},HP=(t,e,r)=>{r&&!BP(r)?t.destroy(r):e&&t.destroy()};var tAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Ki.has(r),{subprocessStdout:a,waitReadableDestroy:c}=AW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=xW(a,o),{read:f,onStdoutDataDone:p}=CW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new JRt({read:f,destroy:XRt(OW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return IW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},AW=(t,e,r)=>{let n=Ng(t,e),i=eb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},xW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:SW},CW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ua(),o=qP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){QRt(this,o,s)},onStdoutDataDone:s}},QRt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},IW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await RW(t),await n,await bW(i),await e,r.readable&&r.push(null)}catch(s){await bW(i),rAe(r,s)}},OW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await jg(r,e)&&(rAe(t,n),await VP(e,n))},rAe=(t,e)=>{HP(t,t.readable,e)};import{Writable as eAt}from"stream";import{callbackify as nAe}from"util";var iAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=PW(t,r,e),o=new eAt({...NW(n,t,i),destroy:nAe($W.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return kW(n,o),o},PW=(t,e,r)=>{let n=oP(t,e),i=eb(r,n,"writableFinal"),s=eb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},NW=(t,e,r)=>({write:tAt.bind(void 0,t),final:nAe(rAt.bind(void 0,t,e,r))}),tAt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rAt=async(t,e,r)=>{await jg(r,e)&&(t.writable&&t.end(),await e)},kW=async(t,e,r)=>{try{await wW(t),e.writable&&e.end()}catch(n){await eAe(r),sAe(e,n)}},$W=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await jg(r,e),await jg(n,e)&&(sAe(t,i),await VP(e,i))},sAe=(t,e)=>{HP(t,t.writable,e)};import{Duplex as nAt}from"stream";import{callbackify as iAt}from"util";var oAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Ki.has(r),{subprocessStdout:c,waitReadableDestroy:l}=AW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=PW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=xW(c,a),{read:_,onStdoutDataDone:S}=CW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new nAt({read:_,...NW(u,t,d),destroy:iAt(sAt.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 IW({subprocessStdout:c,onStdoutDataDone:S,readable:v,subprocess:t,subprocessStdin:u}),kW(u,v,c),v},sAt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([OW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),$W({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var LW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Ki.has(e),o=Ng(t,r),a=qP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return oAt(a,o,t)},oAt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var aAe=(t,{encoding:e})=>{let r=XRe();t.readable=tAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=iAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=oAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=LW.bind(void 0,t,e),t[Symbol.asyncIterator]=LW.bind(void 0,t,e,{})};var cAe=(t,e)=>{for(let[r,n]of cAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},aAt=(async()=>{})().constructor.prototype,cAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aAt,t)]);var lAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dAt(t,e,r),{subprocess:f,promise:p}=pAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=zP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),cAe(f,p),da.set(f,{options:u,fileDescriptors:d}),f},dAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JO(t,e,r),{file:a,commandArguments:c,options:l}=_P(t,e,r),u=fAt(l),d=ERe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},fAt=({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}},pAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uAt(...yP(t,e,r))}catch(h){return gRe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;lAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];IRe(c,a,l),PRe(c,r,l);let d={},f=ua();c.kill=HTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=HRe(c,r),aAe(c,r),pRe(c,r);let p=hAt({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}},hAt=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 JRe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((g,T)=>kc(g,e,T)),v=kc(m,e,"all"),y=mAt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Mg(y,n,e)},mAt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?YT({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof fa,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):AP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var GP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,gAt(n,t[n],i)]));return{...t,...r}},gAt=(t,e,r)=>_At.has(t)&&Cr(e)&&Cr(r)?{...e,...r}:r,_At=new Set(["env",...d3]);var Cu=(t,e,r,n)=>{let i=(o,a,c)=>Cu(o,a,r,c),s=(...o)=>yAt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},yAt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Cr(s))return i(t,GP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=SAt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?aRe(a,c,l):lAe(a,c,l,i)},SAt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Eve(e)?vve(e,r):[e,...r],[o,a,c]=jO(...s),l=GP(GP(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 uAe=({file:t,commandArguments:e})=>fAe(t,e),dAe=({file:t,commandArguments:e})=>({...fAe(t,e),isSync:!0}),fAe=(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]=EAt(t);return{file:r,commandArguments:n}},EAt=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(vAt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},vAt=/ +/g;var pAe=(t,e,r)=>{t.sync=e(TAt,r),t.s=t.sync},hAe=({options:t})=>mAe(t),TAt=({options:t})=>({...mAe(t),isSync:!0}),mAe=t=>({options:{...bAt(t),...t}}),bAt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},gAe={preferLocal:!0};var _Ae=Cu(()=>({})),Ayr=Cu(()=>({isSync:!0})),yAe=Cu(uAe),xyr=Cu(dAe),Cyr=Cu(Cbe),Iyr=Cu(hAe,{},gAe,pAe),{sendMessage:Oyr,getOneMessage:Pyr,getEachMessage:Nyr,getCancelSignal:kyr}=hRe();import{Transform as wAt}from"stream";var RAt=["NETLIFY_AI_GATEWAY_KEY"];function AAt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...RAt])]}function xAt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function CAt(){let e=AAt().map(r=>process.env[r]).filter(r=>!(!r||xAt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ni(t){if(typeof t!="string")return t;let e=CAt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(IAt(n),"g");r=r.replace(i,"******")}),r}function IAt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var tb=class extends wAt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ni(i);n(null,s)}},WP=Symbol("maskedWrite");function SAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[WP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ni(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WP]=!0,process.stdout.write=r}if(!process.stderr.write[WP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ni(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WP]=!0,process.stderr.write=r}}}var EAe=!1,vAe,DW=t=>{vAe??=t},TAe=t=>{EAe=!0,DW(t)},In=()=>EAe,Iu=()=>vAe;var rb=null,bAe=t=>(rb&&rb.destroy(),rb=new uo({totalAllowedTime:t}),rb),wAe=()=>rb;var uo=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&&In())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 LO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Q.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 RAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.187.0-count-api-reqs.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.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.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.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var kAt=PAt(import.meta.url),$At=$c.dirname(kAt),LAt=NAt(import.meta.url),zg=fe("shell"),MW=new Set,AAe={preferLocal:!0},ir=(t,e,r)=>{let[n,i]=DAt(e,r),s={...AAe,...i},o=_Ae(t,n,s);CAe(o,s),PAe(o);let a=r?.idleTimeout;return a&&a>0&&OAe(o,a),o},xAe=(t,e)=>{let r={...AAe,...e},n=yAe(t,r);return CAe(n,r),PAe(n),e?.idleTimeout&&e.idleTimeout>0&&OAe(n,e.idleTimeout),n},DAt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},CAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ha.env.NETLIFY_LOCAL_QUIET==="true")return;if(ha.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new tb).pipe(ha.stdout),t.stderr?.pipe(new tb).pipe(ha.stderr);return}t.stdout?.pipe(ha.stdout),t.stderr?.pipe(ha.stderr)},UW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ha.kill(-t.pid,e),zg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return zg.error("Error killing process:",r),!1}},IAe=t=>UW(t,"SIGKILL"),OAe=(t,e)=>{let r=null,n=()=>{zg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),UW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(zg.log(`Force killing idle process ${t.pid}`),IAe(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)},PAe=t=>{MW.add(t);let e=wAe();if(e){let r=e.onTimesUp(()=>{zg.log(`Global timer expired, killing process ${t.pid}`),UW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(zg.log(`Force killing process ${t.pid} after timeout`),IAe(t))},5e3)});t.on("exit",()=>{MW.delete(t),r()}),t.on("error",()=>{MW.delete(t),r()})}};function ma(t,e){if(!ha.env.NETLIFY_LOCAL_MODE)try{let i=LAt.resolve(RAe.name),s=$c.dirname(i);for(;s!==$c.dirname(s);){let o=$c.dirname(s);if($c.basename(o)==="node_modules"){let a=$c.join(o,".bin",e);if(YP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(ha.env.NODE_PATH){let i=$c.join(ha.env.NODE_PATH,".bin",e);if(YP.existsSync(i))return i}let r=$c.join(t,"node_modules",".bin",e);if(YP.existsSync(r))return r;let n=$c.join($At,"..","node_modules",".bin",e);if(YP.existsSync(n))return n}import _D from"process";import{fileURLToPath as dFt}from"url";import{createRequire as fFt}from"module";import rR from"path";import{readFileSync as pFt}from"fs";var MAt="__netlify__getTracer",UAt="__netlify__shutdownTracers",Tt=(t,e)=>globalThis[MAt]?.(t,e),NAe=async()=>globalThis[UAt]?.();function nb(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as iFt}from"timers/promises";Ne();import Fxt from"process";Ne();var c0t=(t,e)=>{e.recordException(t),e.setStatus({code:Wn.ERROR})};var Mc=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}=R0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>A0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=R0e(r,n,i),c=this._tracer.startSpan(e,s,o);return A0e(c,s,a)}};function R0e(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??Ht.active(),{opts:n,ctx:i,fn:s}}function A0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:c0t,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)}}Ne();var Yg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var yY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=D0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Yg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Yg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=D0e(this._rawAttributes),this._schemaUrl=l0t(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,Yg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&le.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Yg(n)){le.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=u0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function SY(t,e){return yY.FromAttributeList(Object.entries(t),e)}function D0e(t){return t.map(([e,r])=>Yg(r)?[e,r.catch(n=>{le.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function l0t(t){if(typeof t=="string"||t===void 0)return t;le.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function u0t(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;le.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var mb=class{emit(e){}enabled(){return!1}},M0e=new mb;var gb=Symbol.for("io.opentelemetry.js.api.logs"),Kg=globalThis;function U0e(t,e,r){return n=>n===t?e:r}var EY=1;var vY=class{getLogger(e,r,n){return new mb}},_N=new vY;var yN=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):M0e}};var _b=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new yN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:_N}_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 SN=class t{constructor(){this._proxyLoggerProvider=new _b}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Kg[gb]?this.getLoggerProvider():(Kg[gb]=U0e(EY,e,_N),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Kg[gb])===null||e===void 0?void 0:e.call(Kg,EY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Kg[gb],this._proxyLoggerProvider=new _b}};var F0e=SN.getInstance();function j0e(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 z0e(t){t.forEach(e=>e.disable())}function TY(t){let e=t.tracerProvider||Ot.getTracerProvider(),r=t.meterProvider||hb.getMeterProvider(),n=t.loggerProvider||F0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return j0e(i,e,r,n),()=>{z0e(i)}}Ne();var d0t=en("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function q0e(t){return t.getValue(d0t)===!0}var Zg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Zg||(Zg={}));Ne();var bY="[_0-9a-z-*/]",f0t=`[a-z]${bY}{0,255}`,p0t=`[a-z0-9]${bY}{0,240}@[a-z]${bY}{0,13}`,h0t=new RegExp(`^(?:${f0t}|${p0t})$`),m0t=/^[ -~]{0,255}[!-~]$/,g0t=/,|=/;function wY(t){return h0t.test(t)}function RY(t){return m0t.test(t)&&!g0t.test(t)}var _0t=32,B0e=512,V0e=",",H0e="=",EN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!wY(e)||!RY(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>B0e)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=V0e+e),e=`${n[0]}${H0e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(V0e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(H0e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!wY(a)||!RY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>B0e)&&(r.set(a,c),n=l,r.size>=_0t))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 vN="traceparent",TN="tracestate",y0t="00",S0t="(?!ff)[\\da-f]{2}",E0t="(?![0]{32})[\\da-f]{32}",v0t="(?![0]{16})[\\da-f]{16}",T0t="[\\da-f]{2}",b0t=new RegExp(`^\\s?(${S0t})-(${E0t})-(${v0t})-(${T0t})(-.*)?\\s?$`);function G0e(t){let e=b0t.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Nu=class{inject(e,r,n){let i=Ot.getSpanContext(e);if(!i||q0e(e)||!ki(i))return;let s=`${y0t}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Sr.NONE).toString(16)}`;n.set(r,vN,s),i.traceState&&n.set(r,TN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,vN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=G0e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,TN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new EN(typeof c=="string"?c:void 0)}return Ot.setSpanContext(e,o)}fields(){return[vN,TN]}};var bN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var yb=class{_isCalled=!1;_deferred=new bN;_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 hk=hn(uK(),1);Ne();var CIe=t=>{throw TypeError(t)},hK=(t,e,r)=>e.has(t)||CIe("Cannot "+r),pk=(t,e,r)=>(hK(t,e,"read from private field"),r?r.call(t):e.get(t)),dK=(t,e,r)=>e.has(t)?CIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),RIe=(t,e,r,n)=>(hK(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Uxt=(t,e,r)=>(hK(t,e,"access private method"),r),AIe="__netlify__getTracer",jxt="__netlify__shutdownTracers",zxt="__nfOTLPTrace",kb,$b,pK,IIe,qxt=class{constructor(){dK(this,pK),dK(this,kb),dK(this,$b),RIe(this,kb,new yb(Uxt(this,pK,IIe),this)),RIe(this,$b,le.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(pk(this,$b).debug(`export ${t.length.toString()} spans`),pk(this,kb).isCalled){e({code:Zg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zxt,JSON.stringify(Bxt(t))),e({code:Zg.SUCCESS})}shutdown(){return pk(this,kb).call()}};kb=new WeakMap;$b=new WeakMap;pK=new WeakSet;IIe=function(){return pk(this,$b).debug("Shutting down"),Promise.resolve()};function Bxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:fk(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||fo.SERVER,startTimeUnixNano:fK(e.startTime),endTimeUnixNano:fK(e.endTime),attributes:fk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:fK(n.time),attributes:fk(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:fk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function fk(t){return Object.keys(t).map(e=>OIe(e,t[e]))}function OIe(t,e){return{key:t,value:PIe(e)}}function PIe(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(PIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>OIe(r,n))}}:{}}function fK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var xIe={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"}},NIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,AIe))return;let e=Fxt.version.slice(1),r=SY({"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??[Vxt()],i=new hk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Nu});let s=t.instrumentations??[];TY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,AIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Mc(Ot.getTracer(a,c)):new Mc(Ot.getTracer(xIe.name,xIe.version))}}),Object.defineProperty(globalThis,jxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Vxt=()=>new hk.SimpleSpanProcessor(new qxt);Ne();var Lb=hn(uK(),1);Ne();import*as mk from"diagnostics_channel";var kIe=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?Wn.ERROR:Wn.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 Mc?t:new Mc(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){mk.subscribe(t,e);let r=()=>mk.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:fo.CLIENT},Ht.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:Wn.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 n1e=hn(t1e(),1);var mD=fe("tracing"),r1e=8e3,sFt=5e3,Qw=async(t=sFt)=>{try{await Promise.race([NAe(),iFt(t)])}catch(e){mD.warn("Failed to flush tracers on shutdown",e)}},i1e=async(t,e,r)=>{if(!Tt()){let n=[new Lb.SimpleSpanProcessor(new mJ),new Lb.SimpleSpanProcessor(new n1e.OTLPTraceExporter({url:r.exporterUrl}))];await NIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new kIe({skipHeaders:!0})]})}return r.traceparent?(di.setGlobalPropagator(new Nu),di.extract(Ht.active(),{traceparent:r.traceparent,isRemote:!0})):Ht.active()};function Yt(t,e,r){return mD.log(`\u23F3 TRACE: ${e} starting...`),nb(t,e,r)}var mJ=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(", ")}]`:"";mD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&mD.log(` \u274C Error: ${e.status.message}`)}};function gJ(){return Ve().captureLlmContentEnabled}function s1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function gD(t,e,r){let n={role:t,parts:[{type:"text",content:Ni(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var oFt=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 o1e(t,e,r,n){if(!t.length)return;let i=Tt();if(!i)return;let s=gJ(),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&&oFt.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>r1e?`${a.message.slice(0,r1e)}\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":Ni(_)}:{"gen_ai.output.messages":gD("assistant",_)}:{}}}).end(u)})}import{readdir as aFt,rm as cFt}from"fs/promises";import{join as lFt}from"path";async function a1e(t,e=[]){let n=(await aFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>cFt(lFt(t,i),{recursive:!0,force:!0})))}var uFt=300,eR=t=>Ve().budgetCreditThresholds[t.mode]?.[t.runner]??uFt,tR=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var _J=t=>{let e=eR(t);if(!tR(t,e))return"default";let r=Ve();return r.createAskFirstEnabled&&r.questionsEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},c1e=t=>{let e=_J(t),r=eR(t);return{budget_eligible:tR(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var hFt=rR.dirname(dFt(import.meta.url)),l1e=fFt(import.meta.url),mFt=rR.resolve(hFt,"scripts/scaffold.js"),gFt="scripts/scaffold.js",_Ft=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,yJ=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},yFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),SFt=t=>{let e=yJ(t);return e==="node"||e.endsWith("/node")},al=t=>{if(typeof t!="string")return!1;let e=t.match(_Ft)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&yFt(yJ(e[r]));)r+=1;if(r>=e.length||!SFt(e[r]))return!1;let n=e[r+1];return n?yJ(n).includes(gFt):!1},Lp=fe("create_stage"),SJ="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.",EFt=`${SJ}
|
|
597
|
+
if (condition) { yield value; }`)};import{Buffer as qbt}from"buffer";import{StringDecoder as Bbt}from"string_decoder";var NP=(t,e,r)=>{if(r)return;if(t)return{transform:Vbt.bind(void 0,new TextEncoder)};let n=new Bbt(e);return{transform:Hbt.bind(void 0,n),final:Gbt.bind(void 0,n)}},Vbt=function*(t,e){qbt.isBuffer(e)?yield Oc(e):typeof e=="string"?yield t.encode(e):yield e},Hbt=function*(t,e){yield Br(e)?t.write(e):e},Gbt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Hwe}from"util";var Q3=Hwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),kP=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Ybt}=e[r];for await(let i of n(t))yield*kP(i,e,r+1)},Gwe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Wbt(r,Number(e),t)},Wbt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*kP(n,r,e+1)},Wwe=Hwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Ybt=function*(t){yield t};var eW=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Ywe=(t,e)=>[...e.flatMap(r=>[...Wf(r,t,0)]),...KT(t)],Wf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Zbt}=e[r];for(let i of n(t))yield*Wf(i,e,r+1)},KT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kbt(r,Number(e),t)},Kbt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Wf(n,r,e+1)},Zbt=function*(t){yield t};var tW=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Zwe(t,o,s),l=Gf(e),u=Gf(r),d=l?Q3.bind(void 0,kP,a):eW.bind(void 0,Wf),f=l||u?Q3.bind(void 0,Gwe,a):eW.bind(void 0,KT),p=l||u?Wwe.bind(void 0,a):void 0;return{stream:new Jbt({writableObjectMode:n,writableHighWaterMark:Kwe(n),readableObjectMode:i,readableHighWaterMark:Kwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},$P=(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=Zwe(o,r,a);t=Ywe(c,t)}return t},Zwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:qwe(n,a)},NP(r,o,n),PP(r,s,n,c),{transform:t,final:e},{transform:Bwe(i,a)},zwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Jwe=(t,e)=>{for(let r of Xbt(t))Qbt(t,r,e)},Xbt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Qbt=(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 ${xu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>ewt(a,n));r.input=FT(o)},ewt=(t,e)=>{let r=$P(t,e,"utf8",!0);return twt(r),FT(r)},twt=t=>{let e=t.find(r=>typeof r!="string"&&!Br(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 swt,appendFileSync as owt}from"fs";var LP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&xg(r,n)&&!Ki.has(e)&&rwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&nwt.has(s))||t.every(({type:i})=>Os.has(i))),rwt=t=>t===1||t===2,nwt=new Set(["pipe","overlapped"]),Xwe=async(t,e,r,n)=>{for await(let i of t)iwt(e)||eRe(i,r,n)},Qwe=(t,e,r)=>{for(let n of t)eRe(n,e,r)},iwt=t=>t._readableState.pipes.length>0,eRe=(t,e,r)=>{let n=KO(t);la({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var tRe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>awt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},awt=({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=rwe(t,s,d),p=Oc(f),{stdioItems:h,objectMode:m}=e[r],_=cwt([p],h,c,n),{serializedResult:S,finalResult:v=S}=lwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?v:void 0;try{return n.error===void 0&&dwt(S,h,i),y}catch(g){return n.error=g,y}},cwt=(t,e,r,n)=>{try{return $P(t,e,r,!1)}catch(i){return n.error=i,t}},lwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:FT(t)};let o=gve(t,r);return n[s]?{serializedResult:o,finalResult:X3(o,!i[s],e)}:{serializedResult:o}},uwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!LP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=X3(t,!1,o);try{Qwe(a,e,n)}catch(c){r.error??=c}},dwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>IP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?owt(n,t):(r.add(s),swt(n,t))}};var rRe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,kc(e,r,"all")]:Array.isArray(e)?[kc(t,r,"all"),...e]:Br(t)&&Br(e)?a3([t,e]):`${t}${e}`};import{once as rW}from"events";var nRe=async(t,e)=>{let[r,n]=await fwt(t);return e.isForcefullyTerminated??=!1,[r,n]},fwt=async t=>{let[e,r]=await Promise.allSettled([rW(t,"spawn"),rW(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?iRe(t):r.value},iRe=async t=>{try{return await rW(t,"exit")}catch{return iRe(t)}},sRe=async t=>{let[e,r]=await t;if(!pwt(e,r)&&nW(e,r))throw new ao;return[e,r]},pwt=(t,e)=>t===void 0&&e===void 0,nW=(t,e)=>t!==0||e!==null;var oRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=hwt(t,e,r),o=s?.code==="ETIMEDOUT",a=twe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},hwt=(t,e,r)=>t!==void 0?t:nW(e,r)?new ao:void 0;var aRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gwt(t,e,r),d=Swt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Mg(d,c,l)},gwt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JO(t,e,r),a=_wt(r),{file:c,commandArguments:l,options:u}=_P(t,e,a);ywt(u);let d=Mwe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_wt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ywt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&DP("ipcInput"),t&&DP("ipc: true"),r&&DP("detached: true"),n&&DP("cancelSignal")},DP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Swt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Ewt({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}=oRe(c,r),{output:h,error:m=l}=tRe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,y)=>kc(v,r,y)),S=kc(rRe(h,r),r,"all");return Twt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},Ewt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Jwe(s,r);let a=vwt(r);return mwt(...yP(t,e,a))}catch(a){return Dg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},vwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RP(e)}),Twt=({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?AP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):YT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as lAt}from"events";import{spawn as uAt}from"child_process";import fRe from"process";import{once as iW,on as bwt}from"events";var cRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Og({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:dP(t)}),wwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),wwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{aP(e,i);let s=Au(t,e,r),o=new AbortController;try{return await Promise.race([Rwt(s,n,o),Awt(s,r,o),xwt(s,r,o)])}catch(a){throw Pg(t),a}finally{o.abort(),cP(e,i)}},Rwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await iW(t,"message",{signal:r});return n}for await(let[n]of bwt(t,"message",{signal:r}))if(e(n))return n},Awt=async(t,e,{signal:r})=>{await iW(t,"disconnect",{signal:r}),YTe(e)},xwt=async(t,e,{signal:r})=>{let[n]=await iW(t,"strict:error",{signal:r});throw iP(n,e)};import{once as uRe,on as Cwt}from"events";var dRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>sW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),sW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Og({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:dP(t)}),aP(e,s);let o=Au(t,e,r),a=new AbortController,c={};return Iwt(t,o,a),Owt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Pwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Iwt=async(t,e,r)=>{try{await uRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Owt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await uRe(t,"strict:error",{signal:r.signal});n.error=iP(i,e),r.abort()}catch{}},Pwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Cwt(r,"message",{signal:s.signal}))lRe(o),yield c}catch{lRe(o)}finally{s.abort(),cP(e,a),n||Pg(t),i&&await t}},lRe=({error:t})=>{if(t)throw t};var pRe=(t,{ipc:e})=>{Object.assign(t,mRe(t,!1,e))},hRe=()=>{let t=fRe,e=!0,r=fRe.channel!==void 0;return{...mRe(t,e,r),getCancelSignal:vbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},mRe=(t,e,r)=>({sendMessage:mP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:cRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:dRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Nwt}from"child_process";import{PassThrough as kwt,Readable as $wt,Writable as Lwt,Duplex as Dwt}from"stream";var gRe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{K3(n);let a=new Nwt;Mwt(a,n),Object.assign(a,{readable:Uwt,writable:Fwt,duplex:jwt});let c=Dg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=zwt(c,o,i);return{subprocess:a,promise:l}},Mwt=(t,e)=>{let r=ZT(),n=ZT(),i=ZT(),s=Array.from({length:e.length-3},ZT),o=ZT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},ZT=()=>{let t=new kwt;return t.end(),t},Uwt=()=>new $wt({read(){}}),Fwt=()=>new Lwt({write(){}}),jwt=()=>new Dwt({read(){},write(){}}),zwt=async(t,e,r)=>Mg(t,e,r);import{createReadStream as _Re,createWriteStream as yRe}from"fs";import{Buffer as qwt}from"buffer";import{Readable as JT,Writable as Bwt,Duplex as Vwt}from"stream";var ERe=(t,e)=>OP(Hwt,t,e,!1),XT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${xu[t]}.`)},SRe={fileNumber:XT,generator:tW,asyncGenerator:tW,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Vwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Hwt={input:{...SRe,fileUrl:({value:t})=>({stream:_Re(t)}),filePath:({value:{file:t}})=>({stream:_Re(t)}),webStream:({value:t})=>({stream:JT.fromWeb(t)}),iterable:({value:t})=>({stream:JT.from(t)}),asyncIterable:({value:t})=>({stream:JT.from(t)}),string:({value:t})=>({stream:JT.from(t)}),uint8Array:({value:t})=>({stream:JT.from(qwt.from(t))})},output:{...SRe,fileUrl:({value:t})=>({stream:yRe(t)}),filePath:({value:{file:t,append:e}})=>({stream:yRe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Bwt.fromWeb(t)}),iterable:XT,asyncIterable:XT,string:XT,uint8Array:XT}};import{on as Gwt,once as vRe}from"events";import{PassThrough as Wwt,getDefaultHighWaterMark as Ywt}from"stream";import{finished as wRe}from"stream/promises";function Yf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)aW(i);let e=t.some(({readableObjectMode:i})=>i),r=Kwt(t,e),n=new oW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Kwt=(t,e)=>{if(t.length===0)return Ywt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},oW=class extends Wwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(aW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Zwt(this,this.#e,this.#s);let r=Qwt({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(aW(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)}},Zwt=async(t,e,r)=>{MP(t,TRe);let n=new AbortController;try{await Promise.race([Jwt(t,n),Xwt(t,e,r,n)])}finally{n.abort(),MP(t,-TRe)}},Jwt=async(t,{signal:e})=>{try{await wRe(t,{signal:e,cleanup:!0})}catch(r){throw RRe(t,r),r}},Xwt=async(t,e,r,{signal:n})=>{for await(let[i]of Gwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},aW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Qwt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{MP(t,bRe);let a=new AbortController;try{await Promise.race([eRt(s,e,a),tRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),rRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),MP(t,-bRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?cW(t):nRt(t))},eRt=async(t,e,{signal:r})=>{try{await t,r.aborted||cW(e)}catch(n){r.aborted||RRe(e,n)}},tRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await wRe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;ARe(o)?i.add(e):xRe(t,o)}},rRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await vRe(t,i,{signal:s}),!t.readable)return vRe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},nRt=t=>{t.writable&&t.end()},RRe=(t,e)=>{ARe(e)?cW(t):xRe(t,e)},ARe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",cW=t=>{(t.readable||t.writable)&&t.destroy()},xRe=(t,e)=>{t.destroyed||(t.once("error",iRt),t.destroy(e))},iRt=()=>{},MP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},TRe=2,bRe=1;import{finished as CRe}from"stream/promises";var Fg=(t,e)=>{t.pipe(e),sRt(t,e),oRt(t,e)},sRt=async(t,e)=>{if(!(oo(t)||oo(e))){try{await CRe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}lW(e)}},lW=t=>{t.writable&&t.end()},oRt=async(t,e)=>{if(!(oo(t)||oo(e))){try{await CRe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}uW(t)}},uW=t=>{t.readable&&t.destroy()};var IRe=(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})=>Os.has(c)))aRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Os.has(c)))lRt({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]:Yf(s);Fg(o,i)}},aRt=(t,e,r,n)=>{r==="output"?Fg(t.stdio[n],e):Fg(e,t.stdio[n]);let i=cRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},cRt=["stdin","stdout","stderr"],lRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;uRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},uRt=(t,{signal:e})=>{oo(t)&&Vf(t,dRt,e)},dRt=2;import{addAbortListener as hRt}from"events";var Kf=[];Kf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Kf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Kf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var UP=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",dW=Symbol.for("signal-exit emitter"),fW=globalThis,fRt=Object.defineProperty.bind(Object),pW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(fW[dW])return fW[dW];fRt(fW,dW,{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}},FP=class{},pRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),hW=class extends FP{onExit(){return()=>{}}load(){}unload(){}},mW=class extends FP{#e=gW.platform==="win32"?"SIGINT":"SIGHUP";#r=new pW;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Kf)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(!UP(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 Kf)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,Kf.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 UP(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"&&UP(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)}},gW=globalThis.process,{onExit:ORe,load:Dmr,unload:Mmr}=pRt(UP(gW)?new mW(gW):new hW);var PRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ORe(()=>{t.kill()});hRt(n,()=>{i()})};var kRe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=ZO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mRt(r,n,i),{sourceStream:d,sourceError:f}=_Rt(t,l),{options:p,fileDescriptors:h}=da.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},mRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=gRt(t,e,...r),a=oP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},gRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(NRe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||s3(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]=jO(r,...n);return{destination:e(NRe)(i,s,o),pipeOptions:o}}if(da.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}`)},NRe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_Rt=(t,e)=>{try{return{sourceStream:Ng(t,e)}}catch(r){return{sourceError:r}}};var LRe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=yRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw _W({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},yRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return uW(t),n;if(e!==void 0)return lW(r),e},_W=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Dg({error:t,command:$Re,escapedCommand:$Re,fileDescriptors:e,options:r,startTime:n,isSync:!1}),$Re="source.pipe(destination)";var DRe=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 SRt}from"stream/promises";var MRe=(t,e,r)=>{let n=jP.has(e)?vRt(t,e):ERt(t,e);return Vf(t,bRt,r.signal),Vf(e,wRt,r.signal),TRt(e),n},ERt=(t,e)=>{let r=Yf([t]);return Fg(r,e),jP.set(e,r),r},vRt=(t,e)=>{let r=jP.get(e);return r.add(t),r},TRt=async t=>{try{await SRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jP.delete(t)},jP=new WeakMap,bRt=2,wRt=1;import{aborted as RRt}from"util";var URe=(t,e)=>t===void 0?[]:[ARt(t,e)],ARt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await RRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw _W({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var zP=(t,...e)=>{if(Cr(e[0]))return zP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=kRe(t,...e),i=xRt({...n,destination:r});return i.pipe=zP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},xRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=CRt(t,i);LRe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=MRe(e,s,d);return await Promise.race([DRe(u),...URe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},CRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as LRt}from"timers/promises";import{on as IRt}from"events";import{getDefaultHighWaterMark as ORt}from"stream";var qP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return PRt(e,o),jRe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},PRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},yW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;NRt(e,o,t);let a=t.readableObjectMode&&!s;return jRe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},NRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},jRe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=IRt(t,"data",{signal:e.signal,highWaterMark:FRe,highWatermark:FRe});return kRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},SW=ORt(!0),FRe=SW,kRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=$Rt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Wf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*KT(a)}},$Rt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NP(t,r,!e),PP(t,i,!n,{})].filter(Boolean);var zRe=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=DRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([MRt(t),d]);return}let f=Z3(c,r),p=yW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([URt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},DRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!LP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=yW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Xwe(a,t,r,s)},MRt=async t=>{await LRt(),t.readableFlowing===null&&t.resume()},URt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await TP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await bP(r,{maxBuffer:s})):await Lg(r,{maxBuffer:s})}catch(a){return qRe(Xbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},EW=async t=>{try{return await t}catch(e){return qRe(e)}},qRe=({bufferedData:t})=>hve(t)?new Uint8Array(t):t;import{finished as FRt}from"stream/promises";var QT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=jRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],FRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||BRt(a,e,r,n)}finally{o.abort()}},jRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&zRt(t,r,n),n},zRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qRt(e,r),n.call(t,...i)}},qRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},BRt=(t,e,r,n)=>{if(!VRt(t,e,r,n))throw t},VRt=(t,e,r,n=!0)=>r.propagating?BRe(t)||BP(t):(r.propagating=!0,vW(r,e)===n?BRe(t):BP(t)),vW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",BP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",BRe=t=>t?.code==="EPIPE";var VRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>TW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),TW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=QT(t,e,l);if(vW(l,e)){await u;return}let[d]=await Promise.all([zRe({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 HRe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Yf([t,e].filter(Boolean)):void 0,GRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>TW({...HRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:GRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),HRt=({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}},GRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as WRt}from"events";var WRe=t=>xg(t,"ipc"),YRe=(t,e)=>{let r=KO(t);la({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var KRe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=WRe(s),a=Pc(e,"ipc"),c=Pc(r,"ipc");for await(let l of sW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Qbe(t,i,c),i.push(l)),o&&YRe(l,s);return i},ZRe=async(t,e)=>(await Promise.allSettled([t]),e);var JRe=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:S})=>{let v=nRe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=VRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=GRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],R=KRe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=YRt(m,t,y),C=KRt(h,y);try{return await Promise.race([Promise.all([{},sRe(v),Promise.all(g),T,R,Pbe(t,d),...b,...C]),_,ZRt(t,S),...Abe(t,s,f,S),...WTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...wbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},v,Promise.all(g.map(A=>EW(A))),EW(T),ZRe(R,w),Promise.allSettled(b),Promise.allSettled(C)])}},YRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:QT(n,i,r)),KRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>lo(s,{checkOpen:!1})&&!oo(s)).map(({type:i,value:s,stream:o=s})=>QT(o,n,e,{isSameDirection:Os.has(i),stopOnExit:i==="native"}))),ZRt=async(t,{signal:e})=>{let[r]=await WRt(t,"error",{signal:e});throw r};var XRe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),eb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ua();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},jg=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 JRt}from"stream";import{callbackify as XRt}from"util";import{finished as QRe}from"stream/promises";var bW=async t=>{if(t!==void 0)try{await wW(t)}catch{}},eAe=async t=>{if(t!==void 0)try{await RW(t)}catch{}},wW=async t=>{await QRe(t,{cleanup:!0,readable:!1,writable:!0})},RW=async t=>{await QRe(t,{cleanup:!0,readable:!0,writable:!1})},VP=async(t,e)=>{if(await t,e)throw e},HP=(t,e,r)=>{r&&!BP(r)?t.destroy(r):e&&t.destroy()};var tAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Ki.has(r),{subprocessStdout:a,waitReadableDestroy:c}=AW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=xW(a,o),{read:f,onStdoutDataDone:p}=CW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new JRt({read:f,destroy:XRt(OW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return IW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},AW=(t,e,r)=>{let n=Ng(t,e),i=eb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},xW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:SW},CW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ua(),o=qP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){QRt(this,o,s)},onStdoutDataDone:s}},QRt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},IW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await RW(t),await n,await bW(i),await e,r.readable&&r.push(null)}catch(s){await bW(i),rAe(r,s)}},OW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await jg(r,e)&&(rAe(t,n),await VP(e,n))},rAe=(t,e)=>{HP(t,t.readable,e)};import{Writable as eAt}from"stream";import{callbackify as nAe}from"util";var iAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=PW(t,r,e),o=new eAt({...NW(n,t,i),destroy:nAe($W.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return kW(n,o),o},PW=(t,e,r)=>{let n=oP(t,e),i=eb(r,n,"writableFinal"),s=eb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},NW=(t,e,r)=>({write:tAt.bind(void 0,t),final:nAe(rAt.bind(void 0,t,e,r))}),tAt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rAt=async(t,e,r)=>{await jg(r,e)&&(t.writable&&t.end(),await e)},kW=async(t,e,r)=>{try{await wW(t),e.writable&&e.end()}catch(n){await eAe(r),sAe(e,n)}},$W=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await jg(r,e),await jg(n,e)&&(sAe(t,i),await VP(e,i))},sAe=(t,e)=>{HP(t,t.writable,e)};import{Duplex as nAt}from"stream";import{callbackify as iAt}from"util";var oAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Ki.has(r),{subprocessStdout:c,waitReadableDestroy:l}=AW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=PW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=xW(c,a),{read:_,onStdoutDataDone:S}=CW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new nAt({read:_,...NW(u,t,d),destroy:iAt(sAt.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 IW({subprocessStdout:c,onStdoutDataDone:S,readable:v,subprocess:t,subprocessStdin:u}),kW(u,v,c),v},sAt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([OW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),$W({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var LW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Ki.has(e),o=Ng(t,r),a=qP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return oAt(a,o,t)},oAt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var aAe=(t,{encoding:e})=>{let r=XRe();t.readable=tAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=iAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=oAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=LW.bind(void 0,t,e),t[Symbol.asyncIterator]=LW.bind(void 0,t,e,{})};var cAe=(t,e)=>{for(let[r,n]of cAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},aAt=(async()=>{})().constructor.prototype,cAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aAt,t)]);var lAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dAt(t,e,r),{subprocess:f,promise:p}=pAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=zP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),cAe(f,p),da.set(f,{options:u,fileDescriptors:d}),f},dAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JO(t,e,r),{file:a,commandArguments:c,options:l}=_P(t,e,r),u=fAt(l),d=ERe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},fAt=({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}},pAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uAt(...yP(t,e,r))}catch(h){return gRe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;lAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];IRe(c,a,l),PRe(c,r,l);let d={},f=ua();c.kill=HTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=HRe(c,r),aAe(c,r),pRe(c,r);let p=hAt({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}},hAt=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 JRe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((g,T)=>kc(g,e,T)),v=kc(m,e,"all"),y=mAt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Mg(y,n,e)},mAt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?YT({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof fa,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):AP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var GP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,gAt(n,t[n],i)]));return{...t,...r}},gAt=(t,e,r)=>_At.has(t)&&Cr(e)&&Cr(r)?{...e,...r}:r,_At=new Set(["env",...d3]);var Cu=(t,e,r,n)=>{let i=(o,a,c)=>Cu(o,a,r,c),s=(...o)=>yAt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},yAt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Cr(s))return i(t,GP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=SAt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?aRe(a,c,l):lAe(a,c,l,i)},SAt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Eve(e)?vve(e,r):[e,...r],[o,a,c]=jO(...s),l=GP(GP(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 uAe=({file:t,commandArguments:e})=>fAe(t,e),dAe=({file:t,commandArguments:e})=>({...fAe(t,e),isSync:!0}),fAe=(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]=EAt(t);return{file:r,commandArguments:n}},EAt=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(vAt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},vAt=/ +/g;var pAe=(t,e,r)=>{t.sync=e(TAt,r),t.s=t.sync},hAe=({options:t})=>mAe(t),TAt=({options:t})=>({...mAe(t),isSync:!0}),mAe=t=>({options:{...bAt(t),...t}}),bAt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},gAe={preferLocal:!0};var _Ae=Cu(()=>({})),Ayr=Cu(()=>({isSync:!0})),yAe=Cu(uAe),xyr=Cu(dAe),Cyr=Cu(Cbe),Iyr=Cu(hAe,{},gAe,pAe),{sendMessage:Oyr,getOneMessage:Pyr,getEachMessage:Nyr,getCancelSignal:kyr}=hRe();import{Transform as wAt}from"stream";var RAt=["NETLIFY_AI_GATEWAY_KEY"];function AAt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...RAt])]}function xAt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function CAt(){let e=AAt().map(r=>process.env[r]).filter(r=>!(!r||xAt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ni(t){if(typeof t!="string")return t;let e=CAt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(IAt(n),"g");r=r.replace(i,"******")}),r}function IAt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var tb=class extends wAt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ni(i);n(null,s)}},WP=Symbol("maskedWrite");function SAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[WP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ni(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WP]=!0,process.stdout.write=r}if(!process.stderr.write[WP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ni(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WP]=!0,process.stderr.write=r}}}var EAe=!1,vAe,DW=t=>{vAe??=t},TAe=t=>{EAe=!0,DW(t)},In=()=>EAe,Iu=()=>vAe;var rb=null,bAe=t=>(rb&&rb.destroy(),rb=new uo({totalAllowedTime:t}),rb),wAe=()=>rb;var uo=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&&In())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 LO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Q.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 RAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.188.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.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.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.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var kAt=PAt(import.meta.url),$At=$c.dirname(kAt),LAt=NAt(import.meta.url),zg=fe("shell"),MW=new Set,AAe={preferLocal:!0},ir=(t,e,r)=>{let[n,i]=DAt(e,r),s={...AAe,...i},o=_Ae(t,n,s);CAe(o,s),PAe(o);let a=r?.idleTimeout;return a&&a>0&&OAe(o,a),o},xAe=(t,e)=>{let r={...AAe,...e},n=yAe(t,r);return CAe(n,r),PAe(n),e?.idleTimeout&&e.idleTimeout>0&&OAe(n,e.idleTimeout),n},DAt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},CAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ha.env.NETLIFY_LOCAL_QUIET==="true")return;if(ha.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new tb).pipe(ha.stdout),t.stderr?.pipe(new tb).pipe(ha.stderr);return}t.stdout?.pipe(ha.stdout),t.stderr?.pipe(ha.stderr)},UW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ha.kill(-t.pid,e),zg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return zg.error("Error killing process:",r),!1}},IAe=t=>UW(t,"SIGKILL"),OAe=(t,e)=>{let r=null,n=()=>{zg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),UW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(zg.log(`Force killing idle process ${t.pid}`),IAe(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)},PAe=t=>{MW.add(t);let e=wAe();if(e){let r=e.onTimesUp(()=>{zg.log(`Global timer expired, killing process ${t.pid}`),UW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(zg.log(`Force killing process ${t.pid} after timeout`),IAe(t))},5e3)});t.on("exit",()=>{MW.delete(t),r()}),t.on("error",()=>{MW.delete(t),r()})}};function ma(t,e){if(!ha.env.NETLIFY_LOCAL_MODE)try{let i=LAt.resolve(RAe.name),s=$c.dirname(i);for(;s!==$c.dirname(s);){let o=$c.dirname(s);if($c.basename(o)==="node_modules"){let a=$c.join(o,".bin",e);if(YP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(ha.env.NODE_PATH){let i=$c.join(ha.env.NODE_PATH,".bin",e);if(YP.existsSync(i))return i}let r=$c.join(t,"node_modules",".bin",e);if(YP.existsSync(r))return r;let n=$c.join($At,"..","node_modules",".bin",e);if(YP.existsSync(n))return n}import _D from"process";import{fileURLToPath as dFt}from"url";import{createRequire as fFt}from"module";import rR from"path";import{readFileSync as pFt}from"fs";var MAt="__netlify__getTracer",UAt="__netlify__shutdownTracers",Tt=(t,e)=>globalThis[MAt]?.(t,e),NAe=async()=>globalThis[UAt]?.();function nb(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as iFt}from"timers/promises";Ne();import Fxt from"process";Ne();var c0t=(t,e)=>{e.recordException(t),e.setStatus({code:Wn.ERROR})};var Mc=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}=R0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>A0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=R0e(r,n,i),c=this._tracer.startSpan(e,s,o);return A0e(c,s,a)}};function R0e(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??Ht.active(),{opts:n,ctx:i,fn:s}}function A0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:c0t,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)}}Ne();var Yg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var yY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=D0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Yg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Yg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=D0e(this._rawAttributes),this._schemaUrl=l0t(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,Yg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&le.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Yg(n)){le.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=u0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function SY(t,e){return yY.FromAttributeList(Object.entries(t),e)}function D0e(t){return t.map(([e,r])=>Yg(r)?[e,r.catch(n=>{le.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function l0t(t){if(typeof t=="string"||t===void 0)return t;le.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function u0t(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;le.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var mb=class{emit(e){}enabled(){return!1}},M0e=new mb;var gb=Symbol.for("io.opentelemetry.js.api.logs"),Kg=globalThis;function U0e(t,e,r){return n=>n===t?e:r}var EY=1;var vY=class{getLogger(e,r,n){return new mb}},_N=new vY;var yN=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):M0e}};var _b=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new yN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:_N}_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 SN=class t{constructor(){this._proxyLoggerProvider=new _b}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Kg[gb]?this.getLoggerProvider():(Kg[gb]=U0e(EY,e,_N),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Kg[gb])===null||e===void 0?void 0:e.call(Kg,EY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Kg[gb],this._proxyLoggerProvider=new _b}};var F0e=SN.getInstance();function j0e(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 z0e(t){t.forEach(e=>e.disable())}function TY(t){let e=t.tracerProvider||Ot.getTracerProvider(),r=t.meterProvider||hb.getMeterProvider(),n=t.loggerProvider||F0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return j0e(i,e,r,n),()=>{z0e(i)}}Ne();var d0t=en("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function q0e(t){return t.getValue(d0t)===!0}var Zg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Zg||(Zg={}));Ne();var bY="[_0-9a-z-*/]",f0t=`[a-z]${bY}{0,255}`,p0t=`[a-z0-9]${bY}{0,240}@[a-z]${bY}{0,13}`,h0t=new RegExp(`^(?:${f0t}|${p0t})$`),m0t=/^[ -~]{0,255}[!-~]$/,g0t=/,|=/;function wY(t){return h0t.test(t)}function RY(t){return m0t.test(t)&&!g0t.test(t)}var _0t=32,B0e=512,V0e=",",H0e="=",EN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!wY(e)||!RY(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>B0e)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=V0e+e),e=`${n[0]}${H0e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(V0e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(H0e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!wY(a)||!RY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>B0e)&&(r.set(a,c),n=l,r.size>=_0t))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 vN="traceparent",TN="tracestate",y0t="00",S0t="(?!ff)[\\da-f]{2}",E0t="(?![0]{32})[\\da-f]{32}",v0t="(?![0]{16})[\\da-f]{16}",T0t="[\\da-f]{2}",b0t=new RegExp(`^\\s?(${S0t})-(${E0t})-(${v0t})-(${T0t})(-.*)?\\s?$`);function G0e(t){let e=b0t.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Nu=class{inject(e,r,n){let i=Ot.getSpanContext(e);if(!i||q0e(e)||!ki(i))return;let s=`${y0t}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Sr.NONE).toString(16)}`;n.set(r,vN,s),i.traceState&&n.set(r,TN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,vN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=G0e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,TN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new EN(typeof c=="string"?c:void 0)}return Ot.setSpanContext(e,o)}fields(){return[vN,TN]}};var bN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var yb=class{_isCalled=!1;_deferred=new bN;_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 hk=hn(uK(),1);Ne();var CIe=t=>{throw TypeError(t)},hK=(t,e,r)=>e.has(t)||CIe("Cannot "+r),pk=(t,e,r)=>(hK(t,e,"read from private field"),r?r.call(t):e.get(t)),dK=(t,e,r)=>e.has(t)?CIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),RIe=(t,e,r,n)=>(hK(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Uxt=(t,e,r)=>(hK(t,e,"access private method"),r),AIe="__netlify__getTracer",jxt="__netlify__shutdownTracers",zxt="__nfOTLPTrace",kb,$b,pK,IIe,qxt=class{constructor(){dK(this,pK),dK(this,kb),dK(this,$b),RIe(this,kb,new yb(Uxt(this,pK,IIe),this)),RIe(this,$b,le.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(pk(this,$b).debug(`export ${t.length.toString()} spans`),pk(this,kb).isCalled){e({code:Zg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zxt,JSON.stringify(Bxt(t))),e({code:Zg.SUCCESS})}shutdown(){return pk(this,kb).call()}};kb=new WeakMap;$b=new WeakMap;pK=new WeakSet;IIe=function(){return pk(this,$b).debug("Shutting down"),Promise.resolve()};function Bxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:fk(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||fo.SERVER,startTimeUnixNano:fK(e.startTime),endTimeUnixNano:fK(e.endTime),attributes:fk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:fK(n.time),attributes:fk(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:fk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function fk(t){return Object.keys(t).map(e=>OIe(e,t[e]))}function OIe(t,e){return{key:t,value:PIe(e)}}function PIe(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(PIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>OIe(r,n))}}:{}}function fK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var xIe={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"}},NIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,AIe))return;let e=Fxt.version.slice(1),r=SY({"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??[Vxt()],i=new hk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Nu});let s=t.instrumentations??[];TY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,AIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Mc(Ot.getTracer(a,c)):new Mc(Ot.getTracer(xIe.name,xIe.version))}}),Object.defineProperty(globalThis,jxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Vxt=()=>new hk.SimpleSpanProcessor(new qxt);Ne();var Lb=hn(uK(),1);Ne();import*as mk from"diagnostics_channel";var kIe=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?Wn.ERROR:Wn.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 Mc?t:new Mc(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){mk.subscribe(t,e);let r=()=>mk.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:fo.CLIENT},Ht.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:Wn.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 n1e=hn(t1e(),1);var mD=fe("tracing"),r1e=8e3,sFt=5e3,Qw=async(t=sFt)=>{try{await Promise.race([NAe(),iFt(t)])}catch(e){mD.warn("Failed to flush tracers on shutdown",e)}},i1e=async(t,e,r)=>{if(!Tt()){let n=[new Lb.SimpleSpanProcessor(new mJ),new Lb.SimpleSpanProcessor(new n1e.OTLPTraceExporter({url:r.exporterUrl}))];await NIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new kIe({skipHeaders:!0})]})}return r.traceparent?(di.setGlobalPropagator(new Nu),di.extract(Ht.active(),{traceparent:r.traceparent,isRemote:!0})):Ht.active()};function Yt(t,e,r){return mD.log(`\u23F3 TRACE: ${e} starting...`),nb(t,e,r)}var mJ=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(", ")}]`:"";mD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&mD.log(` \u274C Error: ${e.status.message}`)}};function gJ(){return Ve().captureLlmContentEnabled}function s1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function gD(t,e,r){let n={role:t,parts:[{type:"text",content:Ni(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var oFt=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 o1e(t,e,r,n){if(!t.length)return;let i=Tt();if(!i)return;let s=gJ(),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&&oFt.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>r1e?`${a.message.slice(0,r1e)}\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":Ni(_)}:{"gen_ai.output.messages":gD("assistant",_)}:{}}}).end(u)})}import{readdir as aFt,rm as cFt}from"fs/promises";import{join as lFt}from"path";async function a1e(t,e=[]){let n=(await aFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>cFt(lFt(t,i),{recursive:!0,force:!0})))}var uFt=300,eR=t=>Ve().budgetCreditThresholds[t.mode]?.[t.runner]??uFt,tR=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var _J=t=>{let e=eR(t);if(!tR(t,e))return"default";let r=Ve();return r.createAskFirstEnabled&&r.questionsEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},c1e=t=>{let e=_J(t),r=eR(t);return{budget_eligible:tR(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var hFt=rR.dirname(dFt(import.meta.url)),l1e=fFt(import.meta.url),mFt=rR.resolve(hFt,"scripts/scaffold.js"),gFt="scripts/scaffold.js",_Ft=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,yJ=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},yFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),SFt=t=>{let e=yJ(t);return e==="node"||e.endsWith("/node")},al=t=>{if(typeof t!="string")return!1;let e=t.match(_Ft)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&yFt(yJ(e[r]));)r+=1;if(r>=e.length||!SFt(e[r]))return!1;let n=e[r+1];return n?yJ(n).includes(gFt):!1},Lp=fe("create_stage"),SJ="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.",EFt=`${SJ}
|
|
598
598
|
|
|
599
599
|
Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,vFt=`${SJ}
|
|
600
600
|
|
package/dist/index.js
CHANGED
|
@@ -142,7 +142,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
142
142
|
`,LF:`
|
|
143
143
|
`,concatBytes:RU},FVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},zVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:FVe};import{Buffer as jVe}from"buffer";var Sae=(t,e)=>t?void 0:BVe.bind(void 0,e),BVe=function*(t,e){if(typeof e!="string"&&!dr(e)&&!jVe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Eae=(t,e)=>t?qVe.bind(void 0,e):VVe.bind(void 0,e),qVe=function*(t,e){vae(t,e),yield e},VVe=function*(t,e){if(vae(t,e),typeof e!="string"&&!dr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},vae=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
144
144
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
145
|
-
if (condition) { yield value; }`)};import{Buffer as GVe}from"buffer";import{StringDecoder as HVe}from"string_decoder";var AR=(t,e,r)=>{if(r)return;if(t)return{transform:WVe.bind(void 0,new TextEncoder)};let n=new HVe(e);return{transform:YVe.bind(void 0,n),final:KVe.bind(void 0,n)}},WVe=function*(t,e){GVe.isBuffer(e)?yield la(e):typeof e=="string"?yield t.encode(e):yield e},YVe=function*(t,e){yield dr(e)?t.write(e):e},KVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Tae}from"util";var IU=Tae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),xR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=JVe}=e[r];for await(let i of n(t))yield*xR(i,e,r+1)},bae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ZVe(r,Number(e),t)},ZVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*xR(n,r,e+1)},wae=Tae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),JVe=function*(t){yield t};var PU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Aae=(t,e)=>[...e.flatMap(r=>[...Du(r,t,0)]),...Wy(t)],Du=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QVe}=e[r];for(let i of n(t))yield*Du(i,e,r+1)},Wy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XVe(r,Number(e),t)},XVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Du(n,r,e+1)},QVe=function*(t){yield t};var OU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Rae(t,s,o),l=Mu(e),u=Mu(r),d=l?IU.bind(void 0,xR,a):PU.bind(void 0,Du),f=l||u?IU.bind(void 0,bae,a):PU.bind(void 0,Wy),p=l||u?wae.bind(void 0,a):void 0;return{stream:new eGe({writableObjectMode:n,writableHighWaterMark:xae(n),readableObjectMode:i,readableHighWaterMark:xae(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},RR=(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=Rae(s,r,a);t=Aae(c,t)}return t},Rae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Sae(n,a)},AR(r,s,n),wR(r,o,n,c),{transform:t,final:e},{transform:Eae(i,a)},yae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Cae=(t,e)=>{for(let r of tGe(t))rGe(t,r,e)},tGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),rGe=(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 ${Pc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>nGe(a,n));r.input=Ly(s)},nGe=(t,e)=>{let r=RR(t,e,"utf8",!0);return iGe(r),Ly(r)},iGe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(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 cGe,appendFileSync as lGe}from"fs";var CR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Rp(r,n)&&!ri.has(e)&&oGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&sGe.has(o))||t.every(({type:i})=>Pi.has(i))),oGe=t=>t===1||t===2,sGe=new Set(["pipe","overlapped"]),Iae=async(t,e,r,n)=>{for await(let i of t)aGe(e)||Oae(i,r,n)},Pae=(t,e,r)=>{for(let n of t)Oae(n,e,r)},aGe=t=>t._readableState.pipes.length>0,Oae=(t,e,r)=>{let n=Bx(t);is({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Nae=({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)=>uGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},uGe=({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=kse(t,o,d),p=la(f),{stdioItems:h,objectMode:m}=e[r],g=dGe([p],h,c,n),{serializedResult:y,finalResult:v=y}=fGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});pGe({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?v:void 0;try{return n.error===void 0&&hGe(y,h,i),T}catch(w){return n.error=w,T}},dGe=(t,e,r,n)=>{try{return RR(t,e,r,!1)}catch(i){return n.error=i,t}},fGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Ly(t)};let s=Wne(t,r);return n[o]?{serializedResult:s,finalResult:CU(s,!i[o],e)}:{serializedResult:s}},pGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!CR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=CU(t,!1,s);try{Pae(a,e,n)}catch(c){r.error??=c}},hGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>TR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?lGe(n,t):(r.add(o),cGe(n,t))}};var kae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,fa(e,r,"all")]:Array.isArray(e)?[fa(t,r,"all"),...e]:dr(t)&&dr(e)?L1([t,e]):`${t}${e}`};import{once as NU}from"events";var Mae=async(t,e)=>{let[r,n]=await mGe(t);return e.isForcefullyTerminated??=!1,[r,n]},mGe=async t=>{let[e,r]=await Promise.allSettled([NU(t,"spawn"),NU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Dae(t):r.value},Dae=async t=>{try{return await NU(t,"exit")}catch{return Dae(t)}},$ae=async t=>{let[e,r]=await t;if(!gGe(e,r)&&kU(e,r))throw new lo;return[e,r]},gGe=(t,e)=>t===void 0&&e===void 0,kU=(t,e)=>t!==0||e!==null;var Lae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=_Ge(t,e,r),s=o?.code==="ETIMEDOUT",a=Nse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},_Ge=(t,e,r)=>t!==void 0?t:kU(e,r)?new lo:void 0;var Uae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=SGe(t,e,r),d=TGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Lp(d,c,l)},SGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Vx(t,e,r),a=EGe(r),{file:c,commandArguments:l,options:u}=uR(t,e,a);vGe(u);let d=hae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},EGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vGe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&IR("ipcInput"),t&&IR("ipc: true"),r&&IR("detached: true"),n&&IR("cancelSignal")},IR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},TGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=bGe({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}=Lae(c,r),{output:h,error:m=l}=Nae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,T)=>fa(v,r,T)),y=fa(kae(h,r),r,"all");return AGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},bGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Cae(o,r);let a=wGe(r);return yGe(...dR(t,e,a))}catch(a){return $p({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:yR(e)}),AGe=({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?SR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Hy({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 fHe}from"events";import{spawn as pHe}from"child_process";import qae from"process";import{once as MU,on as xGe}from"events";var Fae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Pp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:iR(t)}),RGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),RGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{eR(e,i);let o=Ic(t,e,r),s=new AbortController;try{return await Promise.race([CGe(o,n,s),IGe(o,r,s),PGe(o,r,s)])}catch(a){throw Op(t),a}finally{s.abort(),tR(e,i)}},CGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await MU(t,"message",{signal:r});return n}for await(let[n]of xGe(t,"message",{signal:r}))if(e(n))return n},IGe=async(t,e,{signal:r})=>{await MU(t,"disconnect",{signal:r}),Aoe(e)},PGe=async(t,e,{signal:r})=>{let[n]=await MU(t,"strict:error",{signal:r});throw Jx(n,e)};import{once as jae,on as OGe}from"events";var Bae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>DU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),DU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Pp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:iR(t)}),eR(e,o);let s=Ic(t,e,r),a=new AbortController,c={};return NGe(t,s,a),kGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),MGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},NGe=async(t,e,r)=>{try{await jae(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await jae(t,"strict:error",{signal:r.signal});n.error=Jx(i,e),r.abort()}catch{}},MGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of OGe(r,"message",{signal:o.signal}))zae(s),yield c}catch{zae(s)}finally{o.abort(),tR(e,a),n||Op(t),i&&await t}},zae=({error:t})=>{if(t)throw t};var Vae=(t,{ipc:e})=>{Object.assign(t,Hae(t,!1,e))},Gae=()=>{let t=qae,e=!0,r=qae.channel!==void 0;return{...Hae(t,e,r),getCancelSignal:Xoe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Hae=(t,e,r)=>({sendMessage:cR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Fae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Bae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as DGe}from"child_process";import{PassThrough as $Ge,Readable as LGe,Writable as UGe,Duplex as FGe}from"stream";var Wae=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{AU(n);let a=new DGe;zGe(a,n),Object.assign(a,{readable:jGe,writable:BGe,duplex:qGe});let c=$p({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=VGe(c,s,i);return{subprocess:a,promise:l}},zGe=(t,e)=>{let r=Yy(),n=Yy(),i=Yy(),o=Array.from({length:e.length-3},Yy),s=Yy(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Yy=()=>{let t=new $Ge;return t.end(),t},jGe=()=>new LGe({read(){}}),BGe=()=>new UGe({write(){}}),qGe=()=>new FGe({read(){},write(){}}),VGe=async(t,e,r)=>Lp(t,e,r);import{createReadStream as Yae,createWriteStream as Kae}from"fs";import{Buffer as GGe}from"buffer";import{Readable as Ky,Writable as HGe,Duplex as WGe}from"stream";var Jae=(t,e)=>bR(YGe,t,e,!1),Zy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Pc[t]}.`)},Zae={fileNumber:Zy,generator:OU,asyncGenerator:OU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:WGe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},YGe={input:{...Zae,fileUrl:({value:t})=>({stream:Yae(t)}),filePath:({value:{file:t}})=>({stream:Yae(t)}),webStream:({value:t})=>({stream:Ky.fromWeb(t)}),iterable:({value:t})=>({stream:Ky.from(t)}),asyncIterable:({value:t})=>({stream:Ky.from(t)}),string:({value:t})=>({stream:Ky.from(t)}),uint8Array:({value:t})=>({stream:Ky.from(GGe.from(t))})},output:{...Zae,fileUrl:({value:t})=>({stream:Kae(t)}),filePath:({value:{file:t,append:e}})=>({stream:Kae(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:HGe.fromWeb(t)}),iterable:Zy,asyncIterable:Zy,string:Zy,uint8Array:Zy}};import{on as KGe,once as Xae}from"events";import{PassThrough as ZGe,getDefaultHighWaterMark as JGe}from"stream";import{finished as tce}from"stream/promises";function $u(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)LU(i);let e=t.some(({readableObjectMode:i})=>i),r=XGe(t,e),n=new $U({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var XGe=(t,e)=>{if(t.length===0)return JGe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},$U=class extends ZGe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(LU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=QGe(this,this.#e,this.#o);let r=r4e({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(LU(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)}},QGe=async(t,e,r)=>{PR(t,Qae);let n=new AbortController;try{await Promise.race([e4e(t,n),t4e(t,e,r,n)])}finally{n.abort(),PR(t,-Qae)}},e4e=async(t,{signal:e})=>{try{await tce(t,{signal:e,cleanup:!0})}catch(r){throw rce(t,r),r}},t4e=async(t,e,r,{signal:n})=>{for await(let[i]of KGe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},LU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},r4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{PR(t,ece);let a=new AbortController;try{await Promise.race([n4e(o,e,a),i4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),o4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),PR(t,-ece)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?UU(t):s4e(t))},n4e=async(t,e,{signal:r})=>{try{await t,r.aborted||UU(e)}catch(n){r.aborted||rce(e,n)}},i4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await tce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;nce(s)?i.add(e):ice(t,s)}},o4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Xae(t,i,{signal:o}),!t.readable)return Xae(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},s4e=t=>{t.writable&&t.end()},rce=(t,e)=>{nce(e)?UU(t):ice(t,e)},nce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",UU=t=>{(t.readable||t.writable)&&t.destroy()},ice=(t,e)=>{t.destroyed||(t.once("error",a4e),t.destroy(e))},a4e=()=>{},PR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Qae=2,ece=1;import{finished as oce}from"stream/promises";var Fp=(t,e)=>{t.pipe(e),c4e(t,e),l4e(t,e)},c4e=async(t,e)=>{if(!(co(t)||co(e))){try{await oce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}FU(e)}},FU=t=>{t.writable&&t.end()},l4e=async(t,e)=>{if(!(co(t)||co(e))){try{await oce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}zU(t)}},zU=t=>{t.readable&&t.destroy()};var sce=(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})=>Pi.has(c)))u4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Pi.has(c)))f4e({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]:$u(o);Fp(s,i)}},u4e=(t,e,r,n)=>{r==="output"?Fp(t.stdio[n],e):Fp(e,t.stdio[n]);let i=d4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},d4e=["stdin","stdout","stderr"],f4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;p4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},p4e=(t,{signal:e})=>{co(t)&&Nu(t,h4e,e)},h4e=2;import{addAbortListener as _4e}from"events";var Lu=[];Lu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Lu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Lu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var OR=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",jU=Symbol.for("signal-exit emitter"),BU=globalThis,m4e=Object.defineProperty.bind(Object),qU=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(BU[jU])return BU[jU];m4e(BU,jU,{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}},NR=class{},g4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),VU=class extends NR{onExit(){return()=>{}}load(){}unload(){}},GU=class extends NR{#e=HU.platform==="win32"?"SIGINT":"SIGHUP";#r=new qU;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Lu)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(!OR(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 Lu)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,Lu.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 OR(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"&&OR(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)}},HU=globalThis.process,{onExit:ace,load:KLt,unload:ZLt}=g4e(OR(HU)?new GU(HU):new VU);var cce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ace(()=>{t.kill()});_4e(n,()=>{i()})};var uce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=qx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=y4e(r,n,i),{sourceStream:d,sourceError:f}=E4e(t,l),{options:p,fileDescriptors:h}=ss.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},y4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=S4e(t,e,...r),a=Qx(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},S4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(lce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||D1(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]=kx(r,...n);return{destination:e(lce)(i,o,s),pipeOptions:s}}if(ss.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}`)},lce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),E4e=(t,e)=>{try{return{sourceStream:Np(t,e)}}catch(r){return{sourceError:r}}};var fce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=v4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw WU({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},v4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return zU(t),n;if(e!==void 0)return FU(r),e},WU=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>$p({error:t,command:dce,escapedCommand:dce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),dce="source.pipe(destination)";var pce=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 T4e}from"stream/promises";var hce=(t,e,r)=>{let n=kR.has(e)?w4e(t,e):b4e(t,e);return Nu(t,x4e,r.signal),Nu(e,R4e,r.signal),A4e(e),n},b4e=(t,e)=>{let r=$u([t]);return Fp(r,e),kR.set(e,r),r},w4e=(t,e)=>{let r=kR.get(e);return r.add(t),r},A4e=async t=>{try{await T4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kR.delete(t)},kR=new WeakMap,x4e=2,R4e=1;import{aborted as C4e}from"util";var mce=(t,e)=>t===void 0?[]:[I4e(t,e)],I4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await C4e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw WU({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var MR=(t,...e)=>{if(Jt(e[0]))return MR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=uce(t,...e),i=P4e({...n,destination:r});return i.pipe=MR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},P4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=O4e(t,i);fce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=hce(e,o,d);return await Promise.race([pce(u),...mce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},O4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as U4e}from"timers/promises";import{on as N4e}from"events";import{getDefaultHighWaterMark as k4e}from"stream";var DR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return M4e(e,s),_ce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},M4e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},YU=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;D4e(e,s,t);let a=t.readableObjectMode&&!o;return _ce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},D4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_ce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=N4e(t,"data",{signal:e.signal,highWaterMark:gce,highWatermark:gce});return $4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},KU=k4e(!0),gce=KU,$4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=L4e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Du(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Wy(a)}},L4e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[AR(t,r,!e),wR(t,i,!n,{})].filter(Boolean);var yce=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=F4e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([z4e(t),d]);return}let f=xU(c,r),p=YU({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([j4e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},F4e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!CR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=YU({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Iae(a,t,r,o)},z4e=async t=>{await U4e(),t.readableFlowing===null&&t.resume()},j4e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await mR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await gR(r,{maxBuffer:o})):await Dp(r,{maxBuffer:o})}catch(a){return Sce(Ise({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},ZU=async t=>{try{return await t}catch(e){return Sce(e)}},Sce=({bufferedData:t})=>Gne(t)?new Uint8Array(t):t;import{finished as B4e}from"stream/promises";var Jy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=q4e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],B4e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||H4e(a,e,r,n)}finally{s.abort()}},q4e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&V4e(t,r,n),n},V4e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{G4e(e,r),n.call(t,...i)}},G4e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},H4e=(t,e,r,n)=>{if(!W4e(t,e,r,n))throw t},W4e=(t,e,r,n=!0)=>r.propagating?Ece(t)||$R(t):(r.propagating=!0,JU(r,e)===n?Ece(t):$R(t)),JU=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",$R=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ece=t=>t?.code==="EPIPE";var vce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>XU({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),XU=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=Jy(t,e,l);if(JU(l,e)){await u;return}let[d]=await Promise.all([yce({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 Tce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?$u([t,e].filter(Boolean)):void 0,bce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>XU({...Y4e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:K4e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Y4e=({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}},K4e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Z4e}from"events";var wce=t=>Rp(t,"ipc"),Ace=(t,e)=>{let r=Bx(t);is({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var xce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=wce(o),a=ua(e,"ipc"),c=ua(r,"ipc");for await(let l of DU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Pse(t,i,c),i.push(l)),s&&Ace(l,o);return i},Rce=async(t,e)=>(await Promise.allSettled([t]),e);var Cce=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:y})=>{let v=Mae(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},w=vce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),b=bce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=[],I=xce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),P=J4e(m,t,T),N=X4e(h,T);try{return await Promise.race([Promise.all([{},$ae(v),Promise.all(w),b,I,cse(t,d),...P,...N]),g,Q4e(t,y),...nse(t,o,f,y),...woe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...tse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(U){return f.terminationReason??="other",Promise.all([{error:U},v,Promise.all(w.map(_=>ZU(_))),ZU(b),Rce(I,x),Promise.allSettled(P),Promise.allSettled(N)])}},J4e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Jy(n,i,r)),X4e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>fo(o,{checkOpen:!1})&&!co(o)).map(({type:i,value:o,stream:s=o})=>Jy(s,n,e,{isSameDirection:Pi.has(i),stopOnExit:i==="native"}))),Q4e=async(t,{signal:e})=>{let[r]=await Z4e(t,"error",{signal:e});throw r};var Ice=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Xy=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=os();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},zp=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 eHe}from"stream";import{callbackify as tHe}from"util";import{finished as Pce}from"stream/promises";var QU=async t=>{if(t!==void 0)try{await eF(t)}catch{}},Oce=async t=>{if(t!==void 0)try{await tF(t)}catch{}},eF=async t=>{await Pce(t,{cleanup:!0,readable:!1,writable:!0})},tF=async t=>{await Pce(t,{cleanup:!0,readable:!0,writable:!1})},LR=async(t,e)=>{if(await t,e)throw e},UR=(t,e,r)=>{r&&!$R(r)?t.destroy(r):e&&t.destroy()};var Nce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ri.has(r),{subprocessStdout:a,waitReadableDestroy:c}=rF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=nF(a,s),{read:f,onStdoutDataDone:p}=iF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new eHe({read:f,destroy:tHe(sF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return oF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},rF=(t,e,r)=>{let n=Np(t,e),i=Xy(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},nF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:KU},iF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=os(),s=DR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){rHe(this,s,o)},onStdoutDataDone:o}},rHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},oF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await tF(t),await n,await QU(i),await e,r.readable&&r.push(null)}catch(o){await QU(i),kce(r,o)}},sF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await zp(r,e)&&(kce(t,n),await LR(e,n))},kce=(t,e)=>{UR(t,t.readable,e)};import{Writable as nHe}from"stream";import{callbackify as Mce}from"util";var Dce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=aF(t,r,e),s=new nHe({...cF(n,t,i),destroy:Mce(uF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return lF(n,s),s},aF=(t,e,r)=>{let n=Qx(t,e),i=Xy(r,n,"writableFinal"),o=Xy(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},cF=(t,e,r)=>({write:iHe.bind(void 0,t),final:Mce(oHe.bind(void 0,t,e,r))}),iHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},oHe=async(t,e,r)=>{await zp(r,e)&&(t.writable&&t.end(),await e)},lF=async(t,e,r)=>{try{await eF(t),e.writable&&e.end()}catch(n){await Oce(r),$ce(e,n)}},uF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await zp(r,e),await zp(n,e)&&($ce(t,i),await LR(e,i))},$ce=(t,e)=>{UR(t,t.writable,e)};import{Duplex as sHe}from"stream";import{callbackify as aHe}from"util";var Lce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ri.has(r),{subprocessStdout:c,waitReadableDestroy:l}=rF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=aF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=nF(c,a),{read:g,onStdoutDataDone:y}=iF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new sHe({read:g,...cF(u,t,d),destroy:aHe(cHe.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 oF({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),lF(u,v,c),v},cHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([sF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),uF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var dF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ri.has(e),s=Np(t,r),a=DR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return lHe(a,s,t)},lHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Uce=(t,{encoding:e})=>{let r=Ice();t.readable=Nce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Dce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Lce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=dF.bind(void 0,t,e),t[Symbol.asyncIterator]=dF.bind(void 0,t,e,{})};var Fce=(t,e)=>{for(let[r,n]of dHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},uHe=(async()=>{})().constructor.prototype,dHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(uHe,t)]);var zce=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=hHe(t,e,r),{subprocess:f,promise:p}=gHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=MR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Fce(f,p),ss.set(f,{options:u,fileDescriptors:d}),f},hHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Vx(t,e,r),{file:a,commandArguments:c,options:l}=uR(t,e,r),u=mHe(l),d=Jae(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},mHe=({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}},gHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=pHe(...dR(t,e,r))}catch(h){return Wae({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;fHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];sce(c,a,l),cce(c,r,l);let d={},f=os();c.kill=Toe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Tce(c,r),Uce(c,r),Vae(c,r);let p=_He({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}},_He=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 Cce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((w,b)=>fa(w,e,b)),v=fa(m,e,"all"),T=yHe({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Lp(T,n,e)},yHe=({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?Hy({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}):SR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var FR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,SHe(n,t[n],i)]));return{...t,...r}},SHe=(t,e,r)=>EHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,EHe=new Set(["env",...j1]);var Oc=(t,e,r,n)=>{let i=(s,a,c)=>Oc(s,a,r,c),o=(...s)=>vHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},vHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,FR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=THe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Uae(a,c,l):zce(a,c,l,i)},THe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Jne(e)?Xne(e,r):[e,...r],[s,a,c]=kx(...o),l=FR(FR(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 jce=({file:t,commandArguments:e})=>qce(t,e),Bce=({file:t,commandArguments:e})=>({...qce(t,e),isSync:!0}),qce=(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]=bHe(t);return{file:r,commandArguments:n}},bHe=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(wHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wHe=/ +/g;var Vce=(t,e,r)=>{t.sync=e(AHe,r),t.s=t.sync},Gce=({options:t})=>Hce(t),AHe=({options:t})=>({...Hce(t),isSync:!0}),Hce=t=>({options:{...xHe(t),...t}}),xHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Wce={preferLocal:!0};var Yce=Oc(()=>({})),FFt=Oc(()=>({isSync:!0})),Kce=Oc(jce),zFt=Oc(Bce),jFt=Oc(ose),BFt=Oc(Gce,{},Wce,Vce),{sendMessage:qFt,getOneMessage:VFt,getEachMessage:GFt,getCancelSignal:HFt}=Gae();var Zce=!1,Jce,RHe=t=>{Jce??=t},Xce=t=>{Zce=!0,RHe(t)},ni=()=>Zce,jp=()=>Jce;var Qy=null,Qce=t=>(Qy&&Qy.destroy(),Qy=new po({totalAllowedTime:t}),Qy),ele=()=>Qy;var po=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&&ni())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 bx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{V.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 tle={name:"@netlify/agent-runner-cli",type:"module",version:"1.187.0-count-api-reqs.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.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.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.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var OHe=IHe(import.meta.url),NHe=pa.dirname(OHe),kHe=PHe(import.meta.url),Bp=ie("shell"),fF=new Set,rle={preferLocal:!0},Mt=(t,e,r)=>{let[n,i]=MHe(e,r),o={...rle,...i},s=Yce(t,n,o);ile(s,o),ale(s);let a=r?.idleTimeout;return a&&a>0&&sle(s,a),s},nle=(t,e)=>{let r={...rle,...e},n=Kce(t,r);return ile(n,r),ale(n),e?.idleTimeout&&e.idleTimeout>0&&sle(n,e.idleTimeout),n},MHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ile=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ls.env.NETLIFY_LOCAL_QUIET==="true")return;if(ls.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Cy).pipe(ls.stdout),t.stderr?.pipe(new Cy).pipe(ls.stderr);return}t.stdout?.pipe(ls.stdout),t.stderr?.pipe(ls.stderr)},pF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ls.kill(-t.pid,e),Bp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bp.error("Error killing process:",r),!1}},ole=t=>pF(t,"SIGKILL"),sle=(t,e)=>{let r=null,n=()=>{Bp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),pF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bp.log(`Force killing idle process ${t.pid}`),ole(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)},ale=t=>{fF.add(t);let e=ele();if(e){let r=e.onTimesUp(()=>{Bp.log(`Global timer expired, killing process ${t.pid}`),pF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bp.log(`Force killing process ${t.pid} after timeout`),ole(t))},5e3)});t.on("exit",()=>{fF.delete(t),r()}),t.on("error",()=>{fF.delete(t),r()})}};function us(t,e){if(!ls.env.NETLIFY_LOCAL_MODE)try{let i=kHe.resolve(tle.name),o=pa.dirname(i);for(;o!==pa.dirname(o);){let s=pa.dirname(o);if(pa.basename(s)==="node_modules"){let a=pa.join(s,".bin",e);if(zR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ls.env.NODE_PATH){let i=pa.join(ls.env.NODE_PATH,".bin",e);if(zR.existsSync(i))return i}let r=pa.join(t,"node_modules",".bin",e);if(zR.existsSync(r))return r;let n=pa.join(NHe,"..","node_modules",".bin",e);if(zR.existsSync(n))return n}var cle=ie("repo"),fle="runner-diffs-",qR=t=>`${fle}${t}-`,ple=async t=>{let e=dle.tmpdir(),r;try{r=await jR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(fle)&&!n.startsWith(qR(t))).map(n=>jR.rm(BR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>Mt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),VR=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{cle.info("Getting runner diffs");let n=await _F(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=SF(o);await BHe(l,r)}cle.info("Changes after processing"),await gF(r);let s=await eS(o,r);if(await mF(s,r),i=await FHe(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await jR.mkdtemp(BR.join(dle.tmpdir(),qR(t.sessionId))),c=await hF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await LHe(r),c.hasChanges&&V.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},hF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=BR.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:v}=await jR.stat(g);return{path:g,size:v}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await ule(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await ule(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},lle=async t=>{let e=DHe("sha256");for await(let r of $He(t))e.update(r);return e.digest("hex")},ule=async(t,e)=>t.size===e.size&&await lle(t.path)===await lle(e.path),LHe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},mF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},gF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},hle=/.. (.+)?\.log$/,UHe=[hle],_F=async(t=process.cwd())=>{let e=await gF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
145
|
+
if (condition) { yield value; }`)};import{Buffer as GVe}from"buffer";import{StringDecoder as HVe}from"string_decoder";var AR=(t,e,r)=>{if(r)return;if(t)return{transform:WVe.bind(void 0,new TextEncoder)};let n=new HVe(e);return{transform:YVe.bind(void 0,n),final:KVe.bind(void 0,n)}},WVe=function*(t,e){GVe.isBuffer(e)?yield la(e):typeof e=="string"?yield t.encode(e):yield e},YVe=function*(t,e){yield dr(e)?t.write(e):e},KVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Tae}from"util";var IU=Tae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),xR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=JVe}=e[r];for await(let i of n(t))yield*xR(i,e,r+1)},bae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ZVe(r,Number(e),t)},ZVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*xR(n,r,e+1)},wae=Tae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),JVe=function*(t){yield t};var PU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Aae=(t,e)=>[...e.flatMap(r=>[...Du(r,t,0)]),...Wy(t)],Du=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QVe}=e[r];for(let i of n(t))yield*Du(i,e,r+1)},Wy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XVe(r,Number(e),t)},XVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Du(n,r,e+1)},QVe=function*(t){yield t};var OU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Rae(t,s,o),l=Mu(e),u=Mu(r),d=l?IU.bind(void 0,xR,a):PU.bind(void 0,Du),f=l||u?IU.bind(void 0,bae,a):PU.bind(void 0,Wy),p=l||u?wae.bind(void 0,a):void 0;return{stream:new eGe({writableObjectMode:n,writableHighWaterMark:xae(n),readableObjectMode:i,readableHighWaterMark:xae(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},RR=(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=Rae(s,r,a);t=Aae(c,t)}return t},Rae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Sae(n,a)},AR(r,s,n),wR(r,o,n,c),{transform:t,final:e},{transform:Eae(i,a)},yae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Cae=(t,e)=>{for(let r of tGe(t))rGe(t,r,e)},tGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),rGe=(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 ${Pc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>nGe(a,n));r.input=Ly(s)},nGe=(t,e)=>{let r=RR(t,e,"utf8",!0);return iGe(r),Ly(r)},iGe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(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 cGe,appendFileSync as lGe}from"fs";var CR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Rp(r,n)&&!ri.has(e)&&oGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&sGe.has(o))||t.every(({type:i})=>Pi.has(i))),oGe=t=>t===1||t===2,sGe=new Set(["pipe","overlapped"]),Iae=async(t,e,r,n)=>{for await(let i of t)aGe(e)||Oae(i,r,n)},Pae=(t,e,r)=>{for(let n of t)Oae(n,e,r)},aGe=t=>t._readableState.pipes.length>0,Oae=(t,e,r)=>{let n=Bx(t);is({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Nae=({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)=>uGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},uGe=({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=kse(t,o,d),p=la(f),{stdioItems:h,objectMode:m}=e[r],g=dGe([p],h,c,n),{serializedResult:y,finalResult:v=y}=fGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});pGe({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?v:void 0;try{return n.error===void 0&&hGe(y,h,i),T}catch(w){return n.error=w,T}},dGe=(t,e,r,n)=>{try{return RR(t,e,r,!1)}catch(i){return n.error=i,t}},fGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Ly(t)};let s=Wne(t,r);return n[o]?{serializedResult:s,finalResult:CU(s,!i[o],e)}:{serializedResult:s}},pGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!CR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=CU(t,!1,s);try{Pae(a,e,n)}catch(c){r.error??=c}},hGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>TR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?lGe(n,t):(r.add(o),cGe(n,t))}};var kae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,fa(e,r,"all")]:Array.isArray(e)?[fa(t,r,"all"),...e]:dr(t)&&dr(e)?L1([t,e]):`${t}${e}`};import{once as NU}from"events";var Mae=async(t,e)=>{let[r,n]=await mGe(t);return e.isForcefullyTerminated??=!1,[r,n]},mGe=async t=>{let[e,r]=await Promise.allSettled([NU(t,"spawn"),NU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Dae(t):r.value},Dae=async t=>{try{return await NU(t,"exit")}catch{return Dae(t)}},$ae=async t=>{let[e,r]=await t;if(!gGe(e,r)&&kU(e,r))throw new lo;return[e,r]},gGe=(t,e)=>t===void 0&&e===void 0,kU=(t,e)=>t!==0||e!==null;var Lae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=_Ge(t,e,r),s=o?.code==="ETIMEDOUT",a=Nse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},_Ge=(t,e,r)=>t!==void 0?t:kU(e,r)?new lo:void 0;var Uae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=SGe(t,e,r),d=TGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Lp(d,c,l)},SGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Vx(t,e,r),a=EGe(r),{file:c,commandArguments:l,options:u}=uR(t,e,a);vGe(u);let d=hae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},EGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vGe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&IR("ipcInput"),t&&IR("ipc: true"),r&&IR("detached: true"),n&&IR("cancelSignal")},IR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},TGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=bGe({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}=Lae(c,r),{output:h,error:m=l}=Nae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,T)=>fa(v,r,T)),y=fa(kae(h,r),r,"all");return AGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},bGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Cae(o,r);let a=wGe(r);return yGe(...dR(t,e,a))}catch(a){return $p({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:yR(e)}),AGe=({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?SR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Hy({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 fHe}from"events";import{spawn as pHe}from"child_process";import qae from"process";import{once as MU,on as xGe}from"events";var Fae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Pp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:iR(t)}),RGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),RGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{eR(e,i);let o=Ic(t,e,r),s=new AbortController;try{return await Promise.race([CGe(o,n,s),IGe(o,r,s),PGe(o,r,s)])}catch(a){throw Op(t),a}finally{s.abort(),tR(e,i)}},CGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await MU(t,"message",{signal:r});return n}for await(let[n]of xGe(t,"message",{signal:r}))if(e(n))return n},IGe=async(t,e,{signal:r})=>{await MU(t,"disconnect",{signal:r}),Aoe(e)},PGe=async(t,e,{signal:r})=>{let[n]=await MU(t,"strict:error",{signal:r});throw Jx(n,e)};import{once as jae,on as OGe}from"events";var Bae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>DU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),DU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Pp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:iR(t)}),eR(e,o);let s=Ic(t,e,r),a=new AbortController,c={};return NGe(t,s,a),kGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),MGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},NGe=async(t,e,r)=>{try{await jae(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await jae(t,"strict:error",{signal:r.signal});n.error=Jx(i,e),r.abort()}catch{}},MGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of OGe(r,"message",{signal:o.signal}))zae(s),yield c}catch{zae(s)}finally{o.abort(),tR(e,a),n||Op(t),i&&await t}},zae=({error:t})=>{if(t)throw t};var Vae=(t,{ipc:e})=>{Object.assign(t,Hae(t,!1,e))},Gae=()=>{let t=qae,e=!0,r=qae.channel!==void 0;return{...Hae(t,e,r),getCancelSignal:Xoe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Hae=(t,e,r)=>({sendMessage:cR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Fae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Bae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as DGe}from"child_process";import{PassThrough as $Ge,Readable as LGe,Writable as UGe,Duplex as FGe}from"stream";var Wae=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{AU(n);let a=new DGe;zGe(a,n),Object.assign(a,{readable:jGe,writable:BGe,duplex:qGe});let c=$p({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=VGe(c,s,i);return{subprocess:a,promise:l}},zGe=(t,e)=>{let r=Yy(),n=Yy(),i=Yy(),o=Array.from({length:e.length-3},Yy),s=Yy(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Yy=()=>{let t=new $Ge;return t.end(),t},jGe=()=>new LGe({read(){}}),BGe=()=>new UGe({write(){}}),qGe=()=>new FGe({read(){},write(){}}),VGe=async(t,e,r)=>Lp(t,e,r);import{createReadStream as Yae,createWriteStream as Kae}from"fs";import{Buffer as GGe}from"buffer";import{Readable as Ky,Writable as HGe,Duplex as WGe}from"stream";var Jae=(t,e)=>bR(YGe,t,e,!1),Zy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Pc[t]}.`)},Zae={fileNumber:Zy,generator:OU,asyncGenerator:OU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:WGe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},YGe={input:{...Zae,fileUrl:({value:t})=>({stream:Yae(t)}),filePath:({value:{file:t}})=>({stream:Yae(t)}),webStream:({value:t})=>({stream:Ky.fromWeb(t)}),iterable:({value:t})=>({stream:Ky.from(t)}),asyncIterable:({value:t})=>({stream:Ky.from(t)}),string:({value:t})=>({stream:Ky.from(t)}),uint8Array:({value:t})=>({stream:Ky.from(GGe.from(t))})},output:{...Zae,fileUrl:({value:t})=>({stream:Kae(t)}),filePath:({value:{file:t,append:e}})=>({stream:Kae(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:HGe.fromWeb(t)}),iterable:Zy,asyncIterable:Zy,string:Zy,uint8Array:Zy}};import{on as KGe,once as Xae}from"events";import{PassThrough as ZGe,getDefaultHighWaterMark as JGe}from"stream";import{finished as tce}from"stream/promises";function $u(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)LU(i);let e=t.some(({readableObjectMode:i})=>i),r=XGe(t,e),n=new $U({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var XGe=(t,e)=>{if(t.length===0)return JGe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},$U=class extends ZGe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(LU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=QGe(this,this.#e,this.#o);let r=r4e({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(LU(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)}},QGe=async(t,e,r)=>{PR(t,Qae);let n=new AbortController;try{await Promise.race([e4e(t,n),t4e(t,e,r,n)])}finally{n.abort(),PR(t,-Qae)}},e4e=async(t,{signal:e})=>{try{await tce(t,{signal:e,cleanup:!0})}catch(r){throw rce(t,r),r}},t4e=async(t,e,r,{signal:n})=>{for await(let[i]of KGe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},LU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},r4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{PR(t,ece);let a=new AbortController;try{await Promise.race([n4e(o,e,a),i4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),o4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),PR(t,-ece)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?UU(t):s4e(t))},n4e=async(t,e,{signal:r})=>{try{await t,r.aborted||UU(e)}catch(n){r.aborted||rce(e,n)}},i4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await tce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;nce(s)?i.add(e):ice(t,s)}},o4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Xae(t,i,{signal:o}),!t.readable)return Xae(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},s4e=t=>{t.writable&&t.end()},rce=(t,e)=>{nce(e)?UU(t):ice(t,e)},nce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",UU=t=>{(t.readable||t.writable)&&t.destroy()},ice=(t,e)=>{t.destroyed||(t.once("error",a4e),t.destroy(e))},a4e=()=>{},PR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Qae=2,ece=1;import{finished as oce}from"stream/promises";var Fp=(t,e)=>{t.pipe(e),c4e(t,e),l4e(t,e)},c4e=async(t,e)=>{if(!(co(t)||co(e))){try{await oce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}FU(e)}},FU=t=>{t.writable&&t.end()},l4e=async(t,e)=>{if(!(co(t)||co(e))){try{await oce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}zU(t)}},zU=t=>{t.readable&&t.destroy()};var sce=(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})=>Pi.has(c)))u4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Pi.has(c)))f4e({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]:$u(o);Fp(s,i)}},u4e=(t,e,r,n)=>{r==="output"?Fp(t.stdio[n],e):Fp(e,t.stdio[n]);let i=d4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},d4e=["stdin","stdout","stderr"],f4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;p4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},p4e=(t,{signal:e})=>{co(t)&&Nu(t,h4e,e)},h4e=2;import{addAbortListener as _4e}from"events";var Lu=[];Lu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Lu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Lu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var OR=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",jU=Symbol.for("signal-exit emitter"),BU=globalThis,m4e=Object.defineProperty.bind(Object),qU=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(BU[jU])return BU[jU];m4e(BU,jU,{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}},NR=class{},g4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),VU=class extends NR{onExit(){return()=>{}}load(){}unload(){}},GU=class extends NR{#e=HU.platform==="win32"?"SIGINT":"SIGHUP";#r=new qU;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Lu)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(!OR(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 Lu)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,Lu.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 OR(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"&&OR(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)}},HU=globalThis.process,{onExit:ace,load:KLt,unload:ZLt}=g4e(OR(HU)?new GU(HU):new VU);var cce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ace(()=>{t.kill()});_4e(n,()=>{i()})};var uce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=qx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=y4e(r,n,i),{sourceStream:d,sourceError:f}=E4e(t,l),{options:p,fileDescriptors:h}=ss.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},y4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=S4e(t,e,...r),a=Qx(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},S4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(lce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||D1(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]=kx(r,...n);return{destination:e(lce)(i,o,s),pipeOptions:s}}if(ss.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}`)},lce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),E4e=(t,e)=>{try{return{sourceStream:Np(t,e)}}catch(r){return{sourceError:r}}};var fce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=v4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw WU({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},v4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return zU(t),n;if(e!==void 0)return FU(r),e},WU=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>$p({error:t,command:dce,escapedCommand:dce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),dce="source.pipe(destination)";var pce=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 T4e}from"stream/promises";var hce=(t,e,r)=>{let n=kR.has(e)?w4e(t,e):b4e(t,e);return Nu(t,x4e,r.signal),Nu(e,R4e,r.signal),A4e(e),n},b4e=(t,e)=>{let r=$u([t]);return Fp(r,e),kR.set(e,r),r},w4e=(t,e)=>{let r=kR.get(e);return r.add(t),r},A4e=async t=>{try{await T4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kR.delete(t)},kR=new WeakMap,x4e=2,R4e=1;import{aborted as C4e}from"util";var mce=(t,e)=>t===void 0?[]:[I4e(t,e)],I4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await C4e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw WU({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var MR=(t,...e)=>{if(Jt(e[0]))return MR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=uce(t,...e),i=P4e({...n,destination:r});return i.pipe=MR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},P4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=O4e(t,i);fce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=hce(e,o,d);return await Promise.race([pce(u),...mce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},O4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as U4e}from"timers/promises";import{on as N4e}from"events";import{getDefaultHighWaterMark as k4e}from"stream";var DR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return M4e(e,s),_ce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},M4e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},YU=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;D4e(e,s,t);let a=t.readableObjectMode&&!o;return _ce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},D4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_ce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=N4e(t,"data",{signal:e.signal,highWaterMark:gce,highWatermark:gce});return $4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},KU=k4e(!0),gce=KU,$4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=L4e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Du(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Wy(a)}},L4e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[AR(t,r,!e),wR(t,i,!n,{})].filter(Boolean);var yce=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=F4e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([z4e(t),d]);return}let f=xU(c,r),p=YU({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([j4e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},F4e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!CR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=YU({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Iae(a,t,r,o)},z4e=async t=>{await U4e(),t.readableFlowing===null&&t.resume()},j4e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await mR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await gR(r,{maxBuffer:o})):await Dp(r,{maxBuffer:o})}catch(a){return Sce(Ise({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},ZU=async t=>{try{return await t}catch(e){return Sce(e)}},Sce=({bufferedData:t})=>Gne(t)?new Uint8Array(t):t;import{finished as B4e}from"stream/promises";var Jy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=q4e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],B4e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||H4e(a,e,r,n)}finally{s.abort()}},q4e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&V4e(t,r,n),n},V4e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{G4e(e,r),n.call(t,...i)}},G4e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},H4e=(t,e,r,n)=>{if(!W4e(t,e,r,n))throw t},W4e=(t,e,r,n=!0)=>r.propagating?Ece(t)||$R(t):(r.propagating=!0,JU(r,e)===n?Ece(t):$R(t)),JU=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",$R=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ece=t=>t?.code==="EPIPE";var vce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>XU({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),XU=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=Jy(t,e,l);if(JU(l,e)){await u;return}let[d]=await Promise.all([yce({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 Tce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?$u([t,e].filter(Boolean)):void 0,bce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>XU({...Y4e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:K4e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Y4e=({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}},K4e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Z4e}from"events";var wce=t=>Rp(t,"ipc"),Ace=(t,e)=>{let r=Bx(t);is({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var xce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=wce(o),a=ua(e,"ipc"),c=ua(r,"ipc");for await(let l of DU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Pse(t,i,c),i.push(l)),s&&Ace(l,o);return i},Rce=async(t,e)=>(await Promise.allSettled([t]),e);var Cce=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:y})=>{let v=Mae(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},w=vce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),b=bce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=[],I=xce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),P=J4e(m,t,T),N=X4e(h,T);try{return await Promise.race([Promise.all([{},$ae(v),Promise.all(w),b,I,cse(t,d),...P,...N]),g,Q4e(t,y),...nse(t,o,f,y),...woe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...tse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(U){return f.terminationReason??="other",Promise.all([{error:U},v,Promise.all(w.map(_=>ZU(_))),ZU(b),Rce(I,x),Promise.allSettled(P),Promise.allSettled(N)])}},J4e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Jy(n,i,r)),X4e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>fo(o,{checkOpen:!1})&&!co(o)).map(({type:i,value:o,stream:s=o})=>Jy(s,n,e,{isSameDirection:Pi.has(i),stopOnExit:i==="native"}))),Q4e=async(t,{signal:e})=>{let[r]=await Z4e(t,"error",{signal:e});throw r};var Ice=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Xy=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=os();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},zp=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 eHe}from"stream";import{callbackify as tHe}from"util";import{finished as Pce}from"stream/promises";var QU=async t=>{if(t!==void 0)try{await eF(t)}catch{}},Oce=async t=>{if(t!==void 0)try{await tF(t)}catch{}},eF=async t=>{await Pce(t,{cleanup:!0,readable:!1,writable:!0})},tF=async t=>{await Pce(t,{cleanup:!0,readable:!0,writable:!1})},LR=async(t,e)=>{if(await t,e)throw e},UR=(t,e,r)=>{r&&!$R(r)?t.destroy(r):e&&t.destroy()};var Nce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ri.has(r),{subprocessStdout:a,waitReadableDestroy:c}=rF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=nF(a,s),{read:f,onStdoutDataDone:p}=iF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new eHe({read:f,destroy:tHe(sF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return oF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},rF=(t,e,r)=>{let n=Np(t,e),i=Xy(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},nF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:KU},iF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=os(),s=DR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){rHe(this,s,o)},onStdoutDataDone:o}},rHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},oF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await tF(t),await n,await QU(i),await e,r.readable&&r.push(null)}catch(o){await QU(i),kce(r,o)}},sF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await zp(r,e)&&(kce(t,n),await LR(e,n))},kce=(t,e)=>{UR(t,t.readable,e)};import{Writable as nHe}from"stream";import{callbackify as Mce}from"util";var Dce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=aF(t,r,e),s=new nHe({...cF(n,t,i),destroy:Mce(uF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return lF(n,s),s},aF=(t,e,r)=>{let n=Qx(t,e),i=Xy(r,n,"writableFinal"),o=Xy(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},cF=(t,e,r)=>({write:iHe.bind(void 0,t),final:Mce(oHe.bind(void 0,t,e,r))}),iHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},oHe=async(t,e,r)=>{await zp(r,e)&&(t.writable&&t.end(),await e)},lF=async(t,e,r)=>{try{await eF(t),e.writable&&e.end()}catch(n){await Oce(r),$ce(e,n)}},uF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await zp(r,e),await zp(n,e)&&($ce(t,i),await LR(e,i))},$ce=(t,e)=>{UR(t,t.writable,e)};import{Duplex as sHe}from"stream";import{callbackify as aHe}from"util";var Lce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ri.has(r),{subprocessStdout:c,waitReadableDestroy:l}=rF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=aF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=nF(c,a),{read:g,onStdoutDataDone:y}=iF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new sHe({read:g,...cF(u,t,d),destroy:aHe(cHe.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 oF({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),lF(u,v,c),v},cHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([sF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),uF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var dF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ri.has(e),s=Np(t,r),a=DR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return lHe(a,s,t)},lHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Uce=(t,{encoding:e})=>{let r=Ice();t.readable=Nce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Dce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Lce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=dF.bind(void 0,t,e),t[Symbol.asyncIterator]=dF.bind(void 0,t,e,{})};var Fce=(t,e)=>{for(let[r,n]of dHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},uHe=(async()=>{})().constructor.prototype,dHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(uHe,t)]);var zce=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=hHe(t,e,r),{subprocess:f,promise:p}=gHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=MR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Fce(f,p),ss.set(f,{options:u,fileDescriptors:d}),f},hHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Vx(t,e,r),{file:a,commandArguments:c,options:l}=uR(t,e,r),u=mHe(l),d=Jae(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},mHe=({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}},gHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=pHe(...dR(t,e,r))}catch(h){return Wae({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;fHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];sce(c,a,l),cce(c,r,l);let d={},f=os();c.kill=Toe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Tce(c,r),Uce(c,r),Vae(c,r);let p=_He({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}},_He=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 Cce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((w,b)=>fa(w,e,b)),v=fa(m,e,"all"),T=yHe({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Lp(T,n,e)},yHe=({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?Hy({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}):SR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var FR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,SHe(n,t[n],i)]));return{...t,...r}},SHe=(t,e,r)=>EHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,EHe=new Set(["env",...j1]);var Oc=(t,e,r,n)=>{let i=(s,a,c)=>Oc(s,a,r,c),o=(...s)=>vHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},vHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,FR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=THe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Uae(a,c,l):zce(a,c,l,i)},THe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Jne(e)?Xne(e,r):[e,...r],[s,a,c]=kx(...o),l=FR(FR(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 jce=({file:t,commandArguments:e})=>qce(t,e),Bce=({file:t,commandArguments:e})=>({...qce(t,e),isSync:!0}),qce=(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]=bHe(t);return{file:r,commandArguments:n}},bHe=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(wHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wHe=/ +/g;var Vce=(t,e,r)=>{t.sync=e(AHe,r),t.s=t.sync},Gce=({options:t})=>Hce(t),AHe=({options:t})=>({...Hce(t),isSync:!0}),Hce=t=>({options:{...xHe(t),...t}}),xHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Wce={preferLocal:!0};var Yce=Oc(()=>({})),FFt=Oc(()=>({isSync:!0})),Kce=Oc(jce),zFt=Oc(Bce),jFt=Oc(ose),BFt=Oc(Gce,{},Wce,Vce),{sendMessage:qFt,getOneMessage:VFt,getEachMessage:GFt,getCancelSignal:HFt}=Gae();var Zce=!1,Jce,RHe=t=>{Jce??=t},Xce=t=>{Zce=!0,RHe(t)},ni=()=>Zce,jp=()=>Jce;var Qy=null,Qce=t=>(Qy&&Qy.destroy(),Qy=new po({totalAllowedTime:t}),Qy),ele=()=>Qy;var po=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&&ni())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 bx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{V.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 tle={name:"@netlify/agent-runner-cli",type:"module",version:"1.188.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.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.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.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var OHe=IHe(import.meta.url),NHe=pa.dirname(OHe),kHe=PHe(import.meta.url),Bp=ie("shell"),fF=new Set,rle={preferLocal:!0},Mt=(t,e,r)=>{let[n,i]=MHe(e,r),o={...rle,...i},s=Yce(t,n,o);ile(s,o),ale(s);let a=r?.idleTimeout;return a&&a>0&&sle(s,a),s},nle=(t,e)=>{let r={...rle,...e},n=Kce(t,r);return ile(n,r),ale(n),e?.idleTimeout&&e.idleTimeout>0&&sle(n,e.idleTimeout),n},MHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ile=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ls.env.NETLIFY_LOCAL_QUIET==="true")return;if(ls.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Cy).pipe(ls.stdout),t.stderr?.pipe(new Cy).pipe(ls.stderr);return}t.stdout?.pipe(ls.stdout),t.stderr?.pipe(ls.stderr)},pF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ls.kill(-t.pid,e),Bp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bp.error("Error killing process:",r),!1}},ole=t=>pF(t,"SIGKILL"),sle=(t,e)=>{let r=null,n=()=>{Bp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),pF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bp.log(`Force killing idle process ${t.pid}`),ole(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)},ale=t=>{fF.add(t);let e=ele();if(e){let r=e.onTimesUp(()=>{Bp.log(`Global timer expired, killing process ${t.pid}`),pF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bp.log(`Force killing process ${t.pid} after timeout`),ole(t))},5e3)});t.on("exit",()=>{fF.delete(t),r()}),t.on("error",()=>{fF.delete(t),r()})}};function us(t,e){if(!ls.env.NETLIFY_LOCAL_MODE)try{let i=kHe.resolve(tle.name),o=pa.dirname(i);for(;o!==pa.dirname(o);){let s=pa.dirname(o);if(pa.basename(s)==="node_modules"){let a=pa.join(s,".bin",e);if(zR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ls.env.NODE_PATH){let i=pa.join(ls.env.NODE_PATH,".bin",e);if(zR.existsSync(i))return i}let r=pa.join(t,"node_modules",".bin",e);if(zR.existsSync(r))return r;let n=pa.join(NHe,"..","node_modules",".bin",e);if(zR.existsSync(n))return n}var cle=ie("repo"),fle="runner-diffs-",qR=t=>`${fle}${t}-`,ple=async t=>{let e=dle.tmpdir(),r;try{r=await jR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(fle)&&!n.startsWith(qR(t))).map(n=>jR.rm(BR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>Mt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),VR=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{cle.info("Getting runner diffs");let n=await _F(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=SF(o);await BHe(l,r)}cle.info("Changes after processing"),await gF(r);let s=await eS(o,r);if(await mF(s,r),i=await FHe(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await jR.mkdtemp(BR.join(dle.tmpdir(),qR(t.sessionId))),c=await hF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await LHe(r),c.hasChanges&&V.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},hF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=BR.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:v}=await jR.stat(g);return{path:g,size:v}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await ule(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await ule(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},lle=async t=>{let e=DHe("sha256");for await(let r of $He(t))e.update(r);return e.digest("hex")},ule=async(t,e)=>t.size===e.size&&await lle(t.path)===await lle(e.path),LHe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},mF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},gF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},hle=/.. (.+)?\.log$/,UHe=[hle],_F=async(t=process.cwd())=>{let e=await gF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
146
146
|
`).filter(i=>UHe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},FHe=async(t=process.cwd())=>{try{return await Xt(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},yF=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},zHe=1,jHe=async t=>{try{return await Xt(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===zHe)return!1;throw e}},mle=async(t=process.cwd())=>{if(!await jHe(t))return!0;let{stdout:e}=await Xt(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},gle=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},eS=async(t,e=process.cwd())=>{t||=await gF(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
147
147
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${BR.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(hle)?.[1];o&&n.push(`:!${o}.log`)}),n},_le=async(t=process.cwd())=>{await Xt(["reset","--hard","HEAD"],{cwd:t})},yle=async(t=process.cwd())=>{let e=await Xt(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
148
148
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},SF=t=>{let e=t.split(`
|
package/package.json
CHANGED