@netlify/agent-runner-cli 1.175.0-run-started.0 → 1.175.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
|
@@ -141,7 +141,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
141
141
|
`,LF:`
|
|
142
142
|
`,concatBytes:rj},h6e=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},m6e={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:h6e};import{Buffer as g6e}from"buffer";var Sue=(t,e)=>t?void 0:_6e.bind(void 0,e),_6e=function*(t,e){if(typeof e!="string"&&!Tr(e)&&!g6e.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Eue=(t,e)=>t?y6e.bind(void 0,e):S6e.bind(void 0,e),y6e=function*(t,e){vue(t,e),yield e},S6e=function*(t,e){if(vue(t,e),typeof e!="string"&&!Tr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},vue=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
143
143
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
144
|
-
if (condition) { yield value; }`)};import{Buffer as E6e}from"buffer";import{StringDecoder as v6e}from"string_decoder";var bC=(t,e,r)=>{if(r)return;if(t)return{transform:b6e.bind(void 0,new TextEncoder)};let n=new v6e(e);return{transform:T6e.bind(void 0,n),final:w6e.bind(void 0,n)}},b6e=function*(t,e){E6e.isBuffer(e)?yield za(e):typeof e=="string"?yield t.encode(e):yield e},T6e=function*(t,e){yield Tr(e)?t.write(e):e},w6e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as bue}from"util";var ij=bue(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),TC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=x6e}=e[r];for await(let i of n(t))yield*TC(i,e,r+1)},Tue=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*A6e(r,Number(e),t)},A6e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*TC(n,r,e+1)},wue=bue(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),x6e=function*(t){yield t};var oj=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Aue=(t,e)=>[...e.flatMap(r=>[...Td(r,t,0)]),..._E(t)],Td=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=C6e}=e[r];for(let i of n(t))yield*Td(i,e,r+1)},_E=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*R6e(r,Number(e),t)},R6e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Td(n,r,e+1)},C6e=function*(t){yield t};var sj=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Rue(t,s,o),l=bd(e),u=bd(r),d=l?ij.bind(void 0,TC,a):oj.bind(void 0,Td),f=l||u?ij.bind(void 0,Tue,a):oj.bind(void 0,_E),p=l||u?wue.bind(void 0,a):void 0;return{stream:new I6e({writableObjectMode:n,writableHighWaterMark:xue(n),readableObjectMode:i,readableHighWaterMark:xue(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},wC=(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=Rue(s,r,a);t=Aue(c,t)}return t},Rue=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Sue(n,a)},bC(r,s,n),vC(r,o,n,c),{transform:t,final:e},{transform:Eue(i,a)},yue({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Cue=(t,e)=>{for(let r of P6e(t))O6e(t,r,e)},P6e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),O6e=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${fl[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>N6e(a,n));r.input=aE(s)},N6e=(t,e)=>{let r=wC(t,e,"utf8",!0);return k6e(r),aE(r)},k6e=t=>{let e=t.find(r=>typeof r!="string"&&!Tr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as L6e,appendFileSync as U6e}from"fs";var AC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&wh(r,n)&&!wi.has(e)&&M6e(n)&&(t.some(({type:i,value:o})=>i==="native"&&$6e.has(o))||t.every(({type:i})=>Qi.has(i))),M6e=t=>t===1||t===2,$6e=new Set(["pipe","overlapped"]),Iue=async(t,e,r,n)=>{for await(let i of t)D6e(e)||Oue(i,r,n)},Pue=(t,e,r)=>{for(let n of t)Oue(n,e,r)},D6e=t=>t._readableState.pipes.length>0,Oue=(t,e,r)=>{let n=F0(t);Os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Nue=({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)=>F6e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},F6e=({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=kle(t,o,d),p=za(f),{stdioItems:h,objectMode:m}=e[r],g=z6e([p],h,c,n),{serializedResult:_,finalResult:v=_}=j6e({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});B6e({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?v:void 0;try{return n.error===void 0&&q6e(_,h,i),w}catch(E){return n.error=E,w}},z6e=(t,e,r,n)=>{try{return wC(t,e,r,!1)}catch(i){return n.error=i,t}},j6e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:aE(t)};let s=Wse(t,r);return n[o]?{serializedResult:s,finalResult:nj(s,!i[o],e)}:{serializedResult:s}},B6e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!AC({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=nj(t,!1,s);try{Pue(a,e,n)}catch(c){r.error??=c}},q6e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>SC.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?U6e(n,t):(r.add(o),L6e(n,t))}};var kue=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,qa(e,r,"all")]:Array.isArray(e)?[qa(t,r,"all"),...e]:Tr(t)&&Tr(e)?fz([t,e]):`${t}${e}`};import{once as aj}from"events";var Mue=async(t,e)=>{let[r,n]=await V6e(t);return e.isForcefullyTerminated??=!1,[r,n]},V6e=async t=>{let[e,r]=await Promise.allSettled([aj(t,"spawn"),aj(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$ue(t):r.value},$ue=async t=>{try{return await aj(t,"exit")}catch{return $ue(t)}},Due=async t=>{let[e,r]=await t;if(!G6e(e,r)&&cj(e,r))throw new Fo;return[e,r]},G6e=(t,e)=>t===void 0&&e===void 0,cj=(t,e)=>t!==0||e!==null;var Lue=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=H6e(t,e,r),s=o?.code==="ETIMEDOUT",a=Nle(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},H6e=(t,e,r)=>t!==void 0?t:cj(e,r)?new Fo:void 0;var Uue=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Y6e(t,e,r),d=J6e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Mh(d,c,l)},Y6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=j0(t,e,r),a=K6e(r),{file:c,commandArguments:l,options:u}=aC(t,e,a);Z6e(u);let d=hue(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},K6e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Z6e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&xC("ipcInput"),t&&xC("ipc: true"),r&&xC("detached: true"),n&&xC("cancelSignal")},xC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},J6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=X6e({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}=Lue(c,r),{output:h,error:m=l}=Nue({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,w)=>qa(v,r,w)),_=qa(kue(h,r),r,"all");return e3e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},X6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Cue(o,r);let a=Q6e(r);return W6e(...cC(t,e,a))}catch(a){return kh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Q6e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:mC(e)}),e3e=({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?gC({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):gE({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 jWe}from"events";import{spawn as BWe}from"child_process";import que from"process";import{once as lj,on as t3e}from"events";var Fue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Rh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:tC(t)}),r3e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),r3e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{J0(e,i);let o=dl(t,e,r),s=new AbortController;try{return await Promise.race([n3e(o,n,s),i3e(o,r,s),o3e(o,r,s)])}catch(a){throw Ch(t),a}finally{s.abort(),X0(e,i)}},n3e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await lj(t,"message",{signal:r});return n}for await(let[n]of t3e(t,"message",{signal:r}))if(e(n))return n},i3e=async(t,e,{signal:r})=>{await lj(t,"disconnect",{signal:r}),Ace(e)},o3e=async(t,e,{signal:r})=>{let[n]=await lj(t,"strict:error",{signal:r});throw Y0(n,e)};import{once as jue,on as s3e}from"events";var Bue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>uj({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),uj=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Rh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:tC(t)}),J0(e,o);let s=dl(t,e,r),a=new AbortController,c={};return a3e(t,s,a),c3e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),l3e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},a3e=async(t,e,r)=>{try{await jue(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},c3e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await jue(t,"strict:error",{signal:r.signal});n.error=Y0(i,e),r.abort()}catch{}},l3e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of s3e(r,"message",{signal:o.signal}))zue(s),yield c}catch{zue(s)}finally{o.abort(),X0(e,a),n||Ch(t),i&&await t}},zue=({error:t})=>{if(t)throw t};var Vue=(t,{ipc:e})=>{Object.assign(t,Hue(t,!1,e))},Gue=()=>{let t=que,e=!0,r=que.channel!==void 0;return{...Hue(t,e,r),getCancelSignal:Xce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Hue=(t,e,r)=>({sendMessage:oC.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Fue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Bue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as u3e}from"child_process";import{PassThrough as d3e,Readable as f3e,Writable as p3e,Duplex as h3e}from"stream";var Wue=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ej(n);let a=new u3e;m3e(a,n),Object.assign(a,{readable:g3e,writable:_3e,duplex:y3e});let c=kh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=S3e(c,s,i);return{subprocess:a,promise:l}},m3e=(t,e)=>{let r=yE(),n=yE(),i=yE(),o=Array.from({length:e.length-3},yE),s=yE(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},yE=()=>{let t=new d3e;return t.end(),t},g3e=()=>new f3e({read(){}}),_3e=()=>new p3e({write(){}}),y3e=()=>new h3e({read(){},write(){}}),S3e=async(t,e,r)=>Mh(t,e,r);import{createReadStream as Yue,createWriteStream as Kue}from"fs";import{Buffer as E3e}from"buffer";import{Readable as SE,Writable as v3e,Duplex as b3e}from"stream";var Jue=(t,e)=>EC(T3e,t,e,!1),EE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${fl[t]}.`)},Zue={fileNumber:EE,generator:sj,asyncGenerator:sj,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:b3e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},T3e={input:{...Zue,fileUrl:({value:t})=>({stream:Yue(t)}),filePath:({value:{file:t}})=>({stream:Yue(t)}),webStream:({value:t})=>({stream:SE.fromWeb(t)}),iterable:({value:t})=>({stream:SE.from(t)}),asyncIterable:({value:t})=>({stream:SE.from(t)}),string:({value:t})=>({stream:SE.from(t)}),uint8Array:({value:t})=>({stream:SE.from(E3e.from(t))})},output:{...Zue,fileUrl:({value:t})=>({stream:Kue(t)}),filePath:({value:{file:t,append:e}})=>({stream:Kue(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:v3e.fromWeb(t)}),iterable:EE,asyncIterable:EE,string:EE,uint8Array:EE}};import{on as w3e,once as Xue}from"events";import{PassThrough as A3e,getDefaultHighWaterMark as x3e}from"stream";import{finished as tde}from"stream/promises";function wd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)fj(i);let e=t.some(({readableObjectMode:i})=>i),r=R3e(t,e),n=new dj({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var R3e=(t,e)=>{if(t.length===0)return x3e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},dj=class extends A3e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(fj(e),this.#e.has(e))return;this.#e.add(e),this.#n??=C3e(this,this.#e,this.#o);let r=O3e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(fj(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},C3e=async(t,e,r)=>{RC(t,Que);let n=new AbortController;try{await Promise.race([I3e(t,n),P3e(t,e,r,n)])}finally{n.abort(),RC(t,-Que)}},I3e=async(t,{signal:e})=>{try{await tde(t,{signal:e,cleanup:!0})}catch(r){throw rde(t,r),r}},P3e=async(t,e,r,{signal:n})=>{for await(let[i]of w3e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},fj=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},O3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{RC(t,ede);let a=new AbortController;try{await Promise.race([N3e(o,e,a),k3e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),M3e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),RC(t,-ede)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?pj(t):$3e(t))},N3e=async(t,e,{signal:r})=>{try{await t,r.aborted||pj(e)}catch(n){r.aborted||rde(e,n)}},k3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await tde(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;nde(s)?i.add(e):ide(t,s)}},M3e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Xue(t,i,{signal:o}),!t.readable)return Xue(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},$3e=t=>{t.writable&&t.end()},rde=(t,e)=>{nde(e)?pj(t):ide(t,e)},nde=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",pj=t=>{(t.readable||t.writable)&&t.destroy()},ide=(t,e)=>{t.destroyed||(t.once("error",D3e),t.destroy(e))},D3e=()=>{},RC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Que=2,ede=1;import{finished as ode}from"stream/promises";var Dh=(t,e)=>{t.pipe(e),L3e(t,e),U3e(t,e)},L3e=async(t,e)=>{if(!(Uo(t)||Uo(e))){try{await ode(t,{cleanup:!0,readable:!0,writable:!1})}catch{}hj(e)}},hj=t=>{t.writable&&t.end()},U3e=async(t,e)=>{if(!(Uo(t)||Uo(e))){try{await ode(e,{cleanup:!0,readable:!1,writable:!0})}catch{}mj(t)}},mj=t=>{t.readable&&t.destroy()};var sde=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Qi.has(c)))F3e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qi.has(c)))j3e({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]:wd(o);Dh(s,i)}},F3e=(t,e,r,n)=>{r==="output"?Dh(t.stdio[n],e):Dh(e,t.stdio[n]);let i=z3e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},z3e=["stdin","stdout","stderr"],j3e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;B3e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},B3e=(t,{signal:e})=>{Uo(t)&&Ed(t,q3e,e)},q3e=2;import{addAbortListener as H3e}from"events";var Ad=[];Ad.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ad.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ad.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var CC=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",gj=Symbol.for("signal-exit emitter"),_j=globalThis,V3e=Object.defineProperty.bind(Object),yj=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(_j[gj])return _j[gj];V3e(_j,gj,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},IC=class{},G3e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Sj=class extends IC{onExit(){return()=>{}}load(){}unload(){}},Ej=class extends IC{#e=vj.platform==="win32"?"SIGINT":"SIGHUP";#r=new yj;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ad)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(!CC(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 Ad)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,Ad.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 CC(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"&&CC(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},vj=globalThis.process,{onExit:ade,load:Kzt,unload:Zzt}=G3e(CC(vj)?new Ej(vj):new Sj);var cde=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ade(()=>{t.kill()});H3e(n,()=>{i()})};var ude=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=z0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=W3e(r,n,i),{sourceStream:d,sourceError:f}=K3e(t,l),{options:p,fileDescriptors:h}=ks.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},W3e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Y3e(t,e,...r),a=Z0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Y3e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(lde,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||uz(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=P0(r,...n);return{destination:e(lde)(i,o,s),pipeOptions:s}}if(ks.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},lde=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),K3e=(t,e)=>{try{return{sourceStream:Ih(t,e)}}catch(r){return{sourceError:r}}};var fde=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Z3e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw bj({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Z3e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return mj(t),n;if(e!==void 0)return hj(r),e},bj=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>kh({error:t,command:dde,escapedCommand:dde,fileDescriptors:e,options:r,startTime:n,isSync:!1}),dde="source.pipe(destination)";var pde=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 J3e}from"stream/promises";var hde=(t,e,r)=>{let n=PC.has(e)?Q3e(t,e):X3e(t,e);return Ed(t,tWe,r.signal),Ed(e,rWe,r.signal),eWe(e),n},X3e=(t,e)=>{let r=wd([t]);return Dh(r,e),PC.set(e,r),r},Q3e=(t,e)=>{let r=PC.get(e);return r.add(t),r},eWe=async t=>{try{await J3e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}PC.delete(t)},PC=new WeakMap,tWe=2,rWe=1;import{aborted as nWe}from"util";var mde=(t,e)=>t===void 0?[]:[iWe(t,e)],iWe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await nWe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw bj({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var OC=(t,...e)=>{if(lr(e[0]))return OC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ude(t,...e),i=oWe({...n,destination:r});return i.pipe=OC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},oWe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=sWe(t,i);fde({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=hde(e,o,d);return await Promise.race([pde(u),...mde(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},sWe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as pWe}from"timers/promises";import{on as aWe}from"events";import{getDefaultHighWaterMark as cWe}from"stream";var NC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return lWe(e,s),_de({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},lWe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Tj=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;uWe(e,s,t);let a=t.readableObjectMode&&!o;return _de({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},uWe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_de=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=aWe(t,"data",{signal:e.signal,highWaterMark:gde,highWatermark:gde});return dWe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},wj=cWe(!0),gde=wj,dWe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=fWe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Td(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*_E(a)}},fWe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[bC(t,r,!e),vC(t,i,!n,{})].filter(Boolean);var yde=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=hWe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([mWe(t),d]);return}let f=tj(c,r),p=Tj({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([gWe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},hWe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!AC({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=Tj({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Iue(a,t,r,o)},mWe=async t=>{await pWe(),t.readableFlowing===null&&t.resume()},gWe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await fC(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await pC(r,{maxBuffer:o})):await Nh(r,{maxBuffer:o})}catch(a){return Sde(Ile({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},Aj=async t=>{try{return await t}catch(e){return Sde(e)}},Sde=({bufferedData:t})=>Gse(t)?new Uint8Array(t):t;import{finished as _We}from"stream/promises";var vE=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=yWe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],_We(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||vWe(a,e,r,n)}finally{s.abort()}},yWe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&SWe(t,r,n),n},SWe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{EWe(e,r),n.call(t,...i)}},EWe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},vWe=(t,e,r,n)=>{if(!bWe(t,e,r,n))throw t},bWe=(t,e,r,n=!0)=>r.propagating?Ede(t)||kC(t):(r.propagating=!0,xj(r,e)===n?Ede(t):kC(t)),xj=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",kC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ede=t=>t?.code==="EPIPE";var vde=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>Rj({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Rj=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=vE(t,e,l);if(xj(l,e)){await u;return}let[d]=await Promise.all([yde({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 bde=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?wd([t,e].filter(Boolean)):void 0,Tde=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Rj({...TWe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:wWe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),TWe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},wWe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as AWe}from"events";var wde=t=>wh(t,"ipc"),Ade=(t,e)=>{let r=F0(t);Os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var xde=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=wde(o),a=ja(e,"ipc"),c=ja(r,"ipc");for await(let l of uj({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ple(t,i,c),i.push(l)),s&&Ade(l,o);return i},Rde=async(t,e)=>(await Promise.allSettled([t]),e);var Cde=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let v=Mue(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},E=vde({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),T=Tde({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),A=[],C=xde({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),I=xWe(m,t,w),N=RWe(h,w);try{return await Promise.race([Promise.all([{},Due(v),Promise.all(E),T,C,cle(t,d),...I,...N]),g,CWe(t,_),...nle(t,o,f,_),...wce({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...tle({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},v,Promise.all(E.map(b=>Aj(b))),Aj(T),Rde(C,A),Promise.allSettled(I),Promise.allSettled(N)])}},xWe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:vE(n,i,r)),RWe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>jo(o,{checkOpen:!1})&&!Uo(o)).map(({type:i,value:o,stream:s=o})=>vE(s,n,e,{isSameDirection:Qi.has(i),stopOnExit:i==="native"}))),CWe=async(t,{signal:e})=>{let[r]=await AWe(t,"error",{signal:e});throw r};var Ide=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),bE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Ns();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Lh=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as IWe}from"stream";import{callbackify as PWe}from"util";import{finished as Pde}from"stream/promises";var Cj=async t=>{if(t!==void 0)try{await Ij(t)}catch{}},Ode=async t=>{if(t!==void 0)try{await Pj(t)}catch{}},Ij=async t=>{await Pde(t,{cleanup:!0,readable:!1,writable:!0})},Pj=async t=>{await Pde(t,{cleanup:!0,readable:!0,writable:!1})},MC=async(t,e)=>{if(await t,e)throw e},$C=(t,e,r)=>{r&&!kC(r)?t.destroy(r):e&&t.destroy()};var Nde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||wi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Oj(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Nj(a,s),{read:f,onStdoutDataDone:p}=kj({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new IWe({read:f,destroy:PWe($j.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Mj({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Oj=(t,e,r)=>{let n=Ih(t,e),i=bE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Nj=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:wj},kj=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Ns(),s=NC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){OWe(this,s,o)},onStdoutDataDone:o}},OWe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Mj=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Pj(t),await n,await Cj(i),await e,r.readable&&r.push(null)}catch(o){await Cj(i),kde(r,o)}},$j=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Lh(r,e)&&(kde(t,n),await MC(e,n))},kde=(t,e)=>{$C(t,t.readable,e)};import{Writable as NWe}from"stream";import{callbackify as Mde}from"util";var $de=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Dj(t,r,e),s=new NWe({...Lj(n,t,i),destroy:Mde(Fj.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Uj(n,s),s},Dj=(t,e,r)=>{let n=Z0(t,e),i=bE(r,n,"writableFinal"),o=bE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Lj=(t,e,r)=>({write:kWe.bind(void 0,t),final:Mde(MWe.bind(void 0,t,e,r))}),kWe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},MWe=async(t,e,r)=>{await Lh(r,e)&&(t.writable&&t.end(),await e)},Uj=async(t,e,r)=>{try{await Ij(t),e.writable&&e.end()}catch(n){await Ode(r),Dde(e,n)}},Fj=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Lh(r,e),await Lh(n,e)&&(Dde(t,i),await MC(e,i))},Dde=(t,e)=>{$C(t,t.writable,e)};import{Duplex as $We}from"stream";import{callbackify as DWe}from"util";var Lde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||wi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Oj(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Dj(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Nj(c,a),{read:g,onStdoutDataDone:_}=kj({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new $We({read:g,...Lj(u,t,d),destroy:DWe(LWe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return Mj({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:t,subprocessStdin:u}),Uj(u,v,c),v},LWe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([$j({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Fj({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var zj=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||wi.has(e),s=Ih(t,r),a=NC({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return UWe(a,s,t)},UWe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Ude=(t,{encoding:e})=>{let r=Ide();t.readable=Nde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$de.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Lde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zj.bind(void 0,t,e),t[Symbol.asyncIterator]=zj.bind(void 0,t,e,{})};var Fde=(t,e)=>{for(let[r,n]of zWe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},FWe=(async()=>{})().constructor.prototype,zWe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(FWe,t)]);var zde=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=qWe(t,e,r),{subprocess:f,promise:p}=GWe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=OC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Fde(f,p),ks.set(f,{options:u,fileDescriptors:d}),f},qWe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=j0(t,e,r),{file:a,commandArguments:c,options:l}=aC(t,e,r),u=VWe(l),d=Jue(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},VWe=({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}},GWe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=BWe(...cC(t,e,r))}catch(h){return Wue({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;jWe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];sde(c,a,l),cde(c,r,l);let d={},f=Ns();c.kill=bce.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=bde(c,r),Ude(c,r),Vue(c,r);let p=HWe({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}},HWe=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 Cde({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((E,T)=>qa(E,e,T)),v=qa(m,e,"all"),w=WWe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Mh(w,n,e)},WWe=({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?gE({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Ms,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):gC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var DC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,YWe(n,t[n],i)]));return{...t,...r}},YWe=(t,e,r)=>KWe.has(t)&&lr(e)&&lr(r)?{...e,...r}:r,KWe=new Set(["env",...gz]);var pl=(t,e,r,n)=>{let i=(s,a,c)=>pl(s,a,r,c),o=(...s)=>ZWe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},ZWe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(lr(o))return i(t,DC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=JWe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Uue(a,c,l):zde(a,c,l,i)},JWe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Jse(e)?Xse(e,r):[e,...r],[s,a,c]=P0(...o),l=DC(DC(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 jde=({file:t,commandArguments:e})=>qde(t,e),Bde=({file:t,commandArguments:e})=>({...qde(t,e),isSync:!0}),qde=(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]=XWe(t);return{file:r,commandArguments:n}},XWe=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(QWe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},QWe=/ +/g;var Vde=(t,e,r)=>{t.sync=e(eYe,r),t.s=t.sync},Gde=({options:t})=>Hde(t),eYe=({options:t})=>({...Hde(t),isSync:!0}),Hde=t=>({options:{...tYe(t),...t}}),tYe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Wde={preferLocal:!0};var Yde=pl(()=>({})),F2t=pl(()=>({isSync:!0})),Kde=pl(jde),z2t=pl(Bde),j2t=pl(ole),B2t=pl(Gde,{},Wde,Vde),{sendMessage:q2t,getOneMessage:V2t,getEachMessage:G2t,getCancelSignal:H2t}=Gue();var Zde=!1,Jde=()=>{Zde=!0},Ds=()=>Zde;var TE=null,Xde=t=>(TE&&TE.destroy(),TE=new Bo({totalAllowedTime:t}),TE),Qde=()=>TE;var Bo=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Ds())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await _0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Z.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var efe={name:"@netlify/agent-runner-cli",type:"module",version:"1.175.0-run-started.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var oYe=nYe(import.meta.url),sYe=Va.dirname(oYe),aYe=iYe(import.meta.url),Uh=oe("shell"),jj=new Set,tfe={preferLocal:!0},Ft=(t,e,r)=>{let[n,i]=cYe(e,r),o={...tfe,...i},s=Yde(t,n,o);nfe(s,o),sfe(s);let a=r?.idleTimeout;return a&&a>0&&ofe(s,a),s},rfe=(t,e)=>{let r={...tfe,...e},n=Kde(t,r);return nfe(n,r),sfe(n),e?.idleTimeout&&e.idleTimeout>0&&ofe(n,e.idleTimeout),n},cYe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},nfe=(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 XS).pipe(Ls.stdout),t.stderr?.pipe(new XS).pipe(Ls.stderr);return}t.stdout?.pipe(Ls.stdout),t.stderr?.pipe(Ls.stderr)},Bj=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ls.kill(-t.pid,e),Uh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Uh.error("Error killing process:",r),!1}},ife=t=>Bj(t,"SIGKILL"),ofe=(t,e)=>{let r=null,n=()=>{Uh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Bj(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uh.log(`Force killing idle process ${t.pid}`),ife(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)},sfe=t=>{jj.add(t);let e=Qde();if(e){let r=e.onTimesUp(()=>{Uh.log(`Global timer expired, killing process ${t.pid}`),Bj(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uh.log(`Force killing process ${t.pid} after timeout`),ife(t))},5e3)});t.on("exit",()=>{jj.delete(t),r()}),t.on("error",()=>{jj.delete(t),r()})}};function UC(t,e){return!!qo(t,e)}function qo(t,e){if(!Ls.env.NETLIFY_LOCAL_MODE)try{let i=aYe.resolve(efe.name),o=Va.dirname(i);for(;o!==Va.dirname(o);){let s=Va.dirname(o);if(Va.basename(s)==="node_modules"){let a=Va.join(s,".bin",e);if(LC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ls.env.NODE_PATH){let i=Va.join(Ls.env.NODE_PATH,".bin",e);if(LC.existsSync(i))return i}let r=Va.join(t,"node_modules",".bin",e);if(LC.existsSync(r))return r;let n=Va.join(sYe,"..","node_modules",".bin",e);if(LC.existsSync(n))return n}var afe=oe("repo"),ffe="runner-diffs-",pfe=t=>`${ffe}${t}-`,hfe=async t=>{let e=dfe.tmpdir(),r;try{r=await FC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(ffe)&&!n.startsWith(pfe(t))).map(n=>FC.rm(zC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},ri=(t,e={})=>Ft("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),jC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{afe.info("Getting runner diffs");let n=await fYe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=hYe(o);await mYe(h,r)}afe.info("Changes after processing"),await Vj(r);let s=await Gj(o,r);if(await qj(s,r),i=await pYe(r),!i)return{hasChanges:!1,ignored:s};await ri(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await FC.mkdtemp(zC.join(dfe.tmpdir(),pfe(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let v=zC.join(a,g);await ri([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${v}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:E}=await FC.stat(v);return{path:v,size:E}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await ufe(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await lfe(d,h)||(f=h)}await ufe(r),Z.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await lfe(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},cfe=async t=>{let e=lYe("sha256");for await(let r of uYe(t))e.update(r);return e.digest("hex")},lfe=async(t,e)=>t.size===e.size&&await cfe(t.path)===await cfe(e.path),ufe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await ri(["reset","--soft","HEAD~1"],{cwd:t})},qj=async(t=[],e=process.cwd())=>{await ri(["add",".",...t],{cwd:e})},Vj=async(t=process.cwd())=>{let e=await ri(["status","-s"],{cwd:t});return String(e.stdout??"")},mfe=/.. (.+)?\.log$/,dYe=[mfe],fYe=async(t=process.cwd())=>{let e=await Vj(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
144
|
+
if (condition) { yield value; }`)};import{Buffer as E6e}from"buffer";import{StringDecoder as v6e}from"string_decoder";var bC=(t,e,r)=>{if(r)return;if(t)return{transform:b6e.bind(void 0,new TextEncoder)};let n=new v6e(e);return{transform:T6e.bind(void 0,n),final:w6e.bind(void 0,n)}},b6e=function*(t,e){E6e.isBuffer(e)?yield za(e):typeof e=="string"?yield t.encode(e):yield e},T6e=function*(t,e){yield Tr(e)?t.write(e):e},w6e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as bue}from"util";var ij=bue(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),TC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=x6e}=e[r];for await(let i of n(t))yield*TC(i,e,r+1)},Tue=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*A6e(r,Number(e),t)},A6e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*TC(n,r,e+1)},wue=bue(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),x6e=function*(t){yield t};var oj=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Aue=(t,e)=>[...e.flatMap(r=>[...Td(r,t,0)]),..._E(t)],Td=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=C6e}=e[r];for(let i of n(t))yield*Td(i,e,r+1)},_E=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*R6e(r,Number(e),t)},R6e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Td(n,r,e+1)},C6e=function*(t){yield t};var sj=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Rue(t,s,o),l=bd(e),u=bd(r),d=l?ij.bind(void 0,TC,a):oj.bind(void 0,Td),f=l||u?ij.bind(void 0,Tue,a):oj.bind(void 0,_E),p=l||u?wue.bind(void 0,a):void 0;return{stream:new I6e({writableObjectMode:n,writableHighWaterMark:xue(n),readableObjectMode:i,readableHighWaterMark:xue(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},wC=(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=Rue(s,r,a);t=Aue(c,t)}return t},Rue=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Sue(n,a)},bC(r,s,n),vC(r,o,n,c),{transform:t,final:e},{transform:Eue(i,a)},yue({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Cue=(t,e)=>{for(let r of P6e(t))O6e(t,r,e)},P6e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),O6e=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${fl[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>N6e(a,n));r.input=aE(s)},N6e=(t,e)=>{let r=wC(t,e,"utf8",!0);return k6e(r),aE(r)},k6e=t=>{let e=t.find(r=>typeof r!="string"&&!Tr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as L6e,appendFileSync as U6e}from"fs";var AC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&wh(r,n)&&!wi.has(e)&&M6e(n)&&(t.some(({type:i,value:o})=>i==="native"&&$6e.has(o))||t.every(({type:i})=>Qi.has(i))),M6e=t=>t===1||t===2,$6e=new Set(["pipe","overlapped"]),Iue=async(t,e,r,n)=>{for await(let i of t)D6e(e)||Oue(i,r,n)},Pue=(t,e,r)=>{for(let n of t)Oue(n,e,r)},D6e=t=>t._readableState.pipes.length>0,Oue=(t,e,r)=>{let n=F0(t);Os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Nue=({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)=>F6e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},F6e=({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=kle(t,o,d),p=za(f),{stdioItems:h,objectMode:m}=e[r],g=z6e([p],h,c,n),{serializedResult:_,finalResult:v=_}=j6e({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});B6e({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?v:void 0;try{return n.error===void 0&&q6e(_,h,i),w}catch(E){return n.error=E,w}},z6e=(t,e,r,n)=>{try{return wC(t,e,r,!1)}catch(i){return n.error=i,t}},j6e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:aE(t)};let s=Wse(t,r);return n[o]?{serializedResult:s,finalResult:nj(s,!i[o],e)}:{serializedResult:s}},B6e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!AC({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=nj(t,!1,s);try{Pue(a,e,n)}catch(c){r.error??=c}},q6e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>SC.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?U6e(n,t):(r.add(o),L6e(n,t))}};var kue=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,qa(e,r,"all")]:Array.isArray(e)?[qa(t,r,"all"),...e]:Tr(t)&&Tr(e)?fz([t,e]):`${t}${e}`};import{once as aj}from"events";var Mue=async(t,e)=>{let[r,n]=await V6e(t);return e.isForcefullyTerminated??=!1,[r,n]},V6e=async t=>{let[e,r]=await Promise.allSettled([aj(t,"spawn"),aj(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$ue(t):r.value},$ue=async t=>{try{return await aj(t,"exit")}catch{return $ue(t)}},Due=async t=>{let[e,r]=await t;if(!G6e(e,r)&&cj(e,r))throw new Fo;return[e,r]},G6e=(t,e)=>t===void 0&&e===void 0,cj=(t,e)=>t!==0||e!==null;var Lue=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=H6e(t,e,r),s=o?.code==="ETIMEDOUT",a=Nle(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},H6e=(t,e,r)=>t!==void 0?t:cj(e,r)?new Fo:void 0;var Uue=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Y6e(t,e,r),d=J6e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Mh(d,c,l)},Y6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=j0(t,e,r),a=K6e(r),{file:c,commandArguments:l,options:u}=aC(t,e,a);Z6e(u);let d=hue(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},K6e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Z6e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&xC("ipcInput"),t&&xC("ipc: true"),r&&xC("detached: true"),n&&xC("cancelSignal")},xC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},J6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=X6e({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}=Lue(c,r),{output:h,error:m=l}=Nue({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,w)=>qa(v,r,w)),_=qa(kue(h,r),r,"all");return e3e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},X6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Cue(o,r);let a=Q6e(r);return W6e(...cC(t,e,a))}catch(a){return kh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Q6e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:mC(e)}),e3e=({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?gC({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):gE({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 jWe}from"events";import{spawn as BWe}from"child_process";import que from"process";import{once as lj,on as t3e}from"events";var Fue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Rh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:tC(t)}),r3e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),r3e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{J0(e,i);let o=dl(t,e,r),s=new AbortController;try{return await Promise.race([n3e(o,n,s),i3e(o,r,s),o3e(o,r,s)])}catch(a){throw Ch(t),a}finally{s.abort(),X0(e,i)}},n3e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await lj(t,"message",{signal:r});return n}for await(let[n]of t3e(t,"message",{signal:r}))if(e(n))return n},i3e=async(t,e,{signal:r})=>{await lj(t,"disconnect",{signal:r}),Ace(e)},o3e=async(t,e,{signal:r})=>{let[n]=await lj(t,"strict:error",{signal:r});throw Y0(n,e)};import{once as jue,on as s3e}from"events";var Bue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>uj({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),uj=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Rh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:tC(t)}),J0(e,o);let s=dl(t,e,r),a=new AbortController,c={};return a3e(t,s,a),c3e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),l3e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},a3e=async(t,e,r)=>{try{await jue(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},c3e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await jue(t,"strict:error",{signal:r.signal});n.error=Y0(i,e),r.abort()}catch{}},l3e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of s3e(r,"message",{signal:o.signal}))zue(s),yield c}catch{zue(s)}finally{o.abort(),X0(e,a),n||Ch(t),i&&await t}},zue=({error:t})=>{if(t)throw t};var Vue=(t,{ipc:e})=>{Object.assign(t,Hue(t,!1,e))},Gue=()=>{let t=que,e=!0,r=que.channel!==void 0;return{...Hue(t,e,r),getCancelSignal:Xce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Hue=(t,e,r)=>({sendMessage:oC.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Fue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Bue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as u3e}from"child_process";import{PassThrough as d3e,Readable as f3e,Writable as p3e,Duplex as h3e}from"stream";var Wue=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ej(n);let a=new u3e;m3e(a,n),Object.assign(a,{readable:g3e,writable:_3e,duplex:y3e});let c=kh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=S3e(c,s,i);return{subprocess:a,promise:l}},m3e=(t,e)=>{let r=yE(),n=yE(),i=yE(),o=Array.from({length:e.length-3},yE),s=yE(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},yE=()=>{let t=new d3e;return t.end(),t},g3e=()=>new f3e({read(){}}),_3e=()=>new p3e({write(){}}),y3e=()=>new h3e({read(){},write(){}}),S3e=async(t,e,r)=>Mh(t,e,r);import{createReadStream as Yue,createWriteStream as Kue}from"fs";import{Buffer as E3e}from"buffer";import{Readable as SE,Writable as v3e,Duplex as b3e}from"stream";var Jue=(t,e)=>EC(T3e,t,e,!1),EE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${fl[t]}.`)},Zue={fileNumber:EE,generator:sj,asyncGenerator:sj,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:b3e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},T3e={input:{...Zue,fileUrl:({value:t})=>({stream:Yue(t)}),filePath:({value:{file:t}})=>({stream:Yue(t)}),webStream:({value:t})=>({stream:SE.fromWeb(t)}),iterable:({value:t})=>({stream:SE.from(t)}),asyncIterable:({value:t})=>({stream:SE.from(t)}),string:({value:t})=>({stream:SE.from(t)}),uint8Array:({value:t})=>({stream:SE.from(E3e.from(t))})},output:{...Zue,fileUrl:({value:t})=>({stream:Kue(t)}),filePath:({value:{file:t,append:e}})=>({stream:Kue(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:v3e.fromWeb(t)}),iterable:EE,asyncIterable:EE,string:EE,uint8Array:EE}};import{on as w3e,once as Xue}from"events";import{PassThrough as A3e,getDefaultHighWaterMark as x3e}from"stream";import{finished as tde}from"stream/promises";function wd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)fj(i);let e=t.some(({readableObjectMode:i})=>i),r=R3e(t,e),n=new dj({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var R3e=(t,e)=>{if(t.length===0)return x3e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},dj=class extends A3e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(fj(e),this.#e.has(e))return;this.#e.add(e),this.#n??=C3e(this,this.#e,this.#o);let r=O3e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(fj(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},C3e=async(t,e,r)=>{RC(t,Que);let n=new AbortController;try{await Promise.race([I3e(t,n),P3e(t,e,r,n)])}finally{n.abort(),RC(t,-Que)}},I3e=async(t,{signal:e})=>{try{await tde(t,{signal:e,cleanup:!0})}catch(r){throw rde(t,r),r}},P3e=async(t,e,r,{signal:n})=>{for await(let[i]of w3e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},fj=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},O3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{RC(t,ede);let a=new AbortController;try{await Promise.race([N3e(o,e,a),k3e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),M3e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),RC(t,-ede)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?pj(t):$3e(t))},N3e=async(t,e,{signal:r})=>{try{await t,r.aborted||pj(e)}catch(n){r.aborted||rde(e,n)}},k3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await tde(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;nde(s)?i.add(e):ide(t,s)}},M3e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Xue(t,i,{signal:o}),!t.readable)return Xue(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},$3e=t=>{t.writable&&t.end()},rde=(t,e)=>{nde(e)?pj(t):ide(t,e)},nde=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",pj=t=>{(t.readable||t.writable)&&t.destroy()},ide=(t,e)=>{t.destroyed||(t.once("error",D3e),t.destroy(e))},D3e=()=>{},RC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Que=2,ede=1;import{finished as ode}from"stream/promises";var Dh=(t,e)=>{t.pipe(e),L3e(t,e),U3e(t,e)},L3e=async(t,e)=>{if(!(Uo(t)||Uo(e))){try{await ode(t,{cleanup:!0,readable:!0,writable:!1})}catch{}hj(e)}},hj=t=>{t.writable&&t.end()},U3e=async(t,e)=>{if(!(Uo(t)||Uo(e))){try{await ode(e,{cleanup:!0,readable:!1,writable:!0})}catch{}mj(t)}},mj=t=>{t.readable&&t.destroy()};var sde=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Qi.has(c)))F3e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qi.has(c)))j3e({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]:wd(o);Dh(s,i)}},F3e=(t,e,r,n)=>{r==="output"?Dh(t.stdio[n],e):Dh(e,t.stdio[n]);let i=z3e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},z3e=["stdin","stdout","stderr"],j3e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;B3e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},B3e=(t,{signal:e})=>{Uo(t)&&Ed(t,q3e,e)},q3e=2;import{addAbortListener as H3e}from"events";var Ad=[];Ad.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ad.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ad.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var CC=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",gj=Symbol.for("signal-exit emitter"),_j=globalThis,V3e=Object.defineProperty.bind(Object),yj=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(_j[gj])return _j[gj];V3e(_j,gj,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},IC=class{},G3e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Sj=class extends IC{onExit(){return()=>{}}load(){}unload(){}},Ej=class extends IC{#e=vj.platform==="win32"?"SIGINT":"SIGHUP";#r=new yj;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ad)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(!CC(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 Ad)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,Ad.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 CC(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"&&CC(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},vj=globalThis.process,{onExit:ade,load:Kzt,unload:Zzt}=G3e(CC(vj)?new Ej(vj):new Sj);var cde=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ade(()=>{t.kill()});H3e(n,()=>{i()})};var ude=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=z0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=W3e(r,n,i),{sourceStream:d,sourceError:f}=K3e(t,l),{options:p,fileDescriptors:h}=ks.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},W3e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Y3e(t,e,...r),a=Z0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Y3e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(lde,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||uz(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=P0(r,...n);return{destination:e(lde)(i,o,s),pipeOptions:s}}if(ks.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},lde=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),K3e=(t,e)=>{try{return{sourceStream:Ih(t,e)}}catch(r){return{sourceError:r}}};var fde=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Z3e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw bj({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Z3e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return mj(t),n;if(e!==void 0)return hj(r),e},bj=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>kh({error:t,command:dde,escapedCommand:dde,fileDescriptors:e,options:r,startTime:n,isSync:!1}),dde="source.pipe(destination)";var pde=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 J3e}from"stream/promises";var hde=(t,e,r)=>{let n=PC.has(e)?Q3e(t,e):X3e(t,e);return Ed(t,tWe,r.signal),Ed(e,rWe,r.signal),eWe(e),n},X3e=(t,e)=>{let r=wd([t]);return Dh(r,e),PC.set(e,r),r},Q3e=(t,e)=>{let r=PC.get(e);return r.add(t),r},eWe=async t=>{try{await J3e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}PC.delete(t)},PC=new WeakMap,tWe=2,rWe=1;import{aborted as nWe}from"util";var mde=(t,e)=>t===void 0?[]:[iWe(t,e)],iWe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await nWe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw bj({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var OC=(t,...e)=>{if(lr(e[0]))return OC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ude(t,...e),i=oWe({...n,destination:r});return i.pipe=OC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},oWe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=sWe(t,i);fde({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=hde(e,o,d);return await Promise.race([pde(u),...mde(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},sWe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as pWe}from"timers/promises";import{on as aWe}from"events";import{getDefaultHighWaterMark as cWe}from"stream";var NC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return lWe(e,s),_de({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},lWe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Tj=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;uWe(e,s,t);let a=t.readableObjectMode&&!o;return _de({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},uWe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_de=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=aWe(t,"data",{signal:e.signal,highWaterMark:gde,highWatermark:gde});return dWe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},wj=cWe(!0),gde=wj,dWe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=fWe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Td(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*_E(a)}},fWe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[bC(t,r,!e),vC(t,i,!n,{})].filter(Boolean);var yde=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=hWe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([mWe(t),d]);return}let f=tj(c,r),p=Tj({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([gWe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},hWe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!AC({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=Tj({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Iue(a,t,r,o)},mWe=async t=>{await pWe(),t.readableFlowing===null&&t.resume()},gWe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await fC(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await pC(r,{maxBuffer:o})):await Nh(r,{maxBuffer:o})}catch(a){return Sde(Ile({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},Aj=async t=>{try{return await t}catch(e){return Sde(e)}},Sde=({bufferedData:t})=>Gse(t)?new Uint8Array(t):t;import{finished as _We}from"stream/promises";var vE=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=yWe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],_We(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||vWe(a,e,r,n)}finally{s.abort()}},yWe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&SWe(t,r,n),n},SWe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{EWe(e,r),n.call(t,...i)}},EWe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},vWe=(t,e,r,n)=>{if(!bWe(t,e,r,n))throw t},bWe=(t,e,r,n=!0)=>r.propagating?Ede(t)||kC(t):(r.propagating=!0,xj(r,e)===n?Ede(t):kC(t)),xj=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",kC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ede=t=>t?.code==="EPIPE";var vde=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>Rj({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Rj=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=vE(t,e,l);if(xj(l,e)){await u;return}let[d]=await Promise.all([yde({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 bde=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?wd([t,e].filter(Boolean)):void 0,Tde=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Rj({...TWe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:wWe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),TWe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},wWe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as AWe}from"events";var wde=t=>wh(t,"ipc"),Ade=(t,e)=>{let r=F0(t);Os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var xde=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=wde(o),a=ja(e,"ipc"),c=ja(r,"ipc");for await(let l of uj({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ple(t,i,c),i.push(l)),s&&Ade(l,o);return i},Rde=async(t,e)=>(await Promise.allSettled([t]),e);var Cde=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let v=Mue(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},E=vde({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),T=Tde({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),A=[],C=xde({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),I=xWe(m,t,w),N=RWe(h,w);try{return await Promise.race([Promise.all([{},Due(v),Promise.all(E),T,C,cle(t,d),...I,...N]),g,CWe(t,_),...nle(t,o,f,_),...wce({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...tle({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},v,Promise.all(E.map(b=>Aj(b))),Aj(T),Rde(C,A),Promise.allSettled(I),Promise.allSettled(N)])}},xWe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:vE(n,i,r)),RWe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>jo(o,{checkOpen:!1})&&!Uo(o)).map(({type:i,value:o,stream:s=o})=>vE(s,n,e,{isSameDirection:Qi.has(i),stopOnExit:i==="native"}))),CWe=async(t,{signal:e})=>{let[r]=await AWe(t,"error",{signal:e});throw r};var Ide=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),bE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Ns();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Lh=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as IWe}from"stream";import{callbackify as PWe}from"util";import{finished as Pde}from"stream/promises";var Cj=async t=>{if(t!==void 0)try{await Ij(t)}catch{}},Ode=async t=>{if(t!==void 0)try{await Pj(t)}catch{}},Ij=async t=>{await Pde(t,{cleanup:!0,readable:!1,writable:!0})},Pj=async t=>{await Pde(t,{cleanup:!0,readable:!0,writable:!1})},MC=async(t,e)=>{if(await t,e)throw e},$C=(t,e,r)=>{r&&!kC(r)?t.destroy(r):e&&t.destroy()};var Nde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||wi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Oj(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Nj(a,s),{read:f,onStdoutDataDone:p}=kj({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new IWe({read:f,destroy:PWe($j.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Mj({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Oj=(t,e,r)=>{let n=Ih(t,e),i=bE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Nj=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:wj},kj=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Ns(),s=NC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){OWe(this,s,o)},onStdoutDataDone:o}},OWe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Mj=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Pj(t),await n,await Cj(i),await e,r.readable&&r.push(null)}catch(o){await Cj(i),kde(r,o)}},$j=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Lh(r,e)&&(kde(t,n),await MC(e,n))},kde=(t,e)=>{$C(t,t.readable,e)};import{Writable as NWe}from"stream";import{callbackify as Mde}from"util";var $de=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Dj(t,r,e),s=new NWe({...Lj(n,t,i),destroy:Mde(Fj.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Uj(n,s),s},Dj=(t,e,r)=>{let n=Z0(t,e),i=bE(r,n,"writableFinal"),o=bE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Lj=(t,e,r)=>({write:kWe.bind(void 0,t),final:Mde(MWe.bind(void 0,t,e,r))}),kWe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},MWe=async(t,e,r)=>{await Lh(r,e)&&(t.writable&&t.end(),await e)},Uj=async(t,e,r)=>{try{await Ij(t),e.writable&&e.end()}catch(n){await Ode(r),Dde(e,n)}},Fj=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Lh(r,e),await Lh(n,e)&&(Dde(t,i),await MC(e,i))},Dde=(t,e)=>{$C(t,t.writable,e)};import{Duplex as $We}from"stream";import{callbackify as DWe}from"util";var Lde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||wi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Oj(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Dj(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Nj(c,a),{read:g,onStdoutDataDone:_}=kj({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new $We({read:g,...Lj(u,t,d),destroy:DWe(LWe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return Mj({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:t,subprocessStdin:u}),Uj(u,v,c),v},LWe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([$j({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Fj({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var zj=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||wi.has(e),s=Ih(t,r),a=NC({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return UWe(a,s,t)},UWe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Ude=(t,{encoding:e})=>{let r=Ide();t.readable=Nde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$de.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Lde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zj.bind(void 0,t,e),t[Symbol.asyncIterator]=zj.bind(void 0,t,e,{})};var Fde=(t,e)=>{for(let[r,n]of zWe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},FWe=(async()=>{})().constructor.prototype,zWe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(FWe,t)]);var zde=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=qWe(t,e,r),{subprocess:f,promise:p}=GWe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=OC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Fde(f,p),ks.set(f,{options:u,fileDescriptors:d}),f},qWe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=j0(t,e,r),{file:a,commandArguments:c,options:l}=aC(t,e,r),u=VWe(l),d=Jue(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},VWe=({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}},GWe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=BWe(...cC(t,e,r))}catch(h){return Wue({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;jWe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];sde(c,a,l),cde(c,r,l);let d={},f=Ns();c.kill=bce.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=bde(c,r),Ude(c,r),Vue(c,r);let p=HWe({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}},HWe=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 Cde({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((E,T)=>qa(E,e,T)),v=qa(m,e,"all"),w=WWe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Mh(w,n,e)},WWe=({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?gE({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Ms,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):gC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var DC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,YWe(n,t[n],i)]));return{...t,...r}},YWe=(t,e,r)=>KWe.has(t)&&lr(e)&&lr(r)?{...e,...r}:r,KWe=new Set(["env",...gz]);var pl=(t,e,r,n)=>{let i=(s,a,c)=>pl(s,a,r,c),o=(...s)=>ZWe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},ZWe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(lr(o))return i(t,DC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=JWe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Uue(a,c,l):zde(a,c,l,i)},JWe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Jse(e)?Xse(e,r):[e,...r],[s,a,c]=P0(...o),l=DC(DC(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 jde=({file:t,commandArguments:e})=>qde(t,e),Bde=({file:t,commandArguments:e})=>({...qde(t,e),isSync:!0}),qde=(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]=XWe(t);return{file:r,commandArguments:n}},XWe=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(QWe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},QWe=/ +/g;var Vde=(t,e,r)=>{t.sync=e(eYe,r),t.s=t.sync},Gde=({options:t})=>Hde(t),eYe=({options:t})=>({...Hde(t),isSync:!0}),Hde=t=>({options:{...tYe(t),...t}}),tYe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Wde={preferLocal:!0};var Yde=pl(()=>({})),F2t=pl(()=>({isSync:!0})),Kde=pl(jde),z2t=pl(Bde),j2t=pl(ole),B2t=pl(Gde,{},Wde,Vde),{sendMessage:q2t,getOneMessage:V2t,getEachMessage:G2t,getCancelSignal:H2t}=Gue();var Zde=!1,Jde=()=>{Zde=!0},Ds=()=>Zde;var TE=null,Xde=t=>(TE&&TE.destroy(),TE=new Bo({totalAllowedTime:t}),TE),Qde=()=>TE;var Bo=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Ds())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await _0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Z.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var efe={name:"@netlify/agent-runner-cli",type:"module",version:"1.175.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var oYe=nYe(import.meta.url),sYe=Va.dirname(oYe),aYe=iYe(import.meta.url),Uh=oe("shell"),jj=new Set,tfe={preferLocal:!0},Ft=(t,e,r)=>{let[n,i]=cYe(e,r),o={...tfe,...i},s=Yde(t,n,o);nfe(s,o),sfe(s);let a=r?.idleTimeout;return a&&a>0&&ofe(s,a),s},rfe=(t,e)=>{let r={...tfe,...e},n=Kde(t,r);return nfe(n,r),sfe(n),e?.idleTimeout&&e.idleTimeout>0&&ofe(n,e.idleTimeout),n},cYe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},nfe=(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 XS).pipe(Ls.stdout),t.stderr?.pipe(new XS).pipe(Ls.stderr);return}t.stdout?.pipe(Ls.stdout),t.stderr?.pipe(Ls.stderr)},Bj=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ls.kill(-t.pid,e),Uh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Uh.error("Error killing process:",r),!1}},ife=t=>Bj(t,"SIGKILL"),ofe=(t,e)=>{let r=null,n=()=>{Uh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Bj(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uh.log(`Force killing idle process ${t.pid}`),ife(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)},sfe=t=>{jj.add(t);let e=Qde();if(e){let r=e.onTimesUp(()=>{Uh.log(`Global timer expired, killing process ${t.pid}`),Bj(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uh.log(`Force killing process ${t.pid} after timeout`),ife(t))},5e3)});t.on("exit",()=>{jj.delete(t),r()}),t.on("error",()=>{jj.delete(t),r()})}};function UC(t,e){return!!qo(t,e)}function qo(t,e){if(!Ls.env.NETLIFY_LOCAL_MODE)try{let i=aYe.resolve(efe.name),o=Va.dirname(i);for(;o!==Va.dirname(o);){let s=Va.dirname(o);if(Va.basename(s)==="node_modules"){let a=Va.join(s,".bin",e);if(LC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ls.env.NODE_PATH){let i=Va.join(Ls.env.NODE_PATH,".bin",e);if(LC.existsSync(i))return i}let r=Va.join(t,"node_modules",".bin",e);if(LC.existsSync(r))return r;let n=Va.join(sYe,"..","node_modules",".bin",e);if(LC.existsSync(n))return n}var afe=oe("repo"),ffe="runner-diffs-",pfe=t=>`${ffe}${t}-`,hfe=async t=>{let e=dfe.tmpdir(),r;try{r=await FC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(ffe)&&!n.startsWith(pfe(t))).map(n=>FC.rm(zC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},ri=(t,e={})=>Ft("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),jC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{afe.info("Getting runner diffs");let n=await fYe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=hYe(o);await mYe(h,r)}afe.info("Changes after processing"),await Vj(r);let s=await Gj(o,r);if(await qj(s,r),i=await pYe(r),!i)return{hasChanges:!1,ignored:s};await ri(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await FC.mkdtemp(zC.join(dfe.tmpdir(),pfe(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let v=zC.join(a,g);await ri([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${v}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:E}=await FC.stat(v);return{path:v,size:E}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await ufe(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await lfe(d,h)||(f=h)}await ufe(r),Z.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await lfe(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},cfe=async t=>{let e=lYe("sha256");for await(let r of uYe(t))e.update(r);return e.digest("hex")},lfe=async(t,e)=>t.size===e.size&&await cfe(t.path)===await cfe(e.path),ufe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await ri(["reset","--soft","HEAD~1"],{cwd:t})},qj=async(t=[],e=process.cwd())=>{await ri(["add",".",...t],{cwd:e})},Vj=async(t=process.cwd())=>{let e=await ri(["status","-s"],{cwd:t});return String(e.stdout??"")},mfe=/.. (.+)?\.log$/,dYe=[mfe],fYe=async(t=process.cwd())=>{let e=await Vj(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
145
145
|
`).filter(i=>dYe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},pYe=async(t=process.cwd())=>{try{return await ri(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},wE=async(t=process.cwd())=>{let{stdout:e}=await ri(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},gfe=async(t=process.cwd())=>{let{stdout:e}=await ri(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},Gj=async(t,e=process.cwd())=>{t||=await Vj(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
146
146
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${zC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(mfe)?.[1];o&&n.push(`:!${o}.log`)}),n},_fe=async(t=process.cwd())=>{await ri(["reset","--hard","HEAD"],{cwd:t})},yfe=async(t=process.cwd())=>{let e=await ri(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
147
147
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},hYe=t=>{let e=t.split(`
|
package/dist/bin.js
CHANGED
|
@@ -631,7 +631,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
631
631
|
`,LF:`
|
|
632
632
|
`,concatBytes:DK},DAt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},MAt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:DAt};import{Buffer as UAt}from"buffer";var fxe=(t,e)=>t?void 0:FAt.bind(void 0,e),FAt=function*(t,e){if(typeof e!="string"&&!nn(e)&&!UAt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},pxe=(t,e)=>t?jAt.bind(void 0,e):zAt.bind(void 0,e),jAt=function*(t,e){hxe(t,e),yield e},zAt=function*(t,e){if(hxe(t,e),typeof e!="string"&&!nn(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},hxe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
633
633
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
634
|
-
if (condition) { yield value; }`)};import{Buffer as qAt}from"buffer";import{StringDecoder as BAt}from"string_decoder";var Wk=(t,e,r)=>{if(r)return;if(t)return{transform:VAt.bind(void 0,new TextEncoder)};let n=new BAt(e);return{transform:HAt.bind(void 0,n),final:GAt.bind(void 0,n)}},VAt=function*(t,e){qAt.isBuffer(e)?yield cl(e):typeof e=="string"?yield t.encode(e):yield e},HAt=function*(t,e){yield nn(e)?t.write(e):e},GAt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as mxe}from"util";var UK=mxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Yk=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=YAt}=e[r];for await(let i of n(t))yield*Yk(i,e,r+1)},gxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*WAt(r,Number(e),t)},WAt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Yk(n,r,e+1)},_xe=mxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),YAt=function*(t){yield t};var FK=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},yxe=(t,e)=>[...e.flatMap(r=>[...jp(r,t,0)]),...Uw(t)],jp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=JAt}=e[r];for(let i of n(t))yield*jp(i,e,r+1)},Uw=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*KAt(r,Number(e),t)},KAt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*jp(n,r,e+1)},JAt=function*(t){yield t};var jK=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Exe(t,o,s),l=Fp(e),u=Fp(r),d=l?UK.bind(void 0,Yk,a):FK.bind(void 0,jp),f=l||u?UK.bind(void 0,gxe,a):FK.bind(void 0,Uw),p=l||u?_xe.bind(void 0,a):void 0;return{stream:new ZAt({writableObjectMode:n,writableHighWaterMark:Sxe(n),readableObjectMode:i,readableHighWaterMark:Sxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},Kk=(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=Exe(o,r,a);t=yxe(c,t)}return t},Exe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:fxe(n,a)},Wk(r,o,n),Gk(r,s,n,c),{transform:t,final:e},{transform:pxe(i,a)},dxe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var vxe=(t,e)=>{for(let r of XAt(t))QAt(t,r,e)},XAt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),QAt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${pd[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>ext(a,n));r.input=Pw(o)},ext=(t,e)=>{let r=Kk(t,e,"utf8",!0);return txt(r),Pw(r)},txt=t=>{let e=t.find(r=>typeof r!="string"&&!nn(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as sxt,appendFileSync as oxt}from"fs";var Jk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&J_(r,n)&&!ys.has(e)&&rxt(n)&&(t.some(({type:i,value:s})=>i==="native"&&nxt.has(s))||t.every(({type:i})=>to.has(i))),rxt=t=>t===1||t===2,nxt=new Set(["pipe","overlapped"]),bxe=async(t,e,r,n)=>{for await(let i of t)ixt(e)||wxe(i,r,n)},Txe=(t,e,r)=>{for(let n of t)wxe(n,e,r)},ixt=t=>t._readableState.pipes.length>0,wxe=(t,e,r)=>{let n=uk(t);Da({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Rxe=({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)=>axt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},axt=({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=AAe(t,s,d),p=cl(f),{stdioItems:h,objectMode:m}=e[r],_=cxt([p],h,c,n),{serializedResult:y,finalResult:E=y}=lxt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uxt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&dxt(y,h,i),S}catch(g){return n.error=g,S}},cxt=(t,e,r,n)=>{try{return Kk(t,e,r,!1)}catch(i){return n.error=i,t}},lxt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Pw(t)};let o=jwe(t,r);return n[s]?{serializedResult:o,finalResult:MK(o,!i[s],e)}:{serializedResult:o}},uxt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!Jk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=MK(t,!1,o);try{Txe(a,e,n)}catch(c){r.error??=c}},dxt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>Vk.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?oxt(n,t):(r.add(s),sxt(n,t))}};var Axe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,dl(e,r,"all")]:Array.isArray(e)?[dl(t,r,"all"),...e]:nn(t)&&nn(e)?GY([t,e]):`${t}${e}`};import{once as zK}from"events";var xxe=async(t,e)=>{let[r,n]=await fxt(t);return e.isForcefullyTerminated??=!1,[r,n]},fxt=async t=>{let[e,r]=await Promise.allSettled([zK(t,"spawn"),zK(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Pxe(t):r.value},Pxe=async t=>{try{return await zK(t,"exit")}catch{return Pxe(t)}},Cxe=async t=>{let[e,r]=await t;if(!pxt(e,r)&&qK(e,r))throw new $o;return[e,r]},pxt=(t,e)=>t===void 0&&e===void 0,qK=(t,e)=>t!==0||e!==null;var Ixe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=hxt(t,e,r),o=s?.code==="ETIMEDOUT",a=RAe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},hxt=(t,e,r)=>t!==void 0?t:qK(e,r)?new $o:void 0;var Oxe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gxt(t,e,r),d=Sxt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return oy(d,c,l)},gxt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=fk(t,e,r),a=_xt(r),{file:c,commandArguments:l,options:u}=Nk(t,e,a);yxt(u);let d=axe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_xt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,yxt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Zk("ipcInput"),t&&Zk("ipc: true"),r&&Zk("detached: true"),n&&Zk("cancelSignal")},Zk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Sxt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Ext({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}=Ixe(c,r),{output:h,error:m=l}=Rxe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,S)=>dl(E,r,S)),y=dl(Axe(h,r),r,"all");return bxt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Ext=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{vxe(s,r);let a=vxt(r);return mxt(...kk(t,e,a))}catch(a){return sy({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},vxt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:jk(e)}),bxt=({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?zk({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Mw({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 lCt}from"events";import{spawn as uCt}from"child_process";import Dxe from"process";import{once as BK,on as Txt}from"events";var Nxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Q_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:Ak(t)}),wxt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),wxt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{bk(e,i);let s=fd(t,e,r),o=new AbortController;try{return await Promise.race([Rxt(s,n,o),Axt(s,r,o),xxt(s,r,o)])}catch(a){throw ey(t),a}finally{o.abort(),Tk(e,i)}},Rxt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await BK(t,"message",{signal:r});return n}for await(let[n]of Txt(t,"message",{signal:r}))if(e(n))return n},Axt=async(t,e,{signal:r})=>{await BK(t,"disconnect",{signal:r}),y0e(e)},xxt=async(t,e,{signal:r})=>{let[n]=await BK(t,"strict:error",{signal:r});throw Sk(n,e)};import{once as $xe,on as Pxt}from"events";var Lxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>VK({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),VK=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Q_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:Ak(t)}),bk(e,s);let o=fd(t,e,r),a=new AbortController,c={};return Cxt(t,o,a),Ixt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Oxt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Cxt=async(t,e,r)=>{try{await $xe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Ixt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await $xe(t,"strict:error",{signal:r.signal});n.error=Sk(i,e),r.abort()}catch{}},Oxt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Pxt(r,"message",{signal:s.signal}))kxe(o),yield c}catch{kxe(o)}finally{s.abort(),Tk(e,a),n||ey(t),i&&await t}},kxe=({error:t})=>{if(t)throw t};var Mxe=(t,{ipc:e})=>{Object.assign(t,Fxe(t,!1,e))},Uxe=()=>{let t=Dxe,e=!0,r=Dxe.channel!==void 0;return{...Fxe(t,e,r),getCancelSignal:H0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Fxe=(t,e,r)=>({sendMessage:Ik.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Nxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Lxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Nxt}from"child_process";import{PassThrough as kxt,Readable as $xt,Writable as Lxt,Duplex as Dxt}from"stream";var jxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{$K(n);let a=new Nxt;Mxt(a,n),Object.assign(a,{readable:Uxt,writable:Fxt,duplex:jxt});let c=sy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=zxt(c,o,i);return{subprocess:a,promise:l}},Mxt=(t,e)=>{let r=Fw(),n=Fw(),i=Fw(),s=Array.from({length:e.length-3},Fw),o=Fw(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Fw=()=>{let t=new kxt;return t.end(),t},Uxt=()=>new $xt({read(){}}),Fxt=()=>new Lxt({write(){}}),jxt=()=>new Dxt({read(){},write(){}}),zxt=async(t,e,r)=>oy(t,e,r);import{createReadStream as zxe,createWriteStream as qxe}from"fs";import{Buffer as qxt}from"buffer";import{Readable as jw,Writable as Bxt,Duplex as Vxt}from"stream";var Vxe=(t,e)=>Hk(Hxt,t,e,!1),zw=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Bxe={fileNumber:zw,generator:jK,asyncGenerator:jK,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Vxt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Hxt={input:{...Bxe,fileUrl:({value:t})=>({stream:zxe(t)}),filePath:({value:{file:t}})=>({stream:zxe(t)}),webStream:({value:t})=>({stream:jw.fromWeb(t)}),iterable:({value:t})=>({stream:jw.from(t)}),asyncIterable:({value:t})=>({stream:jw.from(t)}),string:({value:t})=>({stream:jw.from(t)}),uint8Array:({value:t})=>({stream:jw.from(qxt.from(t))})},output:{...Bxe,fileUrl:({value:t})=>({stream:qxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:qxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Bxt.fromWeb(t)}),iterable:zw,asyncIterable:zw,string:zw,uint8Array:zw}};import{on as Gxt,once as Hxe}from"events";import{PassThrough as Wxt,getDefaultHighWaterMark as Yxt}from"stream";import{finished as Yxe}from"stream/promises";function zp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)GK(i);let e=t.some(({readableObjectMode:i})=>i),r=Kxt(t,e),n=new HK({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Kxt=(t,e)=>{if(t.length===0)return Yxt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},HK=class extends Wxt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(GK(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Jxt(this,this.#e,this.#s);let r=Qxt({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(GK(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)}},Jxt=async(t,e,r)=>{Xk(t,Gxe);let n=new AbortController;try{await Promise.race([Zxt(t,n),Xxt(t,e,r,n)])}finally{n.abort(),Xk(t,-Gxe)}},Zxt=async(t,{signal:e})=>{try{await Yxe(t,{signal:e,cleanup:!0})}catch(r){throw Kxe(t,r),r}},Xxt=async(t,e,r,{signal:n})=>{for await(let[i]of Gxt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},GK=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Qxt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{Xk(t,Wxe);let a=new AbortController;try{await Promise.race([ePt(s,e,a),tPt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),rPt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),Xk(t,-Wxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?WK(t):nPt(t))},ePt=async(t,e,{signal:r})=>{try{await t,r.aborted||WK(e)}catch(n){r.aborted||Kxe(e,n)}},tPt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Yxe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Jxe(o)?i.add(e):Zxe(t,o)}},rPt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Hxe(t,i,{signal:s}),!t.readable)return Hxe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},nPt=t=>{t.writable&&t.end()},Kxe=(t,e)=>{Jxe(e)?WK(t):Zxe(t,e)},Jxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",WK=t=>{(t.readable||t.writable)&&t.destroy()},Zxe=(t,e)=>{t.destroyed||(t.once("error",iPt),t.destroy(e))},iPt=()=>{},Xk=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Gxe=2,Wxe=1;import{finished as Xxe}from"stream/promises";var cy=(t,e)=>{t.pipe(e),sPt(t,e),oPt(t,e)},sPt=async(t,e)=>{if(!(ko(t)||ko(e))){try{await Xxe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}YK(e)}},YK=t=>{t.writable&&t.end()},oPt=async(t,e)=>{if(!(ko(t)||ko(e))){try{await Xxe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}KK(t)}},KK=t=>{t.readable&&t.destroy()};var Qxe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>to.has(c)))aPt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!to.has(c)))lPt({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]:zp(s);cy(o,i)}},aPt=(t,e,r,n)=>{r==="output"?cy(t.stdio[n],e):cy(e,t.stdio[n]);let i=cPt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},cPt=["stdin","stdout","stderr"],lPt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;uPt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},uPt=(t,{signal:e})=>{ko(t)&&Mp(t,dPt,e)},dPt=2;import{addAbortListener as hPt}from"events";var qp=[];qp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&qp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&qp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Qk=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",JK=Symbol.for("signal-exit emitter"),ZK=globalThis,fPt=Object.defineProperty.bind(Object),XK=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ZK[JK])return ZK[JK];fPt(ZK,JK,{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}},e$=class{},pPt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),QK=class extends e${onExit(){return()=>{}}load(){}unload(){}},e5=class extends e${#e=t5.platform==="win32"?"SIGINT":"SIGHUP";#r=new XK;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of qp)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(!Qk(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 qp)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,qp.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 Qk(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"&&Qk(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)}},t5=globalThis.process,{onExit:ePe,load:VTr,unload:HTr}=pPt(Qk(t5)?new e5(t5):new QK);var tPe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ePe(()=>{t.kill()});hPt(n,()=>{i()})};var nPe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=dk(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mPt(r,n,i),{sourceStream:d,sourceError:f}=_Pt(t,l),{options:p,fileDescriptors:h}=Ua.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},mPt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=gPt(t,e,...r),a=vk(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},gPt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(rPe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||VY(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]=tk(r,...n);return{destination:e(rPe)(i,s,o),pipeOptions:o}}if(Ua.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}`)},rPe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_Pt=(t,e)=>{try{return{sourceStream:ty(t,e)}}catch(r){return{sourceError:r}}};var sPe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=yPt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw r5({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},yPt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return KK(t),n;if(e!==void 0)return YK(r),e},r5=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>sy({error:t,command:iPe,escapedCommand:iPe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),iPe="source.pipe(destination)";var oPe=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 SPt}from"stream/promises";var aPe=(t,e,r)=>{let n=t$.has(e)?vPt(t,e):EPt(t,e);return Mp(t,TPt,r.signal),Mp(e,wPt,r.signal),bPt(e),n},EPt=(t,e)=>{let r=zp([t]);return cy(r,e),t$.set(e,r),r},vPt=(t,e)=>{let r=t$.get(e);return r.add(t),r},bPt=async t=>{try{await SPt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}t$.delete(t)},t$=new WeakMap,TPt=2,wPt=1;import{aborted as RPt}from"util";var cPe=(t,e)=>t===void 0?[]:[APt(t,e)],APt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await RPt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw r5({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var r$=(t,...e)=>{if(zr(e[0]))return r$.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=nPe(t,...e),i=xPt({...n,destination:r});return i.pipe=r$.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},xPt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=PPt(t,i);sPe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=aPe(e,s,d);return await Promise.race([oPe(u),...cPe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},PPt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as LPt}from"timers/promises";import{on as CPt}from"events";import{getDefaultHighWaterMark as IPt}from"stream";var n$=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return OPt(e,o),uPe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},OPt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},n5=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;NPt(e,o,t);let a=t.readableObjectMode&&!s;return uPe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},NPt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},uPe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=CPt(t,"data",{signal:e.signal,highWaterMark:lPe,highWatermark:lPe});return kPt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},i5=IPt(!0),lPe=i5,kPt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=$Pt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*jp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Uw(a)}},$Pt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Wk(t,r,!e),Gk(t,i,!n,{})].filter(Boolean);var dPe=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=DPt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([MPt(t),d]);return}let f=LK(c,r),p=n5({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([UPt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},DPt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!Jk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=n5({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await bxe(a,t,r,s)},MPt=async t=>{await LPt(),t.readableFlowing===null&&t.resume()},UPt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await Mk(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await Uk(r,{maxBuffer:s})):await iy(r,{maxBuffer:s})}catch(a){return fPe(bAe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},s5=async t=>{try{return await t}catch(e){return fPe(e)}},fPe=({bufferedData:t})=>Uwe(t)?new Uint8Array(t):t;import{finished as FPt}from"stream/promises";var qw=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=jPt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],FPt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||BPt(a,e,r,n)}finally{o.abort()}},jPt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&zPt(t,r,n),n},zPt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qPt(e,r),n.call(t,...i)}},qPt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},BPt=(t,e,r,n)=>{if(!VPt(t,e,r,n))throw t},VPt=(t,e,r,n=!0)=>r.propagating?pPe(t)||i$(t):(r.propagating=!0,o5(r,e)===n?pPe(t):i$(t)),o5=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",i$=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",pPe=t=>t?.code==="EPIPE";var hPe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>a5({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),a5=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=qw(t,e,l);if(o5(l,e)){await u;return}let[d]=await Promise.all([dPe({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 mPe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?zp([t,e].filter(Boolean)):void 0,gPe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>a5({...HPt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:GPt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),HPt=({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}},GPt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as WPt}from"events";var _Pe=t=>J_(t,"ipc"),yPe=(t,e)=>{let r=uk(t);Da({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var SPe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=_Pe(s),a=ll(e,"ipc"),c=ll(r,"ipc");for await(let l of VK({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(TAe(t,i,c),i.push(l)),o&&yPe(l,s);return i},EPe=async(t,e)=>(await Promise.allSettled([t]),e);var vPe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let E=xxe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=hPe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),T=gPe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),R=[],w=SPe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),b=YPt(m,t,S),P=KPt(h,S);try{return await Promise.race([Promise.all([{},Cxe(E),Promise.all(g),T,w,tAe(t,d),...b,...P]),_,JPt(t,y),...J0e(t,s,f,y),..._0e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Y0e({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(N){return f.terminationReason??="other",Promise.all([{error:N},E,Promise.all(g.map(x=>s5(x))),s5(T),EPe(w,R),Promise.allSettled(b),Promise.allSettled(P)])}},YPt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:qw(n,i,r)),KPt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Do(s,{checkOpen:!1})&&!ko(s)).map(({type:i,value:s,stream:o=s})=>qw(o,n,e,{isSameDirection:to.has(i),stopOnExit:i==="native"}))),JPt=async(t,{signal:e})=>{let[r]=await WPt(t,"error",{signal:e});throw r};var bPe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Bw=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Ma();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},ly=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 ZPt}from"stream";import{callbackify as XPt}from"util";import{finished as TPe}from"stream/promises";var c5=async t=>{if(t!==void 0)try{await l5(t)}catch{}},wPe=async t=>{if(t!==void 0)try{await u5(t)}catch{}},l5=async t=>{await TPe(t,{cleanup:!0,readable:!1,writable:!0})},u5=async t=>{await TPe(t,{cleanup:!0,readable:!0,writable:!1})},s$=async(t,e)=>{if(await t,e)throw e},o$=(t,e,r)=>{r&&!i$(r)?t.destroy(r):e&&t.destroy()};var RPe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ys.has(r),{subprocessStdout:a,waitReadableDestroy:c}=d5(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=f5(a,o),{read:f,onStdoutDataDone:p}=p5({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new ZPt({read:f,destroy:XPt(m5.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return h5({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},d5=(t,e,r)=>{let n=ty(t,e),i=Bw(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},f5=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:i5},p5=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Ma(),o=n$({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){QPt(this,o,s)},onStdoutDataDone:s}},QPt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},h5=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await u5(t),await n,await c5(i),await e,r.readable&&r.push(null)}catch(s){await c5(i),APe(r,s)}},m5=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ly(r,e)&&(APe(t,n),await s$(e,n))},APe=(t,e)=>{o$(t,t.readable,e)};import{Writable as eCt}from"stream";import{callbackify as xPe}from"util";var PPe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=g5(t,r,e),o=new eCt({..._5(n,t,i),destroy:xPe(S5.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return y5(n,o),o},g5=(t,e,r)=>{let n=vk(t,e),i=Bw(r,n,"writableFinal"),s=Bw(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},_5=(t,e,r)=>({write:tCt.bind(void 0,t),final:xPe(rCt.bind(void 0,t,e,r))}),tCt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rCt=async(t,e,r)=>{await ly(r,e)&&(t.writable&&t.end(),await e)},y5=async(t,e,r)=>{try{await l5(t),e.writable&&e.end()}catch(n){await wPe(r),CPe(e,n)}},S5=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ly(r,e),await ly(n,e)&&(CPe(t,i),await s$(e,i))},CPe=(t,e)=>{o$(t,t.writable,e)};import{Duplex as nCt}from"stream";import{callbackify as iCt}from"util";var IPe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ys.has(r),{subprocessStdout:c,waitReadableDestroy:l}=d5(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=g5(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=f5(c,a),{read:_,onStdoutDataDone:y}=p5({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new nCt({read:_,..._5(u,t,d),destroy:iCt(sCt.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 h5({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:u}),y5(u,E,c),E},sCt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([m5({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),S5({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var E5=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ys.has(e),o=ty(t,r),a=n$({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return oCt(a,o,t)},oCt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var OPe=(t,{encoding:e})=>{let r=bPe();t.readable=RPe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=PPe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=IPe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=E5.bind(void 0,t,e),t[Symbol.asyncIterator]=E5.bind(void 0,t,e,{})};var NPe=(t,e)=>{for(let[r,n]of cCt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},aCt=(async()=>{})().constructor.prototype,cCt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aCt,t)]);var kPe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dCt(t,e,r),{subprocess:f,promise:p}=pCt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=r$.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),NPe(f,p),Ua.set(f,{options:u,fileDescriptors:d}),f},dCt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=fk(t,e,r),{file:a,commandArguments:c,options:l}=Nk(t,e,r),u=fCt(l),d=Vxe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},fCt=({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}},pCt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uCt(...kk(t,e,r))}catch(h){return jxe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;lCt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Qxe(c,a,l),tPe(c,r,l);let d={},f=Ma();c.kill=m0e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=mPe(c,r),OPe(c,r),Mxe(c,r);let p=hCt({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}},hCt=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 vPe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,T)=>dl(g,e,T)),E=dl(m,e,"all"),S=mCt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return oy(S,n,e)},mCt=({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?Mw({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}):zk({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var a$=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,gCt(n,t[n],i)]));return{...t,...r}},gCt=(t,e,r)=>_Ct.has(t)&&zr(e)&&zr(r)?{...e,...r}:r,_Ct=new Set(["env",...JY]);var hd=(t,e,r,n)=>{let i=(o,a,c)=>hd(o,a,r,c),s=(...o)=>yCt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},yCt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(zr(s))return i(t,a$(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=SCt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?Oxe(a,c,l):kPe(a,c,l,i)},SCt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Vwe(e)?Hwe(e,r):[e,...r],[o,a,c]=tk(...s),l=a$(a$(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 $Pe=({file:t,commandArguments:e})=>DPe(t,e),LPe=({file:t,commandArguments:e})=>({...DPe(t,e),isSync:!0}),DPe=(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]=ECt(t);return{file:r,commandArguments:n}},ECt=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(vCt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},vCt=/ +/g;var MPe=(t,e,r)=>{t.sync=e(bCt,r),t.s=t.sync},UPe=({options:t})=>FPe(t),bCt=({options:t})=>({...FPe(t),isSync:!0}),FPe=t=>({options:{...TCt(t),...t}}),TCt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},jPe={preferLocal:!0};var zPe=hd(()=>({})),$0r=hd(()=>({isSync:!0})),qPe=hd($Pe),L0r=hd(LPe),D0r=hd(X0e),M0r=hd(UPe,{},jPe,MPe),{sendMessage:U0r,getOneMessage:F0r,getEachMessage:j0r,getCancelSignal:z0r}=Uxe();import{Transform as wCt}from"stream";var RCt=["NETLIFY_AI_GATEWAY_KEY"];function ACt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...RCt])]}function xCt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function PCt(){let e=ACt().map(r=>process.env[r]).filter(r=>!(!r||xCt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ki(t){if(typeof t!="string")return t;let e=PCt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(CCt(n),"g");r=r.replace(i,"******")}),r}function CCt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Vw=class extends wCt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ki(i);n(null,s)}},c$=Symbol("maskedWrite");function BPe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[c$]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ki(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[c$]=!0,process.stdout.write=r}if(!process.stderr.write[c$]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ki(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[c$]=!0,process.stderr.write=r}}}var VPe=!1,HPe=()=>{VPe=!0},Ji=()=>VPe;var Hw=null,GPe=t=>(Hw&&Hw.destroy(),Hw=new Mo({totalAllowedTime:t}),Hw),WPe=()=>Hw;var Mo=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Ji())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 JN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{oe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var YPe={name:"@netlify/agent-runner-cli",type:"module",version:"1.175.0-run-started.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var kCt=OCt(import.meta.url),$Ct=fl.dirname(kCt),LCt=NCt(import.meta.url),uy=pe("shell"),v5=new Set,KPe={preferLocal:!0},gr=(t,e,r)=>{let[n,i]=DCt(e,r),s={...KPe,...i},o=zPe(t,n,s);ZPe(o,s),eCe(o);let a=r?.idleTimeout;return a&&a>0&&QPe(o,a),o},JPe=(t,e)=>{let r={...KPe,...e},n=qPe(t,r);return ZPe(n,r),eCe(n),e?.idleTimeout&&e.idleTimeout>0&&QPe(n,e.idleTimeout),n},DCt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ZPe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||za.env.NETLIFY_LOCAL_QUIET==="true")return;if(za.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Vw).pipe(za.stdout),t.stderr?.pipe(new Vw).pipe(za.stderr);return}t.stdout?.pipe(za.stdout),t.stderr?.pipe(za.stderr)},b5=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(za.kill(-t.pid,e),uy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return uy.error("Error killing process:",r),!1}},XPe=t=>b5(t,"SIGKILL"),QPe=(t,e)=>{let r=null,n=()=>{uy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),b5(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(uy.log(`Force killing idle process ${t.pid}`),XPe(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)},eCe=t=>{v5.add(t);let e=WPe();if(e){let r=e.onTimesUp(()=>{uy.log(`Global timer expired, killing process ${t.pid}`),b5(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(uy.log(`Force killing process ${t.pid} after timeout`),XPe(t))},5e3)});t.on("exit",()=>{v5.delete(t),r()}),t.on("error",()=>{v5.delete(t),r()})}};function qa(t,e){if(!za.env.NETLIFY_LOCAL_MODE)try{let i=LCt.resolve(YPe.name),s=fl.dirname(i);for(;s!==fl.dirname(s);){let o=fl.dirname(s);if(fl.basename(o)==="node_modules"){let a=fl.join(o,".bin",e);if(l$.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(za.env.NODE_PATH){let i=fl.join(za.env.NODE_PATH,".bin",e);if(l$.existsSync(i))return i}let r=fl.join(t,"node_modules",".bin",e);if(l$.existsSync(r))return r;let n=fl.join($Ct,"..","node_modules",".bin",e);if(l$.existsSync(n))return n}import N1 from"process";import{fileURLToPath as d2t}from"url";import{createRequire as f2t}from"module";import B0 from"path";import{readFileSync as p2t}from"fs";var MCt="__netlify__getTracer",UCt="__netlify__shutdownTracers",Ot=(t,e)=>globalThis[MCt]?.(t,e),tCe=async()=>globalThis[UCt]?.();function Gw(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 i2t}from"timers/promises";ke();import FOt from"process";ke();var cIt=(t,e)=>{e.recordException(t),e.setStatus({code:ci.ERROR})};var ml=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=YCe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>KCe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=YCe(r,n,i),c=this._tracer.startSpan(e,s,o);return KCe(c,s,a)}};function YCe(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??nr.active(),{opts:n,ctx:i,fn:s}}function KCe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:cIt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}ke();var _y=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var r9=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=sIe(e),n._asyncAttributesPending=e.filter(([i,s])=>_y(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(_y(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=sIe(this._rawAttributes),this._schemaUrl=lIt(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,_y(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(_y(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=uIt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function n9(t,e){return r9.FromAttributeList(Object.entries(t),e)}function sIe(t){return t.map(([e,r])=>_y(r)?[e,r.catch(n=>{le.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function lIt(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 uIt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;le.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}ke();var iR=class{emit(e){}enabled(){return!1}},oIe=new iR;var sR=Symbol.for("io.opentelemetry.js.api.logs"),yy=globalThis;function aIe(t,e,r){return n=>n===t?e:r}var i9=1;var s9=class{getLogger(e,r,n){return new iR}},N$=new s9;var k$=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):oIe}};var oR=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new k$(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 $$=class t{constructor(){this._proxyLoggerProvider=new oR}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return yy[sR]?this.getLoggerProvider():(yy[sR]=aIe(i9,e,N$),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=yy[sR])===null||e===void 0?void 0:e.call(yy,i9))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete yy[sR],this._proxyLoggerProvider=new oR}};var cIe=$$.getInstance();function lIe(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 uIe(t){t.forEach(e=>e.disable())}function o9(t){let e=t.tracerProvider||qt.getTracerProvider(),r=t.meterProvider||nR.getMeterProvider(),n=t.loggerProvider||cIe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return lIe(i,e,r,n),()=>{uIe(i)}}ke();var dIt=mn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function dIe(t){return t.getValue(dIt)===!0}var Sy;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Sy||(Sy={}));ke();var a9="[_0-9a-z-*/]",fIt=`[a-z]${a9}{0,255}`,pIt=`[a-z0-9]${a9}{0,240}@[a-z]${a9}{0,13}`,hIt=new RegExp(`^(?:${fIt}|${pIt})$`),mIt=/^[ -~]{0,255}[!-~]$/,gIt=/,|=/;function c9(t){return hIt.test(t)}function l9(t){return mIt.test(t)&&!gIt.test(t)}var _It=32,fIe=512,pIe=",",hIe="=",L$=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!c9(e)||!l9(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>fIe)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=pIe+e),e=`${n[0]}${hIe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(pIe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(hIe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!c9(a)||!l9(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>fIe)&&(r.set(a,c),n=l,r.size>=_It))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 D$="traceparent",M$="tracestate",yIt="00",SIt="(?!ff)[\\da-f]{2}",EIt="(?![0]{32})[\\da-f]{32}",vIt="(?![0]{16})[\\da-f]{16}",bIt="[\\da-f]{2}",TIt=new RegExp(`^\\s?(${SIt})-(${EIt})-(${vIt})-(${bIt})(-.*)?\\s?$`);function mIe(t){let e=TIt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var _d=class{inject(e,r,n){let i=qt.getSpanContext(e);if(!i||dIe(e)||!Zi(i))return;let s=`${yIt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Nr.NONE).toString(16)}`;n.set(r,D$,s),i.traceState&&n.set(r,M$,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,D$);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=mIe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,M$);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new L$(typeof c=="string"?c:void 0)}return qt.setSpanContext(e,o)}fields(){return[D$,M$]}};var U$=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 aR=class{_isCalled=!1;_deferred=new U$;_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 CL=Pn(Y9(),1);ke();var ZNe=t=>{throw TypeError(t)},X9=(t,e,r)=>e.has(t)||ZNe("Cannot "+r),PL=(t,e,r)=>(X9(t,e,"read from private field"),r?r.call(t):e.get(t)),K9=(t,e,r)=>e.has(t)?ZNe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),YNe=(t,e,r,n)=>(X9(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),UOt=(t,e,r)=>(X9(t,e,"access private method"),r),KNe="__netlify__getTracer",jOt="__netlify__shutdownTracers",zOt="__nfOTLPTrace",bR,TR,Z9,XNe,qOt=class{constructor(){K9(this,Z9),K9(this,bR),K9(this,TR),YNe(this,bR,new aR(UOt(this,Z9,XNe),this)),YNe(this,TR,le.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(PL(this,TR).debug(`export ${t.length.toString()} spans`),PL(this,bR).isCalled){e({code:Sy.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zOt,JSON.stringify(BOt(t))),e({code:Sy.SUCCESS})}shutdown(){return PL(this,bR).call()}};bR=new WeakMap;TR=new WeakMap;Z9=new WeakSet;XNe=function(){return PL(this,TR).debug("Shutting down"),Promise.resolve()};function BOt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:xL(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||Uo.SERVER,startTimeUnixNano:J9(e.startTime),endTimeUnixNano:J9(e.endTime),attributes:xL(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:J9(n.time),attributes:xL(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:xL(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function xL(t){return Object.keys(t).map(e=>QNe(e,t[e]))}function QNe(t,e){return{key:t,value:eke(e)}}function eke(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(eke)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>QNe(r,n))}}:{}}function J9(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var JNe={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"}},tke=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,KNe))return;let e=FOt.version.slice(1),r=n9({"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??[VOt()],i=new CL.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new _d});let s=t.instrumentations??[];o9({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,KNe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new ml(qt.getTracer(a,c)):new ml(qt.getTracer(JNe.name,JNe.version))}}),Object.defineProperty(globalThis,jOt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},VOt=()=>new CL.SimpleSpanProcessor(new qOt);ke();var wR=Pn(Y9(),1);ke();import*as IL from"diagnostics_channel";var rke=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?ci.ERROR:ci.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof ml?t:new ml(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){IL.subscribe(t,e);let r=()=>IL.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:Uo.CLIENT},nr.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:ci.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 Aje=Pn(wje(),1);var I1=pe("tracing"),Rje=8e3,s2t=5e3,q0=async(t=s2t)=>{try{await Promise.race([tCe(),i2t(t)])}catch(e){I1.warn("Failed to flush tracers on shutdown",e)}},xje=async(t,e,r)=>{if(!Ot()){let n=[new wR.SimpleSpanProcessor(new Q7),new wR.SimpleSpanProcessor(new Aje.OTLPTraceExporter({url:r.exporterUrl}))];await tke({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new rke({skipHeaders:!0})]})}return r.traceparent?(Pi.setGlobalPropagator(new _d),Pi.extract(nr.active(),{traceparent:r.traceparent,isRemote:!0})):nr.active()};function or(t,e,r){return I1.log(`\u23F3 TRACE: ${e} starting...`),Gw(t,e,r)}var Q7=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(", ")}]`:"";I1.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&I1.log(` \u274C Error: ${e.status.message}`)}};function eQ(){return Qe().captureLlmContentEnabled}function Pje(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function O1(t,e,r){let n={role:t,parts:[{type:"text",content:Ki(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var o2t=new Set([Q.Task,Q.RunCommand,Q.Explore,Q.FileRead,Q.FileWrite,Q.Notebook,Q.Web,Q.Todo,Q.Skill,Q.Tool,Q.Memorize,Q.Deployment,Q.SiteGeneration]);function Cje(t,e,r,n){if(!t.length)return;let i=Ot();if(!i)return;let s=eQ(),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&&o2t.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>Rje?`${a.message.slice(0,Rje)}\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":Ki(_)}:{"gen_ai.output.messages":O1("assistant",_)}:{}}}).end(u)})}import{readdir as a2t,rm as c2t}from"fs/promises";import{join as l2t}from"path";async function Ije(t,e=[]){let n=(await a2t(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>c2t(l2t(t,i),{recursive:!0,force:!0})))}var u2t=300,Ph=t=>Qe().budgetCreditThresholds[t.mode]?.[t.runner]??u2t,Ch=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var tQ=t=>{let e=Ph(t);if(!Ch(t,e))return"default";let r=Qe();return r.createAskFirstEnabled&&r.questionsEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},Oje=t=>{let e=tQ(t),r=Ph(t);return{budget_eligible:Ch(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var h2t=B0.dirname(d2t(import.meta.url)),Nje=f2t(import.meta.url),m2t=B0.resolve(h2t,"scripts/scaffold.js"),g2t="scripts/scaffold.js",_2t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,rQ=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},y2t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),S2t=t=>{let e=rQ(t);return e==="node"||e.endsWith("/node")},Fl=t=>{if(typeof t!="string")return!1;let e=t.match(_2t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&y2t(rQ(e[r]));)r+=1;if(r>=e.length||!S2t(e[r]))return!1;let n=e[r+1];return n?rQ(n).includes(g2t):!1},Ih=pe("create_stage"),nQ="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.",E2t=`${nQ}
|
|
634
|
+
if (condition) { yield value; }`)};import{Buffer as qAt}from"buffer";import{StringDecoder as BAt}from"string_decoder";var Wk=(t,e,r)=>{if(r)return;if(t)return{transform:VAt.bind(void 0,new TextEncoder)};let n=new BAt(e);return{transform:HAt.bind(void 0,n),final:GAt.bind(void 0,n)}},VAt=function*(t,e){qAt.isBuffer(e)?yield cl(e):typeof e=="string"?yield t.encode(e):yield e},HAt=function*(t,e){yield nn(e)?t.write(e):e},GAt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as mxe}from"util";var UK=mxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Yk=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=YAt}=e[r];for await(let i of n(t))yield*Yk(i,e,r+1)},gxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*WAt(r,Number(e),t)},WAt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Yk(n,r,e+1)},_xe=mxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),YAt=function*(t){yield t};var FK=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},yxe=(t,e)=>[...e.flatMap(r=>[...jp(r,t,0)]),...Uw(t)],jp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=JAt}=e[r];for(let i of n(t))yield*jp(i,e,r+1)},Uw=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*KAt(r,Number(e),t)},KAt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*jp(n,r,e+1)},JAt=function*(t){yield t};var jK=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Exe(t,o,s),l=Fp(e),u=Fp(r),d=l?UK.bind(void 0,Yk,a):FK.bind(void 0,jp),f=l||u?UK.bind(void 0,gxe,a):FK.bind(void 0,Uw),p=l||u?_xe.bind(void 0,a):void 0;return{stream:new ZAt({writableObjectMode:n,writableHighWaterMark:Sxe(n),readableObjectMode:i,readableHighWaterMark:Sxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},Kk=(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=Exe(o,r,a);t=yxe(c,t)}return t},Exe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:fxe(n,a)},Wk(r,o,n),Gk(r,s,n,c),{transform:t,final:e},{transform:pxe(i,a)},dxe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var vxe=(t,e)=>{for(let r of XAt(t))QAt(t,r,e)},XAt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),QAt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${pd[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>ext(a,n));r.input=Pw(o)},ext=(t,e)=>{let r=Kk(t,e,"utf8",!0);return txt(r),Pw(r)},txt=t=>{let e=t.find(r=>typeof r!="string"&&!nn(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as sxt,appendFileSync as oxt}from"fs";var Jk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&J_(r,n)&&!ys.has(e)&&rxt(n)&&(t.some(({type:i,value:s})=>i==="native"&&nxt.has(s))||t.every(({type:i})=>to.has(i))),rxt=t=>t===1||t===2,nxt=new Set(["pipe","overlapped"]),bxe=async(t,e,r,n)=>{for await(let i of t)ixt(e)||wxe(i,r,n)},Txe=(t,e,r)=>{for(let n of t)wxe(n,e,r)},ixt=t=>t._readableState.pipes.length>0,wxe=(t,e,r)=>{let n=uk(t);Da({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Rxe=({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)=>axt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},axt=({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=AAe(t,s,d),p=cl(f),{stdioItems:h,objectMode:m}=e[r],_=cxt([p],h,c,n),{serializedResult:y,finalResult:E=y}=lxt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uxt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&dxt(y,h,i),S}catch(g){return n.error=g,S}},cxt=(t,e,r,n)=>{try{return Kk(t,e,r,!1)}catch(i){return n.error=i,t}},lxt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Pw(t)};let o=jwe(t,r);return n[s]?{serializedResult:o,finalResult:MK(o,!i[s],e)}:{serializedResult:o}},uxt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!Jk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=MK(t,!1,o);try{Txe(a,e,n)}catch(c){r.error??=c}},dxt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>Vk.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?oxt(n,t):(r.add(s),sxt(n,t))}};var Axe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,dl(e,r,"all")]:Array.isArray(e)?[dl(t,r,"all"),...e]:nn(t)&&nn(e)?GY([t,e]):`${t}${e}`};import{once as zK}from"events";var xxe=async(t,e)=>{let[r,n]=await fxt(t);return e.isForcefullyTerminated??=!1,[r,n]},fxt=async t=>{let[e,r]=await Promise.allSettled([zK(t,"spawn"),zK(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Pxe(t):r.value},Pxe=async t=>{try{return await zK(t,"exit")}catch{return Pxe(t)}},Cxe=async t=>{let[e,r]=await t;if(!pxt(e,r)&&qK(e,r))throw new $o;return[e,r]},pxt=(t,e)=>t===void 0&&e===void 0,qK=(t,e)=>t!==0||e!==null;var Ixe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=hxt(t,e,r),o=s?.code==="ETIMEDOUT",a=RAe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},hxt=(t,e,r)=>t!==void 0?t:qK(e,r)?new $o:void 0;var Oxe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gxt(t,e,r),d=Sxt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return oy(d,c,l)},gxt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=fk(t,e,r),a=_xt(r),{file:c,commandArguments:l,options:u}=Nk(t,e,a);yxt(u);let d=axe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_xt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,yxt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Zk("ipcInput"),t&&Zk("ipc: true"),r&&Zk("detached: true"),n&&Zk("cancelSignal")},Zk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Sxt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Ext({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}=Ixe(c,r),{output:h,error:m=l}=Rxe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,S)=>dl(E,r,S)),y=dl(Axe(h,r),r,"all");return bxt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Ext=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{vxe(s,r);let a=vxt(r);return mxt(...kk(t,e,a))}catch(a){return sy({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},vxt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:jk(e)}),bxt=({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?zk({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Mw({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 lCt}from"events";import{spawn as uCt}from"child_process";import Dxe from"process";import{once as BK,on as Txt}from"events";var Nxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Q_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:Ak(t)}),wxt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),wxt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{bk(e,i);let s=fd(t,e,r),o=new AbortController;try{return await Promise.race([Rxt(s,n,o),Axt(s,r,o),xxt(s,r,o)])}catch(a){throw ey(t),a}finally{o.abort(),Tk(e,i)}},Rxt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await BK(t,"message",{signal:r});return n}for await(let[n]of Txt(t,"message",{signal:r}))if(e(n))return n},Axt=async(t,e,{signal:r})=>{await BK(t,"disconnect",{signal:r}),y0e(e)},xxt=async(t,e,{signal:r})=>{let[n]=await BK(t,"strict:error",{signal:r});throw Sk(n,e)};import{once as $xe,on as Pxt}from"events";var Lxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>VK({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),VK=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Q_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:Ak(t)}),bk(e,s);let o=fd(t,e,r),a=new AbortController,c={};return Cxt(t,o,a),Ixt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Oxt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Cxt=async(t,e,r)=>{try{await $xe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Ixt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await $xe(t,"strict:error",{signal:r.signal});n.error=Sk(i,e),r.abort()}catch{}},Oxt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Pxt(r,"message",{signal:s.signal}))kxe(o),yield c}catch{kxe(o)}finally{s.abort(),Tk(e,a),n||ey(t),i&&await t}},kxe=({error:t})=>{if(t)throw t};var Mxe=(t,{ipc:e})=>{Object.assign(t,Fxe(t,!1,e))},Uxe=()=>{let t=Dxe,e=!0,r=Dxe.channel!==void 0;return{...Fxe(t,e,r),getCancelSignal:H0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Fxe=(t,e,r)=>({sendMessage:Ik.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Nxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Lxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Nxt}from"child_process";import{PassThrough as kxt,Readable as $xt,Writable as Lxt,Duplex as Dxt}from"stream";var jxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{$K(n);let a=new Nxt;Mxt(a,n),Object.assign(a,{readable:Uxt,writable:Fxt,duplex:jxt});let c=sy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=zxt(c,o,i);return{subprocess:a,promise:l}},Mxt=(t,e)=>{let r=Fw(),n=Fw(),i=Fw(),s=Array.from({length:e.length-3},Fw),o=Fw(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Fw=()=>{let t=new kxt;return t.end(),t},Uxt=()=>new $xt({read(){}}),Fxt=()=>new Lxt({write(){}}),jxt=()=>new Dxt({read(){},write(){}}),zxt=async(t,e,r)=>oy(t,e,r);import{createReadStream as zxe,createWriteStream as qxe}from"fs";import{Buffer as qxt}from"buffer";import{Readable as jw,Writable as Bxt,Duplex as Vxt}from"stream";var Vxe=(t,e)=>Hk(Hxt,t,e,!1),zw=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Bxe={fileNumber:zw,generator:jK,asyncGenerator:jK,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Vxt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Hxt={input:{...Bxe,fileUrl:({value:t})=>({stream:zxe(t)}),filePath:({value:{file:t}})=>({stream:zxe(t)}),webStream:({value:t})=>({stream:jw.fromWeb(t)}),iterable:({value:t})=>({stream:jw.from(t)}),asyncIterable:({value:t})=>({stream:jw.from(t)}),string:({value:t})=>({stream:jw.from(t)}),uint8Array:({value:t})=>({stream:jw.from(qxt.from(t))})},output:{...Bxe,fileUrl:({value:t})=>({stream:qxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:qxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Bxt.fromWeb(t)}),iterable:zw,asyncIterable:zw,string:zw,uint8Array:zw}};import{on as Gxt,once as Hxe}from"events";import{PassThrough as Wxt,getDefaultHighWaterMark as Yxt}from"stream";import{finished as Yxe}from"stream/promises";function zp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)GK(i);let e=t.some(({readableObjectMode:i})=>i),r=Kxt(t,e),n=new HK({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Kxt=(t,e)=>{if(t.length===0)return Yxt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},HK=class extends Wxt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(GK(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Jxt(this,this.#e,this.#s);let r=Qxt({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(GK(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)}},Jxt=async(t,e,r)=>{Xk(t,Gxe);let n=new AbortController;try{await Promise.race([Zxt(t,n),Xxt(t,e,r,n)])}finally{n.abort(),Xk(t,-Gxe)}},Zxt=async(t,{signal:e})=>{try{await Yxe(t,{signal:e,cleanup:!0})}catch(r){throw Kxe(t,r),r}},Xxt=async(t,e,r,{signal:n})=>{for await(let[i]of Gxt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},GK=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Qxt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{Xk(t,Wxe);let a=new AbortController;try{await Promise.race([ePt(s,e,a),tPt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),rPt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),Xk(t,-Wxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?WK(t):nPt(t))},ePt=async(t,e,{signal:r})=>{try{await t,r.aborted||WK(e)}catch(n){r.aborted||Kxe(e,n)}},tPt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Yxe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Jxe(o)?i.add(e):Zxe(t,o)}},rPt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Hxe(t,i,{signal:s}),!t.readable)return Hxe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},nPt=t=>{t.writable&&t.end()},Kxe=(t,e)=>{Jxe(e)?WK(t):Zxe(t,e)},Jxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",WK=t=>{(t.readable||t.writable)&&t.destroy()},Zxe=(t,e)=>{t.destroyed||(t.once("error",iPt),t.destroy(e))},iPt=()=>{},Xk=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Gxe=2,Wxe=1;import{finished as Xxe}from"stream/promises";var cy=(t,e)=>{t.pipe(e),sPt(t,e),oPt(t,e)},sPt=async(t,e)=>{if(!(ko(t)||ko(e))){try{await Xxe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}YK(e)}},YK=t=>{t.writable&&t.end()},oPt=async(t,e)=>{if(!(ko(t)||ko(e))){try{await Xxe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}KK(t)}},KK=t=>{t.readable&&t.destroy()};var Qxe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>to.has(c)))aPt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!to.has(c)))lPt({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]:zp(s);cy(o,i)}},aPt=(t,e,r,n)=>{r==="output"?cy(t.stdio[n],e):cy(e,t.stdio[n]);let i=cPt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},cPt=["stdin","stdout","stderr"],lPt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;uPt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},uPt=(t,{signal:e})=>{ko(t)&&Mp(t,dPt,e)},dPt=2;import{addAbortListener as hPt}from"events";var qp=[];qp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&qp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&qp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Qk=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",JK=Symbol.for("signal-exit emitter"),ZK=globalThis,fPt=Object.defineProperty.bind(Object),XK=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ZK[JK])return ZK[JK];fPt(ZK,JK,{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}},e$=class{},pPt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),QK=class extends e${onExit(){return()=>{}}load(){}unload(){}},e5=class extends e${#e=t5.platform==="win32"?"SIGINT":"SIGHUP";#r=new XK;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of qp)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(!Qk(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 qp)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,qp.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 Qk(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"&&Qk(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)}},t5=globalThis.process,{onExit:ePe,load:VTr,unload:HTr}=pPt(Qk(t5)?new e5(t5):new QK);var tPe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ePe(()=>{t.kill()});hPt(n,()=>{i()})};var nPe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=dk(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mPt(r,n,i),{sourceStream:d,sourceError:f}=_Pt(t,l),{options:p,fileDescriptors:h}=Ua.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},mPt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=gPt(t,e,...r),a=vk(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},gPt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(rPe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||VY(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]=tk(r,...n);return{destination:e(rPe)(i,s,o),pipeOptions:o}}if(Ua.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}`)},rPe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_Pt=(t,e)=>{try{return{sourceStream:ty(t,e)}}catch(r){return{sourceError:r}}};var sPe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=yPt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw r5({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},yPt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return KK(t),n;if(e!==void 0)return YK(r),e},r5=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>sy({error:t,command:iPe,escapedCommand:iPe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),iPe="source.pipe(destination)";var oPe=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 SPt}from"stream/promises";var aPe=(t,e,r)=>{let n=t$.has(e)?vPt(t,e):EPt(t,e);return Mp(t,TPt,r.signal),Mp(e,wPt,r.signal),bPt(e),n},EPt=(t,e)=>{let r=zp([t]);return cy(r,e),t$.set(e,r),r},vPt=(t,e)=>{let r=t$.get(e);return r.add(t),r},bPt=async t=>{try{await SPt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}t$.delete(t)},t$=new WeakMap,TPt=2,wPt=1;import{aborted as RPt}from"util";var cPe=(t,e)=>t===void 0?[]:[APt(t,e)],APt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await RPt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw r5({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var r$=(t,...e)=>{if(zr(e[0]))return r$.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=nPe(t,...e),i=xPt({...n,destination:r});return i.pipe=r$.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},xPt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=PPt(t,i);sPe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=aPe(e,s,d);return await Promise.race([oPe(u),...cPe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},PPt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as LPt}from"timers/promises";import{on as CPt}from"events";import{getDefaultHighWaterMark as IPt}from"stream";var n$=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return OPt(e,o),uPe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},OPt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},n5=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;NPt(e,o,t);let a=t.readableObjectMode&&!s;return uPe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},NPt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},uPe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=CPt(t,"data",{signal:e.signal,highWaterMark:lPe,highWatermark:lPe});return kPt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},i5=IPt(!0),lPe=i5,kPt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=$Pt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*jp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Uw(a)}},$Pt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Wk(t,r,!e),Gk(t,i,!n,{})].filter(Boolean);var dPe=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=DPt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([MPt(t),d]);return}let f=LK(c,r),p=n5({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([UPt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},DPt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!Jk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=n5({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await bxe(a,t,r,s)},MPt=async t=>{await LPt(),t.readableFlowing===null&&t.resume()},UPt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await Mk(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await Uk(r,{maxBuffer:s})):await iy(r,{maxBuffer:s})}catch(a){return fPe(bAe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},s5=async t=>{try{return await t}catch(e){return fPe(e)}},fPe=({bufferedData:t})=>Uwe(t)?new Uint8Array(t):t;import{finished as FPt}from"stream/promises";var qw=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=jPt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],FPt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||BPt(a,e,r,n)}finally{o.abort()}},jPt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&zPt(t,r,n),n},zPt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qPt(e,r),n.call(t,...i)}},qPt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},BPt=(t,e,r,n)=>{if(!VPt(t,e,r,n))throw t},VPt=(t,e,r,n=!0)=>r.propagating?pPe(t)||i$(t):(r.propagating=!0,o5(r,e)===n?pPe(t):i$(t)),o5=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",i$=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",pPe=t=>t?.code==="EPIPE";var hPe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>a5({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),a5=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=qw(t,e,l);if(o5(l,e)){await u;return}let[d]=await Promise.all([dPe({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 mPe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?zp([t,e].filter(Boolean)):void 0,gPe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>a5({...HPt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:GPt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),HPt=({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}},GPt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as WPt}from"events";var _Pe=t=>J_(t,"ipc"),yPe=(t,e)=>{let r=uk(t);Da({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var SPe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=_Pe(s),a=ll(e,"ipc"),c=ll(r,"ipc");for await(let l of VK({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(TAe(t,i,c),i.push(l)),o&&yPe(l,s);return i},EPe=async(t,e)=>(await Promise.allSettled([t]),e);var vPe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let E=xxe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=hPe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),T=gPe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),R=[],w=SPe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),b=YPt(m,t,S),P=KPt(h,S);try{return await Promise.race([Promise.all([{},Cxe(E),Promise.all(g),T,w,tAe(t,d),...b,...P]),_,JPt(t,y),...J0e(t,s,f,y),..._0e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Y0e({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(N){return f.terminationReason??="other",Promise.all([{error:N},E,Promise.all(g.map(x=>s5(x))),s5(T),EPe(w,R),Promise.allSettled(b),Promise.allSettled(P)])}},YPt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:qw(n,i,r)),KPt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Do(s,{checkOpen:!1})&&!ko(s)).map(({type:i,value:s,stream:o=s})=>qw(o,n,e,{isSameDirection:to.has(i),stopOnExit:i==="native"}))),JPt=async(t,{signal:e})=>{let[r]=await WPt(t,"error",{signal:e});throw r};var bPe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Bw=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Ma();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},ly=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 ZPt}from"stream";import{callbackify as XPt}from"util";import{finished as TPe}from"stream/promises";var c5=async t=>{if(t!==void 0)try{await l5(t)}catch{}},wPe=async t=>{if(t!==void 0)try{await u5(t)}catch{}},l5=async t=>{await TPe(t,{cleanup:!0,readable:!1,writable:!0})},u5=async t=>{await TPe(t,{cleanup:!0,readable:!0,writable:!1})},s$=async(t,e)=>{if(await t,e)throw e},o$=(t,e,r)=>{r&&!i$(r)?t.destroy(r):e&&t.destroy()};var RPe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ys.has(r),{subprocessStdout:a,waitReadableDestroy:c}=d5(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=f5(a,o),{read:f,onStdoutDataDone:p}=p5({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new ZPt({read:f,destroy:XPt(m5.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return h5({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},d5=(t,e,r)=>{let n=ty(t,e),i=Bw(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},f5=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:i5},p5=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Ma(),o=n$({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){QPt(this,o,s)},onStdoutDataDone:s}},QPt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},h5=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await u5(t),await n,await c5(i),await e,r.readable&&r.push(null)}catch(s){await c5(i),APe(r,s)}},m5=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ly(r,e)&&(APe(t,n),await s$(e,n))},APe=(t,e)=>{o$(t,t.readable,e)};import{Writable as eCt}from"stream";import{callbackify as xPe}from"util";var PPe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=g5(t,r,e),o=new eCt({..._5(n,t,i),destroy:xPe(S5.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return y5(n,o),o},g5=(t,e,r)=>{let n=vk(t,e),i=Bw(r,n,"writableFinal"),s=Bw(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},_5=(t,e,r)=>({write:tCt.bind(void 0,t),final:xPe(rCt.bind(void 0,t,e,r))}),tCt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rCt=async(t,e,r)=>{await ly(r,e)&&(t.writable&&t.end(),await e)},y5=async(t,e,r)=>{try{await l5(t),e.writable&&e.end()}catch(n){await wPe(r),CPe(e,n)}},S5=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ly(r,e),await ly(n,e)&&(CPe(t,i),await s$(e,i))},CPe=(t,e)=>{o$(t,t.writable,e)};import{Duplex as nCt}from"stream";import{callbackify as iCt}from"util";var IPe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ys.has(r),{subprocessStdout:c,waitReadableDestroy:l}=d5(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=g5(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=f5(c,a),{read:_,onStdoutDataDone:y}=p5({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new nCt({read:_,..._5(u,t,d),destroy:iCt(sCt.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 h5({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:u}),y5(u,E,c),E},sCt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([m5({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),S5({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var E5=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ys.has(e),o=ty(t,r),a=n$({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return oCt(a,o,t)},oCt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var OPe=(t,{encoding:e})=>{let r=bPe();t.readable=RPe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=PPe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=IPe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=E5.bind(void 0,t,e),t[Symbol.asyncIterator]=E5.bind(void 0,t,e,{})};var NPe=(t,e)=>{for(let[r,n]of cCt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},aCt=(async()=>{})().constructor.prototype,cCt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aCt,t)]);var kPe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dCt(t,e,r),{subprocess:f,promise:p}=pCt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=r$.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),NPe(f,p),Ua.set(f,{options:u,fileDescriptors:d}),f},dCt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=fk(t,e,r),{file:a,commandArguments:c,options:l}=Nk(t,e,r),u=fCt(l),d=Vxe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},fCt=({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}},pCt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uCt(...kk(t,e,r))}catch(h){return jxe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;lCt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Qxe(c,a,l),tPe(c,r,l);let d={},f=Ma();c.kill=m0e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=mPe(c,r),OPe(c,r),Mxe(c,r);let p=hCt({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}},hCt=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 vPe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,T)=>dl(g,e,T)),E=dl(m,e,"all"),S=mCt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return oy(S,n,e)},mCt=({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?Mw({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}):zk({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var a$=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,gCt(n,t[n],i)]));return{...t,...r}},gCt=(t,e,r)=>_Ct.has(t)&&zr(e)&&zr(r)?{...e,...r}:r,_Ct=new Set(["env",...JY]);var hd=(t,e,r,n)=>{let i=(o,a,c)=>hd(o,a,r,c),s=(...o)=>yCt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},yCt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(zr(s))return i(t,a$(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=SCt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?Oxe(a,c,l):kPe(a,c,l,i)},SCt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Vwe(e)?Hwe(e,r):[e,...r],[o,a,c]=tk(...s),l=a$(a$(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 $Pe=({file:t,commandArguments:e})=>DPe(t,e),LPe=({file:t,commandArguments:e})=>({...DPe(t,e),isSync:!0}),DPe=(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]=ECt(t);return{file:r,commandArguments:n}},ECt=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(vCt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},vCt=/ +/g;var MPe=(t,e,r)=>{t.sync=e(bCt,r),t.s=t.sync},UPe=({options:t})=>FPe(t),bCt=({options:t})=>({...FPe(t),isSync:!0}),FPe=t=>({options:{...TCt(t),...t}}),TCt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},jPe={preferLocal:!0};var zPe=hd(()=>({})),$0r=hd(()=>({isSync:!0})),qPe=hd($Pe),L0r=hd(LPe),D0r=hd(X0e),M0r=hd(UPe,{},jPe,MPe),{sendMessage:U0r,getOneMessage:F0r,getEachMessage:j0r,getCancelSignal:z0r}=Uxe();import{Transform as wCt}from"stream";var RCt=["NETLIFY_AI_GATEWAY_KEY"];function ACt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...RCt])]}function xCt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function PCt(){let e=ACt().map(r=>process.env[r]).filter(r=>!(!r||xCt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ki(t){if(typeof t!="string")return t;let e=PCt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(CCt(n),"g");r=r.replace(i,"******")}),r}function CCt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Vw=class extends wCt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ki(i);n(null,s)}},c$=Symbol("maskedWrite");function BPe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[c$]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ki(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[c$]=!0,process.stdout.write=r}if(!process.stderr.write[c$]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ki(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[c$]=!0,process.stderr.write=r}}}var VPe=!1,HPe=()=>{VPe=!0},Ji=()=>VPe;var Hw=null,GPe=t=>(Hw&&Hw.destroy(),Hw=new Mo({totalAllowedTime:t}),Hw),WPe=()=>Hw;var Mo=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Ji())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 JN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{oe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var YPe={name:"@netlify/agent-runner-cli",type:"module",version:"1.175.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var kCt=OCt(import.meta.url),$Ct=fl.dirname(kCt),LCt=NCt(import.meta.url),uy=pe("shell"),v5=new Set,KPe={preferLocal:!0},gr=(t,e,r)=>{let[n,i]=DCt(e,r),s={...KPe,...i},o=zPe(t,n,s);ZPe(o,s),eCe(o);let a=r?.idleTimeout;return a&&a>0&&QPe(o,a),o},JPe=(t,e)=>{let r={...KPe,...e},n=qPe(t,r);return ZPe(n,r),eCe(n),e?.idleTimeout&&e.idleTimeout>0&&QPe(n,e.idleTimeout),n},DCt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ZPe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||za.env.NETLIFY_LOCAL_QUIET==="true")return;if(za.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Vw).pipe(za.stdout),t.stderr?.pipe(new Vw).pipe(za.stderr);return}t.stdout?.pipe(za.stdout),t.stderr?.pipe(za.stderr)},b5=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(za.kill(-t.pid,e),uy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return uy.error("Error killing process:",r),!1}},XPe=t=>b5(t,"SIGKILL"),QPe=(t,e)=>{let r=null,n=()=>{uy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),b5(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(uy.log(`Force killing idle process ${t.pid}`),XPe(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)},eCe=t=>{v5.add(t);let e=WPe();if(e){let r=e.onTimesUp(()=>{uy.log(`Global timer expired, killing process ${t.pid}`),b5(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(uy.log(`Force killing process ${t.pid} after timeout`),XPe(t))},5e3)});t.on("exit",()=>{v5.delete(t),r()}),t.on("error",()=>{v5.delete(t),r()})}};function qa(t,e){if(!za.env.NETLIFY_LOCAL_MODE)try{let i=LCt.resolve(YPe.name),s=fl.dirname(i);for(;s!==fl.dirname(s);){let o=fl.dirname(s);if(fl.basename(o)==="node_modules"){let a=fl.join(o,".bin",e);if(l$.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(za.env.NODE_PATH){let i=fl.join(za.env.NODE_PATH,".bin",e);if(l$.existsSync(i))return i}let r=fl.join(t,"node_modules",".bin",e);if(l$.existsSync(r))return r;let n=fl.join($Ct,"..","node_modules",".bin",e);if(l$.existsSync(n))return n}import N1 from"process";import{fileURLToPath as d2t}from"url";import{createRequire as f2t}from"module";import B0 from"path";import{readFileSync as p2t}from"fs";var MCt="__netlify__getTracer",UCt="__netlify__shutdownTracers",Ot=(t,e)=>globalThis[MCt]?.(t,e),tCe=async()=>globalThis[UCt]?.();function Gw(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 i2t}from"timers/promises";ke();import FOt from"process";ke();var cIt=(t,e)=>{e.recordException(t),e.setStatus({code:ci.ERROR})};var ml=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=YCe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>KCe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=YCe(r,n,i),c=this._tracer.startSpan(e,s,o);return KCe(c,s,a)}};function YCe(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??nr.active(),{opts:n,ctx:i,fn:s}}function KCe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:cIt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}ke();var _y=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var r9=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=sIe(e),n._asyncAttributesPending=e.filter(([i,s])=>_y(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(_y(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=sIe(this._rawAttributes),this._schemaUrl=lIt(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,_y(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(_y(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=uIt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function n9(t,e){return r9.FromAttributeList(Object.entries(t),e)}function sIe(t){return t.map(([e,r])=>_y(r)?[e,r.catch(n=>{le.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function lIt(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 uIt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;le.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}ke();var iR=class{emit(e){}enabled(){return!1}},oIe=new iR;var sR=Symbol.for("io.opentelemetry.js.api.logs"),yy=globalThis;function aIe(t,e,r){return n=>n===t?e:r}var i9=1;var s9=class{getLogger(e,r,n){return new iR}},N$=new s9;var k$=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):oIe}};var oR=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new k$(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 $$=class t{constructor(){this._proxyLoggerProvider=new oR}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return yy[sR]?this.getLoggerProvider():(yy[sR]=aIe(i9,e,N$),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=yy[sR])===null||e===void 0?void 0:e.call(yy,i9))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete yy[sR],this._proxyLoggerProvider=new oR}};var cIe=$$.getInstance();function lIe(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 uIe(t){t.forEach(e=>e.disable())}function o9(t){let e=t.tracerProvider||qt.getTracerProvider(),r=t.meterProvider||nR.getMeterProvider(),n=t.loggerProvider||cIe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return lIe(i,e,r,n),()=>{uIe(i)}}ke();var dIt=mn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function dIe(t){return t.getValue(dIt)===!0}var Sy;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Sy||(Sy={}));ke();var a9="[_0-9a-z-*/]",fIt=`[a-z]${a9}{0,255}`,pIt=`[a-z0-9]${a9}{0,240}@[a-z]${a9}{0,13}`,hIt=new RegExp(`^(?:${fIt}|${pIt})$`),mIt=/^[ -~]{0,255}[!-~]$/,gIt=/,|=/;function c9(t){return hIt.test(t)}function l9(t){return mIt.test(t)&&!gIt.test(t)}var _It=32,fIe=512,pIe=",",hIe="=",L$=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!c9(e)||!l9(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>fIe)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=pIe+e),e=`${n[0]}${hIe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(pIe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(hIe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!c9(a)||!l9(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>fIe)&&(r.set(a,c),n=l,r.size>=_It))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 D$="traceparent",M$="tracestate",yIt="00",SIt="(?!ff)[\\da-f]{2}",EIt="(?![0]{32})[\\da-f]{32}",vIt="(?![0]{16})[\\da-f]{16}",bIt="[\\da-f]{2}",TIt=new RegExp(`^\\s?(${SIt})-(${EIt})-(${vIt})-(${bIt})(-.*)?\\s?$`);function mIe(t){let e=TIt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var _d=class{inject(e,r,n){let i=qt.getSpanContext(e);if(!i||dIe(e)||!Zi(i))return;let s=`${yIt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Nr.NONE).toString(16)}`;n.set(r,D$,s),i.traceState&&n.set(r,M$,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,D$);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=mIe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,M$);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new L$(typeof c=="string"?c:void 0)}return qt.setSpanContext(e,o)}fields(){return[D$,M$]}};var U$=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 aR=class{_isCalled=!1;_deferred=new U$;_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 CL=Pn(Y9(),1);ke();var ZNe=t=>{throw TypeError(t)},X9=(t,e,r)=>e.has(t)||ZNe("Cannot "+r),PL=(t,e,r)=>(X9(t,e,"read from private field"),r?r.call(t):e.get(t)),K9=(t,e,r)=>e.has(t)?ZNe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),YNe=(t,e,r,n)=>(X9(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),UOt=(t,e,r)=>(X9(t,e,"access private method"),r),KNe="__netlify__getTracer",jOt="__netlify__shutdownTracers",zOt="__nfOTLPTrace",bR,TR,Z9,XNe,qOt=class{constructor(){K9(this,Z9),K9(this,bR),K9(this,TR),YNe(this,bR,new aR(UOt(this,Z9,XNe),this)),YNe(this,TR,le.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(PL(this,TR).debug(`export ${t.length.toString()} spans`),PL(this,bR).isCalled){e({code:Sy.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zOt,JSON.stringify(BOt(t))),e({code:Sy.SUCCESS})}shutdown(){return PL(this,bR).call()}};bR=new WeakMap;TR=new WeakMap;Z9=new WeakSet;XNe=function(){return PL(this,TR).debug("Shutting down"),Promise.resolve()};function BOt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:xL(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||Uo.SERVER,startTimeUnixNano:J9(e.startTime),endTimeUnixNano:J9(e.endTime),attributes:xL(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:J9(n.time),attributes:xL(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:xL(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function xL(t){return Object.keys(t).map(e=>QNe(e,t[e]))}function QNe(t,e){return{key:t,value:eke(e)}}function eke(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(eke)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>QNe(r,n))}}:{}}function J9(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var JNe={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"}},tke=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,KNe))return;let e=FOt.version.slice(1),r=n9({"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??[VOt()],i=new CL.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new _d});let s=t.instrumentations??[];o9({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,KNe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new ml(qt.getTracer(a,c)):new ml(qt.getTracer(JNe.name,JNe.version))}}),Object.defineProperty(globalThis,jOt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},VOt=()=>new CL.SimpleSpanProcessor(new qOt);ke();var wR=Pn(Y9(),1);ke();import*as IL from"diagnostics_channel";var rke=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?ci.ERROR:ci.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof ml?t:new ml(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){IL.subscribe(t,e);let r=()=>IL.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:Uo.CLIENT},nr.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:ci.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 Aje=Pn(wje(),1);var I1=pe("tracing"),Rje=8e3,s2t=5e3,q0=async(t=s2t)=>{try{await Promise.race([tCe(),i2t(t)])}catch(e){I1.warn("Failed to flush tracers on shutdown",e)}},xje=async(t,e,r)=>{if(!Ot()){let n=[new wR.SimpleSpanProcessor(new Q7),new wR.SimpleSpanProcessor(new Aje.OTLPTraceExporter({url:r.exporterUrl}))];await tke({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new rke({skipHeaders:!0})]})}return r.traceparent?(Pi.setGlobalPropagator(new _d),Pi.extract(nr.active(),{traceparent:r.traceparent,isRemote:!0})):nr.active()};function or(t,e,r){return I1.log(`\u23F3 TRACE: ${e} starting...`),Gw(t,e,r)}var Q7=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(", ")}]`:"";I1.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&I1.log(` \u274C Error: ${e.status.message}`)}};function eQ(){return Qe().captureLlmContentEnabled}function Pje(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function O1(t,e,r){let n={role:t,parts:[{type:"text",content:Ki(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var o2t=new Set([Q.Task,Q.RunCommand,Q.Explore,Q.FileRead,Q.FileWrite,Q.Notebook,Q.Web,Q.Todo,Q.Skill,Q.Tool,Q.Memorize,Q.Deployment,Q.SiteGeneration]);function Cje(t,e,r,n){if(!t.length)return;let i=Ot();if(!i)return;let s=eQ(),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&&o2t.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>Rje?`${a.message.slice(0,Rje)}\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":Ki(_)}:{"gen_ai.output.messages":O1("assistant",_)}:{}}}).end(u)})}import{readdir as a2t,rm as c2t}from"fs/promises";import{join as l2t}from"path";async function Ije(t,e=[]){let n=(await a2t(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>c2t(l2t(t,i),{recursive:!0,force:!0})))}var u2t=300,Ph=t=>Qe().budgetCreditThresholds[t.mode]?.[t.runner]??u2t,Ch=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var tQ=t=>{let e=Ph(t);if(!Ch(t,e))return"default";let r=Qe();return r.createAskFirstEnabled&&r.questionsEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},Oje=t=>{let e=tQ(t),r=Ph(t);return{budget_eligible:Ch(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var h2t=B0.dirname(d2t(import.meta.url)),Nje=f2t(import.meta.url),m2t=B0.resolve(h2t,"scripts/scaffold.js"),g2t="scripts/scaffold.js",_2t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,rQ=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},y2t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),S2t=t=>{let e=rQ(t);return e==="node"||e.endsWith("/node")},Fl=t=>{if(typeof t!="string")return!1;let e=t.match(_2t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&y2t(rQ(e[r]));)r+=1;if(r>=e.length||!S2t(e[r]))return!1;let n=e[r+1];return n?rQ(n).includes(g2t):!1},Ih=pe("create_stage"),nQ="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.",E2t=`${nQ}
|
|
635
635
|
|
|
636
636
|
Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,v2t=`${nQ}
|
|
637
637
|
|
package/dist/index.js
CHANGED
|
@@ -140,7 +140,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
140
140
|
`,LF:`
|
|
141
141
|
`,concatBytes:qz},jHe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},BHe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:jHe};import{Buffer as qHe}from"buffer";var eue=(t,e)=>t?void 0:VHe.bind(void 0,e),VHe=function*(t,e){if(typeof e!="string"&&!Tr(e)&&!qHe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},tue=(t,e)=>t?GHe.bind(void 0,e):HHe.bind(void 0,e),GHe=function*(t,e){rue(t,e),yield e},HHe=function*(t,e){if(rue(t,e),typeof e!="string"&&!Tr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},rue=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
142
142
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
143
|
-
if (condition) { yield value; }`)};import{Buffer as WHe}from"buffer";import{StringDecoder as YHe}from"string_decoder";var pC=(t,e,r)=>{if(r)return;if(t)return{transform:KHe.bind(void 0,new TextEncoder)};let n=new YHe(e);return{transform:ZHe.bind(void 0,n),final:JHe.bind(void 0,n)}},KHe=function*(t,e){WHe.isBuffer(e)?yield $a(e):typeof e=="string"?yield t.encode(e):yield e},ZHe=function*(t,e){yield Tr(e)?t.write(e):e},JHe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as nue}from"util";var Gz=nue(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),hC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QHe}=e[r];for await(let i of n(t))yield*hC(i,e,r+1)},iue=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XHe(r,Number(e),t)},XHe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*hC(n,r,e+1)},oue=nue(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),QHe=function*(t){yield t};var Hz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},sue=(t,e)=>[...e.flatMap(r=>[...yd(r,t,0)]),...dE(t)],yd=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=t6e}=e[r];for(let i of n(t))yield*yd(i,e,r+1)},dE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*e6e(r,Number(e),t)},e6e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*yd(n,r,e+1)},t6e=function*(t){yield t};var Wz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=cue(t,s,o),l=_d(e),u=_d(r),d=l?Gz.bind(void 0,hC,a):Hz.bind(void 0,yd),f=l||u?Gz.bind(void 0,iue,a):Hz.bind(void 0,dE),p=l||u?oue.bind(void 0,a):void 0;return{stream:new r6e({writableObjectMode:n,writableHighWaterMark:aue(n),readableObjectMode:i,readableHighWaterMark:aue(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},mC=(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=cue(s,r,a);t=sue(c,t)}return t},cue=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:eue(n,a)},pC(r,s,n),fC(r,o,n,c),{transform:t,final:e},{transform:tue(i,a)},Qle({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var lue=(t,e)=>{for(let r of n6e(t))i6e(t,r,e)},n6e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),i6e=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${al[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>o6e(a,n));r.input=tE(s)},o6e=(t,e)=>{let r=mC(t,e,"utf8",!0);return s6e(r),tE(r)},s6e=t=>{let e=t.find(r=>typeof r!="string"&&!Tr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as u6e,appendFileSync as d6e}from"fs";var gC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&yh(r,n)&&!vi.has(e)&&a6e(n)&&(t.some(({type:i,value:o})=>i==="native"&&c6e.has(o))||t.every(({type:i})=>Zi.has(i))),a6e=t=>t===1||t===2,c6e=new Set(["pipe","overlapped"]),uue=async(t,e,r,n)=>{for await(let i of t)l6e(e)||fue(i,r,n)},due=(t,e,r)=>{for(let n of t)fue(n,e,r)},l6e=t=>t._readableState.pipes.length>0,fue=(t,e,r)=>{let n=P0(t);xs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var pue=({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)=>f6e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},f6e=({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=hle(t,o,d),p=$a(f),{stdioItems:h,objectMode:m}=e[r],g=p6e([p],h,c,n),{serializedResult:_,finalResult:E=_}=h6e({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});m6e({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let b=a[r]?E:void 0;try{return n.error===void 0&&g6e(_,h,i),b}catch(T){return n.error=T,b}},p6e=(t,e,r,n)=>{try{return mC(t,e,r,!1)}catch(i){return n.error=i,t}},h6e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:tE(t)};let s=Cse(t,r);return n[o]?{serializedResult:s,finalResult:Vz(s,!i[o],e)}:{serializedResult:s}},m6e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!gC({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=Vz(t,!1,s);try{due(a,e,n)}catch(c){r.error??=c}},g6e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>uC.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?d6e(n,t):(r.add(o),u6e(n,t))}};var hue=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ua(e,r,"all")]:Array.isArray(e)?[Ua(t,r,"all"),...e]:Tr(t)&&Tr(e)?QF([t,e]):`${t}${e}`};import{once as Yz}from"events";var mue=async(t,e)=>{let[r,n]=await _6e(t);return e.isForcefullyTerminated??=!1,[r,n]},_6e=async t=>{let[e,r]=await Promise.allSettled([Yz(t,"spawn"),Yz(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?gue(t):r.value},gue=async t=>{try{return await Yz(t,"exit")}catch{return gue(t)}},_ue=async t=>{let[e,r]=await t;if(!y6e(e,r)&&Kz(e,r))throw new $o;return[e,r]},y6e=(t,e)=>t===void 0&&e===void 0,Kz=(t,e)=>t!==0||e!==null;var yue=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=S6e(t,e,r),s=o?.code==="ETIMEDOUT",a=ple(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},S6e=(t,e,r)=>t!==void 0?t:Kz(e,r)?new $o:void 0;var Sue=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=v6e(t,e,r),d=w6e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Ch(d,c,l)},v6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=N0(t,e,r),a=b6e(r),{file:c,commandArguments:l,options:u}=X0(t,e,a);T6e(u);let d=Kle(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},b6e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,T6e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&_C("ipcInput"),t&&_C("ipc: true"),r&&_C("detached: true"),n&&_C("cancelSignal")},_C=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},w6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=A6e({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}=yue(c,r),{output:h,error:m=l}=pue({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((E,b)=>Ua(E,r,b)),_=Ua(hue(h,r),r,"all");return R6e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},A6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{lue(o,r);let a=x6e(r);return E6e(...Q0(t,e,a))}catch(a){return Rh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},x6e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:sC(e)}),R6e=({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?aC({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):uE({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as hWe}from"events";import{spawn as mWe}from"child_process";import wue from"process";import{once as Zz,on as C6e}from"events";var Eue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(vh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:H0(t)}),I6e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),I6e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{B0(e,i);let o=sl(t,e,r),s=new AbortController;try{return await Promise.race([P6e(o,n,s),O6e(o,r,s),N6e(o,r,s)])}catch(a){throw bh(t),a}finally{s.abort(),q0(e,i)}},P6e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await Zz(t,"message",{signal:r});return n}for await(let[n]of C6e(t,"message",{signal:r}))if(e(n))return n},O6e=async(t,e,{signal:r})=>{await Zz(t,"disconnect",{signal:r}),sce(e)},N6e=async(t,e,{signal:r})=>{let[n]=await Zz(t,"strict:error",{signal:r});throw F0(n,e)};import{once as bue,on as k6e}from"events";var Tue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>Jz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),Jz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{vh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:H0(t)}),B0(e,o);let s=sl(t,e,r),a=new AbortController,c={};return M6e(t,s,a),$6e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),D6e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},M6e=async(t,e,r)=>{try{await bue(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},$6e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await bue(t,"strict:error",{signal:r.signal});n.error=F0(i,e),r.abort()}catch{}},D6e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of k6e(r,"message",{signal:o.signal}))vue(s),yield c}catch{vue(s)}finally{o.abort(),q0(e,a),n||bh(t),i&&await t}},vue=({error:t})=>{if(t)throw t};var Aue=(t,{ipc:e})=>{Object.assign(t,Rue(t,!1,e))},xue=()=>{let t=wue,e=!0,r=wue.channel!==void 0;return{...Rue(t,e,r),getCancelSignal:kce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Rue=(t,e,r)=>({sendMessage:Z0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Eue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Tue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as L6e}from"child_process";import{PassThrough as U6e,Readable as F6e,Writable as z6e,Duplex as j6e}from"stream";var Cue=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{jz(n);let a=new L6e;B6e(a,n),Object.assign(a,{readable:q6e,writable:V6e,duplex:G6e});let c=Rh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=H6e(c,s,i);return{subprocess:a,promise:l}},B6e=(t,e)=>{let r=fE(),n=fE(),i=fE(),o=Array.from({length:e.length-3},fE),s=fE(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},fE=()=>{let t=new U6e;return t.end(),t},q6e=()=>new F6e({read(){}}),V6e=()=>new z6e({write(){}}),G6e=()=>new j6e({read(){},write(){}}),H6e=async(t,e,r)=>Ch(t,e,r);import{createReadStream as Iue,createWriteStream as Pue}from"fs";import{Buffer as W6e}from"buffer";import{Readable as pE,Writable as Y6e,Duplex as K6e}from"stream";var Nue=(t,e)=>dC(Z6e,t,e,!1),hE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${al[t]}.`)},Oue={fileNumber:hE,generator:Wz,asyncGenerator:Wz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:K6e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Z6e={input:{...Oue,fileUrl:({value:t})=>({stream:Iue(t)}),filePath:({value:{file:t}})=>({stream:Iue(t)}),webStream:({value:t})=>({stream:pE.fromWeb(t)}),iterable:({value:t})=>({stream:pE.from(t)}),asyncIterable:({value:t})=>({stream:pE.from(t)}),string:({value:t})=>({stream:pE.from(t)}),uint8Array:({value:t})=>({stream:pE.from(W6e.from(t))})},output:{...Oue,fileUrl:({value:t})=>({stream:Pue(t)}),filePath:({value:{file:t,append:e}})=>({stream:Pue(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Y6e.fromWeb(t)}),iterable:hE,asyncIterable:hE,string:hE,uint8Array:hE}};import{on as J6e,once as kue}from"events";import{PassThrough as X6e,getDefaultHighWaterMark as Q6e}from"stream";import{finished as Due}from"stream/promises";function Sd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Qz(i);let e=t.some(({readableObjectMode:i})=>i),r=e3e(t,e),n=new Xz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var e3e=(t,e)=>{if(t.length===0)return Q6e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},Xz=class extends X6e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(Qz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=t3e(this,this.#e,this.#o);let r=i3e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(Qz(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},t3e=async(t,e,r)=>{yC(t,Mue);let n=new AbortController;try{await Promise.race([r3e(t,n),n3e(t,e,r,n)])}finally{n.abort(),yC(t,-Mue)}},r3e=async(t,{signal:e})=>{try{await Due(t,{signal:e,cleanup:!0})}catch(r){throw Lue(t,r),r}},n3e=async(t,e,r,{signal:n})=>{for await(let[i]of J6e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},Qz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},i3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{yC(t,$ue);let a=new AbortController;try{await Promise.race([o3e(o,e,a),s3e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),a3e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),yC(t,-$ue)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?ej(t):c3e(t))},o3e=async(t,e,{signal:r})=>{try{await t,r.aborted||ej(e)}catch(n){r.aborted||Lue(e,n)}},s3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Due(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Uue(s)?i.add(e):Fue(t,s)}},a3e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await kue(t,i,{signal:o}),!t.readable)return kue(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},c3e=t=>{t.writable&&t.end()},Lue=(t,e)=>{Uue(e)?ej(t):Fue(t,e)},Uue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",ej=t=>{(t.readable||t.writable)&&t.destroy()},Fue=(t,e)=>{t.destroyed||(t.once("error",l3e),t.destroy(e))},l3e=()=>{},yC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Mue=2,$ue=1;import{finished as zue}from"stream/promises";var Ph=(t,e)=>{t.pipe(e),u3e(t,e),d3e(t,e)},u3e=async(t,e)=>{if(!(Mo(t)||Mo(e))){try{await zue(t,{cleanup:!0,readable:!0,writable:!1})}catch{}tj(e)}},tj=t=>{t.writable&&t.end()},d3e=async(t,e)=>{if(!(Mo(t)||Mo(e))){try{await zue(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rj(t)}},rj=t=>{t.readable&&t.destroy()};var jue=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Zi.has(c)))f3e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zi.has(c)))h3e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Sd(o);Ph(s,i)}},f3e=(t,e,r,n)=>{r==="output"?Ph(t.stdio[n],e):Ph(e,t.stdio[n]);let i=p3e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},p3e=["stdin","stdout","stderr"],h3e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;m3e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},m3e=(t,{signal:e})=>{Mo(t)&&md(t,g3e,e)},g3e=2;import{addAbortListener as S3e}from"events";var Ed=[];Ed.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ed.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ed.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var SC=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",nj=Symbol.for("signal-exit emitter"),ij=globalThis,_3e=Object.defineProperty.bind(Object),oj=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ij[nj])return ij[nj];_3e(ij,nj,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},EC=class{},y3e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),sj=class extends EC{onExit(){return()=>{}}load(){}unload(){}},aj=class extends EC{#e=cj.platform==="win32"?"SIGINT":"SIGHUP";#r=new oj;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ed)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(!SC(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 Ed)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,Ed.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 SC(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"&&SC(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},cj=globalThis.process,{onExit:Bue,load:xzt,unload:Rzt}=y3e(SC(cj)?new aj(cj):new sj);var que=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Bue(()=>{t.kill()});S3e(n,()=>{i()})};var Gue=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=O0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=E3e(r,n,i),{sourceStream:d,sourceError:f}=b3e(t,l),{options:p,fileDescriptors:h}=Cs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},E3e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=v3e(t,e,...r),a=j0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},v3e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Vue,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||JF(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=v0(r,...n);return{destination:e(Vue)(i,o,s),pipeOptions:s}}if(Cs.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Vue=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),b3e=(t,e)=>{try{return{sourceStream:Th(t,e)}}catch(r){return{sourceError:r}}};var Wue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=T3e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw lj({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},T3e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return rj(t),n;if(e!==void 0)return tj(r),e},lj=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Rh({error:t,command:Hue,escapedCommand:Hue,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Hue="source.pipe(destination)";var Yue=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 w3e}from"stream/promises";var Kue=(t,e,r)=>{let n=vC.has(e)?x3e(t,e):A3e(t,e);return md(t,C3e,r.signal),md(e,I3e,r.signal),R3e(e),n},A3e=(t,e)=>{let r=Sd([t]);return Ph(r,e),vC.set(e,r),r},x3e=(t,e)=>{let r=vC.get(e);return r.add(t),r},R3e=async t=>{try{await w3e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}vC.delete(t)},vC=new WeakMap,C3e=2,I3e=1;import{aborted as P3e}from"util";var Zue=(t,e)=>t===void 0?[]:[O3e(t,e)],O3e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await P3e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw lj({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var bC=(t,...e)=>{if(lr(e[0]))return bC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Gue(t,...e),i=N3e({...n,destination:r});return i.pipe=bC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},N3e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=k3e(t,i);Wue({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Kue(e,o,d);return await Promise.race([Yue(u),...Zue(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},k3e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as z3e}from"timers/promises";import{on as M3e}from"events";import{getDefaultHighWaterMark as $3e}from"stream";var TC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return D3e(e,s),Xue({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},D3e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},uj=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;L3e(e,s,t);let a=t.readableObjectMode&&!o;return Xue({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},L3e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Xue=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=M3e(t,"data",{signal:e.signal,highWaterMark:Jue,highWatermark:Jue});return U3e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},dj=$3e(!0),Jue=dj,U3e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=F3e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*yd(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*dE(a)}},F3e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[pC(t,r,!e),fC(t,i,!n,{})].filter(Boolean);var Que=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=j3e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([B3e(t),d]);return}let f=Bz(c,r),p=uj({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([q3e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},j3e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!gC({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=uj({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await uue(a,t,r,o)},B3e=async t=>{await z3e(),t.readableFlowing===null&&t.resume()},q3e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await nC(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await iC(r,{maxBuffer:o})):await xh(r,{maxBuffer:o})}catch(a){return ede(ule({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},fj=async t=>{try{return await t}catch(e){return ede(e)}},ede=({bufferedData:t})=>xse(t)?new Uint8Array(t):t;import{finished as V3e}from"stream/promises";var mE=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=G3e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],V3e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Y3e(a,e,r,n)}finally{s.abort()}},G3e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&H3e(t,r,n),n},H3e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{W3e(e,r),n.call(t,...i)}},W3e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Y3e=(t,e,r,n)=>{if(!K3e(t,e,r,n))throw t},K3e=(t,e,r,n=!0)=>r.propagating?tde(t)||wC(t):(r.propagating=!0,pj(r,e)===n?tde(t):wC(t)),pj=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",wC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",tde=t=>t?.code==="EPIPE";var rde=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>hj({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),hj=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=mE(t,e,l);if(pj(l,e)){await u;return}let[d]=await Promise.all([Que({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 nde=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Sd([t,e].filter(Boolean)):void 0,ide=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>hj({...Z3e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:J3e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Z3e=({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}},J3e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as X3e}from"events";var ode=t=>yh(t,"ipc"),sde=(t,e)=>{let r=P0(t);xs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ade=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=ode(o),a=Da(e,"ipc"),c=Da(r,"ipc");for await(let l of Jz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(dle(t,i,c),i.push(l)),s&&sde(l,o);return i},cde=async(t,e)=>(await Promise.allSettled([t]),e);var lde=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let E=mue(t,f),b={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},T=rde({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),w=ide({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),x=[],P=ade({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),C=Q3e(m,t,b),M=eWe(h,b);try{return await Promise.race([Promise.all([{},_ue(E),Promise.all(T),w,P,qce(t,d),...C,...M]),g,tWe(t,_),...Uce(t,o,f,_),...oce({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Dce({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},E,Promise.all(T.map(v=>fj(v))),fj(w),cde(P,x),Promise.allSettled(C),Promise.allSettled(M)])}},Q3e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:mE(n,i,r)),eWe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Lo(o,{checkOpen:!1})&&!Mo(o)).map(({type:i,value:o,stream:s=o})=>mE(s,n,e,{isSameDirection:Zi.has(i),stopOnExit:i==="native"}))),tWe=async(t,{signal:e})=>{let[r]=await X3e(t,"error",{signal:e});throw r};var ude=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),gE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Rs();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Oh=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 rWe}from"stream";import{callbackify as nWe}from"util";import{finished as dde}from"stream/promises";var mj=async t=>{if(t!==void 0)try{await gj(t)}catch{}},fde=async t=>{if(t!==void 0)try{await _j(t)}catch{}},gj=async t=>{await dde(t,{cleanup:!0,readable:!1,writable:!0})},_j=async t=>{await dde(t,{cleanup:!0,readable:!0,writable:!1})},AC=async(t,e)=>{if(await t,e)throw e},xC=(t,e,r)=>{r&&!wC(r)?t.destroy(r):e&&t.destroy()};var pde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||vi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=yj(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Sj(a,s),{read:f,onStdoutDataDone:p}=Ej({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new rWe({read:f,destroy:nWe(bj.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return vj({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},yj=(t,e,r)=>{let n=Th(t,e),i=gE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Sj=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:dj},Ej=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Rs(),s=TC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){iWe(this,s,o)},onStdoutDataDone:o}},iWe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},vj=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await _j(t),await n,await mj(i),await e,r.readable&&r.push(null)}catch(o){await mj(i),hde(r,o)}},bj=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Oh(r,e)&&(hde(t,n),await AC(e,n))},hde=(t,e)=>{xC(t,t.readable,e)};import{Writable as oWe}from"stream";import{callbackify as mde}from"util";var gde=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Tj(t,r,e),s=new oWe({...wj(n,t,i),destroy:mde(xj.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Aj(n,s),s},Tj=(t,e,r)=>{let n=j0(t,e),i=gE(r,n,"writableFinal"),o=gE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},wj=(t,e,r)=>({write:sWe.bind(void 0,t),final:mde(aWe.bind(void 0,t,e,r))}),sWe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},aWe=async(t,e,r)=>{await Oh(r,e)&&(t.writable&&t.end(),await e)},Aj=async(t,e,r)=>{try{await gj(t),e.writable&&e.end()}catch(n){await fde(r),_de(e,n)}},xj=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Oh(r,e),await Oh(n,e)&&(_de(t,i),await AC(e,i))},_de=(t,e)=>{xC(t,t.writable,e)};import{Duplex as cWe}from"stream";import{callbackify as lWe}from"util";var yde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||vi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=yj(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Tj(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Sj(c,a),{read:g,onStdoutDataDone:_}=Ej({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),E=new cWe({read:g,...wj(u,t,d),destroy:lWe(uWe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return vj({subprocessStdout:c,onStdoutDataDone:_,readable:E,subprocess:t,subprocessStdin:u}),Aj(u,E,c),E},uWe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([bj({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),xj({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Rj=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||vi.has(e),s=Th(t,r),a=TC({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return dWe(a,s,t)},dWe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Sde=(t,{encoding:e})=>{let r=ude();t.readable=pde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=gde.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=yde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Rj.bind(void 0,t,e),t[Symbol.asyncIterator]=Rj.bind(void 0,t,e,{})};var Ede=(t,e)=>{for(let[r,n]of pWe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},fWe=(async()=>{})().constructor.prototype,pWe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(fWe,t)]);var vde=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=gWe(t,e,r),{subprocess:f,promise:p}=yWe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=bC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Ede(f,p),Cs.set(f,{options:u,fileDescriptors:d}),f},gWe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=N0(t,e,r),{file:a,commandArguments:c,options:l}=X0(t,e,r),u=_We(l),d=Nue(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},_We=({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}},yWe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=mWe(...Q0(t,e,r))}catch(h){return Cue({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;hWe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];jue(c,a,l),que(c,r,l);let d={},f=Rs();c.kill=nce.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=nde(c,r),Sde(c,r),Aue(c,r);let p=SWe({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}},SWe=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 lde({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((T,w)=>Ua(T,e,w)),E=Ua(m,e,"all"),b=EWe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:E,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Ch(b,n,e)},EWe=({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?uE({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Is,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):aC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var RC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,vWe(n,t[n],i)]));return{...t,...r}},vWe=(t,e,r)=>bWe.has(t)&&lr(e)&&lr(r)?{...e,...r}:r,bWe=new Set(["env",...nz]);var cl=(t,e,r,n)=>{let i=(s,a,c)=>cl(s,a,r,c),o=(...s)=>TWe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},TWe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(lr(o))return i(t,RC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=wWe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Sue(a,c,l):vde(a,c,l,i)},wWe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Nse(e)?kse(e,r):[e,...r],[s,a,c]=v0(...o),l=RC(RC(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 bde=({file:t,commandArguments:e})=>wde(t,e),Tde=({file:t,commandArguments:e})=>({...wde(t,e),isSync:!0}),wde=(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]=AWe(t);return{file:r,commandArguments:n}},AWe=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(xWe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},xWe=/ +/g;var Ade=(t,e,r)=>{t.sync=e(RWe,r),t.s=t.sync},xde=({options:t})=>Rde(t),RWe=({options:t})=>({...Rde(t),isSync:!0}),Rde=t=>({options:{...CWe(t),...t}}),CWe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Cde={preferLocal:!0};var Ide=cl(()=>({})),g2t=cl(()=>({isSync:!0})),Pde=cl(bde),_2t=cl(Tde),y2t=cl(zce),S2t=cl(xde,{},Cde,Ade),{sendMessage:E2t,getOneMessage:v2t,getEachMessage:b2t,getCancelSignal:T2t}=xue();var Ode=!1,Nde=()=>{Ode=!0},Os=()=>Ode;var _E=null,kde=t=>(_E&&_E.destroy(),_E=new Uo({totalAllowedTime:t}),_E),Mde=()=>_E;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&&Os())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await l0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Z.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var $de={name:"@netlify/agent-runner-cli",type:"module",version:"1.175.0-run-started.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var NWe=PWe(import.meta.url),kWe=Fa.dirname(NWe),MWe=OWe(import.meta.url),Nh=ae("shell"),Cj=new Set,Dde={preferLocal:!0},Gt=(t,e,r)=>{let[n,i]=$We(e,r),o={...Dde,...i},s=Ide(t,n,o);Ude(s,o),jde(s);let a=r?.idleTimeout;return a&&a>0&&zde(s,a),s},Lde=(t,e)=>{let r={...Dde,...e},n=Pde(t,r);return Ude(n,r),jde(n),e?.idleTimeout&&e.idleTimeout>0&&zde(n,e.idleTimeout),n},$We=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ude=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ns.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ns.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new HS).pipe(Ns.stdout),t.stderr?.pipe(new HS).pipe(Ns.stderr);return}t.stdout?.pipe(Ns.stdout),t.stderr?.pipe(Ns.stderr)},Ij=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ns.kill(-t.pid,e),Nh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Nh.error("Error killing process:",r),!1}},Fde=t=>Ij(t,"SIGKILL"),zde=(t,e)=>{let r=null,n=()=>{Nh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Ij(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nh.log(`Force killing idle process ${t.pid}`),Fde(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)},jde=t=>{Cj.add(t);let e=Mde();if(e){let r=e.onTimesUp(()=>{Nh.log(`Global timer expired, killing process ${t.pid}`),Ij(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nh.log(`Force killing process ${t.pid} after timeout`),Fde(t))},5e3)});t.on("exit",()=>{Cj.delete(t),r()}),t.on("error",()=>{Cj.delete(t),r()})}};function ks(t,e){if(!Ns.env.NETLIFY_LOCAL_MODE)try{let i=MWe.resolve($de.name),o=Fa.dirname(i);for(;o!==Fa.dirname(o);){let s=Fa.dirname(o);if(Fa.basename(s)==="node_modules"){let a=Fa.join(s,".bin",e);if(CC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ns.env.NODE_PATH){let i=Fa.join(Ns.env.NODE_PATH,".bin",e);if(CC.existsSync(i))return i}let r=Fa.join(t,"node_modules",".bin",e);if(CC.existsSync(r))return r;let n=Fa.join(kWe,"..","node_modules",".bin",e);if(CC.existsSync(n))return n}var Bde=ae("repo"),Wde="runner-diffs-",Yde=t=>`${Wde}${t}-`,Kde=async t=>{let e=Hde.tmpdir(),r;try{r=await IC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Wde)&&!n.startsWith(Yde(t))).map(n=>IC.rm(PC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Qn=(t,e={})=>Gt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),OC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Bde.info("Getting runner diffs");let n=await FWe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=jWe(o);await BWe(h,r)}Bde.info("Changes after processing"),await Oj(r);let s=await kj(o,r);if(await Pj(s,r),i=await zWe(r),!i)return{hasChanges:!1,ignored:s};await Qn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await IC.mkdtemp(PC.join(Hde.tmpdir(),Yde(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let E=PC.join(a,g);await Qn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${E}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:T}=await IC.stat(E);return{path:E,size:T}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Gde(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await Vde(d,h)||(f=h)}await Gde(r),Z.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Vde(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},qde=async t=>{let e=DWe("sha256");for await(let r of LWe(t))e.update(r);return e.digest("hex")},Vde=async(t,e)=>t.size===e.size&&await qde(t.path)===await qde(e.path),Gde=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Qn(["reset","--soft","HEAD~1"],{cwd:t})},Pj=async(t=[],e=process.cwd())=>{await Qn(["add",".",...t],{cwd:e})},Oj=async(t=process.cwd())=>{let e=await Qn(["status","-s"],{cwd:t});return String(e.stdout??"")},Zde=/.. (.+)?\.log$/,UWe=[Zde],FWe=async(t=process.cwd())=>{let e=await Oj(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
143
|
+
if (condition) { yield value; }`)};import{Buffer as WHe}from"buffer";import{StringDecoder as YHe}from"string_decoder";var pC=(t,e,r)=>{if(r)return;if(t)return{transform:KHe.bind(void 0,new TextEncoder)};let n=new YHe(e);return{transform:ZHe.bind(void 0,n),final:JHe.bind(void 0,n)}},KHe=function*(t,e){WHe.isBuffer(e)?yield $a(e):typeof e=="string"?yield t.encode(e):yield e},ZHe=function*(t,e){yield Tr(e)?t.write(e):e},JHe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as nue}from"util";var Gz=nue(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),hC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QHe}=e[r];for await(let i of n(t))yield*hC(i,e,r+1)},iue=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XHe(r,Number(e),t)},XHe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*hC(n,r,e+1)},oue=nue(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),QHe=function*(t){yield t};var Hz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},sue=(t,e)=>[...e.flatMap(r=>[...yd(r,t,0)]),...dE(t)],yd=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=t6e}=e[r];for(let i of n(t))yield*yd(i,e,r+1)},dE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*e6e(r,Number(e),t)},e6e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*yd(n,r,e+1)},t6e=function*(t){yield t};var Wz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=cue(t,s,o),l=_d(e),u=_d(r),d=l?Gz.bind(void 0,hC,a):Hz.bind(void 0,yd),f=l||u?Gz.bind(void 0,iue,a):Hz.bind(void 0,dE),p=l||u?oue.bind(void 0,a):void 0;return{stream:new r6e({writableObjectMode:n,writableHighWaterMark:aue(n),readableObjectMode:i,readableHighWaterMark:aue(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},mC=(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=cue(s,r,a);t=sue(c,t)}return t},cue=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:eue(n,a)},pC(r,s,n),fC(r,o,n,c),{transform:t,final:e},{transform:tue(i,a)},Qle({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var lue=(t,e)=>{for(let r of n6e(t))i6e(t,r,e)},n6e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),i6e=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${al[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>o6e(a,n));r.input=tE(s)},o6e=(t,e)=>{let r=mC(t,e,"utf8",!0);return s6e(r),tE(r)},s6e=t=>{let e=t.find(r=>typeof r!="string"&&!Tr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as u6e,appendFileSync as d6e}from"fs";var gC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&yh(r,n)&&!vi.has(e)&&a6e(n)&&(t.some(({type:i,value:o})=>i==="native"&&c6e.has(o))||t.every(({type:i})=>Zi.has(i))),a6e=t=>t===1||t===2,c6e=new Set(["pipe","overlapped"]),uue=async(t,e,r,n)=>{for await(let i of t)l6e(e)||fue(i,r,n)},due=(t,e,r)=>{for(let n of t)fue(n,e,r)},l6e=t=>t._readableState.pipes.length>0,fue=(t,e,r)=>{let n=P0(t);xs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var pue=({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)=>f6e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},f6e=({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=hle(t,o,d),p=$a(f),{stdioItems:h,objectMode:m}=e[r],g=p6e([p],h,c,n),{serializedResult:_,finalResult:E=_}=h6e({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});m6e({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let b=a[r]?E:void 0;try{return n.error===void 0&&g6e(_,h,i),b}catch(T){return n.error=T,b}},p6e=(t,e,r,n)=>{try{return mC(t,e,r,!1)}catch(i){return n.error=i,t}},h6e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:tE(t)};let s=Cse(t,r);return n[o]?{serializedResult:s,finalResult:Vz(s,!i[o],e)}:{serializedResult:s}},m6e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!gC({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=Vz(t,!1,s);try{due(a,e,n)}catch(c){r.error??=c}},g6e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>uC.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?d6e(n,t):(r.add(o),u6e(n,t))}};var hue=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ua(e,r,"all")]:Array.isArray(e)?[Ua(t,r,"all"),...e]:Tr(t)&&Tr(e)?QF([t,e]):`${t}${e}`};import{once as Yz}from"events";var mue=async(t,e)=>{let[r,n]=await _6e(t);return e.isForcefullyTerminated??=!1,[r,n]},_6e=async t=>{let[e,r]=await Promise.allSettled([Yz(t,"spawn"),Yz(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?gue(t):r.value},gue=async t=>{try{return await Yz(t,"exit")}catch{return gue(t)}},_ue=async t=>{let[e,r]=await t;if(!y6e(e,r)&&Kz(e,r))throw new $o;return[e,r]},y6e=(t,e)=>t===void 0&&e===void 0,Kz=(t,e)=>t!==0||e!==null;var yue=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=S6e(t,e,r),s=o?.code==="ETIMEDOUT",a=ple(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},S6e=(t,e,r)=>t!==void 0?t:Kz(e,r)?new $o:void 0;var Sue=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=v6e(t,e,r),d=w6e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Ch(d,c,l)},v6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=N0(t,e,r),a=b6e(r),{file:c,commandArguments:l,options:u}=X0(t,e,a);T6e(u);let d=Kle(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},b6e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,T6e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&_C("ipcInput"),t&&_C("ipc: true"),r&&_C("detached: true"),n&&_C("cancelSignal")},_C=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},w6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=A6e({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}=yue(c,r),{output:h,error:m=l}=pue({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((E,b)=>Ua(E,r,b)),_=Ua(hue(h,r),r,"all");return R6e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},A6e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{lue(o,r);let a=x6e(r);return E6e(...Q0(t,e,a))}catch(a){return Rh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},x6e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:sC(e)}),R6e=({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?aC({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):uE({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as hWe}from"events";import{spawn as mWe}from"child_process";import wue from"process";import{once as Zz,on as C6e}from"events";var Eue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(vh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:H0(t)}),I6e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),I6e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{B0(e,i);let o=sl(t,e,r),s=new AbortController;try{return await Promise.race([P6e(o,n,s),O6e(o,r,s),N6e(o,r,s)])}catch(a){throw bh(t),a}finally{s.abort(),q0(e,i)}},P6e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await Zz(t,"message",{signal:r});return n}for await(let[n]of C6e(t,"message",{signal:r}))if(e(n))return n},O6e=async(t,e,{signal:r})=>{await Zz(t,"disconnect",{signal:r}),sce(e)},N6e=async(t,e,{signal:r})=>{let[n]=await Zz(t,"strict:error",{signal:r});throw F0(n,e)};import{once as bue,on as k6e}from"events";var Tue=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>Jz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),Jz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{vh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:H0(t)}),B0(e,o);let s=sl(t,e,r),a=new AbortController,c={};return M6e(t,s,a),$6e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),D6e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},M6e=async(t,e,r)=>{try{await bue(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},$6e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await bue(t,"strict:error",{signal:r.signal});n.error=F0(i,e),r.abort()}catch{}},D6e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of k6e(r,"message",{signal:o.signal}))vue(s),yield c}catch{vue(s)}finally{o.abort(),q0(e,a),n||bh(t),i&&await t}},vue=({error:t})=>{if(t)throw t};var Aue=(t,{ipc:e})=>{Object.assign(t,Rue(t,!1,e))},xue=()=>{let t=wue,e=!0,r=wue.channel!==void 0;return{...Rue(t,e,r),getCancelSignal:kce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Rue=(t,e,r)=>({sendMessage:Z0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Eue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Tue.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as L6e}from"child_process";import{PassThrough as U6e,Readable as F6e,Writable as z6e,Duplex as j6e}from"stream";var Cue=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{jz(n);let a=new L6e;B6e(a,n),Object.assign(a,{readable:q6e,writable:V6e,duplex:G6e});let c=Rh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=H6e(c,s,i);return{subprocess:a,promise:l}},B6e=(t,e)=>{let r=fE(),n=fE(),i=fE(),o=Array.from({length:e.length-3},fE),s=fE(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},fE=()=>{let t=new U6e;return t.end(),t},q6e=()=>new F6e({read(){}}),V6e=()=>new z6e({write(){}}),G6e=()=>new j6e({read(){},write(){}}),H6e=async(t,e,r)=>Ch(t,e,r);import{createReadStream as Iue,createWriteStream as Pue}from"fs";import{Buffer as W6e}from"buffer";import{Readable as pE,Writable as Y6e,Duplex as K6e}from"stream";var Nue=(t,e)=>dC(Z6e,t,e,!1),hE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${al[t]}.`)},Oue={fileNumber:hE,generator:Wz,asyncGenerator:Wz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:K6e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Z6e={input:{...Oue,fileUrl:({value:t})=>({stream:Iue(t)}),filePath:({value:{file:t}})=>({stream:Iue(t)}),webStream:({value:t})=>({stream:pE.fromWeb(t)}),iterable:({value:t})=>({stream:pE.from(t)}),asyncIterable:({value:t})=>({stream:pE.from(t)}),string:({value:t})=>({stream:pE.from(t)}),uint8Array:({value:t})=>({stream:pE.from(W6e.from(t))})},output:{...Oue,fileUrl:({value:t})=>({stream:Pue(t)}),filePath:({value:{file:t,append:e}})=>({stream:Pue(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Y6e.fromWeb(t)}),iterable:hE,asyncIterable:hE,string:hE,uint8Array:hE}};import{on as J6e,once as kue}from"events";import{PassThrough as X6e,getDefaultHighWaterMark as Q6e}from"stream";import{finished as Due}from"stream/promises";function Sd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Qz(i);let e=t.some(({readableObjectMode:i})=>i),r=e3e(t,e),n=new Xz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var e3e=(t,e)=>{if(t.length===0)return Q6e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},Xz=class extends X6e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(Qz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=t3e(this,this.#e,this.#o);let r=i3e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(Qz(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},t3e=async(t,e,r)=>{yC(t,Mue);let n=new AbortController;try{await Promise.race([r3e(t,n),n3e(t,e,r,n)])}finally{n.abort(),yC(t,-Mue)}},r3e=async(t,{signal:e})=>{try{await Due(t,{signal:e,cleanup:!0})}catch(r){throw Lue(t,r),r}},n3e=async(t,e,r,{signal:n})=>{for await(let[i]of J6e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},Qz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},i3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{yC(t,$ue);let a=new AbortController;try{await Promise.race([o3e(o,e,a),s3e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),a3e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),yC(t,-$ue)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?ej(t):c3e(t))},o3e=async(t,e,{signal:r})=>{try{await t,r.aborted||ej(e)}catch(n){r.aborted||Lue(e,n)}},s3e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Due(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Uue(s)?i.add(e):Fue(t,s)}},a3e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await kue(t,i,{signal:o}),!t.readable)return kue(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},c3e=t=>{t.writable&&t.end()},Lue=(t,e)=>{Uue(e)?ej(t):Fue(t,e)},Uue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",ej=t=>{(t.readable||t.writable)&&t.destroy()},Fue=(t,e)=>{t.destroyed||(t.once("error",l3e),t.destroy(e))},l3e=()=>{},yC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Mue=2,$ue=1;import{finished as zue}from"stream/promises";var Ph=(t,e)=>{t.pipe(e),u3e(t,e),d3e(t,e)},u3e=async(t,e)=>{if(!(Mo(t)||Mo(e))){try{await zue(t,{cleanup:!0,readable:!0,writable:!1})}catch{}tj(e)}},tj=t=>{t.writable&&t.end()},d3e=async(t,e)=>{if(!(Mo(t)||Mo(e))){try{await zue(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rj(t)}},rj=t=>{t.readable&&t.destroy()};var jue=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Zi.has(c)))f3e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zi.has(c)))h3e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Sd(o);Ph(s,i)}},f3e=(t,e,r,n)=>{r==="output"?Ph(t.stdio[n],e):Ph(e,t.stdio[n]);let i=p3e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},p3e=["stdin","stdout","stderr"],h3e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;m3e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},m3e=(t,{signal:e})=>{Mo(t)&&md(t,g3e,e)},g3e=2;import{addAbortListener as S3e}from"events";var Ed=[];Ed.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ed.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ed.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var SC=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",nj=Symbol.for("signal-exit emitter"),ij=globalThis,_3e=Object.defineProperty.bind(Object),oj=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ij[nj])return ij[nj];_3e(ij,nj,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},EC=class{},y3e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),sj=class extends EC{onExit(){return()=>{}}load(){}unload(){}},aj=class extends EC{#e=cj.platform==="win32"?"SIGINT":"SIGHUP";#r=new oj;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ed)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(!SC(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 Ed)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,Ed.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 SC(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"&&SC(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},cj=globalThis.process,{onExit:Bue,load:xzt,unload:Rzt}=y3e(SC(cj)?new aj(cj):new sj);var que=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Bue(()=>{t.kill()});S3e(n,()=>{i()})};var Gue=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=O0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=E3e(r,n,i),{sourceStream:d,sourceError:f}=b3e(t,l),{options:p,fileDescriptors:h}=Cs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},E3e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=v3e(t,e,...r),a=j0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},v3e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Vue,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||JF(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=v0(r,...n);return{destination:e(Vue)(i,o,s),pipeOptions:s}}if(Cs.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Vue=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),b3e=(t,e)=>{try{return{sourceStream:Th(t,e)}}catch(r){return{sourceError:r}}};var Wue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=T3e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw lj({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},T3e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return rj(t),n;if(e!==void 0)return tj(r),e},lj=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Rh({error:t,command:Hue,escapedCommand:Hue,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Hue="source.pipe(destination)";var Yue=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 w3e}from"stream/promises";var Kue=(t,e,r)=>{let n=vC.has(e)?x3e(t,e):A3e(t,e);return md(t,C3e,r.signal),md(e,I3e,r.signal),R3e(e),n},A3e=(t,e)=>{let r=Sd([t]);return Ph(r,e),vC.set(e,r),r},x3e=(t,e)=>{let r=vC.get(e);return r.add(t),r},R3e=async t=>{try{await w3e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}vC.delete(t)},vC=new WeakMap,C3e=2,I3e=1;import{aborted as P3e}from"util";var Zue=(t,e)=>t===void 0?[]:[O3e(t,e)],O3e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await P3e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw lj({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var bC=(t,...e)=>{if(lr(e[0]))return bC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Gue(t,...e),i=N3e({...n,destination:r});return i.pipe=bC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},N3e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=k3e(t,i);Wue({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Kue(e,o,d);return await Promise.race([Yue(u),...Zue(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},k3e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as z3e}from"timers/promises";import{on as M3e}from"events";import{getDefaultHighWaterMark as $3e}from"stream";var TC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return D3e(e,s),Xue({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},D3e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},uj=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;L3e(e,s,t);let a=t.readableObjectMode&&!o;return Xue({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},L3e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Xue=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=M3e(t,"data",{signal:e.signal,highWaterMark:Jue,highWatermark:Jue});return U3e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},dj=$3e(!0),Jue=dj,U3e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=F3e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*yd(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*dE(a)}},F3e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[pC(t,r,!e),fC(t,i,!n,{})].filter(Boolean);var Que=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=j3e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([B3e(t),d]);return}let f=Bz(c,r),p=uj({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([q3e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},j3e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!gC({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=uj({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await uue(a,t,r,o)},B3e=async t=>{await z3e(),t.readableFlowing===null&&t.resume()},q3e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await nC(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await iC(r,{maxBuffer:o})):await xh(r,{maxBuffer:o})}catch(a){return ede(ule({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},fj=async t=>{try{return await t}catch(e){return ede(e)}},ede=({bufferedData:t})=>xse(t)?new Uint8Array(t):t;import{finished as V3e}from"stream/promises";var mE=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=G3e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],V3e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Y3e(a,e,r,n)}finally{s.abort()}},G3e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&H3e(t,r,n),n},H3e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{W3e(e,r),n.call(t,...i)}},W3e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Y3e=(t,e,r,n)=>{if(!K3e(t,e,r,n))throw t},K3e=(t,e,r,n=!0)=>r.propagating?tde(t)||wC(t):(r.propagating=!0,pj(r,e)===n?tde(t):wC(t)),pj=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",wC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",tde=t=>t?.code==="EPIPE";var rde=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>hj({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),hj=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=mE(t,e,l);if(pj(l,e)){await u;return}let[d]=await Promise.all([Que({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 nde=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Sd([t,e].filter(Boolean)):void 0,ide=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>hj({...Z3e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:J3e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Z3e=({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}},J3e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as X3e}from"events";var ode=t=>yh(t,"ipc"),sde=(t,e)=>{let r=P0(t);xs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ade=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=ode(o),a=Da(e,"ipc"),c=Da(r,"ipc");for await(let l of Jz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(dle(t,i,c),i.push(l)),s&&sde(l,o);return i},cde=async(t,e)=>(await Promise.allSettled([t]),e);var lde=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let E=mue(t,f),b={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},T=rde({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),w=ide({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),x=[],P=ade({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),C=Q3e(m,t,b),M=eWe(h,b);try{return await Promise.race([Promise.all([{},_ue(E),Promise.all(T),w,P,qce(t,d),...C,...M]),g,tWe(t,_),...Uce(t,o,f,_),...oce({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Dce({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},E,Promise.all(T.map(v=>fj(v))),fj(w),cde(P,x),Promise.allSettled(C),Promise.allSettled(M)])}},Q3e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:mE(n,i,r)),eWe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Lo(o,{checkOpen:!1})&&!Mo(o)).map(({type:i,value:o,stream:s=o})=>mE(s,n,e,{isSameDirection:Zi.has(i),stopOnExit:i==="native"}))),tWe=async(t,{signal:e})=>{let[r]=await X3e(t,"error",{signal:e});throw r};var ude=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),gE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Rs();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Oh=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 rWe}from"stream";import{callbackify as nWe}from"util";import{finished as dde}from"stream/promises";var mj=async t=>{if(t!==void 0)try{await gj(t)}catch{}},fde=async t=>{if(t!==void 0)try{await _j(t)}catch{}},gj=async t=>{await dde(t,{cleanup:!0,readable:!1,writable:!0})},_j=async t=>{await dde(t,{cleanup:!0,readable:!0,writable:!1})},AC=async(t,e)=>{if(await t,e)throw e},xC=(t,e,r)=>{r&&!wC(r)?t.destroy(r):e&&t.destroy()};var pde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||vi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=yj(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Sj(a,s),{read:f,onStdoutDataDone:p}=Ej({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new rWe({read:f,destroy:nWe(bj.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return vj({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},yj=(t,e,r)=>{let n=Th(t,e),i=gE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Sj=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:dj},Ej=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Rs(),s=TC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){iWe(this,s,o)},onStdoutDataDone:o}},iWe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},vj=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await _j(t),await n,await mj(i),await e,r.readable&&r.push(null)}catch(o){await mj(i),hde(r,o)}},bj=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Oh(r,e)&&(hde(t,n),await AC(e,n))},hde=(t,e)=>{xC(t,t.readable,e)};import{Writable as oWe}from"stream";import{callbackify as mde}from"util";var gde=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Tj(t,r,e),s=new oWe({...wj(n,t,i),destroy:mde(xj.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Aj(n,s),s},Tj=(t,e,r)=>{let n=j0(t,e),i=gE(r,n,"writableFinal"),o=gE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},wj=(t,e,r)=>({write:sWe.bind(void 0,t),final:mde(aWe.bind(void 0,t,e,r))}),sWe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},aWe=async(t,e,r)=>{await Oh(r,e)&&(t.writable&&t.end(),await e)},Aj=async(t,e,r)=>{try{await gj(t),e.writable&&e.end()}catch(n){await fde(r),_de(e,n)}},xj=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Oh(r,e),await Oh(n,e)&&(_de(t,i),await AC(e,i))},_de=(t,e)=>{xC(t,t.writable,e)};import{Duplex as cWe}from"stream";import{callbackify as lWe}from"util";var yde=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||vi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=yj(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Tj(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Sj(c,a),{read:g,onStdoutDataDone:_}=Ej({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),E=new cWe({read:g,...wj(u,t,d),destroy:lWe(uWe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return vj({subprocessStdout:c,onStdoutDataDone:_,readable:E,subprocess:t,subprocessStdin:u}),Aj(u,E,c),E},uWe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([bj({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),xj({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Rj=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||vi.has(e),s=Th(t,r),a=TC({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return dWe(a,s,t)},dWe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Sde=(t,{encoding:e})=>{let r=ude();t.readable=pde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=gde.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=yde.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Rj.bind(void 0,t,e),t[Symbol.asyncIterator]=Rj.bind(void 0,t,e,{})};var Ede=(t,e)=>{for(let[r,n]of pWe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},fWe=(async()=>{})().constructor.prototype,pWe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(fWe,t)]);var vde=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=gWe(t,e,r),{subprocess:f,promise:p}=yWe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=bC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Ede(f,p),Cs.set(f,{options:u,fileDescriptors:d}),f},gWe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=N0(t,e,r),{file:a,commandArguments:c,options:l}=X0(t,e,r),u=_We(l),d=Nue(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},_We=({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}},yWe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=mWe(...Q0(t,e,r))}catch(h){return Cue({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;hWe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];jue(c,a,l),que(c,r,l);let d={},f=Rs();c.kill=nce.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=nde(c,r),Sde(c,r),Aue(c,r);let p=SWe({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}},SWe=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 lde({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((T,w)=>Ua(T,e,w)),E=Ua(m,e,"all"),b=EWe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:E,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Ch(b,n,e)},EWe=({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?uE({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Is,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):aC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var RC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,vWe(n,t[n],i)]));return{...t,...r}},vWe=(t,e,r)=>bWe.has(t)&&lr(e)&&lr(r)?{...e,...r}:r,bWe=new Set(["env",...nz]);var cl=(t,e,r,n)=>{let i=(s,a,c)=>cl(s,a,r,c),o=(...s)=>TWe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},TWe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(lr(o))return i(t,RC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=wWe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Sue(a,c,l):vde(a,c,l,i)},wWe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Nse(e)?kse(e,r):[e,...r],[s,a,c]=v0(...o),l=RC(RC(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 bde=({file:t,commandArguments:e})=>wde(t,e),Tde=({file:t,commandArguments:e})=>({...wde(t,e),isSync:!0}),wde=(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]=AWe(t);return{file:r,commandArguments:n}},AWe=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(xWe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},xWe=/ +/g;var Ade=(t,e,r)=>{t.sync=e(RWe,r),t.s=t.sync},xde=({options:t})=>Rde(t),RWe=({options:t})=>({...Rde(t),isSync:!0}),Rde=t=>({options:{...CWe(t),...t}}),CWe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Cde={preferLocal:!0};var Ide=cl(()=>({})),g2t=cl(()=>({isSync:!0})),Pde=cl(bde),_2t=cl(Tde),y2t=cl(zce),S2t=cl(xde,{},Cde,Ade),{sendMessage:E2t,getOneMessage:v2t,getEachMessage:b2t,getCancelSignal:T2t}=xue();var Ode=!1,Nde=()=>{Ode=!0},Os=()=>Ode;var _E=null,kde=t=>(_E&&_E.destroy(),_E=new Uo({totalAllowedTime:t}),_E),Mde=()=>_E;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&&Os())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await l0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Z.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var $de={name:"@netlify/agent-runner-cli",type:"module",version:"1.175.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var NWe=PWe(import.meta.url),kWe=Fa.dirname(NWe),MWe=OWe(import.meta.url),Nh=ae("shell"),Cj=new Set,Dde={preferLocal:!0},Gt=(t,e,r)=>{let[n,i]=$We(e,r),o={...Dde,...i},s=Ide(t,n,o);Ude(s,o),jde(s);let a=r?.idleTimeout;return a&&a>0&&zde(s,a),s},Lde=(t,e)=>{let r={...Dde,...e},n=Pde(t,r);return Ude(n,r),jde(n),e?.idleTimeout&&e.idleTimeout>0&&zde(n,e.idleTimeout),n},$We=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ude=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ns.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ns.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new HS).pipe(Ns.stdout),t.stderr?.pipe(new HS).pipe(Ns.stderr);return}t.stdout?.pipe(Ns.stdout),t.stderr?.pipe(Ns.stderr)},Ij=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ns.kill(-t.pid,e),Nh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Nh.error("Error killing process:",r),!1}},Fde=t=>Ij(t,"SIGKILL"),zde=(t,e)=>{let r=null,n=()=>{Nh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Ij(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nh.log(`Force killing idle process ${t.pid}`),Fde(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)},jde=t=>{Cj.add(t);let e=Mde();if(e){let r=e.onTimesUp(()=>{Nh.log(`Global timer expired, killing process ${t.pid}`),Ij(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nh.log(`Force killing process ${t.pid} after timeout`),Fde(t))},5e3)});t.on("exit",()=>{Cj.delete(t),r()}),t.on("error",()=>{Cj.delete(t),r()})}};function ks(t,e){if(!Ns.env.NETLIFY_LOCAL_MODE)try{let i=MWe.resolve($de.name),o=Fa.dirname(i);for(;o!==Fa.dirname(o);){let s=Fa.dirname(o);if(Fa.basename(s)==="node_modules"){let a=Fa.join(s,".bin",e);if(CC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ns.env.NODE_PATH){let i=Fa.join(Ns.env.NODE_PATH,".bin",e);if(CC.existsSync(i))return i}let r=Fa.join(t,"node_modules",".bin",e);if(CC.existsSync(r))return r;let n=Fa.join(kWe,"..","node_modules",".bin",e);if(CC.existsSync(n))return n}var Bde=ae("repo"),Wde="runner-diffs-",Yde=t=>`${Wde}${t}-`,Kde=async t=>{let e=Hde.tmpdir(),r;try{r=await IC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Wde)&&!n.startsWith(Yde(t))).map(n=>IC.rm(PC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Qn=(t,e={})=>Gt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),OC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Bde.info("Getting runner diffs");let n=await FWe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=jWe(o);await BWe(h,r)}Bde.info("Changes after processing"),await Oj(r);let s=await kj(o,r);if(await Pj(s,r),i=await zWe(r),!i)return{hasChanges:!1,ignored:s};await Qn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await IC.mkdtemp(PC.join(Hde.tmpdir(),Yde(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let E=PC.join(a,g);await Qn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${E}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:T}=await IC.stat(E);return{path:E,size:T}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Gde(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await Vde(d,h)||(f=h)}await Gde(r),Z.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Vde(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},qde=async t=>{let e=DWe("sha256");for await(let r of LWe(t))e.update(r);return e.digest("hex")},Vde=async(t,e)=>t.size===e.size&&await qde(t.path)===await qde(e.path),Gde=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Qn(["reset","--soft","HEAD~1"],{cwd:t})},Pj=async(t=[],e=process.cwd())=>{await Qn(["add",".",...t],{cwd:e})},Oj=async(t=process.cwd())=>{let e=await Qn(["status","-s"],{cwd:t});return String(e.stdout??"")},Zde=/.. (.+)?\.log$/,UWe=[Zde],FWe=async(t=process.cwd())=>{let e=await Oj(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
144
144
|
`).filter(i=>UWe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},zWe=async(t=process.cwd())=>{try{return await Qn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},Nj=async(t=process.cwd())=>{let{stdout:e}=await Qn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Jde=async(t=process.cwd())=>{let{stdout:e}=await Qn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},kj=async(t,e=process.cwd())=>{t||=await Oj(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
145
145
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${PC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Zde)?.[1];o&&n.push(`:!${o}.log`)}),n},Xde=async(t=process.cwd())=>{await Qn(["reset","--hard","HEAD"],{cwd:t})},Qde=async(t=process.cwd())=>{let e=await Qn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
146
146
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},jWe=t=>{let e=t.split(`
|
package/package.json
CHANGED