@netlify/agent-runner-cli 1.145.0-ex-2517.6 → 1.145.0-ex-2517.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin-local.js CHANGED
@@ -99,7 +99,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
99
99
  `,LF:`
100
100
  `,concatBytes:PD},BNe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},jNe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:BNe};import{Buffer as zNe}from"buffer";var i7=(t,e)=>t?void 0:GNe.bind(void 0,e),GNe=function*(t,e){if(typeof e!="string"&&!jt(e)&&!zNe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},o7=(t,e)=>t?qNe.bind(void 0,e):VNe.bind(void 0,e),qNe=function*(t,e){s7(t,e),yield e},VNe=function*(t,e){if(s7(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},s7=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
101
101
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
102
- if (condition) { yield value; }`)};import{Buffer as HNe}from"buffer";import{StringDecoder as WNe}from"string_decoder";var Cx=(t,e,r)=>{if(r)return;if(t)return{transform:YNe.bind(void 0,new TextEncoder)};let n=new WNe(e);return{transform:KNe.bind(void 0,n),final:ZNe.bind(void 0,n)}},YNe=function*(t,e){HNe.isBuffer(e)?yield ms(e):typeof e=="string"?yield t.encode(e):yield e},KNe=function*(t,e){yield jt(e)?t.write(e):e},ZNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as a7}from"util";var ND=a7(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Px=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=XNe}=e[r];for await(let i of n(t))yield*Px(i,e,r+1)},c7=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*JNe(r,Number(e),t)},JNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Px(n,r,e+1)},l7=a7(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),XNe=function*(t){yield t};var kD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},u7=(t,e)=>[...e.flatMap(r=>[...Rl(r,t,0)]),...l_(t)],Rl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=eke}=e[r];for(let i of n(t))yield*Rl(i,e,r+1)},l_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*QNe(r,Number(e),t)},QNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Rl(n,r,e+1)},eke=function*(t){yield t};var MD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=f7(t,s,o),l=Al(e),u=Al(r),d=l?ND.bind(void 0,Px,a):kD.bind(void 0,Rl),f=l||u?ND.bind(void 0,c7,a):kD.bind(void 0,l_),p=l||u?l7.bind(void 0,a):void 0;return{stream:new tke({writableObjectMode:n,writableHighWaterMark:d7(n),readableObjectMode:i,readableHighWaterMark:d7(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Ox=(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=f7(s,r,a);t=u7(c,t)}return t},f7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:i7(n,a)},Cx(r,s,n),Ix(r,o,n,c),{transform:t,final:e},{transform:o7(i,a)},n7({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var p7=(t,e)=>{for(let r of rke(t))nke(t,r,e)},rke=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),nke=(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 ${ka[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>ike(a,n));r.input=Qg(s)},ike=(t,e)=>{let r=Ox(t,e,"utf8",!0);return oke(r),Qg(r)},oke=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 lke,appendFileSync as uke}from"fs";var Nx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Gd(r,n)&&!Sn.has(e)&&ske(n)&&(t.some(({type:i,value:o})=>i==="native"&&ake.has(o))||t.every(({type:i})=>Yn.has(i))),ske=t=>t===1||t===2,ake=new Set(["pipe","overlapped"]),h7=async(t,e,r,n)=>{for await(let i of t)cke(e)||g7(i,r,n)},m7=(t,e,r)=>{for(let n of t)g7(n,e,r)},cke=t=>t._readableState.pipes.length>0,g7=(t,e,r)=>{let n=HT(t);po({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var _7=({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)=>dke({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},dke=({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=yQ(t,o,d),p=ms(f),{stdioItems:h,objectMode:m}=e[r],S=fke([p],h,c,n),{serializedResult:E,finalResult:T=E}=pke({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});hke({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?T:void 0;try{return n.error===void 0&&mke(E,h,i),x}catch(_){return n.error=_,x}},fke=(t,e,r,n)=>{try{return Ox(t,e,r,!1)}catch(i){return n.error=i,t}},pke=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Qg(t)};let s=N9(t,r);return n[o]?{serializedResult:s,finalResult:OD(s,!i[o],e)}:{serializedResult:s}},hke=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Nx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=OD(t,!1,s);try{m7(a,e,n)}catch(c){r.error??=c}},mke=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Ax.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?uke(n,t):(r.add(o),lke(n,t))}};var y7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ys(e,r,"all")]:Array.isArray(e)?[ys(t,r,"all"),...e]:jt(t)&&jt(e)?BM([t,e]):`${t}${e}`};import{once as DD}from"events";var S7=async(t,e)=>{let[r,n]=await gke(t);return e.isForcefullyTerminated??=!1,[r,n]},gke=async t=>{let[e,r]=await Promise.allSettled([DD(t,"spawn"),DD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?E7(t):r.value},E7=async t=>{try{return await DD(t,"exit")}catch{return E7(t)}},v7=async t=>{let[e,r]=await t;if(!_ke(e,r)&&LD(e,r))throw new Ai;return[e,r]},_ke=(t,e)=>t===void 0&&e===void 0,LD=(t,e)=>t!==0||e!==null;var b7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=yke(t,e,r),s=o?.code==="ETIMEDOUT",a=_Q(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},yke=(t,e,r)=>t!==void 0?t:LD(e,r)?new Ai:void 0;var T7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Eke(t,e,r),d=Tke({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Qd(d,c,l)},Eke=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=YT(t,e,r),a=vke(r),{file:c,commandArguments:l,options:u}=hx(t,e,a);bke(u);let d=QQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},vke=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,bke=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&kx("ipcInput"),t&&kx("ipc: true"),r&&kx("detached: true"),n&&kx("cancelSignal")},kx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Tke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=xke({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}=b7(c,r),{output:h,error:m=l}=_7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((T,x)=>ys(T,r,x)),E=ys(y7(h,r),r,"all");return Ake({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},xke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{p7(o,r);let a=wke(r);return Ske(...mx(t,e,a))}catch(a){return Xd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wke=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:bx(e)}),Ake=({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?Tx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):c_({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 pDe}from"events";import{spawn as hDe}from"child_process";import I7 from"process";import{once as $D,on as Rke}from"events";var x7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Hd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:cx(t)}),Ike({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Ike=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ix(e,i);let o=Na(t,e,r),s=new AbortController;try{return await Promise.race([Cke(o,n,s),Pke(o,r,s),Oke(o,r,s)])}catch(a){throw Wd(t),a}finally{s.abort(),ox(e,i)}},Cke=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await $D(t,"message",{signal:r});return n}for await(let[n]of Rke(t,"message",{signal:r}))if(e(n))return n},Pke=async(t,e,{signal:r})=>{await $D(t,"disconnect",{signal:r}),uX(e)},Oke=async(t,e,{signal:r})=>{let[n]=await $D(t,"strict:error",{signal:r});throw tx(n,e)};import{once as A7,on as Nke}from"events";var R7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>UD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),UD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Hd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:cx(t)}),ix(e,o);let s=Na(t,e,r),a=new AbortController,c={};return kke(t,s,a),Mke({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Dke({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},kke=async(t,e,r)=>{try{await A7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Mke=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await A7(t,"strict:error",{signal:r.signal});n.error=tx(i,e),r.abort()}catch{}},Dke=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Nke(r,"message",{signal:o.signal}))w7(s),yield c}catch{w7(s)}finally{o.abort(),ox(e,a),n||Wd(t),i&&await t}},w7=({error:t})=>{if(t)throw t};var C7=(t,{ipc:e})=>{Object.assign(t,O7(t,!1,e))},P7=()=>{let t=I7,e=!0,r=I7.channel!==void 0;return{...O7(t,e,r),getCancelSignal:$X.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},O7=(t,e,r)=>({sendMessage:fx.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:x7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:R7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Lke}from"child_process";import{PassThrough as $ke,Readable as Uke,Writable as Fke,Duplex as Bke}from"stream";var N7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ID(n);let a=new Lke;jke(a,n),Object.assign(a,{readable:zke,writable:Gke,duplex:qke});let c=Xd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=Vke(c,s,i);return{subprocess:a,promise:l}},jke=(t,e)=>{let r=u_(),n=u_(),i=u_(),o=Array.from({length:e.length-3},u_),s=u_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},u_=()=>{let t=new $ke;return t.end(),t},zke=()=>new Uke({read(){}}),Gke=()=>new Fke({write(){}}),qke=()=>new Bke({read(){},write(){}}),Vke=async(t,e,r)=>Qd(t,e,r);import{createReadStream as k7,createWriteStream as M7}from"fs";import{Buffer as Hke}from"buffer";import{Readable as d_,Writable as Wke,Duplex as Yke}from"stream";var L7=(t,e)=>Rx(Kke,t,e,!1),f_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ka[t]}.`)},D7={fileNumber:f_,generator:MD,asyncGenerator:MD,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Yke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Kke={input:{...D7,fileUrl:({value:t})=>({stream:k7(t)}),filePath:({value:{file:t}})=>({stream:k7(t)}),webStream:({value:t})=>({stream:d_.fromWeb(t)}),iterable:({value:t})=>({stream:d_.from(t)}),asyncIterable:({value:t})=>({stream:d_.from(t)}),string:({value:t})=>({stream:d_.from(t)}),uint8Array:({value:t})=>({stream:d_.from(Hke.from(t))})},output:{...D7,fileUrl:({value:t})=>({stream:M7(t)}),filePath:({value:{file:t,append:e}})=>({stream:M7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Wke.fromWeb(t)}),iterable:f_,asyncIterable:f_,string:f_,uint8Array:f_}};import{on as Zke,once as $7}from"events";import{PassThrough as Jke,getDefaultHighWaterMark as Xke}from"stream";import{finished as B7}from"stream/promises";function Il(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)BD(i);let e=t.some(({readableObjectMode:i})=>i),r=Qke(t,e),n=new FD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Qke=(t,e)=>{if(t.length===0)return Xke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},FD=class extends Jke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(BD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=eMe(this,this.#e,this.#o);let r=nMe({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(BD(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)}},eMe=async(t,e,r)=>{Mx(t,U7);let n=new AbortController;try{await Promise.race([tMe(t,n),rMe(t,e,r,n)])}finally{n.abort(),Mx(t,-U7)}},tMe=async(t,{signal:e})=>{try{await B7(t,{signal:e,cleanup:!0})}catch(r){throw j7(t,r),r}},rMe=async(t,e,r,{signal:n})=>{for await(let[i]of Zke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},BD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},nMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Mx(t,F7);let a=new AbortController;try{await Promise.race([iMe(o,e,a),oMe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),sMe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Mx(t,-F7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?jD(t):aMe(t))},iMe=async(t,e,{signal:r})=>{try{await t,r.aborted||jD(e)}catch(n){r.aborted||j7(e,n)}},oMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await B7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;z7(s)?i.add(e):G7(t,s)}},sMe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await $7(t,i,{signal:o}),!t.readable)return $7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},aMe=t=>{t.writable&&t.end()},j7=(t,e)=>{z7(e)?jD(t):G7(t,e)},z7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",jD=t=>{(t.readable||t.writable)&&t.destroy()},G7=(t,e)=>{t.destroyed||(t.once("error",cMe),t.destroy(e))},cMe=()=>{},Mx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},U7=2,F7=1;import{finished as q7}from"stream/promises";var tf=(t,e)=>{t.pipe(e),lMe(t,e),uMe(t,e)},lMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await q7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}zD(e)}},zD=t=>{t.writable&&t.end()},uMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await q7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}GD(t)}},GD=t=>{t.readable&&t.destroy()};var V7=(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})=>Yn.has(c)))dMe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))pMe({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]:Il(o);tf(s,i)}},dMe=(t,e,r,n)=>{r==="output"?tf(t.stdio[n],e):tf(e,t.stdio[n]);let i=fMe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},fMe=["stdin","stdout","stderr"],pMe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;hMe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},hMe=(t,{signal:e})=>{wi(t)&&xl(t,mMe,e)},mMe=2;import{addAbortListener as yMe}from"events";var Cl=[];Cl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Cl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Cl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Dx=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",qD=Symbol.for("signal-exit emitter"),VD=globalThis,gMe=Object.defineProperty.bind(Object),HD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(VD[qD])return VD[qD];gMe(VD,qD,{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}},Lx=class{},_Me=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),WD=class extends Lx{onExit(){return()=>{}}load(){}unload(){}},YD=class extends Lx{#e=KD.platform==="win32"?"SIGINT":"SIGHUP";#r=new HD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Cl)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(!Dx(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 Cl)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,Cl.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 Dx(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"&&Dx(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)}},KD=globalThis.process,{onExit:H7,load:Qpt,unload:eht}=_Me(Dx(KD)?new YD(KD):new WD);var W7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=H7(()=>{t.kill()});yMe(n,()=>{i()})};var K7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=WT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=SMe(r,n,i),{sourceStream:d,sourceError:f}=vMe(t,l),{options:p,fileDescriptors:h}=mo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},SMe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=EMe(t,e,...r),a=nx(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},EMe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Y7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||UM(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]=$T(r,...n);return{destination:e(Y7)(i,o,s),pipeOptions:s}}if(mo.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}`)},Y7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),vMe=(t,e)=>{try{return{sourceStream:Yd(t,e)}}catch(r){return{sourceError:r}}};var J7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=bMe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ZD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},bMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return GD(t),n;if(e!==void 0)return zD(r),e},ZD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Xd({error:t,command:Z7,escapedCommand:Z7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Z7="source.pipe(destination)";var X7=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 TMe}from"stream/promises";var Q7=(t,e,r)=>{let n=$x.has(e)?wMe(t,e):xMe(t,e);return xl(t,RMe,r.signal),xl(e,IMe,r.signal),AMe(e),n},xMe=(t,e)=>{let r=Il([t]);return tf(r,e),$x.set(e,r),r},wMe=(t,e)=>{let r=$x.get(e);return r.add(t),r},AMe=async t=>{try{await TMe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}$x.delete(t)},$x=new WeakMap,RMe=2,IMe=1;import{aborted as CMe}from"util";var eee=(t,e)=>t===void 0?[]:[PMe(t,e)],PMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await CMe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ZD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Ux=(t,...e)=>{if(Ct(e[0]))return Ux.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=K7(t,...e),i=OMe({...n,destination:r});return i.pipe=Ux.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},OMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=NMe(t,i);J7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Q7(e,o,d);return await Promise.race([X7(u),...eee(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},NMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as FMe}from"timers/promises";import{on as kMe}from"events";import{getDefaultHighWaterMark as MMe}from"stream";var Fx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return DMe(e,s),ree({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},DMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},JD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;LMe(e,s,t);let a=t.readableObjectMode&&!o;return ree({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},LMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},ree=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=kMe(t,"data",{signal:e.signal,highWaterMark:tee,highWatermark:tee});return $Me({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},XD=MMe(!0),tee=XD,$Me=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=UMe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Rl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*l_(a)}},UMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Cx(t,r,!e),Ix(t,i,!n,{})].filter(Boolean);var nee=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=BMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([jMe(t),d]);return}let f=CD(c,r),p=JD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},BMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Nx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=JD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await h7(a,t,r,o)},jMe=async t=>{await FMe(),t.readableFlowing===null&&t.resume()},zMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await Sx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await Ex(r,{maxBuffer:o})):await Jd(r,{maxBuffer:o})}catch(a){return iee(hQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},QD=async t=>{try{return await t}catch(e){return iee(e)}},iee=({bufferedData:t})=>P9(t)?new Uint8Array(t):t;import{finished as GMe}from"stream/promises";var p_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=qMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],GMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||WMe(a,e,r,n)}finally{s.abort()}},qMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&VMe(t,r,n),n},VMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{HMe(e,r),n.call(t,...i)}},HMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},WMe=(t,e,r,n)=>{if(!YMe(t,e,r,n))throw t},YMe=(t,e,r,n=!0)=>r.propagating?oee(t)||Bx(t):(r.propagating=!0,eL(r,e)===n?oee(t):Bx(t)),eL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Bx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oee=t=>t?.code==="EPIPE";var see=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>tL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),tL=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=p_(t,e,l);if(eL(l,e)){await u;return}let[d]=await Promise.all([nee({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 aee=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Il([t,e].filter(Boolean)):void 0,cee=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>tL({...KMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:ZMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),KMe=({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}},ZMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as JMe}from"events";var lee=t=>Gd(t,"ipc"),uee=(t,e)=>{let r=HT(t);po({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var dee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=lee(o),a=gs(e,"ipc"),c=gs(r,"ipc");for await(let l of UD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(mQ(t,i,c),i.push(l)),s&&uee(l,o);return i},fee=async(t,e)=>(await Promise.allSettled([t]),e);var pee=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:S,controller:E})=>{let T=S7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},_=see({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),A=cee({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),R=[],P=dee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),C=XMe(m,t,x),M=QMe(h,x);try{return await Promise.race([Promise.all([{},v7(T),Promise.all(_),A,P,WX(t,d),...C,...M]),S,eDe(t,E),...zX(t,o,f,E),...lX({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...BX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},T,Promise.all(_.map(y=>QD(y))),QD(A),fee(P,R),Promise.allSettled(C),Promise.allSettled(M)])}},XMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:p_(n,i,r)),QMe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ii(o,{checkOpen:!1})&&!wi(o)).map(({type:i,value:o,stream:s=o})=>p_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),eDe=async(t,{signal:e})=>{let[r]=await JMe(t,"error",{signal:e});throw r};var hee=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),h_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ho();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},rf=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 tDe}from"stream";import{callbackify as rDe}from"util";import{finished as mee}from"stream/promises";var rL=async t=>{if(t!==void 0)try{await nL(t)}catch{}},gee=async t=>{if(t!==void 0)try{await iL(t)}catch{}},nL=async t=>{await mee(t,{cleanup:!0,readable:!1,writable:!0})},iL=async t=>{await mee(t,{cleanup:!0,readable:!0,writable:!1})},jx=async(t,e)=>{if(await t,e)throw e},zx=(t,e,r)=>{r&&!Bx(r)?t.destroy(r):e&&t.destroy()};var _ee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||Sn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=oL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=sL(a,s),{read:f,onStdoutDataDone:p}=aL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new tDe({read:f,destroy:rDe(lL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return cL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},oL=(t,e,r)=>{let n=Yd(t,e),i=h_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},sL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:XD},aL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ho(),s=Fx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){nDe(this,s,o)},onStdoutDataDone:o}},nDe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},cL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await iL(t),await n,await rL(i),await e,r.readable&&r.push(null)}catch(o){await rL(i),yee(r,o)}},lL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await rf(r,e)&&(yee(t,n),await jx(e,n))},yee=(t,e)=>{zx(t,t.readable,e)};import{Writable as iDe}from"stream";import{callbackify as See}from"util";var Eee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=uL(t,r,e),s=new iDe({...dL(n,t,i),destroy:See(pL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return fL(n,s),s},uL=(t,e,r)=>{let n=nx(t,e),i=h_(r,n,"writableFinal"),o=h_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},dL=(t,e,r)=>({write:oDe.bind(void 0,t),final:See(sDe.bind(void 0,t,e,r))}),oDe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},sDe=async(t,e,r)=>{await rf(r,e)&&(t.writable&&t.end(),await e)},fL=async(t,e,r)=>{try{await nL(t),e.writable&&e.end()}catch(n){await gee(r),vee(e,n)}},pL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await rf(r,e),await rf(n,e)&&(vee(t,i),await jx(e,i))},vee=(t,e)=>{zx(t,t.writable,e)};import{Duplex as aDe}from"stream";import{callbackify as cDe}from"util";var bee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||Sn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=oL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=uL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=sL(c,a),{read:S,onStdoutDataDone:E}=aL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new aDe({read:S,...dL(u,t,d),destroy:cDe(lDe.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 cL({subprocessStdout:c,onStdoutDataDone:E,readable:T,subprocess:t,subprocessStdin:u}),fL(u,T,c),T},lDe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([lL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),pL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var hL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||Sn.has(e),s=Yd(t,r),a=Fx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return uDe(a,s,t)},uDe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Tee=(t,{encoding:e})=>{let r=hee();t.readable=_ee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Eee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=bee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=hL.bind(void 0,t,e),t[Symbol.asyncIterator]=hL.bind(void 0,t,e,{})};var xee=(t,e)=>{for(let[r,n]of fDe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},dDe=(async()=>{})().constructor.prototype,fDe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(dDe,t)]);var wee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=mDe(t,e,r),{subprocess:f,promise:p}=_De({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Ux.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),xee(f,p),mo.set(f,{options:u,fileDescriptors:d}),f},mDe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=YT(t,e,r),{file:a,commandArguments:c,options:l}=hx(t,e,r),u=gDe(l),d=L7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},gDe=({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}},_De=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=hDe(...mx(t,e,r))}catch(h){return N7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;pDe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];V7(c,a,l),W7(c,r,l);let d={},f=ho();c.kill=aX.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=aee(c,r),Tee(c,r),C7(c,r);let p=yDe({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}},yDe=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,S]=await pee({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((_,A)=>ys(_,e,A)),T=ys(m,e,"all"),x=SDe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:T,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Qd(x,n,e)},SDe=({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?c_({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 go,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Tx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Gx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,EDe(n,t[n],i)]));return{...t,...r}},EDe=(t,e,r)=>vDe.has(t)&&Ct(e)&&Ct(r)?{...e,...r}:r,vDe=new Set(["env",...qM]);var Ma=(t,e,r,n)=>{let i=(s,a,c)=>Ma(s,a,r,c),o=(...s)=>bDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},bDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ct(o))return i(t,Gx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=TDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?T7(a,c,l):wee(a,c,l,i)},TDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=L9(e)?$9(e,r):[e,...r],[s,a,c]=$T(...o),l=Gx(Gx(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 Aee=({file:t,commandArguments:e})=>Iee(t,e),Ree=({file:t,commandArguments:e})=>({...Iee(t,e),isSync:!0}),Iee=(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]=xDe(t);return{file:r,commandArguments:n}},xDe=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(wDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wDe=/ +/g;var Cee=(t,e,r)=>{t.sync=e(ADe,r),t.s=t.sync},Pee=({options:t})=>Oee(t),ADe=({options:t})=>({...Oee(t),isSync:!0}),Oee=t=>({options:{...RDe(t),...t}}),RDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Nee={preferLocal:!0};var kee=Ma(()=>({})),Ggt=Ma(()=>({isSync:!0})),Mee=Ma(Aee),qgt=Ma(Ree),Vgt=Ma(qX),Hgt=Ma(Pee,{},Nee,Cee),{sendMessage:Wgt,getOneMessage:Ygt,getEachMessage:Kgt,getCancelSignal:Zgt}=P7();var Dee=!1,Lee=()=>{Dee=!0},yo=()=>Dee;var m_=null,$ee=t=>(m_&&m_.destroy(),m_=new Ss({totalAllowedTime:t}),m_),Uee=()=>m_;var Ss=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&&yo())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 PT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{fe.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 Fee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.6",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:{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: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.2","@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.197","@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.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var ODe=CDe(import.meta.url),NDe=Es.dirname(ODe),kDe=PDe(import.meta.url),nf=ye("shell"),mL=new Set,Bee={preferLocal:!0},cr=(t,e,r)=>{let[n,i]=MDe(e,r),o={...Bee,...i},s=kee(t,n,o);zee(s,o),Vee(s);let a=r?.idleTimeout;return a&&a>0&&qee(s,a),s},jee=(t,e)=>{let r={...Bee,...e},n=Mee(t,r);return zee(n,r),Vee(n),e?.idleTimeout&&e.idleTimeout>0&&qee(n,e.idleTimeout),n},MDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},zee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Vg).pipe(vs.stdout),t.stderr?.pipe(new Vg).pipe(vs.stderr);return}t.stdout?.pipe(vs.stdout),t.stderr?.pipe(vs.stderr)},gL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vs.kill(-t.pid,e),nf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return nf.error("Error killing process:",r),!1}},Gee=t=>gL(t,"SIGKILL"),qee=(t,e)=>{let r=null,n=()=>{nf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),gL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing idle process ${t.pid}`),Gee(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)},Vee=t=>{mL.add(t);let e=Uee();if(e){let r=e.onTimesUp(()=>{nf.log(`Global timer expired, killing process ${t.pid}`),gL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing process ${t.pid} after timeout`),Gee(t))},5e3)});t.on("exit",()=>{mL.delete(t),r()}),t.on("error",()=>{mL.delete(t),r()})}};function Vx(t,e){return!!Ci(t,e)}function Ci(t,e){if(!vs.env.NETLIFY_LOCAL_MODE)try{let i=kDe.resolve(Fee.name),o=Es.dirname(i);for(;o!==Es.dirname(o);){let s=Es.dirname(o);if(Es.basename(s)==="node_modules"){let a=Es.join(s,".bin",e);if(qx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(vs.env.NODE_PATH){let i=Es.join(vs.env.NODE_PATH,".bin",e);if(qx.existsSync(i))return i}let r=Es.join(t,"node_modules",".bin",e);if(qx.existsSync(r))return r;let n=Es.join(NDe,"..","node_modules",".bin",e);if(qx.existsSync(n))return n}var DDe=ye("utils"),LDe=t=>new Promise(e=>{setTimeout(e,t)});var Hx=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await LDe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Da=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Hee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):DDe.error("Could not parse JSON",n))}},$De=t=>t.charAt(0).toUpperCase()+t.slice(1),So=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():$De(e)).join(" ");function bs(t,e){e&&t.log(`Skill invoked: ${e}`)}var Wx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Wee=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var _L=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},UDe=1e4,yL=(t,e=UDe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as Yee}from"buffer";import FDe from"path";var Kee=ye("repo"),Jr=(t,e={})=>cr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Yx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Kee.info("Getting runner diffs");let n=await jDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=GDe(o);await qDe(m,r)}Kee.info("Changes after processing"),await EL(r);let s=await vL(o,r);if(await SL(s,r),i=await zDe(r),!i)return{hasChanges:!1,ignored:s};await Jr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Jr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Zee(r),{hasChanges:!1,ignored:s};let u=await Jr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Jr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let S=await Jr(["diff",t.sha,"HEAD","--binary"],a),E=String(S.stdout??"");f!==E&&(p=Yee.from(E).toString("base64"))}await Zee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Yee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Zee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Jr(["reset","--soft","HEAD~1"],{cwd:t})},SL=async(t=[],e=process.cwd())=>{await Jr(["add",".",...t],{cwd:e})},EL=async(t=process.cwd())=>{let e=await Jr(["status","-s"],{cwd:t});return String(e.stdout??"")},Jee=/.. (.+)?\.log$/,BDe=[Jee],jDe=async(t=process.cwd())=>{let e=await EL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
102
+ if (condition) { yield value; }`)};import{Buffer as HNe}from"buffer";import{StringDecoder as WNe}from"string_decoder";var Cx=(t,e,r)=>{if(r)return;if(t)return{transform:YNe.bind(void 0,new TextEncoder)};let n=new WNe(e);return{transform:KNe.bind(void 0,n),final:ZNe.bind(void 0,n)}},YNe=function*(t,e){HNe.isBuffer(e)?yield ms(e):typeof e=="string"?yield t.encode(e):yield e},KNe=function*(t,e){yield jt(e)?t.write(e):e},ZNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as a7}from"util";var ND=a7(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Px=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=XNe}=e[r];for await(let i of n(t))yield*Px(i,e,r+1)},c7=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*JNe(r,Number(e),t)},JNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Px(n,r,e+1)},l7=a7(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),XNe=function*(t){yield t};var kD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},u7=(t,e)=>[...e.flatMap(r=>[...Rl(r,t,0)]),...l_(t)],Rl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=eke}=e[r];for(let i of n(t))yield*Rl(i,e,r+1)},l_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*QNe(r,Number(e),t)},QNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Rl(n,r,e+1)},eke=function*(t){yield t};var MD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=f7(t,s,o),l=Al(e),u=Al(r),d=l?ND.bind(void 0,Px,a):kD.bind(void 0,Rl),f=l||u?ND.bind(void 0,c7,a):kD.bind(void 0,l_),p=l||u?l7.bind(void 0,a):void 0;return{stream:new tke({writableObjectMode:n,writableHighWaterMark:d7(n),readableObjectMode:i,readableHighWaterMark:d7(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Ox=(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=f7(s,r,a);t=u7(c,t)}return t},f7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:i7(n,a)},Cx(r,s,n),Ix(r,o,n,c),{transform:t,final:e},{transform:o7(i,a)},n7({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var p7=(t,e)=>{for(let r of rke(t))nke(t,r,e)},rke=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),nke=(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 ${ka[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>ike(a,n));r.input=Qg(s)},ike=(t,e)=>{let r=Ox(t,e,"utf8",!0);return oke(r),Qg(r)},oke=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 lke,appendFileSync as uke}from"fs";var Nx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Gd(r,n)&&!Sn.has(e)&&ske(n)&&(t.some(({type:i,value:o})=>i==="native"&&ake.has(o))||t.every(({type:i})=>Yn.has(i))),ske=t=>t===1||t===2,ake=new Set(["pipe","overlapped"]),h7=async(t,e,r,n)=>{for await(let i of t)cke(e)||g7(i,r,n)},m7=(t,e,r)=>{for(let n of t)g7(n,e,r)},cke=t=>t._readableState.pipes.length>0,g7=(t,e,r)=>{let n=HT(t);po({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var _7=({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)=>dke({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},dke=({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=yQ(t,o,d),p=ms(f),{stdioItems:h,objectMode:m}=e[r],S=fke([p],h,c,n),{serializedResult:E,finalResult:T=E}=pke({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});hke({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?T:void 0;try{return n.error===void 0&&mke(E,h,i),x}catch(_){return n.error=_,x}},fke=(t,e,r,n)=>{try{return Ox(t,e,r,!1)}catch(i){return n.error=i,t}},pke=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Qg(t)};let s=N9(t,r);return n[o]?{serializedResult:s,finalResult:OD(s,!i[o],e)}:{serializedResult:s}},hke=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Nx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=OD(t,!1,s);try{m7(a,e,n)}catch(c){r.error??=c}},mke=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Ax.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?uke(n,t):(r.add(o),lke(n,t))}};var y7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ys(e,r,"all")]:Array.isArray(e)?[ys(t,r,"all"),...e]:jt(t)&&jt(e)?BM([t,e]):`${t}${e}`};import{once as DD}from"events";var S7=async(t,e)=>{let[r,n]=await gke(t);return e.isForcefullyTerminated??=!1,[r,n]},gke=async t=>{let[e,r]=await Promise.allSettled([DD(t,"spawn"),DD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?E7(t):r.value},E7=async t=>{try{return await DD(t,"exit")}catch{return E7(t)}},v7=async t=>{let[e,r]=await t;if(!_ke(e,r)&&LD(e,r))throw new Ai;return[e,r]},_ke=(t,e)=>t===void 0&&e===void 0,LD=(t,e)=>t!==0||e!==null;var b7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=yke(t,e,r),s=o?.code==="ETIMEDOUT",a=_Q(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},yke=(t,e,r)=>t!==void 0?t:LD(e,r)?new Ai:void 0;var T7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Eke(t,e,r),d=Tke({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Qd(d,c,l)},Eke=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=YT(t,e,r),a=vke(r),{file:c,commandArguments:l,options:u}=hx(t,e,a);bke(u);let d=QQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},vke=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,bke=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&kx("ipcInput"),t&&kx("ipc: true"),r&&kx("detached: true"),n&&kx("cancelSignal")},kx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Tke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=xke({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}=b7(c,r),{output:h,error:m=l}=_7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((T,x)=>ys(T,r,x)),E=ys(y7(h,r),r,"all");return Ake({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},xke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{p7(o,r);let a=wke(r);return Ske(...mx(t,e,a))}catch(a){return Xd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wke=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:bx(e)}),Ake=({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?Tx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):c_({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 pDe}from"events";import{spawn as hDe}from"child_process";import I7 from"process";import{once as $D,on as Rke}from"events";var x7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Hd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:cx(t)}),Ike({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Ike=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ix(e,i);let o=Na(t,e,r),s=new AbortController;try{return await Promise.race([Cke(o,n,s),Pke(o,r,s),Oke(o,r,s)])}catch(a){throw Wd(t),a}finally{s.abort(),ox(e,i)}},Cke=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await $D(t,"message",{signal:r});return n}for await(let[n]of Rke(t,"message",{signal:r}))if(e(n))return n},Pke=async(t,e,{signal:r})=>{await $D(t,"disconnect",{signal:r}),uX(e)},Oke=async(t,e,{signal:r})=>{let[n]=await $D(t,"strict:error",{signal:r});throw tx(n,e)};import{once as A7,on as Nke}from"events";var R7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>UD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),UD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Hd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:cx(t)}),ix(e,o);let s=Na(t,e,r),a=new AbortController,c={};return kke(t,s,a),Mke({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Dke({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},kke=async(t,e,r)=>{try{await A7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Mke=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await A7(t,"strict:error",{signal:r.signal});n.error=tx(i,e),r.abort()}catch{}},Dke=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Nke(r,"message",{signal:o.signal}))w7(s),yield c}catch{w7(s)}finally{o.abort(),ox(e,a),n||Wd(t),i&&await t}},w7=({error:t})=>{if(t)throw t};var C7=(t,{ipc:e})=>{Object.assign(t,O7(t,!1,e))},P7=()=>{let t=I7,e=!0,r=I7.channel!==void 0;return{...O7(t,e,r),getCancelSignal:$X.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},O7=(t,e,r)=>({sendMessage:fx.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:x7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:R7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Lke}from"child_process";import{PassThrough as $ke,Readable as Uke,Writable as Fke,Duplex as Bke}from"stream";var N7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ID(n);let a=new Lke;jke(a,n),Object.assign(a,{readable:zke,writable:Gke,duplex:qke});let c=Xd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=Vke(c,s,i);return{subprocess:a,promise:l}},jke=(t,e)=>{let r=u_(),n=u_(),i=u_(),o=Array.from({length:e.length-3},u_),s=u_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},u_=()=>{let t=new $ke;return t.end(),t},zke=()=>new Uke({read(){}}),Gke=()=>new Fke({write(){}}),qke=()=>new Bke({read(){},write(){}}),Vke=async(t,e,r)=>Qd(t,e,r);import{createReadStream as k7,createWriteStream as M7}from"fs";import{Buffer as Hke}from"buffer";import{Readable as d_,Writable as Wke,Duplex as Yke}from"stream";var L7=(t,e)=>Rx(Kke,t,e,!1),f_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ka[t]}.`)},D7={fileNumber:f_,generator:MD,asyncGenerator:MD,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Yke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Kke={input:{...D7,fileUrl:({value:t})=>({stream:k7(t)}),filePath:({value:{file:t}})=>({stream:k7(t)}),webStream:({value:t})=>({stream:d_.fromWeb(t)}),iterable:({value:t})=>({stream:d_.from(t)}),asyncIterable:({value:t})=>({stream:d_.from(t)}),string:({value:t})=>({stream:d_.from(t)}),uint8Array:({value:t})=>({stream:d_.from(Hke.from(t))})},output:{...D7,fileUrl:({value:t})=>({stream:M7(t)}),filePath:({value:{file:t,append:e}})=>({stream:M7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Wke.fromWeb(t)}),iterable:f_,asyncIterable:f_,string:f_,uint8Array:f_}};import{on as Zke,once as $7}from"events";import{PassThrough as Jke,getDefaultHighWaterMark as Xke}from"stream";import{finished as B7}from"stream/promises";function Il(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)BD(i);let e=t.some(({readableObjectMode:i})=>i),r=Qke(t,e),n=new FD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Qke=(t,e)=>{if(t.length===0)return Xke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},FD=class extends Jke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(BD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=eMe(this,this.#e,this.#o);let r=nMe({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(BD(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)}},eMe=async(t,e,r)=>{Mx(t,U7);let n=new AbortController;try{await Promise.race([tMe(t,n),rMe(t,e,r,n)])}finally{n.abort(),Mx(t,-U7)}},tMe=async(t,{signal:e})=>{try{await B7(t,{signal:e,cleanup:!0})}catch(r){throw j7(t,r),r}},rMe=async(t,e,r,{signal:n})=>{for await(let[i]of Zke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},BD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},nMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Mx(t,F7);let a=new AbortController;try{await Promise.race([iMe(o,e,a),oMe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),sMe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Mx(t,-F7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?jD(t):aMe(t))},iMe=async(t,e,{signal:r})=>{try{await t,r.aborted||jD(e)}catch(n){r.aborted||j7(e,n)}},oMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await B7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;z7(s)?i.add(e):G7(t,s)}},sMe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await $7(t,i,{signal:o}),!t.readable)return $7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},aMe=t=>{t.writable&&t.end()},j7=(t,e)=>{z7(e)?jD(t):G7(t,e)},z7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",jD=t=>{(t.readable||t.writable)&&t.destroy()},G7=(t,e)=>{t.destroyed||(t.once("error",cMe),t.destroy(e))},cMe=()=>{},Mx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},U7=2,F7=1;import{finished as q7}from"stream/promises";var tf=(t,e)=>{t.pipe(e),lMe(t,e),uMe(t,e)},lMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await q7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}zD(e)}},zD=t=>{t.writable&&t.end()},uMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await q7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}GD(t)}},GD=t=>{t.readable&&t.destroy()};var V7=(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})=>Yn.has(c)))dMe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))pMe({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]:Il(o);tf(s,i)}},dMe=(t,e,r,n)=>{r==="output"?tf(t.stdio[n],e):tf(e,t.stdio[n]);let i=fMe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},fMe=["stdin","stdout","stderr"],pMe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;hMe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},hMe=(t,{signal:e})=>{wi(t)&&xl(t,mMe,e)},mMe=2;import{addAbortListener as yMe}from"events";var Cl=[];Cl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Cl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Cl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Dx=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",qD=Symbol.for("signal-exit emitter"),VD=globalThis,gMe=Object.defineProperty.bind(Object),HD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(VD[qD])return VD[qD];gMe(VD,qD,{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}},Lx=class{},_Me=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),WD=class extends Lx{onExit(){return()=>{}}load(){}unload(){}},YD=class extends Lx{#e=KD.platform==="win32"?"SIGINT":"SIGHUP";#r=new HD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Cl)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(!Dx(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 Cl)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,Cl.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 Dx(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"&&Dx(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)}},KD=globalThis.process,{onExit:H7,load:Qpt,unload:eht}=_Me(Dx(KD)?new YD(KD):new WD);var W7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=H7(()=>{t.kill()});yMe(n,()=>{i()})};var K7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=WT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=SMe(r,n,i),{sourceStream:d,sourceError:f}=vMe(t,l),{options:p,fileDescriptors:h}=mo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},SMe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=EMe(t,e,...r),a=nx(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},EMe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Y7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||UM(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]=$T(r,...n);return{destination:e(Y7)(i,o,s),pipeOptions:s}}if(mo.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}`)},Y7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),vMe=(t,e)=>{try{return{sourceStream:Yd(t,e)}}catch(r){return{sourceError:r}}};var J7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=bMe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ZD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},bMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return GD(t),n;if(e!==void 0)return zD(r),e},ZD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Xd({error:t,command:Z7,escapedCommand:Z7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Z7="source.pipe(destination)";var X7=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 TMe}from"stream/promises";var Q7=(t,e,r)=>{let n=$x.has(e)?wMe(t,e):xMe(t,e);return xl(t,RMe,r.signal),xl(e,IMe,r.signal),AMe(e),n},xMe=(t,e)=>{let r=Il([t]);return tf(r,e),$x.set(e,r),r},wMe=(t,e)=>{let r=$x.get(e);return r.add(t),r},AMe=async t=>{try{await TMe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}$x.delete(t)},$x=new WeakMap,RMe=2,IMe=1;import{aborted as CMe}from"util";var eee=(t,e)=>t===void 0?[]:[PMe(t,e)],PMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await CMe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ZD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Ux=(t,...e)=>{if(Ct(e[0]))return Ux.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=K7(t,...e),i=OMe({...n,destination:r});return i.pipe=Ux.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},OMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=NMe(t,i);J7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Q7(e,o,d);return await Promise.race([X7(u),...eee(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},NMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as FMe}from"timers/promises";import{on as kMe}from"events";import{getDefaultHighWaterMark as MMe}from"stream";var Fx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return DMe(e,s),ree({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},DMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},JD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;LMe(e,s,t);let a=t.readableObjectMode&&!o;return ree({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},LMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},ree=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=kMe(t,"data",{signal:e.signal,highWaterMark:tee,highWatermark:tee});return $Me({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},XD=MMe(!0),tee=XD,$Me=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=UMe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Rl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*l_(a)}},UMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Cx(t,r,!e),Ix(t,i,!n,{})].filter(Boolean);var nee=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=BMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([jMe(t),d]);return}let f=CD(c,r),p=JD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},BMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Nx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=JD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await h7(a,t,r,o)},jMe=async t=>{await FMe(),t.readableFlowing===null&&t.resume()},zMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await Sx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await Ex(r,{maxBuffer:o})):await Jd(r,{maxBuffer:o})}catch(a){return iee(hQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},QD=async t=>{try{return await t}catch(e){return iee(e)}},iee=({bufferedData:t})=>P9(t)?new Uint8Array(t):t;import{finished as GMe}from"stream/promises";var p_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=qMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],GMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||WMe(a,e,r,n)}finally{s.abort()}},qMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&VMe(t,r,n),n},VMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{HMe(e,r),n.call(t,...i)}},HMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},WMe=(t,e,r,n)=>{if(!YMe(t,e,r,n))throw t},YMe=(t,e,r,n=!0)=>r.propagating?oee(t)||Bx(t):(r.propagating=!0,eL(r,e)===n?oee(t):Bx(t)),eL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Bx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oee=t=>t?.code==="EPIPE";var see=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>tL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),tL=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=p_(t,e,l);if(eL(l,e)){await u;return}let[d]=await Promise.all([nee({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 aee=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Il([t,e].filter(Boolean)):void 0,cee=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>tL({...KMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:ZMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),KMe=({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}},ZMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as JMe}from"events";var lee=t=>Gd(t,"ipc"),uee=(t,e)=>{let r=HT(t);po({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var dee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=lee(o),a=gs(e,"ipc"),c=gs(r,"ipc");for await(let l of UD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(mQ(t,i,c),i.push(l)),s&&uee(l,o);return i},fee=async(t,e)=>(await Promise.allSettled([t]),e);var pee=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:S,controller:E})=>{let T=S7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},_=see({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),A=cee({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),R=[],P=dee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),C=XMe(m,t,x),M=QMe(h,x);try{return await Promise.race([Promise.all([{},v7(T),Promise.all(_),A,P,WX(t,d),...C,...M]),S,eDe(t,E),...zX(t,o,f,E),...lX({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...BX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},T,Promise.all(_.map(y=>QD(y))),QD(A),fee(P,R),Promise.allSettled(C),Promise.allSettled(M)])}},XMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:p_(n,i,r)),QMe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ii(o,{checkOpen:!1})&&!wi(o)).map(({type:i,value:o,stream:s=o})=>p_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),eDe=async(t,{signal:e})=>{let[r]=await JMe(t,"error",{signal:e});throw r};var hee=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),h_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ho();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},rf=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 tDe}from"stream";import{callbackify as rDe}from"util";import{finished as mee}from"stream/promises";var rL=async t=>{if(t!==void 0)try{await nL(t)}catch{}},gee=async t=>{if(t!==void 0)try{await iL(t)}catch{}},nL=async t=>{await mee(t,{cleanup:!0,readable:!1,writable:!0})},iL=async t=>{await mee(t,{cleanup:!0,readable:!0,writable:!1})},jx=async(t,e)=>{if(await t,e)throw e},zx=(t,e,r)=>{r&&!Bx(r)?t.destroy(r):e&&t.destroy()};var _ee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||Sn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=oL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=sL(a,s),{read:f,onStdoutDataDone:p}=aL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new tDe({read:f,destroy:rDe(lL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return cL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},oL=(t,e,r)=>{let n=Yd(t,e),i=h_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},sL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:XD},aL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ho(),s=Fx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){nDe(this,s,o)},onStdoutDataDone:o}},nDe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},cL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await iL(t),await n,await rL(i),await e,r.readable&&r.push(null)}catch(o){await rL(i),yee(r,o)}},lL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await rf(r,e)&&(yee(t,n),await jx(e,n))},yee=(t,e)=>{zx(t,t.readable,e)};import{Writable as iDe}from"stream";import{callbackify as See}from"util";var Eee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=uL(t,r,e),s=new iDe({...dL(n,t,i),destroy:See(pL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return fL(n,s),s},uL=(t,e,r)=>{let n=nx(t,e),i=h_(r,n,"writableFinal"),o=h_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},dL=(t,e,r)=>({write:oDe.bind(void 0,t),final:See(sDe.bind(void 0,t,e,r))}),oDe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},sDe=async(t,e,r)=>{await rf(r,e)&&(t.writable&&t.end(),await e)},fL=async(t,e,r)=>{try{await nL(t),e.writable&&e.end()}catch(n){await gee(r),vee(e,n)}},pL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await rf(r,e),await rf(n,e)&&(vee(t,i),await jx(e,i))},vee=(t,e)=>{zx(t,t.writable,e)};import{Duplex as aDe}from"stream";import{callbackify as cDe}from"util";var bee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||Sn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=oL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=uL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=sL(c,a),{read:S,onStdoutDataDone:E}=aL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new aDe({read:S,...dL(u,t,d),destroy:cDe(lDe.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 cL({subprocessStdout:c,onStdoutDataDone:E,readable:T,subprocess:t,subprocessStdin:u}),fL(u,T,c),T},lDe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([lL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),pL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var hL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||Sn.has(e),s=Yd(t,r),a=Fx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return uDe(a,s,t)},uDe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Tee=(t,{encoding:e})=>{let r=hee();t.readable=_ee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Eee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=bee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=hL.bind(void 0,t,e),t[Symbol.asyncIterator]=hL.bind(void 0,t,e,{})};var xee=(t,e)=>{for(let[r,n]of fDe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},dDe=(async()=>{})().constructor.prototype,fDe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(dDe,t)]);var wee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=mDe(t,e,r),{subprocess:f,promise:p}=_De({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Ux.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),xee(f,p),mo.set(f,{options:u,fileDescriptors:d}),f},mDe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=YT(t,e,r),{file:a,commandArguments:c,options:l}=hx(t,e,r),u=gDe(l),d=L7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},gDe=({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}},_De=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=hDe(...mx(t,e,r))}catch(h){return N7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;pDe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];V7(c,a,l),W7(c,r,l);let d={},f=ho();c.kill=aX.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=aee(c,r),Tee(c,r),C7(c,r);let p=yDe({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}},yDe=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,S]=await pee({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((_,A)=>ys(_,e,A)),T=ys(m,e,"all"),x=SDe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:T,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Qd(x,n,e)},SDe=({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?c_({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 go,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Tx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Gx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,EDe(n,t[n],i)]));return{...t,...r}},EDe=(t,e,r)=>vDe.has(t)&&Ct(e)&&Ct(r)?{...e,...r}:r,vDe=new Set(["env",...qM]);var Ma=(t,e,r,n)=>{let i=(s,a,c)=>Ma(s,a,r,c),o=(...s)=>bDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},bDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ct(o))return i(t,Gx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=TDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?T7(a,c,l):wee(a,c,l,i)},TDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=L9(e)?$9(e,r):[e,...r],[s,a,c]=$T(...o),l=Gx(Gx(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 Aee=({file:t,commandArguments:e})=>Iee(t,e),Ree=({file:t,commandArguments:e})=>({...Iee(t,e),isSync:!0}),Iee=(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]=xDe(t);return{file:r,commandArguments:n}},xDe=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(wDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wDe=/ +/g;var Cee=(t,e,r)=>{t.sync=e(ADe,r),t.s=t.sync},Pee=({options:t})=>Oee(t),ADe=({options:t})=>({...Oee(t),isSync:!0}),Oee=t=>({options:{...RDe(t),...t}}),RDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Nee={preferLocal:!0};var kee=Ma(()=>({})),Ggt=Ma(()=>({isSync:!0})),Mee=Ma(Aee),qgt=Ma(Ree),Vgt=Ma(qX),Hgt=Ma(Pee,{},Nee,Cee),{sendMessage:Wgt,getOneMessage:Ygt,getEachMessage:Kgt,getCancelSignal:Zgt}=P7();var Dee=!1,Lee=()=>{Dee=!0},yo=()=>Dee;var m_=null,$ee=t=>(m_&&m_.destroy(),m_=new Ss({totalAllowedTime:t}),m_),Uee=()=>m_;var Ss=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&&yo())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 PT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{fe.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 Fee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.7",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:{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: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.2","@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.197","@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.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var ODe=CDe(import.meta.url),NDe=Es.dirname(ODe),kDe=PDe(import.meta.url),nf=ye("shell"),mL=new Set,Bee={preferLocal:!0},cr=(t,e,r)=>{let[n,i]=MDe(e,r),o={...Bee,...i},s=kee(t,n,o);zee(s,o),Vee(s);let a=r?.idleTimeout;return a&&a>0&&qee(s,a),s},jee=(t,e)=>{let r={...Bee,...e},n=Mee(t,r);return zee(n,r),Vee(n),e?.idleTimeout&&e.idleTimeout>0&&qee(n,e.idleTimeout),n},MDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},zee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Vg).pipe(vs.stdout),t.stderr?.pipe(new Vg).pipe(vs.stderr);return}t.stdout?.pipe(vs.stdout),t.stderr?.pipe(vs.stderr)},gL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vs.kill(-t.pid,e),nf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return nf.error("Error killing process:",r),!1}},Gee=t=>gL(t,"SIGKILL"),qee=(t,e)=>{let r=null,n=()=>{nf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),gL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing idle process ${t.pid}`),Gee(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)},Vee=t=>{mL.add(t);let e=Uee();if(e){let r=e.onTimesUp(()=>{nf.log(`Global timer expired, killing process ${t.pid}`),gL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing process ${t.pid} after timeout`),Gee(t))},5e3)});t.on("exit",()=>{mL.delete(t),r()}),t.on("error",()=>{mL.delete(t),r()})}};function Vx(t,e){return!!Ci(t,e)}function Ci(t,e){if(!vs.env.NETLIFY_LOCAL_MODE)try{let i=kDe.resolve(Fee.name),o=Es.dirname(i);for(;o!==Es.dirname(o);){let s=Es.dirname(o);if(Es.basename(s)==="node_modules"){let a=Es.join(s,".bin",e);if(qx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(vs.env.NODE_PATH){let i=Es.join(vs.env.NODE_PATH,".bin",e);if(qx.existsSync(i))return i}let r=Es.join(t,"node_modules",".bin",e);if(qx.existsSync(r))return r;let n=Es.join(NDe,"..","node_modules",".bin",e);if(qx.existsSync(n))return n}var DDe=ye("utils"),LDe=t=>new Promise(e=>{setTimeout(e,t)});var Hx=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await LDe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Da=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Hee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):DDe.error("Could not parse JSON",n))}},$De=t=>t.charAt(0).toUpperCase()+t.slice(1),So=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():$De(e)).join(" ");function bs(t,e){e&&t.log(`Skill invoked: ${e}`)}var Wx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Wee=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var _L=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},UDe=1e4,yL=(t,e=UDe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as Yee}from"buffer";import FDe from"path";var Kee=ye("repo"),Jr=(t,e={})=>cr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Yx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Kee.info("Getting runner diffs");let n=await jDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=GDe(o);await qDe(m,r)}Kee.info("Changes after processing"),await EL(r);let s=await vL(o,r);if(await SL(s,r),i=await zDe(r),!i)return{hasChanges:!1,ignored:s};await Jr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Jr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Zee(r),{hasChanges:!1,ignored:s};let u=await Jr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Jr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let S=await Jr(["diff",t.sha,"HEAD","--binary"],a),E=String(S.stdout??"");f!==E&&(p=Yee.from(E).toString("base64"))}await Zee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Yee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Zee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Jr(["reset","--soft","HEAD~1"],{cwd:t})},SL=async(t=[],e=process.cwd())=>{await Jr(["add",".",...t],{cwd:e})},EL=async(t=process.cwd())=>{let e=await Jr(["status","-s"],{cwd:t});return String(e.stdout??"")},Jee=/.. (.+)?\.log$/,BDe=[Jee],jDe=async(t=process.cwd())=>{let e=await EL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
103
103
  `).filter(i=>BDe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},zDe=async(t=process.cwd())=>{try{return await Jr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},g_=async(t=process.cwd())=>{let{stdout:e}=await Jr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Xee=async(t=process.cwd())=>{let{stdout:e}=await Jr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},vL=async(t,e=process.cwd())=>{t||=await EL(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(`
104
104
  `).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${FDe.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Jee)?.[1];o&&n.push(`:!${o}.log`)}),n},bL=async(t=process.cwd())=>{await Jr(["reset","--hard","HEAD"],{cwd:t})},Qee=async(t=process.cwd())=>{let e=await Jr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
105
105
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},GDe=t=>{let e=t.split(`
@@ -494,12 +494,12 @@ You're an AI agent designed to assist with tasks related to a Netlify project. P
494
494
  </request>
495
495
 
496
496
  Use the following file for the complete context of the ask, the environment, and what's available. ${u} You MUST READ ALL OF IT. Make sure to read it first. Never cite or paraphrase private context.
497
- `),x};var w2e=ye("prompt"),Mse=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:o})=>{let s=await kse({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:o});return process.env.AGENT_RUNNER_DEBUG&&w2e.log("Contextful Prompt:",s),{prompt:s}};var Dse=ye("session_manager"),cj=null;var A2e,lj,R2e=0,I2e,C2e;var uj=()=>A2e,Lse=()=>cj!==null,$se=()=>R2e,Use=()=>C2e,Fse=()=>I2e,dj=async(t,e)=>{if(!We().idleTimeoutEnabled||!t||t===e)return;let r=ph[t];if(r)try{await r.clean(),Dse.info(`Wiped previous agent state (${t}) on switch to ${e}`)}catch(n){Dse.warn(`Failed to clean previous agent ${t} on switch`,{error:n?.message||n})}finally{lj=void 0}},mh=t=>{lj=t};var Bse=t=>{let e=t.previousSession?.nativeSessionId;return!!e&&e===lj},jse=async()=>{if(cj)try{await cj}catch{}};var zse=t=>{let e=t.previousSession;return e?e.agent!==t.runner?{viable:!1,outcome:"agent_switch"}:e.nativeSessionId?{viable:!0,outcome:"resumed"}:{viable:!1,outcome:"missing_native_session_id"}:{viable:!1,outcome:"not_eligible"}};import{randomUUID as P2e}from"crypto";var O2e=ye("interactions"),Gse=async(t,e,r)=>{let n=P2e();return await Kr(t.id,t.sessionId,{state:"await_input",interactions:{[n]:{type:"question",status:"pending",payload:e.questions,nativeToolId:e.toolUseId}},steps:[{id:n,refId:n,category:Y.Question}],...r?.nativeSessionId?{native_session_id:r.nativeSessionId}:{},...r?.nativeSessionS3Key?{native_session_s3_key:r.nativeSessionS3Key}:{}}),n},qse=async t=>{let e;try{e=await MT(t.id,t.sessionId)}catch(s){return O2e.warn("Failed to fetch session for the full answer fold",{error:s?.message}),fe.inc("inference.answer_fetch_failed",1),null}let r=e?.interactions;if(!r)return[];let n=[],i=new Set,o=(s,a)=>{!a||i.has(s)||(i.add(s),a.type==="question"&&a.status==="answered"&&n.push({refId:s,questions:a.payload??[],responses:a.response??[]}))};for(let s of e?.steps??[])s?.refId&&o(s.refId,r[s.refId]);for(let[s,a]of Object.entries(r))o(s,a);return n},Vse=()=>({counted:!1}),Hse=(t,e)=>{let r=e.map(n=>n.questions.map((i,o)=>{let s=n.responses[o],a=s==null?"(skipped)":Array.isArray(s)?s.join(", "):s;return`Q: ${i.question}
498
- A: ${a}`}).join(`
497
+ `),x};var w2e=ye("prompt"),Mse=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:o})=>{let s=await kse({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:o});return process.env.AGENT_RUNNER_DEBUG&&w2e.log("Contextful Prompt:",s),{prompt:s}};var Dse=ye("session_manager"),cj=null;var A2e,lj,R2e=0,I2e,C2e;var uj=()=>A2e,Lse=()=>cj!==null,$se=()=>R2e,Use=()=>C2e,Fse=()=>I2e,dj=async(t,e)=>{if(!We().idleTimeoutEnabled||!t||t===e)return;let r=ph[t];if(r)try{await r.clean(),Dse.info(`Wiped previous agent state (${t}) on switch to ${e}`)}catch(n){Dse.warn(`Failed to clean previous agent ${t} on switch`,{error:n?.message||n})}finally{lj=void 0}},mh=t=>{lj=t};var Bse=t=>{let e=t.previousSession?.nativeSessionId;return!!e&&e===lj},jse=async()=>{if(cj)try{await cj}catch{}};var zse=t=>{let e=t.previousSession;return e?e.agent!==t.runner?{viable:!1,outcome:"agent_switch"}:e.nativeSessionId?{viable:!0,outcome:"resumed"}:{viable:!1,outcome:"missing_native_session_id"}:{viable:!1,outcome:"not_eligible"}};import{randomUUID as P2e}from"crypto";var O2e=ye("interactions"),Gse=async(t,e,r)=>{let n=P2e();return await Kr(t.id,t.sessionId,{state:"await_input",interactions:{[n]:{type:"question",status:"pending",payload:e.questions,nativeToolId:e.toolUseId}},steps:[{id:n,refId:n,category:Y.Question}],...r?.nativeSessionId?{native_session_id:r.nativeSessionId}:{},...r?.nativeSessionS3Key?{native_session_s3_key:r.nativeSessionS3Key}:{}}),n},qse=async t=>{let e;try{e=await MT(t.id,t.sessionId)}catch(s){return O2e.warn("Failed to fetch session for the full answer fold",{error:s?.message}),fe.inc("inference.answer_fetch_failed",1),null}let r=e?.interactions;if(!r)return[];let n=[],i=new Set,o=(s,a)=>{!a||i.has(s)||(i.add(s),a.type==="question"&&(a.status==="answered"||a.status==="skipped")&&n.push({refId:s,questions:a.payload??[],responses:a.response??[]}))};for(let s of e?.steps??[])s?.refId&&o(s.refId,r[s.refId]);for(let[s,a]of Object.entries(r))o(s,a);return n},Vse=()=>({counted:!1}),Hse=(t,e)=>{let r=!1,n=e.map(o=>o.questions.map((s,a)=>{let c=o.responses[a];c==null&&(r=!0);let l=c==null?"(skipped)":Array.isArray(c)?c.join(", "):c;return`Q: ${s.question}
498
+ A: ${l}`}).join(`
499
499
 
500
500
  `)).join(`
501
501
 
502
- `);return[t,"You previously paused to ask the user for clarification. Here are their answers:",r,"Continue with the task using these answers. Do not ask these questions again."].filter(Boolean).join(`
502
+ `);return[t,"You previously paused to ask the user for clarification. Here are their answers:",n,`Continue with the task using these answers.${r?' A "(skipped)" answer means the user chose not to answer; proceed with your best judgment there.':""} Do not ask these questions again.`].filter(Boolean).join(`
503
503
 
504
504
  `)};import Ks from"fs/promises";import Kde from"os";import Zs from"path";import{rm as HG}from"fs/promises";import{resolve as N2e}from"path";var k2e=".netlify/cache/",bu=function({cacheDir:t=k2e,cwd:e="."}={}){return N2e(e,t)};import{promises as zVe}from"fs";import{basename as Tde,dirname as xde,join as GVe}from"path";import iVe from"process";import oVe from"events";import Je from"path";import sVe from"os";async function Zy(t,e,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:n=!0,signal:i}={}){return new Promise((o,s)=>{if(t[Symbol.iterator]===void 0&&t[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(r)&&r>=1||r===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let a=[],c=[],l=new Map,u=!1,d=!1,f=!1,p=0,h=0,m=t[Symbol.iterator]===void 0?t[Symbol.asyncIterator]():t[Symbol.iterator](),S=()=>{x(i.reason)},E=()=>{i?.removeEventListener("abort",S)},T=A=>{o(A),E()},x=A=>{u=!0,d=!0,s(A),E()};i&&(i.aborted&&x(i.reason),i.addEventListener("abort",S,{once:!0}));let _=async()=>{if(d)return;let A=await m.next(),R=h;if(h++,A.done){if(f=!0,p===0&&!d){if(!n&&c.length>0){x(new AggregateError(c));return}if(d=!0,l.size===0){T(a);return}let P=[];for(let[C,M]of a.entries())l.get(C)!==Wse&&P.push(M);T(P)}return}p++,(async()=>{try{let P=await A.value;if(d)return;let C=await e(P,R);C===Wse&&l.set(R,C),a[R]=C,p--,await _()}catch(P){if(n)x(P);else{c.push(P),p--;try{await _()}catch(C){x(C)}}}})()};(async()=>{for(let A=0;A<r;A++){try{await _()}catch(R){x(R);break}if(f||u)break}})()})}var Wse=Symbol("skip");import xu from"path";import VDt,{constants as vj}from"fs";import bj from"fs/promises";var pj=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},hj=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Yse=t=>globalThis.DOMException===void 0?new hj(t):new DOMException(t),Kse=t=>{let e=t.reason===void 0?Yse("This operation was aborted."):t.reason;return e instanceof Error?e:Yse(e)};function mj(t,e){let{milliseconds:r,fallback:n,message:i,customTimers:o={setTimeout,clearTimeout}}=e,s,a,l=new Promise((u,d)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:p}=e;p.aborted&&d(Kse(p)),a=()=>{d(Kse(p))},p.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let f=new pj;s=o.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(p){d(p)}return}typeof t.cancel=="function"&&t.cancel(),i===!1?u():i instanceof Error?d(i):(f.message=i??`Promise timed out after ${r} milliseconds`,d(f))},r),(async()=>{try{u(await t)}catch(p){d(p)}})()}).finally(()=>{l.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return l.clear=()=>{o.clearTimeout.call(void 0,s),s=void 0},l}var M2e=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function D2e(t,e,r){let n,i=new Promise((o,s)=>{if(r={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:l,removeListener:u}=M2e(t),d=(...p)=>{let h=r.multiArgs?p:p[0];r.filter&&!r.filter(h)||(c.push(h),r.count===c.length&&(n(),o(c)))},f=p=>{n(),s(p)};n=()=>{for(let p of a)u(p,d);for(let p of r.rejectionEvents)u(p,f)};for(let p of a)l(p,d);for(let p of r.rejectionEvents)l(p,f);r.signal&&r.signal.addEventListener("abort",()=>{f(r.signal.reason)},{once:!0}),r.resolveImmediately&&o(c)});if(i.cancel=n,typeof r.timeout=="number"){let o=mj(i,{milliseconds:r.timeout});return o.cancel=n,o}return i}function KR(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=D2e(t,e,r),i=n.then(o=>o[0]);return i.cancel=n.cancel,i}var Br=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CopyFileError"}};var Li=Gr(sae(),1);import{promisify as Jy}from"util";var UDt=Jy(Li.default.stat),H2e=Jy(Li.default.lstat),W2e=Jy(Li.default.utimes),Y2e=Jy(Li.default.chmod),K2e=Jy(Li.default.mkdir),FDt=Li.default.closeSync.bind(Li.default),aae=Li.default.createWriteStream.bind(Li.default);async function cae(t,e){let r=Li.default.createReadStream(t,e);try{await KR(r,["readable","end"])}catch(n){throw new Br(`Cannot read from \`${t}\`: ${n.message}`,{cause:n})}return r}var Ej=t=>H2e(t).catch(e=>{throw new Br(`lstat \`${t}\` failed: ${e.message}`,{cause:e})}),lae=(t,e,r)=>W2e(t,e,r).catch(n=>{throw new Br(`utimes \`${t}\` failed: ${n.message}`,{cause:n})}),uae=(t,e)=>Y2e(t,e).catch(r=>{throw new Br(`chmod \`${t}\` failed: ${r.message}`,{cause:r})});var dae=(t,e)=>K2e(t,{...e,recursive:!0}).catch(r=>{throw new Br(`Cannot create directory \`${t}\`: ${r.message}`,{cause:r})});var J2e=(t,e,r)=>({sourcePath:xu.resolve(t,e),destinationPath:xu.resolve(t,r)}),X2e=(t,e)=>{if(!t.isFile())throw Object.assign(new Br(`EISDIR: illegal operation on a directory '${e}'`),{errno:-21,code:"EISDIR",source:e})};async function fae(t,e,r={}){if(!t||!e)throw new Br("`source` and `destination` required");r.cwd&&({sourcePath:t,destinationPath:e}=J2e(r.cwd,t,e)),r={overwrite:!0,...r};let n=await Ej(t),{size:i}=n;X2e(n,t);let o=xu.dirname(e);if(xu.parse(o).root===o||await dae(xu.dirname(e),{mode:r.directoryMode}),typeof r.onProgress=="function"){let a=await cae(t),c=aae(e,{flags:r.overwrite?"w":"wx"}),l=p=>{r.onProgress({sourcePath:xu.resolve(t),destinationPath:xu.resolve(e),size:i,writtenBytes:p,percent:p===i?1:p/i})},u=-1;a.on("data",()=>{let p=c.bytesWritten,h=p===i?1:p/i;(h===1||h-u>=.01)&&(u=h,l(p))});let d;a.once("error",p=>{d=new Br(`Cannot read from \`${t}\`: ${p.message}`,{cause:p})});let f=!1;try{let p=KR(c,"close");a.pipe(c),await p,l(i),f=!0}catch(p){throw new Br(`Cannot write to \`${e}\`: ${p.message}`,{cause:p})}if(d)throw d;if(f){let p=await Ej(t);return Promise.all([lae(e,p.atime,p.mtime).catch(h=>{if(h.code!=="EPERM")throw h}),uae(e,p.mode)])}}else{let a=r.overwrite?vj.COPYFILE_FICLONE:vj.COPYFILE_FICLONE|vj.COPYFILE_EXCL;try{await bj.copyFile(t,e,a),await Promise.all([bj.utimes(e,n.atime,n.mtime).catch(c=>{if(c.code!=="EPERM")throw c}),bj.chmod(e,n.mode)])}catch(c){throw new Br(c.message,{cause:c})}}}async function Tj(t,e,r){return(await Zy(t,(i,o)=>Promise.all([e(i,o),i]),r)).filter(i=>!!i[0]).map(i=>i[1])}import Cue from"process";import Jqe from"fs";import Ih from"path";import{on as Q2e,once as eje}from"events";import{PassThrough as tje}from"stream";import{finished as mae}from"stream/promises";function Rj(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)wj(i);let e=t.some(({readableObjectMode:i})=>i),r=rje(t,e),n=new xj({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&yae(n),n}var rje=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},xj=class extends tje{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){wj(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=nje(this,this.#e),sje({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return wj(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},nje=async(t,e)=>{eI(t,pae);let r=new AbortController;try{await Promise.race([ije(t,r),oje(t,e,r)])}finally{r.abort(),eI(t,-pae)}},ije=async(t,{signal:e})=>{await mae(t,{signal:e,cleanup:!0})},oje=async(t,e,{signal:r})=>{for await(let[n]of Q2e(t,"unpipe",{signal:r}))e.has(n)&&n.emit(_ae)},wj=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},sje=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o})=>{eI(t,hae);let s=new AbortController;try{await Promise.race([aje(o,e),cje({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:s}),lje({stream:e,streams:r,ended:n,aborted:i,controller:s})])}finally{s.abort(),eI(t,-hae)}r.size===n.size+i.size&&(n.size===0&&i.size>0?Aj(t):yae(t))},gae=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",aje=async(t,e)=>{try{await t,Aj(e)}catch(r){gae(r)?Aj(e):Sae(e,r)}},cje=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await mae(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;gae(s)?i.add(e):Sae(t,s)}},lje=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await eje(t,_ae,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},_ae=Symbol("unpipe"),yae=t=>{t.writable&&t.end()},Aj=t=>{(t.readable||t.writable)&&t.destroy()},Sae=(t,e)=>{t.destroyed||(t.once("error",uje),t.destroy(e))},uje=()=>{},eI=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},pae=2,hae=1;var Ch=Gr(iS(),1);import bqe from"fs";import Tqe from"fs/promises";async function pG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await Tqe[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function hG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return bqe[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var x$t=pG.bind(void 0,"stat","isFile"),uue=pG.bind(void 0,"stat","isDirectory"),w$t=pG.bind(void 0,"lstat","isSymbolicLink"),A$t=hG.bind(void 0,"statSync","isFile"),due=hG.bind(void 0,"statSync","isDirectory"),R$t=hG.bind(void 0,"lstatSync","isSymbolicLink");var bG=Gr(iS(),1),Eue=Gr(vG(),1);import qqe from"process";import Vqe from"fs";import Hqe from"fs/promises";import Rh from"path";function Ah(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var sS=t=>t[0]==="!";var Wqe=["**/node_modules","**/flow-typed","**/coverage","**/.git"],vue={absolute:!0,dot:!0},bue="**/.gitignore",Yqe=(t,e)=>sS(t)?"!"+Rh.posix.join(e,t.slice(1)):Rh.posix.join(e,t),Kqe=(t,e)=>{let r=Ah(Rh.relative(e,Rh.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>Yqe(n,r))},Zqe=(t,e)=>{if(e=Ah(e),Rh.isAbsolute(t)){if(Ah(t).startsWith(e))return Rh.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},Tue=(t,e)=>{let r=t.flatMap(i=>Kqe(i,e)),n=(0,Eue.default)().add(r);return i=>(i=Zr(i),i=Zqe(i,e),i?n.ignores(Ah(i)):!1)},xue=(t={})=>({cwd:Zr(t.cwd)??qqe.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...Wqe]}),wue=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=xue(e),s=await(0,bG.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...vue}),a=await Promise.all(s.map(async c=>({filePath:c,content:await Hqe.readFile(c,"utf8")})));return Tue(a,r)},Aue=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=xue(e),a=bG.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...vue}).map(c=>({filePath:c,content:Vqe.readFileSync(c,"utf8")}));return Tue(a,r)};var Xqe=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},Pue=(t,e)=>{let r=sS(t)?t.slice(1):t;return Ih.isAbsolute(r)?r:Ih.join(e,r)},Oue=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>Ih.posix.join(t,`**/${Ih.extname(i)?i:`${i}${n}`}`)):[Ih.posix.join(t,`**${n?`/*${n}`:""}`)]},Rue=async(t,{cwd:e=Cue.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async o=>await uue(Pue(o,e))?Oue({directoryPath:o,files:r,extensions:n}):o))).flat(),Iue=(t,{cwd:e=Cue.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>due(Pue(i,e))?Oue({directoryPath:i,files:r,extensions:n}):i),TG=t=>(t=[...new Set([t].flat())],Xqe(t),t),Qqe=t=>{if(!t)return;let e;try{e=Jqe.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},Nue=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Zr(t.cwd)},Qqe(t.cwd),t),kue=t=>async(e,r)=>t(TG(e),Nue(r)),NI=t=>(e,r)=>t(TG(e),Nue(r)),Mue=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?TG(e):[];return r&&n.push(bue),n},eVe=async t=>{let e=Mue(t);return Lue(e.length>0&&await wue(e,t))},Due=t=>{let e=Mue(t);return Lue(e.length>0&&Aue(e,t))},Lue=t=>{let e=new Set;return r=>{let n=Ih.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},$ue=(t,e)=>t.flat().filter(r=>e(r)),Uue=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(o=>sS(o));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let o of r)o.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},Fue=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),Bue=async(t,e)=>{let r=Uue(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=Fue(i,n);return Promise.all(r.map(async s=>{let{patterns:a,options:c}=s;return[a,c.ignore]=await Promise.all([Rue(a,o),Rue(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},xG=(t,e)=>{let r=Uue(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=Fue(i,n);return r.map(s=>{let{patterns:a,options:c}=s;return a=Iue(a,o),c.ignore=Iue(c.ignore,{cwd:n}),{patterns:a,options:c}})},Y$t=kue(async(t,e)=>{let[r,n]=await Promise.all([Bue(t,e),eVe(e)]),i=await Promise.all(r.map(o=>(0,Ch.default)(o.patterns,o.options)));return $ue(i,n)}),jue=NI((t,e)=>{let r=xG(t,e),n=Due(e),i=r.map(o=>Ch.default.sync(o.patterns,o.options));return $ue(i,n)}),K$t=NI((t,e)=>{let r=xG(t,e),n=Due(e),i=r.map(s=>Ch.default.stream(s.patterns,s.options));return Rj(i).filter(s=>n(s))}),Iu=NI((t,e)=>t.some(r=>Ch.default.isDynamicPattern(r,e))),Z$t=kue(Bue),J$t=NI(xG),{convertPathToPattern:X$t}=Ch.default;var Gue=Gr(Kj(),1);var Oc=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CpyError"}};import MI from"path";import zue from"fs";var tVe=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],rVe=new RegExp(tVe.join("|"));function nVe(t){return rVe.test(t)}function kI(t){return!nVe(t)}var aS=class{constructor(e,r,n){this.path=e,this.originalPath=e,this.destination=r,this.options=n,this.isDirectory=!1,!Iu(e)&&zue.existsSync(e)&&zue.lstatSync(e).isDirectory()&&(this.path=[e,"**"].join("/"),this.isDirectory=!0)}get name(){return MI.basename(this.originalPath)}get normalizedPath(){let e=this.originalPath.split("/"),r=e.findIndex(i=>i?Iu(i):!1),n=e.slice(0,r).join("/");return n?MI.isAbsolute(n)?n:MI.join(this.options.cwd,n):this.destination}hasMagic(){return Iu(this.options.flat?this.path:this.originalPath)}getMatches(){let e=jue(this.path,{...this.options,dot:!0,absolute:!0,onlyFiles:!0});return this.options.ignoreJunk&&(e=e.filter(r=>kI(MI.basename(r)))),e}};var aVe={ignoreJunk:!0,flat:!1,cwd:iVe.cwd()},wG=class{constructor(e,r,n){this.path=e.split("/").join(Je.sep),this.relativePath=r.split("/").join(Je.sep),this.pattern=n,Object.freeze(this)}get name(){return Je.basename(this.path)}get nameWithoutExtension(){return Je.basename(this.path,Je.extname(this.path))}get extension(){return Je.extname(this.path).slice(1)}},cVe=t=>t.flatMap(e=>Gue.default.braces(e,{expand:!0,nodupes:!0})),lVe=({entry:t,destination:e,options:r})=>t.pattern.hasMagic()?r.flat?Je.isAbsolute(e)?Je.join(e,t.name):Je.join(r.cwd,e,t.name):Je.join(e,Je.relative(t.pattern.normalizedPath,t.path)):Je.isAbsolute(e)?Je.join(e,t.name):t.pattern.isDirectory&&Je.relative(r.cwd,t.path).startsWith("..")?Je.join(r.cwd,e,Je.basename(t.pattern.originalPath),Je.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&t.path===t.relativePath?Je.join(r.cwd,e,Je.basename(t.pattern.originalPath),Je.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&r.flat?Je.join(r.cwd,e,Je.basename(t.pattern.originalPath)):Je.join(r.cwd,e,Je.relative(r.cwd,t.path)),uVe=(t,e)=>{let r=Je.dirname(t);if(typeof e=="string")return Je.join(r,e);if(typeof e=="function"){let n=Je.basename(t);return Je.join(r,e(n))}return t};function AG(t,e,{concurrency:r=sVe.availableParallelism(),...n}={}){let i=new Map,o=new oVe;n={...aVe,...n};let s=(async()=>{let a=[],c=0,l=0,u=cVe([t??[]].flat()).map(h=>h.replaceAll("\\","/")),d=u.filter(h=>!h.startsWith("!")),f=u.filter(h=>h.startsWith("!"));if(d.length===0||!e)throw new Oc("`source` and `destination` required");u=u.map(h=>new aS(h,e,{...n,ignore:f}));for(let h of u){let m=[];try{m=h.getMatches()}catch(S){throw new Oc(`Cannot glob \`${h.originalPath}\`: ${S.message}`,{cause:S})}if(m.length===0&&!Iu(h.originalPath)&&!Iu(f))throw new Oc(`Cannot copy \`${h.originalPath}\`: the file doesn't exist`);a=[...a,...m.map(S=>new wG(S,Je.relative(n.cwd,S),h))]}n.filter!==void 0&&(a=await Tj(a,n.filter,{concurrency:1024})),a.length===0&&o.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0});let p=h=>{let m=i.get(h.sourcePath)||{writtenBytes:0,percent:0};(m.writtenBytes!==h.writtenBytes||m.percent!==h.percent)&&(l-=m.writtenBytes,l+=h.writtenBytes,h.percent===1&&m.percent!==1&&c++,i.set(h.sourcePath,{writtenBytes:h.writtenBytes,percent:h.percent}),o.emit("progress",{totalFiles:a.length,percent:c/a.length,completedFiles:c,completedSize:l,sourcePath:h.sourcePath,destinationPath:h.destinationPath}))};return Zy(a,async h=>{let m=uVe(lVe({entry:h,destination:e,options:n}),n.rename);try{await fae(h.path,m,{...n,onProgress:p})}catch(S){throw new Oc(`Cannot copy from \`${h.relativePath}\` to \`${m}\`: ${S.message}`,{cause:S})}return m},{concurrency:r})})();return s.on=(...a)=>(o.on(...a),s),s}import cde from"process";import NVe from"fs";import Nh from"path";import{on as dVe,once as fVe}from"events";import{PassThrough as pVe}from"stream";import{finished as Hue}from"stream/promises";function PG(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)IG(i);let e=t.some(({readableObjectMode:i})=>i),r=hVe(t,e),n=new RG({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&Kue(n),n}var hVe=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},RG=class extends pVe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){IG(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=mVe(this,this.#e),yVe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return IG(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},mVe=async(t,e)=>{DI(t,que);let r=new AbortController;try{await Promise.race([gVe(t,r),_Ve(t,e,r)])}finally{r.abort(),DI(t,-que)}},gVe=async(t,{signal:e})=>{await Hue(t,{signal:e,cleanup:!0})},_Ve=async(t,e,{signal:r})=>{for await(let[n]of dVe(t,"unpipe",{signal:r}))e.has(n)&&n.emit(Yue)},IG=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},yVe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o})=>{DI(t,Vue);let s=new AbortController;try{await Promise.race([SVe(o,e),EVe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:s}),vVe({stream:e,streams:r,ended:n,aborted:i,controller:s})])}finally{s.abort(),DI(t,-Vue)}r.size===n.size+i.size&&(n.size===0&&i.size>0?CG(t):Kue(t))},Wue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",SVe=async(t,e)=>{try{await t,CG(e)}catch(r){Wue(r)?CG(e):Zue(e,r)}},EVe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Hue(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Wue(s)?i.add(e):Zue(t,s)}},vVe=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await fVe(t,Yue,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},Yue=Symbol("unpipe"),Kue=t=>{t.writable&&t.end()},CG=t=>{(t.readable||t.writable)&&t.destroy()},Zue=(t,e)=>{t.destroyed||(t.once("error",bVe),t.destroy(e))},bVe=()=>{},DI=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},que=2,Vue=1;var kh=Gr(iS(),1);import TVe from"fs";import xVe from"fs/promises";async function OG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await xVe[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function NG(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return TVe[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var x1t=OG.bind(void 0,"stat","isFile"),Jue=OG.bind(void 0,"stat","isDirectory"),w1t=OG.bind(void 0,"lstat","isSymbolicLink"),A1t=NG.bind(void 0,"statSync","isFile"),Xue=NG.bind(void 0,"statSync","isDirectory"),R1t=NG.bind(void 0,"lstatSync","isSymbolicLink");var kG=Gr(iS(),1),Que=Gr(vG(),1);import wVe from"process";import AVe from"fs";import RVe from"fs/promises";import Oh from"path";function Ph(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var cS=t=>t[0]==="!";var IVe=["**/node_modules","**/flow-typed","**/coverage","**/.git"],ede={absolute:!0,dot:!0},tde="**/.gitignore",CVe=(t,e)=>cS(t)?"!"+Oh.posix.join(e,t.slice(1)):Oh.posix.join(e,t),PVe=(t,e)=>{let r=Ph(Oh.relative(e,Oh.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>CVe(n,r))},OVe=(t,e)=>{if(e=Ph(e),Oh.isAbsolute(t)){if(Ph(t).startsWith(e))return Oh.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},rde=(t,e)=>{let r=t.flatMap(i=>PVe(i,e)),n=(0,Que.default)().add(r);return i=>(i=Zr(i),i=OVe(i,e),i?n.ignores(Ph(i)):!1)},nde=(t={})=>({cwd:Zr(t.cwd)??wVe.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...IVe]}),ide=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=nde(e),s=await(0,kG.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...ede}),a=await Promise.all(s.map(async c=>({filePath:c,content:await RVe.readFile(c,"utf8")})));return rde(a,r)},ode=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=nde(e),a=kG.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...ede}).map(c=>({filePath:c,content:AVe.readFileSync(c,"utf8")}));return rde(a,r)};var kVe=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},lde=(t,e)=>{let r=cS(t)?t.slice(1):t;return Nh.isAbsolute(r)?r:Nh.join(e,r)},ude=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>Nh.posix.join(t,`**/${Nh.extname(i)?i:`${i}${n}`}`)):[Nh.posix.join(t,`**${n?`/*${n}`:""}`)]},sde=async(t,{cwd:e=cde.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async o=>await Jue(lde(o,e))?ude({directoryPath:o,files:r,extensions:n}):o))).flat(),ade=(t,{cwd:e=cde.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>Xue(lde(i,e))?ude({directoryPath:i,files:r,extensions:n}):i),MG=t=>(t=[...new Set([t].flat())],kVe(t),t),MVe=t=>{if(!t)return;let e;try{e=NVe.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},dde=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Zr(t.cwd)},MVe(t.cwd),t),fde=t=>async(e,r)=>t(MG(e),dde(r)),LI=t=>(e,r)=>t(MG(e),dde(r)),pde=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?MG(e):[];return r&&n.push(tde),n},DVe=async t=>{let e=pde(t);return mde(e.length>0&&await ide(e,t))},hde=t=>{let e=pde(t);return mde(e.length>0&&ode(e,t))},mde=t=>{let e=new Set;return r=>{let n=Nh.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},gde=(t,e)=>t.flat().filter(r=>e(r)),_de=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(o=>cS(o));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let o of r)o.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},yde=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),Sde=async(t,e)=>{let r=_de(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=yde(i,n);return Promise.all(r.map(async s=>{let{patterns:a,options:c}=s;return[a,c.ignore]=await Promise.all([sde(a,o),sde(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},DG=(t,e)=>{let r=_de(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=yde(i,n);return r.map(s=>{let{patterns:a,options:c}=s;return a=ade(a,o),c.ignore=ade(c.ignore,{cwd:n}),{patterns:a,options:c}})},Ede=fde(async(t,e)=>{let[r,n]=await Promise.all([Sde(t,e),DVe(e)]),i=await Promise.all(r.map(o=>(0,kh.default)(o.patterns,o.options)));return gde(i,n)}),W1t=LI((t,e)=>{let r=DG(t,e),n=hde(e),i=r.map(o=>kh.default.sync(o.patterns,o.options));return gde(i,n)}),Y1t=LI((t,e)=>{let r=DG(t,e),n=hde(e),i=r.map(s=>kh.default.stream(s.patterns,s.options));return PG(i).filter(s=>n(s))}),K1t=LI((t,e)=>t.some(r=>kh.default.isDynamicPattern(r,e))),Z1t=fde(Sde),J1t=LI(DG),{convertPathToPattern:X1t}=kh.default;import $Ve from"process";import lS from"path";import sUt,{promises as $I}from"fs";import tUt,{promises as LVe}from"fs";async function vde(t){try{return await LVe.access(t),!0}catch{return!1}}var UVe=(t,e,r)=>(e=lS.resolve(t,e),r=lS.resolve(t,r),{sourcePath:e,destinationPath:r}),FVe=(t,e,r="Path")=>{if(!t||!e)throw new TypeError(`\`source${r}\` and \`destination${r}\` required`)},BVe=(t,e)=>{if(lS.dirname(t)!==lS.dirname(e))throw new Error("`source` and `destination` must be in the same directory")},jVe=async(t,e,{overwrite:r=!0,cwd:n=$Ve.cwd(),directoryMode:i,validateDirectory:o=!1}={})=>{if(n&&({sourcePath:t,destinationPath:e}=UVe(n,t,e)),o&&BVe(t,e),!r&&await vde(e))throw new Error(`The destination file exists: ${e}`);await $I.mkdir(lS.dirname(e),{recursive:!0,mode:i});try{await $I.rename(t,e)}catch(s){if(s.code==="EXDEV")await $I.copyFile(t,e),await $I.unlink(t);else throw s}};async function bde(t,e,r){return FVe(t,e),jVe(t,e,r)}var LG=async function(t,e,r=!1){if(r)return bde(t,e,{overwrite:!1});let{srcGlob:n,dest:i,...o}=await wde(t,xde(e));if(n&&i)return AG(n,i,{...o,overwrite:!1})},uS=async function(t){let{srcGlob:e,isDir:r,dest:n,...i}=await wde(t,"");return e!==void 0&&!await qVe(e,r,i)},qVe=async function(t,e,r){return e?(await Ede(t,r)).filter(o=>kI(Tde(o))).length===0:!1},wde=async function(t,e){let r=await VVe(t);if(r===void 0)return{srcGlob:void 0,isDir:!1,cwd:""};let n=r.isDirectory(),i=Tde(t),o=xde(t),s={srcGlob:i,dest:e,isDir:n,cwd:o,dot:!0};return n?{...s,srcGlob:`${i}/**`,dest:GVe(e,i)}:s},VVe=async t=>{try{return await zVe.stat(t)}catch{return}};import{join as B6e}from"path";import{stat as HVe,lstat as Ade,readdir as WVe,realpath as YVe}from"fs/promises";import{Readable as KVe}from"stream";import{resolve as Rde,relative as ZVe,join as JVe,sep as XVe}from"path";var On={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},$G={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:On.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze($G);var Ode="READDIRP_RECURSIVE_ERROR",QVe=new Set(["ENOENT","EPERM","EACCES","ELOOP",Ode]),Ide=[On.DIR_TYPE,On.EVERYTHING_TYPE,On.FILE_DIR_TYPE,On.FILE_TYPE],e6e=new Set([On.DIR_TYPE,On.EVERYTHING_TYPE,On.FILE_DIR_TYPE]),t6e=new Set([On.EVERYTHING_TYPE,On.FILE_DIR_TYPE,On.FILE_TYPE]),r6e=t=>QVe.has(t.code),n6e=process.platform==="win32",Cde=t=>!0,Pde=t=>{if(t===void 0)return Cde;if(typeof t=="function")return t;if(typeof t=="string"){let e=t.trim();return r=>r.basename===e}if(Array.isArray(t)){let e=t.map(r=>r.trim());return r=>e.some(n=>r.basename===n)}return Cde},UG=class extends KVe{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...$G,...e},{root:n,type:i}=r;this._fileFilter=Pde(r.fileFilter),this._directoryFilter=Pde(r.directoryFilter);let o=r.lstat?Ade:HVe;n6e?this._stat=s=>o(s,{bigint:!0}):this._stat=o,this._maxDepth=r.depth??$G.depth,this._wantsDir=i?e6e.has(i):!1,this._wantsFile=i?t6e.has(i):!1,this._wantsEverything=i===On.EVERYTHING_TYPE,this._root=Rde(n),this._isDirent=!r.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let r=this.parent,n=r&&r.files;if(n&&n.length>0){let{path:i,depth:o}=r,s=n.splice(0,e).map(c=>this._formatEntry(c,i)),a=await Promise.all(s);for(let c of a){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(o<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,o+1)),this._wantsDir&&(this.push(c),e--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let i=this.parents.pop();if(!i){this.push(null);break}if(this.parent=await i,this.destroyed)return}}}catch(r){this.destroy(r)}finally{this.reading=!1}}}async _exploreDir(e,r){let n;try{n=await WVe(e,this._rdOptions)}catch(i){this._onError(i)}return{files:n,depth:r,path:e}}async _formatEntry(e,r){let n,i=this._isDirent?e.name:e;try{let o=Rde(JVe(r,i));n={path:ZVe(this._root,o),fullPath:o,basename:i},n[this._statsProp]=this._isDirent?e:await this._stat(o)}catch(o){this._onError(o);return}return n}_onError(e){r6e(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let r=e[this._statsProp];if(r.isFile())return"file";if(r.isDirectory())return"directory";if(r&&r.isSymbolicLink()){let n=e.fullPath;try{let i=await YVe(n),o=await Ade(i);if(o.isFile())return"file";if(o.isDirectory()){let s=i.length;if(n.startsWith(i)&&n.substr(s,1)===XVe){let a=new Error(`Circular symlink detected: "${n}" points to "${i}"`);return a.code=Ode,this._onError(a)}return"directory"}}catch(i){return this._onError(i),""}}}_includeAsFile(e){let r=e&&e[this._statsProp];return r&&this._wantsEverything&&!r.isDirectory()}};function i6e(t,e={}){let r=e.entryType||e.type;if(r==="both"&&(r=On.FILE_DIR_TYPE),r&&(e.type=r),t){if(typeof t!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(r&&!Ide.includes(r))throw new Error(`readdirp: Invalid type passed. Use one of ${Ide.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new UG(e)}function Nde(t,e={}){return new Promise((r,n)=>{let i=[];i6e(t,e).on("data",o=>i.push(o)).on("end",()=>r(i)).on("error",o=>n(o))})}import{mkdir as _6e,readFile as Fde,rm as y6e,writeFile as S6e}from"fs/promises";import{existsSync as Bde}from"fs";import{dirname as E6e}from"path";var kde=t=>{if(!(!Number.isInteger(t)||t<1))return Date.now()+t*1e3},Mde=t=>t!==void 0&&Date.now()>t;import{createHash as p6e}from"crypto";import{createReadStream as h6e}from"fs";import a6e from"process";import c6e from"path";import CUt,{promises as Dde}from"fs";import{fileURLToPath as l6e}from"url";var FG=class{value;next;constructor(e){this.value=e}},dS=class{#e;#r;#t;constructor(){this.clear()}enqueue(e){let r=new FG(e);this.#e?(this.#r.next=r,this.#r=r):(this.#e=r,this.#r=r),this.#t++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#t--,this.#e||(this.#r=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#r=void 0,this.#t=0}get size(){return this.#t}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}};function UI(t){if(!((Number.isInteger(t)||t===Number.POSITIVE_INFINITY)&&t>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new dS,r=0,n=()=>{r--,e.size>0&&e.dequeue()()},i=async(a,c,l)=>{r++;let u=(async()=>a(...l))();c(u);try{await u}catch{}n()},o=(a,c,l)=>{e.enqueue(i.bind(void 0,a,c,l)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.dequeue()()))()},s=(a,...c)=>new Promise(l=>{o(a,l,c)});return Object.defineProperties(s,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),s}var FI=class extends Error{constructor(e){super(),this.value=e}},o6e=async(t,e)=>e(await t),s6e=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new FI(e[0]);return!1};async function BG(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let i=UI(r),o=[...t].map(a=>[a,i(o6e,a,e)]),s=UI(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(o.map(a=>s(s6e,a)))}catch(a){if(a instanceof FI)return a.value;throw a}}var Lde={directory:"isDirectory",file:"isFile"};function u6e(t){if(!Object.hasOwnProperty.call(Lde,t))throw new Error(`Invalid type specified: ${t}`)}var d6e=(t,e)=>e[Lde[t]](),f6e=t=>t instanceof URL?l6e(t):t;async function $de(t,{cwd:e=a6e.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:i,preserveOrder:o}={}){u6e(r),e=f6e(e);let s=n?Dde.stat:Dde.lstat;return BG(t,async a=>{try{let c=await s(c6e.resolve(e,a));return d6e(r,c)}catch{return!1}},{concurrency:i,preserveOrder:o})}var m6e="sha1",Ude=async function(t,e){if(e||t.length===0)return;let r=await $de(t);return r===void 0?void 0:await g6e(r)},g6e=async function(t){let e=h6e(t,"utf8"),r=p6e(m6e,{encoding:"hex"});return e.pipe(r),await Jd(r)};var jde=async function({cachePath:t,move:e,ttl:r,digests:n}){let i=BI(t),o=kde(r),s=await Ude(n,e),c=`${JSON.stringify({expires:o,hash:s},null,2)}
505
505
  `,l=await v6e({hash:s,manifestPath:i,manifestString:c});return{manifestInfo:{manifestPath:i,manifestString:c},identical:l}},v6e=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!Bde(e)?!1:await Fde(e,"utf8")===r},zde=async function({manifestPath:t,manifestString:e}){await _6e(E6e(t),{recursive:!0}),await S6e(t,e)},Gde=async function(t){let e=BI(t);await y6e(e,{force:!0,recursive:!0,maxRetries:3})},BI=function(t){return`${t}${Vde}`},qde=function(t){return t.endsWith(Vde)},Vde=".netlify.cache.json",jG=async function(t){let e=BI(t);if(!Bde(e))return!1;let{expires:r}=await b6e(t);return Mde(r)},b6e=async function(t){let e=BI(t),r=await Fde(e,"utf-8");return JSON.parse(r)};import{homedir as R6e}from"os";import{resolve as Hde,isAbsolute as I6e,join as C6e,sep as GG}from"path";import{normalize as T6e}from"path";import{existsSync as x6e}from"fs";import w6e from"process";var zG=function(t){try{let e=A6e(t);return x6e(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},A6e=function(t=w6e.cwd()){return T6e(t)};var fS=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await P6e(t,r),i=await M6e({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:i}},P6e=async function(t,e){let r=await zG(e),n=O6e(t,r);return N6e(n,r),n},O6e=function(t,e){if(I6e(t))return Hde(t);if(e!=="")return Hde(e,t);throw new Error(`Current directory does not exist: ${e}`)},N6e=function(t,e){if(e!==""&&k6e(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},k6e=function(t,e){return`${e}${GG}`.startsWith(`${t}${GG}`)},M6e=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=bu({cacheDir:e,cwd:r}),{name:i,relPath:o}=await D6e(t,r);return C6e(n,i,o)},D6e=async function(t,e){let r=await qG(e),n=L6e(t);return r.map(({name:i,base:o})=>U6e(i,o,n)).find(Boolean)},L6e=function(t){return t.replace($6e,"\\")},$6e=/^[a-zA-Z]:\\/,U6e=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},qG=async function(t){return[...await F6e(t),{name:"home",base:R6e()},{name:"root",base:GG}]},F6e=async function(t){let e=await zG(t);return e===""?[]:[{name:"cwd",base:e}]};var j6e=1,VG=async function({cacheDir:t,cwd:e,depth:r=j6e}={}){let n=await qG(e),i=bu({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>z6e({name:a,base:c,cacheDir:i,depth:r})))).flat()},z6e=async function({name:t,base:e,cacheDir:r,depth:n}){return(await Nde(`${r}/${t}`,{fileFilter:G6e,depth:n,type:"files_directories"})).map(({path:s})=>B6e(e,s))},G6e=function({basename:t}){return!qde(t)};var q6e=async function(t,{move:e=Wde,ttl:r=Y6e,digests:n=[],cacheDir:i,cwd:o}={}){let{srcPath:s,cachePath:a}=await fS({path:t,cacheDir:i,cwdOpt:o});if(!await uS(s))return!1;let{manifestInfo:c,identical:l}=await jde({cachePath:a,move:e,ttl:r,digests:n});return l||(await HG(a,{force:!0,recursive:!0,maxRetries:3}),await LG(s,a,e),await zde(c)),!0},V6e=async function(t,{move:e=Wde,cacheDir:r,cwd:n}={}){let{srcPath:i,cachePath:o}=await fS({path:t,cacheDir:r,cwdOpt:n});return!await uS(o)||await jG(o)?!1:(await HG(i,{force:!0,recursive:!0,maxRetries:3}),await LG(o,i,e),!0)},H6e=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await fS({path:t,cacheDir:e,cwdOpt:r});return await uS(n)?(await HG(n,{force:!0,recursive:!0,maxRetries:3}),await Gde(n),!0):!1},W6e=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await fS({path:t,cacheDir:e,cwdOpt:r});return await uS(n)&&!await jG(n)},Wde=!1,Y6e=void 0,jI=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(i=>t(i,...r)))).some(Boolean):t(e,...r)},K6e=jI.bind(null,q6e),Z6e=jI.bind(null,V6e),J6e=jI.bind(null,H6e),X6e=jI.bind(null,W6e),Yde=function(t){return{save:(e,r)=>K6e(e,{...t,...r}),restore:(e,r)=>Z6e(e,{...t,...r}),remove:(e,r)=>J6e(e,{...t,...r}),has:(e,r)=>X6e(e,{...t,...r}),list:e=>VG({...t,...e}),getCacheDir:e=>bu({...t,...e})}};var rr=ye("native_session"),WG=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await Ks.stat(Zs.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),Cu=async({runnerId:t,sessionId:e,archive:r,nativeSessionId:n})=>{if(!r)return rr.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:i,include:o}=r,s=!1;try{s=(await Ks.stat(i)).isDirectory()}catch{}if(!s)return rr.log(`Native session base dir ${i} not found, skipping`),null;let a=await WG(i,o);if(a.length===0)return rr.log(`No native session history found under ${i}, skipping`),null;let c=Zs.join(Kde.tmpdir(),`native-session-${e}.zip`);try{await cr("zip",["-r","-q","-X",c,...a],{cwd:i});let l=await Ks.readFile(c);rr.log(`Zipped native session (${l.length} bytes) from ${a.join(", ")}`,{nativeSessionId:n});let{upload_url:u,s3_key:d}=await f9(t,e);return await Kg(u,l,{contentType:"application/zip"}),rr.log("Successfully uploaded native session to S3"),d}catch(l){return rr.error("Failed to archive/upload native session, continuing without it:",l),null}finally{await Ks.rm(c,{force:!0}).catch(()=>{})}},Zde=async t=>{if(!t)return!1;let{baseDir:e,include:r}=t,n=await WG(e,r);for(let i of n)if((await Ks.readdir(Zs.join(e,i)).catch(()=>[])).length>0)return!0;return!1},Q6e=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Jde=async(t,e)=>{let r=await Ks.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await Jde(Zs.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},Xde=async(t,e)=>{if(!t||!e)return!1;let r=new RegExp(`(^|[^a-zA-Z0-9])${Q6e(e)}([^a-zA-Z0-9]|$)`),{baseDir:n,include:i}=t,o=await WG(n,i);for(let s of o)if(await Jde(Zs.join(n,s),r))return!0;return!1},Qde=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return rr.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,i=Zs.join(Kde.tmpdir(),`native-session-restore-${e}.zip`);try{let o=await p9(t,e);if(!o?.download_url)return rr.log("No native session available to restore, skipping"),!1;let s=await E9(o.download_url);return await Ks.writeFile(i,s),rr.log(`Downloaded native session (${s.length} bytes) to ${i}`),await Ks.mkdir(n,{recursive:!0}),await cr("unzip",["-o","-q",i,"-d",n]),rr.log(`Restored native session into ${n}`),!0}catch(o){return rr.error("Failed to fetch/restore native session, continuing without it:",o),!1}finally{await Ks.rm(i,{force:!0}).catch(()=>{})}},eHe="native-sessions",efe=(t,e)=>Yde({cacheDir:Zs.join(e.dir,eHe),cwd:t}),tfe=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await efe(r,e).restore(n.map(o=>Zs.join(r,o)),{})?(rr.log(`Restored native session from buildbot cache into ${r}`),!0):(rr.log("No native session in buildbot cache, skipping restore"),!1)}catch(i){return rr.error("Failed to restore native session from buildbot cache, continuing without it:",i),!1}},Mh=async({archive:t,cache:e,nativeSessionId:r})=>{if(!e?.dir||!t)return rr.log("No buildbot cache configured for the native session, skipping cache seed",{nativeSessionId:r}),!1;let{baseDir:n,include:i}=t;try{return await efe(n,e).save(i.map(s=>Zs.join(n,s)),{})?(rr.log(`Saved native session to buildbot cache under ${e.dir}`,{nativeSessionId:r}),!0):(rr.log("No native session history to save to buildbot cache, skipping"),!1)}catch(o){return rr.error("Failed to save native session to buildbot cache, continuing:",o),!1}};var Dh=ye("inference_stage"),rfe=5,Uo=async t=>{let{additionalContext:e,cliPath:r,config:n,context:i,buildErrors:o,runner:s,persistSteps:a,aiGateway:c,attempt:l,contextPrefix:u,priorAgentSessionId:d,cwd:f,abortSignal:p,onSessionId:h,resumeSession:m,effortOverride:S,answerFold:E}=t;if(yo())throw new Error("Shutdown in progress, aborting inference stage");Dh.log(`Running inference stage, attempt ${l} of ${rfe}`);let T=!1,x=await ft(qe(),"inference-stage",async _=>{_?.setAttributes({"inference.attempt":l||1}),K5();let A=!!(l&&l>1),R=await tHe(n,A),P=!!m&&!!d;P&&n.runner==="gemini"&&!await Hy(d)&&(P=!1);let C=R.viable||P;T=C,R.outcome!=="not_eligible"&&fe.inc("inference.native_resume",1,{outcome:R.outcome,...R.source?{source:R.source}:{}});let M=n;if("prompt"in n&&n.answeredInteraction&&We().questionsEnabled){let v=n.answeredInteraction,w=C||A&&!!d,W=[v];if(!w){E.allAnswered??=qse(n);let G=await E.allAnswered;G===null&&(E.allAnswered=void 0),G&&G.length>0&&(W=G.some(ce=>ce.refId===v.refId)?G:[...G,v])}M={...n,prompt:Hse(n.prompt,W)},!A&&!E.counted&&(E.counted=!0,Dh.log("Resuming session with answered questions",{sessionId:n.sessionId,interactionCount:W.length}),fe.inc("inference.answer_resume",1,{fold:w?"latest":"all"}))}let{prompt:F}=await ft(qe(),"compose-prompt",async()=>await Mse({cliPath:r,config:M,buildErrorContext:rHe(o),netlify:i,additionalContext:e,resumePrompt:C})),y=`