@netlify/agent-runner-cli 1.191.0 → 1.191.1

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
@@ -143,7 +143,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
143
143
  `,LF:`
144
144
  `,concatBytes:qU},fVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},pVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:fVe};import{Buffer as hVe}from"buffer";var Uae=(t,e)=>t?void 0:mVe.bind(void 0,e),mVe=function*(t,e){if(typeof e!="string"&&!dr(e)&&!hVe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Fae=(t,e)=>t?gVe.bind(void 0,e):_Ve.bind(void 0,e),gVe=function*(t,e){zae(t,e),yield e},_Ve=function*(t,e){if(zae(t,e),typeof e!="string"&&!dr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},zae=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
145
145
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
146
- if (condition) { yield value; }`)};import{Buffer as yVe}from"buffer";import{StringDecoder as SVe}from"string_decoder";var $R=(t,e,r)=>{if(r)return;if(t)return{transform:EVe.bind(void 0,new TextEncoder)};let n=new SVe(e);return{transform:vVe.bind(void 0,n),final:TVe.bind(void 0,n)}},EVe=function*(t,e){yVe.isBuffer(e)?yield _a(e):typeof e=="string"?yield t.encode(e):yield e},vVe=function*(t,e){yield dr(e)?t.write(e):e},TVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as jae}from"util";var VU=jae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),LR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=wVe}=e[r];for await(let i of n(t))yield*LR(i,e,r+1)},Bae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*bVe(r,Number(e),t)},bVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*LR(n,r,e+1)},qae=jae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),wVe=function*(t){yield t};var HU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Gae=(t,e)=>[...e.flatMap(r=>[...Gu(r,t,0)]),...Qy(t)],Gu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=xVe}=e[r];for(let i of n(t))yield*Gu(i,e,r+1)},Qy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*AVe(r,Number(e),t)},AVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Gu(n,r,e+1)},xVe=function*(t){yield t};var WU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Hae(t,s,o),l=qu(e),u=qu(r),d=l?VU.bind(void 0,LR,a):HU.bind(void 0,Gu),f=l||u?VU.bind(void 0,Bae,a):HU.bind(void 0,Qy),p=l||u?qae.bind(void 0,a):void 0;return{stream:new RVe({writableObjectMode:n,writableHighWaterMark:Vae(n),readableObjectMode:i,readableHighWaterMark:Vae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},UR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Hae(s,r,a);t=Gae(c,t)}return t},Hae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Uae(n,a)},$R(r,s,n),DR(r,o,n,c),{transform:t,final:e},{transform:Fae(i,a)},Lae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Wae=(t,e)=>{for(let r of CVe(t))IVe(t,r,e)},CVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),IVe=(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 ${Lc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>PVe(a,n));r.input=qy(s)},PVe=(t,e)=>{let r=UR(t,e,"utf8",!0);return OVe(r),qy(r)},OVe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as DVe,appendFileSync as $Ve}from"fs";var FR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Dp(r,n)&&!ii.has(e)&&NVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&kVe.has(o))||t.every(({type:i})=>ki.has(i))),NVe=t=>t===1||t===2,kVe=new Set(["pipe","overlapped"]),Yae=async(t,e,r,n)=>{for await(let i of t)MVe(e)||Zae(i,r,n)},Kae=(t,e,r)=>{for(let n of t)Zae(n,e,r)},MVe=t=>t._readableState.pipes.length>0,Zae=(t,e,r)=>{let n=Qx(t);us({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Jae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>LVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},LVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Xse(t,o,d),p=_a(f),{stdioItems:h,objectMode:m}=e[r],g=UVe([p],h,c,n),{serializedResult:_,finalResult:v=_}=FVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});zVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?v:void 0;try{return n.error===void 0&&jVe(_,h,i),T}catch(y){return n.error=y,T}},UVe=(t,e,r,n)=>{try{return UR(t,e,r,!1)}catch(i){return n.error=i,t}},FVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qy(t)};let s=fie(t,r);return n[o]?{serializedResult:s,finalResult:GU(s,!i[o],e)}:{serializedResult:s}},zVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!FR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=GU(t,!1,s);try{Kae(a,e,n)}catch(c){r.error??=c}},jVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>kR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?$Ve(n,t):(r.add(o),DVe(n,t))}};var Xae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ea(e,r,"all")]:Array.isArray(e)?[Ea(t,r,"all"),...e]:dr(t)&&dr(e)?Q1([t,e]):`${t}${e}`};import{once as YU}from"events";var Qae=async(t,e)=>{let[r,n]=await BVe(t);return e.isForcefullyTerminated??=!1,[r,n]},BVe=async t=>{let[e,r]=await Promise.allSettled([YU(t,"spawn"),YU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?ece(t):r.value},ece=async t=>{try{return await YU(t,"exit")}catch{return ece(t)}},tce=async t=>{let[e,r]=await t;if(!qVe(e,r)&&KU(e,r))throw new ho;return[e,r]},qVe=(t,e)=>t===void 0&&e===void 0,KU=(t,e)=>t!==0||e!==null;var rce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=GVe(t,e,r),s=o?.code==="ETIMEDOUT",a=Jse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},GVe=(t,e,r)=>t!==void 0?t:KU(e,r)?new ho:void 0;var nce=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=HVe(t,e,r),d=KVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Vp(d,c,l)},HVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),a=WVe(r),{file:c,commandArguments:l,options:u}=vR(t,e,a);YVe(u);let d=kae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},WVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,YVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&zR("ipcInput"),t&&zR("ipc: true"),r&&zR("detached: true"),n&&zR("cancelSignal")},zR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},KVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=ZVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=rce(c,r),{output:h,error:m=l}=Jae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,T)=>Ea(v,r,T)),_=Ea(Xae(h,r),r,"all");return XVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},ZVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Wae(o,r);let a=JVe(r);return VVe(...TR(t,e,a))}catch(a){return Gp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},JVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:IR(e)}),XVe=({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?PR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Xy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as FHe}from"events";import{spawn as zHe}from"child_process";import cce from"process";import{once as ZU,on as QVe}from"events";var ice=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Up({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),e4e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),e4e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{dR(e,i);let o=$c(t,e,r),s=new AbortController;try{return await Promise.race([t4e(o,n,s),r4e(o,r,s),n4e(o,r,s)])}catch(a){throw Fp(t),a}finally{s.abort(),fR(e,i)}},t4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await ZU(t,"message",{signal:r});return n}for await(let[n]of QVe(t,"message",{signal:r}))if(e(n))return n},r4e=async(t,e,{signal:r})=>{await ZU(t,"disconnect",{signal:r}),Goe(e)},n4e=async(t,e,{signal:r})=>{let[n]=await ZU(t,"strict:error",{signal:r});throw cR(n,e)};import{once as sce,on as i4e}from"events";var ace=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>JU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),JU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Up({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),dR(e,o);let s=$c(t,e,r),a=new AbortController,c={};return o4e(t,s,a),s4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),a4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},o4e=async(t,e,r)=>{try{await sce(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},s4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await sce(t,"strict:error",{signal:r.signal});n.error=cR(i,e),r.abort()}catch{}},a4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of i4e(r,"message",{signal:o.signal}))oce(s),yield c}catch{oce(s)}finally{o.abort(),fR(e,a),n||Fp(t),i&&await t}},oce=({error:t})=>{if(t)throw t};var lce=(t,{ipc:e})=>{Object.assign(t,dce(t,!1,e))},uce=()=>{let t=cce,e=!0,r=cce.channel!==void 0;return{...dce(t,e,r),getCancelSignal:_se.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},dce=(t,e,r)=>({sendMessage:SR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ice.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ace.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as c4e}from"child_process";import{PassThrough as l4e,Readable as u4e,Writable as d4e,Duplex as f4e}from"stream";var fce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{jU(n);let a=new c4e;p4e(a,n),Object.assign(a,{readable:h4e,writable:m4e,duplex:g4e});let c=Gp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=_4e(c,s,i);return{subprocess:a,promise:l}},p4e=(t,e)=>{let r=eS(),n=eS(),i=eS(),o=Array.from({length:e.length-3},eS),s=eS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},eS=()=>{let t=new l4e;return t.end(),t},h4e=()=>new u4e({read(){}}),m4e=()=>new d4e({write(){}}),g4e=()=>new f4e({read(){},write(){}}),_4e=async(t,e,r)=>Vp(t,e,r);import{createReadStream as pce,createWriteStream as hce}from"fs";import{Buffer as y4e}from"buffer";import{Readable as tS,Writable as S4e,Duplex as E4e}from"stream";var gce=(t,e)=>MR(v4e,t,e,!1),rS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Lc[t]}.`)},mce={fileNumber:rS,generator:WU,asyncGenerator:WU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:E4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},v4e={input:{...mce,fileUrl:({value:t})=>({stream:pce(t)}),filePath:({value:{file:t}})=>({stream:pce(t)}),webStream:({value:t})=>({stream:tS.fromWeb(t)}),iterable:({value:t})=>({stream:tS.from(t)}),asyncIterable:({value:t})=>({stream:tS.from(t)}),string:({value:t})=>({stream:tS.from(t)}),uint8Array:({value:t})=>({stream:tS.from(y4e.from(t))})},output:{...mce,fileUrl:({value:t})=>({stream:hce(t)}),filePath:({value:{file:t,append:e}})=>({stream:hce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:S4e.fromWeb(t)}),iterable:rS,asyncIterable:rS,string:rS,uint8Array:rS}};import{on as T4e,once as _ce}from"events";import{PassThrough as b4e,getDefaultHighWaterMark as w4e}from"stream";import{finished as Ece}from"stream/promises";function Vu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)QU(i);let e=t.some(({readableObjectMode:i})=>i),r=A4e(t,e),n=new XU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var A4e=(t,e)=>{if(t.length===0)return w4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},XU=class extends b4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(QU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=x4e(this,this.#e,this.#o);let r=I4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(QU(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},x4e=async(t,e,r)=>{jR(t,yce);let n=new AbortController;try{await Promise.race([R4e(t,n),C4e(t,e,r,n)])}finally{n.abort(),jR(t,-yce)}},R4e=async(t,{signal:e})=>{try{await Ece(t,{signal:e,cleanup:!0})}catch(r){throw vce(t,r),r}},C4e=async(t,e,r,{signal:n})=>{for await(let[i]of T4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},QU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},I4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{jR(t,Sce);let a=new AbortController;try{await Promise.race([P4e(o,e,a),O4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),N4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),jR(t,-Sce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?eF(t):k4e(t))},P4e=async(t,e,{signal:r})=>{try{await t,r.aborted||eF(e)}catch(n){r.aborted||vce(e,n)}},O4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Ece(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Tce(s)?i.add(e):bce(t,s)}},N4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await _ce(t,i,{signal:o}),!t.readable)return _ce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},k4e=t=>{t.writable&&t.end()},vce=(t,e)=>{Tce(e)?eF(t):bce(t,e)},Tce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",eF=t=>{(t.readable||t.writable)&&t.destroy()},bce=(t,e)=>{t.destroyed||(t.once("error",M4e),t.destroy(e))},M4e=()=>{},jR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},yce=2,Sce=1;import{finished as wce}from"stream/promises";var Wp=(t,e)=>{t.pipe(e),D4e(t,e),$4e(t,e)},D4e=async(t,e)=>{if(!(po(t)||po(e))){try{await wce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}tF(e)}},tF=t=>{t.writable&&t.end()},$4e=async(t,e)=>{if(!(po(t)||po(e))){try{await wce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rF(t)}},rF=t=>{t.readable&&t.destroy()};var Ace=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>ki.has(c)))L4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ki.has(c)))F4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Vu(o);Wp(s,i)}},L4e=(t,e,r,n)=>{r==="output"?Wp(t.stdio[n],e):Wp(e,t.stdio[n]);let i=U4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},U4e=["stdin","stdout","stderr"],F4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;z4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},z4e=(t,{signal:e})=>{po(t)&&ju(t,j4e,e)},j4e=2;import{addAbortListener as G4e}from"events";var Hu=[];Hu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Hu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Hu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var BR=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",nF=Symbol.for("signal-exit emitter"),iF=globalThis,B4e=Object.defineProperty.bind(Object),oF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(iF[nF])return iF[nF];B4e(iF,nF,{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}},qR=class{},q4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),sF=class extends qR{onExit(){return()=>{}}load(){}unload(){}},aF=class extends qR{#e=cF.platform==="win32"?"SIGINT":"SIGHUP";#r=new oF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Hu)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(!BR(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 Hu)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,Hu.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 BR(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"&&BR(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)}},cF=globalThis.process,{onExit:xce,load:g1t,unload:_1t}=q4e(BR(cF)?new aF(cF):new sF);var Rce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=xce(()=>{t.kill()});G4e(n,()=>{i()})};var Ice=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=eR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=V4e(r,n,i),{sourceStream:d,sourceError:f}=W4e(t,l),{options:p,fileDescriptors:h}=fs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},V4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=H4e(t,e,...r),a=uR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},H4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Cce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||J1(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]=Gx(r,...n);return{destination:e(Cce)(i,o,s),pipeOptions:s}}if(fs.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Cce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),W4e=(t,e)=>{try{return{sourceStream:zp(t,e)}}catch(r){return{sourceError:r}}};var Oce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Y4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw lF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Y4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return rF(t),n;if(e!==void 0)return tF(r),e},lF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Gp({error:t,command:Pce,escapedCommand:Pce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Pce="source.pipe(destination)";var Nce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as K4e}from"stream/promises";var kce=(t,e,r)=>{let n=GR.has(e)?J4e(t,e):Z4e(t,e);return ju(t,Q4e,r.signal),ju(e,eHe,r.signal),X4e(e),n},Z4e=(t,e)=>{let r=Vu([t]);return Wp(r,e),GR.set(e,r),r},J4e=(t,e)=>{let r=GR.get(e);return r.add(t),r},X4e=async t=>{try{await K4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}GR.delete(t)},GR=new WeakMap,Q4e=2,eHe=1;import{aborted as tHe}from"util";var Mce=(t,e)=>t===void 0?[]:[rHe(t,e)],rHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await tHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw lF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var VR=(t,...e)=>{if(Jt(e[0]))return VR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Ice(t,...e),i=nHe({...n,destination:r});return i.pipe=VR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},nHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=iHe(t,i);Oce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=kce(e,o,d);return await Promise.race([Nce(u),...Mce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},iHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as dHe}from"timers/promises";import{on as oHe}from"events";import{getDefaultHighWaterMark as sHe}from"stream";var HR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return aHe(e,s),$ce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},aHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},uF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;cHe(e,s,t);let a=t.readableObjectMode&&!o;return $ce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},cHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},$ce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=oHe(t,"data",{signal:e.signal,highWaterMark:Dce,highWatermark:Dce});return lHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},dF=sHe(!0),Dce=dF,lHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=uHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Gu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Qy(a)}},uHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[$R(t,r,!e),DR(t,i,!n,{})].filter(Boolean);var Lce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=fHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([pHe(t),d]);return}let f=BU(c,r),p=uF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([hHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},fHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!FR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=uF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Yae(a,t,r,o)},pHe=async t=>{await dHe(),t.readableFlowing===null&&t.resume()},hHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await xR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await RR(r,{maxBuffer:o})):await qp(r,{maxBuffer:o})}catch(a){return Uce(Yse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},fF=async t=>{try{return await t}catch(e){return Uce(e)}},Uce=({bufferedData:t})=>uie(t)?new Uint8Array(t):t;import{finished as mHe}from"stream/promises";var nS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=gHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],mHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||SHe(a,e,r,n)}finally{s.abort()}},gHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&_He(t,r,n),n},_He=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{yHe(e,r),n.call(t,...i)}},yHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},SHe=(t,e,r,n)=>{if(!EHe(t,e,r,n))throw t},EHe=(t,e,r,n=!0)=>r.propagating?Fce(t)||WR(t):(r.propagating=!0,pF(r,e)===n?Fce(t):WR(t)),pF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",WR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Fce=t=>t?.code==="EPIPE";var zce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>hF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),hF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=nS(t,e,l);if(pF(l,e)){await u;return}let[d]=await Promise.all([Lce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var jce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Vu([t,e].filter(Boolean)):void 0,Bce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>hF({...vHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:THe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),vHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},THe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as bHe}from"events";var qce=t=>Dp(t,"ipc"),Gce=(t,e)=>{let r=Qx(t);us({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Vce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=qce(o),a=ya(e,"ipc"),c=ya(r,"ipc");for await(let l of JU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Kse(t,i,c),i.push(l)),s&&Gce(l,o);return i},Hce=async(t,e)=>(await Promise.allSettled([t]),e);var Wce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let v=Qae(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},y=zce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=Bce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),A=[],R=Vce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),I=wHe(m,t,T),N=AHe(h,T);try{return await Promise.race([Promise.all([{},tce(v),Promise.all(y),w,R,Rse(t,d),...I,...N]),g,xHe(t,_),...Tse(t,o,f,_),...qoe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Ese({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},v,Promise.all(y.map(b=>fF(b))),fF(w),Hce(R,A),Promise.allSettled(I),Promise.allSettled(N)])}},wHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:nS(n,i,r)),AHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>go(o,{checkOpen:!1})&&!po(o)).map(({type:i,value:o,stream:s=o})=>nS(s,n,e,{isSameDirection:ki.has(i),stopOnExit:i==="native"}))),xHe=async(t,{signal:e})=>{let[r]=await bHe(t,"error",{signal:e});throw r};var Yce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),iS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ds();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Yp=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as RHe}from"stream";import{callbackify as CHe}from"util";import{finished as Kce}from"stream/promises";var mF=async t=>{if(t!==void 0)try{await gF(t)}catch{}},Zce=async t=>{if(t!==void 0)try{await _F(t)}catch{}},gF=async t=>{await Kce(t,{cleanup:!0,readable:!1,writable:!0})},_F=async t=>{await Kce(t,{cleanup:!0,readable:!0,writable:!1})},YR=async(t,e)=>{if(await t,e)throw e},KR=(t,e,r)=>{r&&!WR(r)?t.destroy(r):e&&t.destroy()};var Jce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ii.has(r),{subprocessStdout:a,waitReadableDestroy:c}=yF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=SF(a,s),{read:f,onStdoutDataDone:p}=EF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new RHe({read:f,destroy:CHe(TF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return vF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},yF=(t,e,r)=>{let n=zp(t,e),i=iS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},SF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:dF},EF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ds(),s=HR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){IHe(this,s,o)},onStdoutDataDone:o}},IHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},vF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await _F(t),await n,await mF(i),await e,r.readable&&r.push(null)}catch(o){await mF(i),Xce(r,o)}},TF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Yp(r,e)&&(Xce(t,n),await YR(e,n))},Xce=(t,e)=>{KR(t,t.readable,e)};import{Writable as PHe}from"stream";import{callbackify as Qce}from"util";var ele=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=bF(t,r,e),s=new PHe({...wF(n,t,i),destroy:Qce(xF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return AF(n,s),s},bF=(t,e,r)=>{let n=uR(t,e),i=iS(r,n,"writableFinal"),o=iS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},wF=(t,e,r)=>({write:OHe.bind(void 0,t),final:Qce(NHe.bind(void 0,t,e,r))}),OHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},NHe=async(t,e,r)=>{await Yp(r,e)&&(t.writable&&t.end(),await e)},AF=async(t,e,r)=>{try{await gF(t),e.writable&&e.end()}catch(n){await Zce(r),tle(e,n)}},xF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Yp(r,e),await Yp(n,e)&&(tle(t,i),await YR(e,i))},tle=(t,e)=>{KR(t,t.writable,e)};import{Duplex as kHe}from"stream";import{callbackify as MHe}from"util";var rle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ii.has(r),{subprocessStdout:c,waitReadableDestroy:l}=yF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=bF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=SF(c,a),{read:g,onStdoutDataDone:_}=EF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new kHe({read:g,...wF(u,t,d),destroy:MHe(DHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return vF({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:t,subprocessStdin:u}),AF(u,v,c),v},DHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([TF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),xF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var RF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ii.has(e),s=zp(t,r),a=HR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return $He(a,s,t)},$He=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var nle=(t,{encoding:e})=>{let r=Yce();t.readable=Jce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=ele.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=rle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=RF.bind(void 0,t,e),t[Symbol.asyncIterator]=RF.bind(void 0,t,e,{})};var ile=(t,e)=>{for(let[r,n]of UHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},LHe=(async()=>{})().constructor.prototype,UHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(LHe,t)]);var ole=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=jHe(t,e,r),{subprocess:f,promise:p}=qHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=VR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ile(f,p),fs.set(f,{options:u,fileDescriptors:d}),f},jHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),{file:a,commandArguments:c,options:l}=vR(t,e,r),u=BHe(l),d=gce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},BHe=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},qHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=zHe(...TR(t,e,r))}catch(h){return fce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;FHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ace(c,a,l),Rce(c,r,l);let d={},f=ds();c.kill=joe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=jce(c,r),nle(c,r),lce(c,r);let p=GHe({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}},GHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Wce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((y,w)=>Ea(y,e,w)),v=Ea(m,e,"all"),T=VHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Vp(T,n,e)},VHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Xy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ps,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):PR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var ZR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,HHe(n,t[n],i)]));return{...t,...r}},HHe=(t,e,r)=>WHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,WHe=new Set(["env",...nU]);var Uc=(t,e,r,n)=>{let i=(s,a,c)=>Uc(s,a,r,c),o=(...s)=>YHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},YHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,ZR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=KHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?nce(a,c,l):ole(a,c,l,i)},KHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=gie(e)?_ie(e,r):[e,...r],[s,a,c]=Gx(...o),l=ZR(ZR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var sle=({file:t,commandArguments:e})=>cle(t,e),ale=({file:t,commandArguments:e})=>({...cle(t,e),isSync:!0}),cle=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=ZHe(t);return{file:r,commandArguments:n}},ZHe=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(JHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},JHe=/ +/g;var lle=(t,e,r)=>{t.sync=e(XHe,r),t.s=t.sync},ule=({options:t})=>dle(t),XHe=({options:t})=>({...dle(t),isSync:!0}),dle=t=>({options:{...QHe(t),...t}}),QHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},fle={preferLocal:!0};var ple=Uc(()=>({})),szt=Uc(()=>({isSync:!0})),hle=Uc(sle),azt=Uc(ale),czt=Uc(wse),lzt=Uc(ule,{},fle,lle),{sendMessage:uzt,getOneMessage:dzt,getEachMessage:fzt,getCancelSignal:pzt}=uce();var mle=!1,gle,e6e=t=>{gle??=t},_le=t=>{mle=!0,e6e(t)},oi=()=>mle,Fc=()=>gle,yle=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var oS=null,Sle=t=>(oS&&oS.destroy(),oS=new _o({totalAllowedTime:t}),oS),Ele=()=>oS;var _o=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&oi())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 kx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{q.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),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 vle={name:"@netlify/agent-runner-cli",type:"module",version:"1.191.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.19.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var i6e=r6e(import.meta.url),o6e=va.dirname(i6e),s6e=n6e(import.meta.url),Kp=oe("shell"),CF=new Set,Tle={preferLocal:!0},It=(t,e,r)=>{let[n,i]=a6e(e,r),o={...Tle,...i},s=ple(t,n,o);wle(s,o),Rle(s);let a=r?.idleTimeout;return a&&a>0&&xle(s,a),s},ble=(t,e)=>{let r={...Tle,...e},n=hle(t,r);return wle(n,r),Rle(n),e?.idleTimeout&&e.idleTimeout>0&&xle(n,e.idleTimeout),n},a6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},wle=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ms.env.NETLIFY_LOCAL_QUIET==="true")return;if(ms.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new My).pipe(ms.stdout),t.stderr?.pipe(new My).pipe(ms.stderr);return}t.stdout?.pipe(ms.stdout),t.stderr?.pipe(ms.stderr)},IF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ms.kill(-t.pid,e),Kp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Kp.error("Error killing process:",r),!1}},Ale=t=>IF(t,"SIGKILL"),xle=(t,e)=>{let r=null,n=()=>{Kp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing idle process ${t.pid}`),Ale(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)},Rle=t=>{CF.add(t);let e=Ele();if(e){let r=e.onTimesUp(()=>{Kp.log(`Global timer expired, killing process ${t.pid}`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing process ${t.pid} after timeout`),Ale(t))},5e3)});t.on("exit",()=>{CF.delete(t),r()}),t.on("error",()=>{CF.delete(t),r()})}};function XR(t,e){return!!yo(t,e)}function yo(t,e){if(!ms.env.NETLIFY_LOCAL_MODE)try{let i=s6e.resolve(vle.name),o=va.dirname(i);for(;o!==va.dirname(o);){let s=va.dirname(o);if(va.basename(s)==="node_modules"){let a=va.join(s,".bin",e);if(JR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ms.env.NODE_PATH){let i=va.join(ms.env.NODE_PATH,".bin",e);if(JR.existsSync(i))return i}let r=va.join(t,"node_modules",".bin",e);if(JR.existsSync(r))return r;let n=va.join(o6e,"..","node_modules",".bin",e);if(JR.existsSync(n))return n}var Cle=oe("repo"),Nle="runner-diffs-",tC=t=>`${Nle}${t}-`,kle=async t=>{let e=Ole.tmpdir(),r;try{r=await QR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Nle)&&!n.startsWith(tC(t))).map(n=>QR.rm(eC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>It("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),rC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Cle.info("Getting runner diffs");let n=await kF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=MF(o);await m6e(l,r)}Cle.info("Changes after processing"),await NF(r);let s=await aS(o,r);if(await OF(s,r),i=await f6e(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await QR.mkdtemp(eC.join(Ole.tmpdir(),tC(t.sessionId))),c=await PF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await u6e(r),c.hasChanges&&q.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},PF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=eC.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:v}=await QR.stat(g);return{path:g,size:v}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Ple(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Ple(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Ile=async t=>{let e=c6e("sha256");for await(let r of l6e(t))e.update(r);return e.digest("hex")},Ple=async(t,e)=>t.size===e.size&&await Ile(t.path)===await Ile(e.path),u6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},OF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},NF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},Mle=/.. (.+)?\.log$/,d6e=[Mle],kF=async(t=process.cwd())=>{let e=await NF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
146
+ if (condition) { yield value; }`)};import{Buffer as yVe}from"buffer";import{StringDecoder as SVe}from"string_decoder";var $R=(t,e,r)=>{if(r)return;if(t)return{transform:EVe.bind(void 0,new TextEncoder)};let n=new SVe(e);return{transform:vVe.bind(void 0,n),final:TVe.bind(void 0,n)}},EVe=function*(t,e){yVe.isBuffer(e)?yield _a(e):typeof e=="string"?yield t.encode(e):yield e},vVe=function*(t,e){yield dr(e)?t.write(e):e},TVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as jae}from"util";var VU=jae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),LR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=wVe}=e[r];for await(let i of n(t))yield*LR(i,e,r+1)},Bae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*bVe(r,Number(e),t)},bVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*LR(n,r,e+1)},qae=jae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),wVe=function*(t){yield t};var HU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Gae=(t,e)=>[...e.flatMap(r=>[...Gu(r,t,0)]),...Qy(t)],Gu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=xVe}=e[r];for(let i of n(t))yield*Gu(i,e,r+1)},Qy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*AVe(r,Number(e),t)},AVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Gu(n,r,e+1)},xVe=function*(t){yield t};var WU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Hae(t,s,o),l=qu(e),u=qu(r),d=l?VU.bind(void 0,LR,a):HU.bind(void 0,Gu),f=l||u?VU.bind(void 0,Bae,a):HU.bind(void 0,Qy),p=l||u?qae.bind(void 0,a):void 0;return{stream:new RVe({writableObjectMode:n,writableHighWaterMark:Vae(n),readableObjectMode:i,readableHighWaterMark:Vae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},UR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Hae(s,r,a);t=Gae(c,t)}return t},Hae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Uae(n,a)},$R(r,s,n),DR(r,o,n,c),{transform:t,final:e},{transform:Fae(i,a)},Lae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Wae=(t,e)=>{for(let r of CVe(t))IVe(t,r,e)},CVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),IVe=(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 ${Lc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>PVe(a,n));r.input=qy(s)},PVe=(t,e)=>{let r=UR(t,e,"utf8",!0);return OVe(r),qy(r)},OVe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as DVe,appendFileSync as $Ve}from"fs";var FR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Dp(r,n)&&!ii.has(e)&&NVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&kVe.has(o))||t.every(({type:i})=>ki.has(i))),NVe=t=>t===1||t===2,kVe=new Set(["pipe","overlapped"]),Yae=async(t,e,r,n)=>{for await(let i of t)MVe(e)||Zae(i,r,n)},Kae=(t,e,r)=>{for(let n of t)Zae(n,e,r)},MVe=t=>t._readableState.pipes.length>0,Zae=(t,e,r)=>{let n=Qx(t);us({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Jae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>LVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},LVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Xse(t,o,d),p=_a(f),{stdioItems:h,objectMode:m}=e[r],g=UVe([p],h,c,n),{serializedResult:_,finalResult:v=_}=FVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});zVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?v:void 0;try{return n.error===void 0&&jVe(_,h,i),T}catch(y){return n.error=y,T}},UVe=(t,e,r,n)=>{try{return UR(t,e,r,!1)}catch(i){return n.error=i,t}},FVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qy(t)};let s=fie(t,r);return n[o]?{serializedResult:s,finalResult:GU(s,!i[o],e)}:{serializedResult:s}},zVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!FR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=GU(t,!1,s);try{Kae(a,e,n)}catch(c){r.error??=c}},jVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>kR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?$Ve(n,t):(r.add(o),DVe(n,t))}};var Xae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ea(e,r,"all")]:Array.isArray(e)?[Ea(t,r,"all"),...e]:dr(t)&&dr(e)?Q1([t,e]):`${t}${e}`};import{once as YU}from"events";var Qae=async(t,e)=>{let[r,n]=await BVe(t);return e.isForcefullyTerminated??=!1,[r,n]},BVe=async t=>{let[e,r]=await Promise.allSettled([YU(t,"spawn"),YU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?ece(t):r.value},ece=async t=>{try{return await YU(t,"exit")}catch{return ece(t)}},tce=async t=>{let[e,r]=await t;if(!qVe(e,r)&&KU(e,r))throw new ho;return[e,r]},qVe=(t,e)=>t===void 0&&e===void 0,KU=(t,e)=>t!==0||e!==null;var rce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=GVe(t,e,r),s=o?.code==="ETIMEDOUT",a=Jse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},GVe=(t,e,r)=>t!==void 0?t:KU(e,r)?new ho:void 0;var nce=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=HVe(t,e,r),d=KVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Vp(d,c,l)},HVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),a=WVe(r),{file:c,commandArguments:l,options:u}=vR(t,e,a);YVe(u);let d=kae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},WVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,YVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&zR("ipcInput"),t&&zR("ipc: true"),r&&zR("detached: true"),n&&zR("cancelSignal")},zR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},KVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=ZVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=rce(c,r),{output:h,error:m=l}=Jae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,T)=>Ea(v,r,T)),_=Ea(Xae(h,r),r,"all");return XVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},ZVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Wae(o,r);let a=JVe(r);return VVe(...TR(t,e,a))}catch(a){return Gp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},JVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:IR(e)}),XVe=({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?PR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Xy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as FHe}from"events";import{spawn as zHe}from"child_process";import cce from"process";import{once as ZU,on as QVe}from"events";var ice=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Up({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),e4e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),e4e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{dR(e,i);let o=$c(t,e,r),s=new AbortController;try{return await Promise.race([t4e(o,n,s),r4e(o,r,s),n4e(o,r,s)])}catch(a){throw Fp(t),a}finally{s.abort(),fR(e,i)}},t4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await ZU(t,"message",{signal:r});return n}for await(let[n]of QVe(t,"message",{signal:r}))if(e(n))return n},r4e=async(t,e,{signal:r})=>{await ZU(t,"disconnect",{signal:r}),Goe(e)},n4e=async(t,e,{signal:r})=>{let[n]=await ZU(t,"strict:error",{signal:r});throw cR(n,e)};import{once as sce,on as i4e}from"events";var ace=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>JU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),JU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Up({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),dR(e,o);let s=$c(t,e,r),a=new AbortController,c={};return o4e(t,s,a),s4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),a4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},o4e=async(t,e,r)=>{try{await sce(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},s4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await sce(t,"strict:error",{signal:r.signal});n.error=cR(i,e),r.abort()}catch{}},a4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of i4e(r,"message",{signal:o.signal}))oce(s),yield c}catch{oce(s)}finally{o.abort(),fR(e,a),n||Fp(t),i&&await t}},oce=({error:t})=>{if(t)throw t};var lce=(t,{ipc:e})=>{Object.assign(t,dce(t,!1,e))},uce=()=>{let t=cce,e=!0,r=cce.channel!==void 0;return{...dce(t,e,r),getCancelSignal:_se.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},dce=(t,e,r)=>({sendMessage:SR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ice.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ace.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as c4e}from"child_process";import{PassThrough as l4e,Readable as u4e,Writable as d4e,Duplex as f4e}from"stream";var fce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{jU(n);let a=new c4e;p4e(a,n),Object.assign(a,{readable:h4e,writable:m4e,duplex:g4e});let c=Gp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=_4e(c,s,i);return{subprocess:a,promise:l}},p4e=(t,e)=>{let r=eS(),n=eS(),i=eS(),o=Array.from({length:e.length-3},eS),s=eS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},eS=()=>{let t=new l4e;return t.end(),t},h4e=()=>new u4e({read(){}}),m4e=()=>new d4e({write(){}}),g4e=()=>new f4e({read(){},write(){}}),_4e=async(t,e,r)=>Vp(t,e,r);import{createReadStream as pce,createWriteStream as hce}from"fs";import{Buffer as y4e}from"buffer";import{Readable as tS,Writable as S4e,Duplex as E4e}from"stream";var gce=(t,e)=>MR(v4e,t,e,!1),rS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Lc[t]}.`)},mce={fileNumber:rS,generator:WU,asyncGenerator:WU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:E4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},v4e={input:{...mce,fileUrl:({value:t})=>({stream:pce(t)}),filePath:({value:{file:t}})=>({stream:pce(t)}),webStream:({value:t})=>({stream:tS.fromWeb(t)}),iterable:({value:t})=>({stream:tS.from(t)}),asyncIterable:({value:t})=>({stream:tS.from(t)}),string:({value:t})=>({stream:tS.from(t)}),uint8Array:({value:t})=>({stream:tS.from(y4e.from(t))})},output:{...mce,fileUrl:({value:t})=>({stream:hce(t)}),filePath:({value:{file:t,append:e}})=>({stream:hce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:S4e.fromWeb(t)}),iterable:rS,asyncIterable:rS,string:rS,uint8Array:rS}};import{on as T4e,once as _ce}from"events";import{PassThrough as b4e,getDefaultHighWaterMark as w4e}from"stream";import{finished as Ece}from"stream/promises";function Vu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)QU(i);let e=t.some(({readableObjectMode:i})=>i),r=A4e(t,e),n=new XU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var A4e=(t,e)=>{if(t.length===0)return w4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},XU=class extends b4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(QU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=x4e(this,this.#e,this.#o);let r=I4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(QU(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},x4e=async(t,e,r)=>{jR(t,yce);let n=new AbortController;try{await Promise.race([R4e(t,n),C4e(t,e,r,n)])}finally{n.abort(),jR(t,-yce)}},R4e=async(t,{signal:e})=>{try{await Ece(t,{signal:e,cleanup:!0})}catch(r){throw vce(t,r),r}},C4e=async(t,e,r,{signal:n})=>{for await(let[i]of T4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},QU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},I4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{jR(t,Sce);let a=new AbortController;try{await Promise.race([P4e(o,e,a),O4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),N4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),jR(t,-Sce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?eF(t):k4e(t))},P4e=async(t,e,{signal:r})=>{try{await t,r.aborted||eF(e)}catch(n){r.aborted||vce(e,n)}},O4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Ece(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Tce(s)?i.add(e):bce(t,s)}},N4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await _ce(t,i,{signal:o}),!t.readable)return _ce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},k4e=t=>{t.writable&&t.end()},vce=(t,e)=>{Tce(e)?eF(t):bce(t,e)},Tce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",eF=t=>{(t.readable||t.writable)&&t.destroy()},bce=(t,e)=>{t.destroyed||(t.once("error",M4e),t.destroy(e))},M4e=()=>{},jR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},yce=2,Sce=1;import{finished as wce}from"stream/promises";var Wp=(t,e)=>{t.pipe(e),D4e(t,e),$4e(t,e)},D4e=async(t,e)=>{if(!(po(t)||po(e))){try{await wce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}tF(e)}},tF=t=>{t.writable&&t.end()},$4e=async(t,e)=>{if(!(po(t)||po(e))){try{await wce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rF(t)}},rF=t=>{t.readable&&t.destroy()};var Ace=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>ki.has(c)))L4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ki.has(c)))F4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Vu(o);Wp(s,i)}},L4e=(t,e,r,n)=>{r==="output"?Wp(t.stdio[n],e):Wp(e,t.stdio[n]);let i=U4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},U4e=["stdin","stdout","stderr"],F4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;z4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},z4e=(t,{signal:e})=>{po(t)&&ju(t,j4e,e)},j4e=2;import{addAbortListener as G4e}from"events";var Hu=[];Hu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Hu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Hu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var BR=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",nF=Symbol.for("signal-exit emitter"),iF=globalThis,B4e=Object.defineProperty.bind(Object),oF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(iF[nF])return iF[nF];B4e(iF,nF,{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}},qR=class{},q4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),sF=class extends qR{onExit(){return()=>{}}load(){}unload(){}},aF=class extends qR{#e=cF.platform==="win32"?"SIGINT":"SIGHUP";#r=new oF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Hu)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(!BR(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 Hu)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,Hu.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 BR(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"&&BR(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)}},cF=globalThis.process,{onExit:xce,load:g1t,unload:_1t}=q4e(BR(cF)?new aF(cF):new sF);var Rce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=xce(()=>{t.kill()});G4e(n,()=>{i()})};var Ice=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=eR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=V4e(r,n,i),{sourceStream:d,sourceError:f}=W4e(t,l),{options:p,fileDescriptors:h}=fs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},V4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=H4e(t,e,...r),a=uR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},H4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Cce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||J1(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]=Gx(r,...n);return{destination:e(Cce)(i,o,s),pipeOptions:s}}if(fs.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Cce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),W4e=(t,e)=>{try{return{sourceStream:zp(t,e)}}catch(r){return{sourceError:r}}};var Oce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Y4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw lF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Y4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return rF(t),n;if(e!==void 0)return tF(r),e},lF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Gp({error:t,command:Pce,escapedCommand:Pce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Pce="source.pipe(destination)";var Nce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as K4e}from"stream/promises";var kce=(t,e,r)=>{let n=GR.has(e)?J4e(t,e):Z4e(t,e);return ju(t,Q4e,r.signal),ju(e,eHe,r.signal),X4e(e),n},Z4e=(t,e)=>{let r=Vu([t]);return Wp(r,e),GR.set(e,r),r},J4e=(t,e)=>{let r=GR.get(e);return r.add(t),r},X4e=async t=>{try{await K4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}GR.delete(t)},GR=new WeakMap,Q4e=2,eHe=1;import{aborted as tHe}from"util";var Mce=(t,e)=>t===void 0?[]:[rHe(t,e)],rHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await tHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw lF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var VR=(t,...e)=>{if(Jt(e[0]))return VR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Ice(t,...e),i=nHe({...n,destination:r});return i.pipe=VR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},nHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=iHe(t,i);Oce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=kce(e,o,d);return await Promise.race([Nce(u),...Mce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},iHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as dHe}from"timers/promises";import{on as oHe}from"events";import{getDefaultHighWaterMark as sHe}from"stream";var HR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return aHe(e,s),$ce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},aHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},uF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;cHe(e,s,t);let a=t.readableObjectMode&&!o;return $ce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},cHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},$ce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=oHe(t,"data",{signal:e.signal,highWaterMark:Dce,highWatermark:Dce});return lHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},dF=sHe(!0),Dce=dF,lHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=uHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Gu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Qy(a)}},uHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[$R(t,r,!e),DR(t,i,!n,{})].filter(Boolean);var Lce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=fHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([pHe(t),d]);return}let f=BU(c,r),p=uF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([hHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},fHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!FR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=uF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Yae(a,t,r,o)},pHe=async t=>{await dHe(),t.readableFlowing===null&&t.resume()},hHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await xR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await RR(r,{maxBuffer:o})):await qp(r,{maxBuffer:o})}catch(a){return Uce(Yse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},fF=async t=>{try{return await t}catch(e){return Uce(e)}},Uce=({bufferedData:t})=>uie(t)?new Uint8Array(t):t;import{finished as mHe}from"stream/promises";var nS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=gHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],mHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||SHe(a,e,r,n)}finally{s.abort()}},gHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&_He(t,r,n),n},_He=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{yHe(e,r),n.call(t,...i)}},yHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},SHe=(t,e,r,n)=>{if(!EHe(t,e,r,n))throw t},EHe=(t,e,r,n=!0)=>r.propagating?Fce(t)||WR(t):(r.propagating=!0,pF(r,e)===n?Fce(t):WR(t)),pF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",WR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Fce=t=>t?.code==="EPIPE";var zce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>hF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),hF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=nS(t,e,l);if(pF(l,e)){await u;return}let[d]=await Promise.all([Lce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var jce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Vu([t,e].filter(Boolean)):void 0,Bce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>hF({...vHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:THe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),vHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},THe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as bHe}from"events";var qce=t=>Dp(t,"ipc"),Gce=(t,e)=>{let r=Qx(t);us({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Vce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=qce(o),a=ya(e,"ipc"),c=ya(r,"ipc");for await(let l of JU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Kse(t,i,c),i.push(l)),s&&Gce(l,o);return i},Hce=async(t,e)=>(await Promise.allSettled([t]),e);var Wce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let v=Qae(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},y=zce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=Bce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),A=[],R=Vce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),I=wHe(m,t,T),N=AHe(h,T);try{return await Promise.race([Promise.all([{},tce(v),Promise.all(y),w,R,Rse(t,d),...I,...N]),g,xHe(t,_),...Tse(t,o,f,_),...qoe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Ese({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},v,Promise.all(y.map(b=>fF(b))),fF(w),Hce(R,A),Promise.allSettled(I),Promise.allSettled(N)])}},wHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:nS(n,i,r)),AHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>go(o,{checkOpen:!1})&&!po(o)).map(({type:i,value:o,stream:s=o})=>nS(s,n,e,{isSameDirection:ki.has(i),stopOnExit:i==="native"}))),xHe=async(t,{signal:e})=>{let[r]=await bHe(t,"error",{signal:e});throw r};var Yce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),iS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ds();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Yp=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as RHe}from"stream";import{callbackify as CHe}from"util";import{finished as Kce}from"stream/promises";var mF=async t=>{if(t!==void 0)try{await gF(t)}catch{}},Zce=async t=>{if(t!==void 0)try{await _F(t)}catch{}},gF=async t=>{await Kce(t,{cleanup:!0,readable:!1,writable:!0})},_F=async t=>{await Kce(t,{cleanup:!0,readable:!0,writable:!1})},YR=async(t,e)=>{if(await t,e)throw e},KR=(t,e,r)=>{r&&!WR(r)?t.destroy(r):e&&t.destroy()};var Jce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ii.has(r),{subprocessStdout:a,waitReadableDestroy:c}=yF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=SF(a,s),{read:f,onStdoutDataDone:p}=EF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new RHe({read:f,destroy:CHe(TF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return vF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},yF=(t,e,r)=>{let n=zp(t,e),i=iS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},SF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:dF},EF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ds(),s=HR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){IHe(this,s,o)},onStdoutDataDone:o}},IHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},vF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await _F(t),await n,await mF(i),await e,r.readable&&r.push(null)}catch(o){await mF(i),Xce(r,o)}},TF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Yp(r,e)&&(Xce(t,n),await YR(e,n))},Xce=(t,e)=>{KR(t,t.readable,e)};import{Writable as PHe}from"stream";import{callbackify as Qce}from"util";var ele=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=bF(t,r,e),s=new PHe({...wF(n,t,i),destroy:Qce(xF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return AF(n,s),s},bF=(t,e,r)=>{let n=uR(t,e),i=iS(r,n,"writableFinal"),o=iS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},wF=(t,e,r)=>({write:OHe.bind(void 0,t),final:Qce(NHe.bind(void 0,t,e,r))}),OHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},NHe=async(t,e,r)=>{await Yp(r,e)&&(t.writable&&t.end(),await e)},AF=async(t,e,r)=>{try{await gF(t),e.writable&&e.end()}catch(n){await Zce(r),tle(e,n)}},xF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Yp(r,e),await Yp(n,e)&&(tle(t,i),await YR(e,i))},tle=(t,e)=>{KR(t,t.writable,e)};import{Duplex as kHe}from"stream";import{callbackify as MHe}from"util";var rle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ii.has(r),{subprocessStdout:c,waitReadableDestroy:l}=yF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=bF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=SF(c,a),{read:g,onStdoutDataDone:_}=EF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new kHe({read:g,...wF(u,t,d),destroy:MHe(DHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return vF({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:t,subprocessStdin:u}),AF(u,v,c),v},DHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([TF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),xF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var RF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ii.has(e),s=zp(t,r),a=HR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return $He(a,s,t)},$He=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var nle=(t,{encoding:e})=>{let r=Yce();t.readable=Jce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=ele.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=rle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=RF.bind(void 0,t,e),t[Symbol.asyncIterator]=RF.bind(void 0,t,e,{})};var ile=(t,e)=>{for(let[r,n]of UHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},LHe=(async()=>{})().constructor.prototype,UHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(LHe,t)]);var ole=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=jHe(t,e,r),{subprocess:f,promise:p}=qHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=VR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ile(f,p),fs.set(f,{options:u,fileDescriptors:d}),f},jHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),{file:a,commandArguments:c,options:l}=vR(t,e,r),u=BHe(l),d=gce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},BHe=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},qHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=zHe(...TR(t,e,r))}catch(h){return fce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;FHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ace(c,a,l),Rce(c,r,l);let d={},f=ds();c.kill=joe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=jce(c,r),nle(c,r),lce(c,r);let p=GHe({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}},GHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Wce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((y,w)=>Ea(y,e,w)),v=Ea(m,e,"all"),T=VHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Vp(T,n,e)},VHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Xy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ps,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):PR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var ZR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,HHe(n,t[n],i)]));return{...t,...r}},HHe=(t,e,r)=>WHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,WHe=new Set(["env",...nU]);var Uc=(t,e,r,n)=>{let i=(s,a,c)=>Uc(s,a,r,c),o=(...s)=>YHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},YHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,ZR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=KHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?nce(a,c,l):ole(a,c,l,i)},KHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=gie(e)?_ie(e,r):[e,...r],[s,a,c]=Gx(...o),l=ZR(ZR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var sle=({file:t,commandArguments:e})=>cle(t,e),ale=({file:t,commandArguments:e})=>({...cle(t,e),isSync:!0}),cle=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=ZHe(t);return{file:r,commandArguments:n}},ZHe=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(JHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},JHe=/ +/g;var lle=(t,e,r)=>{t.sync=e(XHe,r),t.s=t.sync},ule=({options:t})=>dle(t),XHe=({options:t})=>({...dle(t),isSync:!0}),dle=t=>({options:{...QHe(t),...t}}),QHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},fle={preferLocal:!0};var ple=Uc(()=>({})),szt=Uc(()=>({isSync:!0})),hle=Uc(sle),azt=Uc(ale),czt=Uc(wse),lzt=Uc(ule,{},fle,lle),{sendMessage:uzt,getOneMessage:dzt,getEachMessage:fzt,getCancelSignal:pzt}=uce();var mle=!1,gle,e6e=t=>{gle??=t},_le=t=>{mle=!0,e6e(t)},oi=()=>mle,Fc=()=>gle,yle=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var oS=null,Sle=t=>(oS&&oS.destroy(),oS=new _o({totalAllowedTime:t}),oS),Ele=()=>oS;var _o=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&oi())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 kx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{q.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),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 vle={name:"@netlify/agent-runner-cli",type:"module",version:"1.191.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.19.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var i6e=r6e(import.meta.url),o6e=va.dirname(i6e),s6e=n6e(import.meta.url),Kp=oe("shell"),CF=new Set,Tle={preferLocal:!0},It=(t,e,r)=>{let[n,i]=a6e(e,r),o={...Tle,...i},s=ple(t,n,o);wle(s,o),Rle(s);let a=r?.idleTimeout;return a&&a>0&&xle(s,a),s},ble=(t,e)=>{let r={...Tle,...e},n=hle(t,r);return wle(n,r),Rle(n),e?.idleTimeout&&e.idleTimeout>0&&xle(n,e.idleTimeout),n},a6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},wle=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ms.env.NETLIFY_LOCAL_QUIET==="true")return;if(ms.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new My).pipe(ms.stdout),t.stderr?.pipe(new My).pipe(ms.stderr);return}t.stdout?.pipe(ms.stdout),t.stderr?.pipe(ms.stderr)},IF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ms.kill(-t.pid,e),Kp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Kp.error("Error killing process:",r),!1}},Ale=t=>IF(t,"SIGKILL"),xle=(t,e)=>{let r=null,n=()=>{Kp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing idle process ${t.pid}`),Ale(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)},Rle=t=>{CF.add(t);let e=Ele();if(e){let r=e.onTimesUp(()=>{Kp.log(`Global timer expired, killing process ${t.pid}`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing process ${t.pid} after timeout`),Ale(t))},5e3)});t.on("exit",()=>{CF.delete(t),r()}),t.on("error",()=>{CF.delete(t),r()})}};function XR(t,e){return!!yo(t,e)}function yo(t,e){if(!ms.env.NETLIFY_LOCAL_MODE)try{let i=s6e.resolve(vle.name),o=va.dirname(i);for(;o!==va.dirname(o);){let s=va.dirname(o);if(va.basename(s)==="node_modules"){let a=va.join(s,".bin",e);if(JR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ms.env.NODE_PATH){let i=va.join(ms.env.NODE_PATH,".bin",e);if(JR.existsSync(i))return i}let r=va.join(t,"node_modules",".bin",e);if(JR.existsSync(r))return r;let n=va.join(o6e,"..","node_modules",".bin",e);if(JR.existsSync(n))return n}var Cle=oe("repo"),Nle="runner-diffs-",tC=t=>`${Nle}${t}-`,kle=async t=>{let e=Ole.tmpdir(),r;try{r=await QR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Nle)&&!n.startsWith(tC(t))).map(n=>QR.rm(eC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>It("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),rC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Cle.info("Getting runner diffs");let n=await kF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=MF(o);await m6e(l,r)}Cle.info("Changes after processing"),await NF(r);let s=await aS(o,r);if(await OF(s,r),i=await f6e(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await QR.mkdtemp(eC.join(Ole.tmpdir(),tC(t.sessionId))),c=await PF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await u6e(r),c.hasChanges&&q.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},PF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=eC.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:v}=await QR.stat(g);return{path:g,size:v}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Ple(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Ple(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Ile=async t=>{let e=c6e("sha256");for await(let r of l6e(t))e.update(r);return e.digest("hex")},Ple=async(t,e)=>t.size===e.size&&await Ile(t.path)===await Ile(e.path),u6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},OF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},NF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},Mle=/.. (.+)?\.log$/,d6e=[Mle],kF=async(t=process.cwd())=>{let e=await NF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
147
147
  `).filter(i=>d6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},f6e=async(t=process.cwd())=>{try{return await Xt(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},sS=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},p6e=1,h6e=async t=>{try{return await Xt(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===p6e)return!1;throw e}},Dle=async(t=process.cwd())=>{if(!await h6e(t))return!0;let{stdout:e}=await Xt(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},$le=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},aS=async(t,e=process.cwd())=>{t||=await NF(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
148
148
  `).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${eC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Mle)?.[1];o&&n.push(`:!${o}.log`)}),n},Lle=async(t=process.cwd())=>{await Xt(["reset","--hard","HEAD"],{cwd:t})},Ule=async(t=process.cwd())=>{let e=await Xt(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
149
149
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},MF=t=>{let e=t.split(`
@@ -501,13 +501,21 @@ ${t}
501
501
  Earlier turns in this session ran in "Ask mode". Those restrictions no longer apply; ignore them and follow the instructions below instead:
502
502
  ${nwe({netlifyFolder:t,resultsFilename:pa})}
503
503
  ${owe(e,n)}${lwe(r)}
504
- </mode_reminder>`,pwe=({dirPath:t,config:e,skillsDir:r,cliPath:n})=>e.mode==="ask"?Alt(ylt.basename(t)):e.previousSession?.mode==="ask"?xlt({netlifyFolder:t,skillsDir:r,cliPath:n,runner:e.runner}):"",hwe=({sanitizedPrompt:t,buildErrorContextText:e,assetsSection:r,modeReminder:n})=>`
504
+ </mode_reminder>`,pwe=({dirPath:t,config:e,skillsDir:r,cliPath:n})=>e.mode==="ask"?Alt(ylt.basename(t)):e.previousSession?.mode==="ask"?xlt({netlifyFolder:t,skillsDir:r,cliPath:n,runner:e.runner}):"",hwe=({userRequestLast:t=!1,sanitizedPrompt:e,buildErrorContextText:r,assetsSection:n,modeReminder:i})=>t?`
505
+ ${n}${i}
505
506
  <request>
507
+ ${r}
506
508
  <user_request>
507
- ${t}
509
+ ${e}
508
510
  </user_request>
509
- ${e}
510
- </request>${r}${n}
511
+ </request>
512
+ `.trim():`
513
+ <request>
514
+ <user_request>
515
+ ${e}
516
+ </user_request>
517
+ ${r}
518
+ </request>${n}${i}
511
519
  `.trim();var Wn=oe("context"),Ilt=Clt(import.meta.url),Plt=ut.dirname(Ilt),mwe={claude:ut.join(RO.homedir(),".claude","skills"),gemini:ut.join(RO.homedir(),".agents","skills"),codex:ut.join(RO.homedir(),".agents","skills"),opencode:ut.join(RO.homedir(),".agents","skills")},Olt=ut.join(Plt,"skills"),gwe=t=>t.replace(/<\/user_request/gi,"&lt;/user_request"),IO=t=>typeof t=="string"&&/^[A-Za-z0-9_-]+$/.test(t)?t:null,_we=(t,e,r)=>{let n=` <user_request>
512
520
  ${gwe(t)}
513
521
  </user_request>`,i=` ${e}`;return`<request>
@@ -556,16 +564,16 @@ ${I}
556
564
  ${m.models.map(g=>`- \`${g}\``).join(`
557
565
  `)}`).join(`
558
566
 
559
- `);f=f.replace("<!-- AVAILABLE_MODELS -->",p),await ar.writeFile(d,f,"utf-8"),Wn.log("Injected dynamic model list into AI Gateway skill",{modelList:p})}}catch(u){Wn.warn("Failed to inject dynamic model list into AI Gateway skill:",u.message),q.inc("context.degraded",1,{component:"model_list"})}return l.length>0&&(Wn.log(`Installed ${l.length} skills for ${t}: ${l.join(", ")}`,{runner:t,skills:l,targetDir:i}),pt.getActiveSpan()?.setAttributes({"agent.skills_loaded":l,"agent.skills_loaded_count":l.length})),dW={key:c,skills:l},l},Ult=t=>{let e=t?.constants||{};return{siteId:e.SITE_ID,accountId:Ls.env.NETLIFY_TEAM_ID,userId:Ls.env.NETLIFY_AGENT_RUNNER_USER_ID,siteSlug:Ls.env.SITE_NAME,apiHost:e.NETLIFY_API_HOST,functionsDir:e.FUNCTIONS_DIST}},Flt=10,zlt=async t=>{let{name:e,ext:r}=ut.parse(t),n=t,i=ut.join(Ls.cwd(),Lr,n),o=0;for(;await jlt(i);){if(o>=Flt)throw new Error("Failed to generate context file");n=`${e}-${Rlt.randomUUID().slice(0,5)}${r}`,i=ut.join(Ls.cwd(),Lr,n),o+=1}return n},jlt=async t=>{try{return await ar.access(t),!0}catch{return!1}},CO=async t=>{try{return(await ar.readdir(t)).length>0}catch{return!1}},Swe=async({cliPath:t,netlify:e,config:r,buildErrorContext:n,additionalContext:i,resumePrompt:o,preserveResultsFile:s})=>{let a=Ult(e),c=await zlt(Ene),l=ut.join(Ls.cwd(),Lr);await ar.mkdir(l,{recursive:!0});let u=ut.join(Lr,c),d=ut.join(Ls.cwd(),u);if(!s){let A=ut.join(Ls.cwd(),Lr,pa);try{await ar.unlink(A),Wn.log(`Deleted old results file: ${A}`)}catch{}}let f=fwe(n),p=r.skillsTargetDir||mwe[r.runner];if(r.runner&&await Llt(r.runner,{targetDir:r.skillsTargetDir,mode:r.mode}),o){let A=IO(r.sessionId),R=A?ut.join(l,uo,A):null,I=R&&await CO(R)?`
567
+ `);f=f.replace("<!-- AVAILABLE_MODELS -->",p),await ar.writeFile(d,f,"utf-8"),Wn.log("Injected dynamic model list into AI Gateway skill",{modelList:p})}}catch(u){Wn.warn("Failed to inject dynamic model list into AI Gateway skill:",u.message),q.inc("context.degraded",1,{component:"model_list"})}return l.length>0&&(Wn.log(`Installed ${l.length} skills for ${t}: ${l.join(", ")}`,{runner:t,skills:l,targetDir:i}),pt.getActiveSpan()?.setAttributes({"agent.skills_loaded":l,"agent.skills_loaded_count":l.length})),dW={key:c,skills:l},l},Ult=t=>{let e=t?.constants||{};return{siteId:e.SITE_ID,accountId:Ls.env.NETLIFY_TEAM_ID,userId:Ls.env.NETLIFY_AGENT_RUNNER_USER_ID,siteSlug:Ls.env.SITE_NAME,apiHost:e.NETLIFY_API_HOST,functionsDir:e.FUNCTIONS_DIST}},Flt=10,zlt=async t=>{let{name:e,ext:r}=ut.parse(t),n=t,i=ut.join(Ls.cwd(),Lr,n),o=0;for(;await jlt(i);){if(o>=Flt)throw new Error("Failed to generate context file");n=`${e}-${Rlt.randomUUID().slice(0,5)}${r}`,i=ut.join(Ls.cwd(),Lr,n),o+=1}return n},jlt=async t=>{try{return await ar.access(t),!0}catch{return!1}},CO=async t=>{try{return(await ar.readdir(t)).length>0}catch{return!1}},Swe=async({cliPath:t,netlify:e,config:r,buildErrorContext:n,additionalContext:i,resumePrompt:o,preserveResultsFile:s})=>{let a=Ult(e),c=await zlt(Ene),l=ut.join(Ls.cwd(),Lr);await ar.mkdir(l,{recursive:!0});let u=ut.join(Lr,c),d=ut.join(Ls.cwd(),u);if(!s){let A=ut.join(Ls.cwd(),Lr,pa);try{await ar.unlink(A),Wn.log(`Deleted old results file: ${A}`)}catch{}}let f=fwe(n),p=r.skillsTargetDir||mwe[r.runner];r.runner&&await Llt(r.runner,{targetDir:r.skillsTargetDir,mode:r.mode});let h=Je().promptImprovementsEnabled;if(o){let A=IO(r.sessionId),R=A?ut.join(l,uo,A):null,I=R&&await CO(R)?`
560
568
  <attachments>
561
569
  New uploads for this request are in ${R}/
562
- </attachments>`:"",N=pwe({dirPath:l,config:r,skillsDir:p,cliPath:t}),$=hwe({sanitizedPrompt:gwe(r.prompt),buildErrorContextText:f,assetsSection:I,modeReminder:N});return await ar.writeFile(d,$,"utf-8"),Wn.log(`Generated minimal resume prompt at: ${d}`),$}let h="";r.siteContext&&r.siteContext.length!==0&&(h=`
570
+ </attachments>`:"",N=pwe({dirPath:l,config:r,skillsDir:p,cliPath:t}),$=hwe({userRequestLast:h,sanitizedPrompt:gwe(r.prompt),buildErrorContextText:f,assetsSection:I,modeReminder:N});return await ar.writeFile(d,$,"utf-8"),Wn.log(`Generated minimal resume prompt at: ${d}`),$}let m="";r.siteContext&&r.siteContext.length!==0&&(m=`
563
571
  <project_rules>
564
572
  ${r.siteContext.filter(R=>R.site_context).map(R=>typeof R.site_context=="string"?R.site_context:typeof R.site_context=="object"?JSON.stringify(R.site_context):"").join(`
565
573
 
566
574
  `)}
567
575
  </project_rules>
568
- `);let m="";if(r.sessionHistoryContext?.length){let A=ut.join(Ls.cwd(),Lr,$1);await ar.mkdir(A,{recursive:!0});let R=await Promise.all(r.sessionHistoryContext.map(async(I,N)=>{let $=N+1,b=`attempt-${$}.md`,Z=ut.join(A,b),M=ut.join(Lr,$1,b),S=IO(I.id),x=S?` ID ${S}`:"",O="";if(S){let W=ut.resolve(l,uo),le=ut.resolve(W,S);le.startsWith(W+ut.sep)&&await CO(le)&&(O=`
576
+ `);let g="";if(r.sessionHistoryContext?.length){let A=ut.join(Ls.cwd(),Lr,$1);await ar.mkdir(A,{recursive:!0});let R=await Promise.all(r.sessionHistoryContext.map(async(I,N)=>{let $=N+1,b=`attempt-${$}.md`,Z=ut.join(A,b),M=ut.join(Lr,$1,b),S=IO(I.id),x=S?` ID ${S}`:"",O="";if(S){let W=ut.resolve(l,uo),le=ut.resolve(W,S);le.startsWith(W+ut.sep)&&await CO(le)&&(O=`
569
577
  ---
570
578
 
571
579
  ## Assets: ${le}/
@@ -579,7 +587,7 @@ ${I.request}
579
587
  ## Response - what the agent replied with after its work
580
588
 
581
589
  ${I.response}
582
- ${O}`;return await ar.writeFile(Z,Q,"utf-8"),Wn.log(`Created history file: ${M}`),M}));m+=`
590
+ ${O}`;return await ar.writeFile(Z,Q,"utf-8"),Wn.log(`Created history file: ${M}`),M}));g+=`
583
591
  <session_history_context>
584
592
  History of prior work on this task.
585
593
  You MUST review ALL of the files below as context to understand the context of previous attempts. Use this information to continue the discussion appropriately.
@@ -588,13 +596,13 @@ ${O}`;return await ar.writeFile(Z,Q,"utf-8"),Wn.log(`Created history file: ${M}`
588
596
  `)}
589
597
 
590
598
  </session_history_context>
591
- `}let g=IO(r.sessionId),_=g?ut.join(l,uo,g):null,v=!!_&&await CO(_),T=await CO(ut.join(l,uo)),y=r.mode==="create"&&Je().promptImprovementsEnabled,w=Nlt({userRequest:r.prompt,userRequestLast:y,buildErrorContextText:f,projectContext:h,sessionHistoryContextText:m,additionalContext:i,netlifyInfo:a,cliPath:t,skillsDir:p,netlifyFolder:l,resultsFilename:pa,assetsFolder:uo,sessionId:r.sessionId,currentSessionHasAssets:v,hasAnyAssets:T,mode:r.mode,runner:r.runner});if(await ar.writeFile(d,w,"utf-8"),Wn.log(`Generated agent context document at: ${d}`),w.length>5e5){let A=_we(r.prompt,f,y);w=`
599
+ `}let _=IO(r.sessionId),v=_?ut.join(l,uo,_):null,T=!!v&&await CO(v),y=await CO(ut.join(l,uo)),w=Nlt({userRequest:r.prompt,userRequestLast:h,buildErrorContextText:f,projectContext:m,sessionHistoryContextText:g,additionalContext:i,netlifyInfo:a,cliPath:t,skillsDir:p,netlifyFolder:l,resultsFilename:pa,assetsFolder:uo,sessionId:r.sessionId,currentSessionHasAssets:T,hasAnyAssets:y,mode:r.mode,runner:r.runner});if(await ar.writeFile(d,w,"utf-8"),Wn.log(`Generated agent context document at: ${d}`),w.length>5e5){let A=_we(r.prompt,f,h);w=`
592
600
  You're an AI agent designed to assist with tasks related to a Netlify project. Please review, understand, and use the context provided to complete the user's request as needed.
593
601
 
594
- ${y?"":`${A}
602
+ ${h?"":`${A}
595
603
 
596
604
  `}Use the following file for the complete context of the ask, the environment, and what's available. ${d} You MUST READ ALL OF IT. Make sure to read it first. Never cite or paraphrase private context.
597
- ${y?`
605
+ ${h?`
598
606
  ${A}
599
607
  `:""}`}return w};var Blt=oe("prompt"),Ewe=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:o,preserveResultsFile:s})=>{let a=await Swe({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:o,preserveResultsFile:s});return process.env.AGENT_RUNNER_DEBUG&&Blt.log("Contextful Prompt:",a),{prompt:a}};var vwe=oe("session_manager"),fW=null;var qlt,pW,Glt=0,Vlt,Hlt;var hW=()=>qlt,mW=()=>fW!==null,Twe=()=>Glt,bwe=()=>Hlt,wwe=()=>Vlt,gW=async(t,e)=>{if(!Je().idleTimeoutEnabled||!t||t===e)return;let r=rg[t];if(r)try{await r.clean(),vwe.info(`Wiped previous agent state (${t}) on switch to ${e}`)}catch(n){vwe.warn(`Failed to clean previous agent ${t} on switch`,{error:n?.message||n})}finally{pW=void 0}},PO=t=>{pW=t};var Awe=t=>{let e=t.previousSession?.nativeSessionId;return!!e&&e===pW},xwe=async()=>{if(fW)try{await fW}catch{}};var Rwe=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 Wlt}from"crypto";var yW=oe("interactions"),Cwe="question",Iwe="authorization",Ylt=["answered","skipped","dismissed"],Pwe=async(t,e,r)=>{let n=Wlt(),{authorization:i}=e,[o,s]=i?[{type:Iwe,status:"pending",payload:{...i}},G.Authorization]:[{type:Cwe,status:"pending",payload:e.questions},G.Question];return await xr(t.id,t.sessionId,{state:"await_input",interactions:{[n]:o},steps:[{id:n,refId:n,category:s}],...r?.diffFields,...r?.nativeSessionId?{native_session_id:r.nativeSessionId}:{},...r?.nativeSessionS3Key?{native_session_s3_key:r.nativeSessionS3Key}:{}}),n},Owe=(t,e,r)=>{if(t.authorization){yW.log("Agent paused on a service authorization; session set to await_input",{sessionId:e,refId:r,service:t.authorization.service}),q.inc("inference.pending_authorization",1);return}let n=t.questions?.length??0;yW.log("Agent paused on a question; session set to await_input",{sessionId:e,refId:r,questionCount:n}),q.inc("inference.pending_question",1),q.distribution("inference.questions_per_ask",n)},Nwe=async t=>{let e;try{e=await Op(t.id,t.sessionId)}catch(s){return yW.warn("Failed to fetch session for the full answer fold",{error:s?.message}),q.inc("inference.answer_fetch_failed",1),null}let r=e?.interactions;if(!r)return[];let n=[],i=new Set,o=(s,a)=>{if(!(!a||i.has(s))&&(i.add(s),!!Ylt.includes(a.status??""))){if(a.type===Iwe){let c=a.payload??{};n.push({refId:s,questions:[],responses:[],authorization:{service:c.service,granted:a.status==="answered"}});return}a.type===Cwe&&n.push({refId:s,questions:a.payload??[],responses:a.response??[],...a.instruction?{instruction:a.instruction}:{}})}};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},kwe=()=>({counted:!1}),Klt=(t,e)=>{if(e==null)return"skipped";let r=new Set(t.options?.map(o=>o.label)??[]),i=(Array.isArray(e)?e:[e]).filter(o=>r.has(o)).length;return i===0?"free_text":i===1?"option":"multi_select"},Mwe=t=>{let e=0;t.questions.forEach((r,n)=>{let i=Klt(r,t.responses[n]);i==="skipped"&&(e+=1),q.inc("interaction.answer_kind",1,{kind:i})}),q.distribution("interaction.questions_skipped",e),t.instruction?.trim()&&q.inc("interaction.override_instruction",1)},Dwe=(t,e)=>{let r=!1,n=e.flatMap(s=>s.questions.map((a,c)=>{let l=s.responses[c];l==null&&(r=!0);let u=l==null?"(skipped)":Array.isArray(l)?l.join(", "):l;return{question:a.question,answer:u}})),i=e.map(s=>s.instruction?.trim()).filter(s=>!!s).join(`
600
608