@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 +20 -12
- package/dist/bin.js +20 -12
- package/dist/index.js +20 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -142,7 +142,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
142
142
|
`,LF:`
|
|
143
143
|
`,concatBytes:PU},FGe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},zGe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:FGe};import{Buffer as jGe}from"buffer";var Sae=(t,e)=>t?void 0:BGe.bind(void 0,e),BGe=function*(t,e){if(typeof e!="string"&&!dr(e)&&!jGe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Eae=(t,e)=>t?qGe.bind(void 0,e):GGe.bind(void 0,e),qGe=function*(t,e){vae(t,e),yield e},GGe=function*(t,e){if(vae(t,e),typeof e!="string"&&!dr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},vae=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
144
144
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
145
|
-
if (condition) { yield value; }`)};import{Buffer as VGe}from"buffer";import{StringDecoder as HGe}from"string_decoder";var RR=(t,e,r)=>{if(r)return;if(t)return{transform:WGe.bind(void 0,new TextEncoder)};let n=new HGe(e);return{transform:YGe.bind(void 0,n),final:KGe.bind(void 0,n)}},WGe=function*(t,e){VGe.isBuffer(e)?yield fa(e):typeof e=="string"?yield t.encode(e):yield e},YGe=function*(t,e){yield dr(e)?t.write(e):e},KGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Tae}from"util";var NU=Tae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),CR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=JGe}=e[r];for await(let i of n(t))yield*CR(i,e,r+1)},bae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ZGe(r,Number(e),t)},ZGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*CR(n,r,e+1)},wae=Tae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),JGe=function*(t){yield t};var kU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Aae=(t,e)=>[...e.flatMap(r=>[...Fu(r,t,0)]),...Wy(t)],Fu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QGe}=e[r];for(let i of n(t))yield*Fu(i,e,r+1)},Wy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XGe(r,Number(e),t)},XGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Fu(n,r,e+1)},QGe=function*(t){yield t};var MU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Rae(t,s,o),l=Uu(e),u=Uu(r),d=l?NU.bind(void 0,CR,a):kU.bind(void 0,Fu),f=l||u?NU.bind(void 0,bae,a):kU.bind(void 0,Wy),p=l||u?wae.bind(void 0,a):void 0;return{stream:new eVe({writableObjectMode:n,writableHighWaterMark:xae(n),readableObjectMode:i,readableHighWaterMark:xae(i),transform(m,g,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},IR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Rae(s,r,a);t=Aae(c,t)}return t},Rae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Sae(n,a)},RR(r,s,n),xR(r,o,n,c),{transform:t,final:e},{transform:Eae(i,a)},yae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Cae=(t,e)=>{for(let r of tVe(t))rVe(t,r,e)},tVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),rVe=(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 ${Nc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>nVe(a,n));r.input=Ly(s)},nVe=(t,e)=>{let r=IR(t,e,"utf8",!0);return iVe(r),Ly(r)},iVe=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 cVe,appendFileSync as lVe}from"fs";var PR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ip(r,n)&&!ti.has(e)&&oVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&sVe.has(o))||t.every(({type:i})=>Pi.has(i))),oVe=t=>t===1||t===2,sVe=new Set(["pipe","overlapped"]),Iae=async(t,e,r,n)=>{for await(let i of t)aVe(e)||Oae(i,r,n)},Pae=(t,e,r)=>{for(let n of t)Oae(n,e,r)},aVe=t=>t._readableState.pipes.length>0,Oae=(t,e,r)=>{let n=Gx(t);os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Nae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>uVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},uVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=kse(t,o,d),p=fa(f),{stdioItems:h,objectMode:m}=e[r],g=dVe([p],h,c,n),{serializedResult:S,finalResult:E=S}=fVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});pVe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?E:void 0;try{return n.error===void 0&&hVe(S,h,i),T}catch(b){return n.error=b,T}},dVe=(t,e,r,n)=>{try{return IR(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:Ly(t)};let s=Wne(t,r);return n[o]?{serializedResult:s,finalResult:OU(s,!i[o],e)}:{serializedResult:s}},pVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!PR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=OU(t,!1,s);try{Pae(a,e,n)}catch(c){r.error??=c}},hVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>wR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?lVe(n,t):(r.add(o),cVe(n,t))}};var kae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ma(e,r,"all")]:Array.isArray(e)?[ma(t,r,"all"),...e]:dr(t)&&dr(e)?z1([t,e]):`${t}${e}`};import{once as DU}from"events";var Mae=async(t,e)=>{let[r,n]=await mVe(t);return e.isForcefullyTerminated??=!1,[r,n]},mVe=async t=>{let[e,r]=await Promise.allSettled([DU(t,"spawn"),DU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Dae(t):r.value},Dae=async t=>{try{return await DU(t,"exit")}catch{return Dae(t)}},$ae=async t=>{let[e,r]=await t;if(!gVe(e,r)&&$U(e,r))throw new lo;return[e,r]},gVe=(t,e)=>t===void 0&&e===void 0,$U=(t,e)=>t!==0||e!==null;var Lae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=_Ve(t,e,r),s=o?.code==="ETIMEDOUT",a=Nse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},_Ve=(t,e,r)=>t!==void 0?t:$U(e,r)?new lo:void 0;var Uae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=SVe(t,e,r),d=TVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Fp(d,c,l)},SVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Hx(t,e,r),a=EVe(r),{file:c,commandArguments:l,options:u}=fR(t,e,a);vVe(u);let d=hae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},EVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&OR("ipcInput"),t&&OR("ipc: true"),r&&OR("detached: true"),n&&OR("cancelSignal")},OR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},TVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=bVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Lae(c,r),{output:h,error:m=l}=Nae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((E,T)=>ma(E,r,T)),S=ma(kae(h,r),r,"all");return AVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:S,options:r,command:n,escapedCommand:i,startTime:a})},bVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Cae(o,r);let a=wVe(r);return yVe(...pR(t,e,a))}catch(a){return Up({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:ER(e)}),AVe=({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?vR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Hy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as fHe}from"events";import{spawn as pHe}from"child_process";import qae from"process";import{once as LU,on as xVe}from"events";var Fae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Np({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:sR(t)}),RVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),RVe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{rR(e,i);let o=Oc(t,e,r),s=new AbortController;try{return await Promise.race([CVe(o,n,s),IVe(o,r,s),PVe(o,r,s)])}catch(a){throw kp(t),a}finally{s.abort(),nR(e,i)}},CVe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await LU(t,"message",{signal:r});return n}for await(let[n]of xVe(t,"message",{signal:r}))if(e(n))return n},IVe=async(t,e,{signal:r})=>{await LU(t,"disconnect",{signal:r}),Aoe(e)},PVe=async(t,e,{signal:r})=>{let[n]=await LU(t,"strict:error",{signal:r});throw Qx(n,e)};import{once as jae,on as OVe}from"events";var Bae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>UU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),UU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Np({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:sR(t)}),rR(e,o);let s=Oc(t,e,r),a=new AbortController,c={};return NVe(t,s,a),kVe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),MVe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},NVe=async(t,e,r)=>{try{await jae(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kVe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await jae(t,"strict:error",{signal:r.signal});n.error=Qx(i,e),r.abort()}catch{}},MVe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of OVe(r,"message",{signal:o.signal}))zae(s),yield c}catch{zae(s)}finally{o.abort(),nR(e,a),n||kp(t),i&&await t}},zae=({error:t})=>{if(t)throw t};var Gae=(t,{ipc:e})=>{Object.assign(t,Hae(t,!1,e))},Vae=()=>{let t=qae,e=!0,r=qae.channel!==void 0;return{...Hae(t,e,r),getCancelSignal:Xoe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Hae=(t,e,r)=>({sendMessage:uR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Fae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Bae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as DVe}from"child_process";import{PassThrough as $Ve,Readable as LVe,Writable as UVe,Duplex as FVe}from"stream";var Wae=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{CU(n);let a=new DVe;zVe(a,n),Object.assign(a,{readable:jVe,writable:BVe,duplex:qVe});let c=Up({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=GVe(c,s,i);return{subprocess:a,promise:l}},zVe=(t,e)=>{let r=Yy(),n=Yy(),i=Yy(),o=Array.from({length:e.length-3},Yy),s=Yy(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Yy=()=>{let t=new $Ve;return t.end(),t},jVe=()=>new LVe({read(){}}),BVe=()=>new UVe({write(){}}),qVe=()=>new FVe({read(){},write(){}}),GVe=async(t,e,r)=>Fp(t,e,r);import{createReadStream as Yae,createWriteStream as Kae}from"fs";import{Buffer as VVe}from"buffer";import{Readable as Ky,Writable as HVe,Duplex as WVe}from"stream";var Jae=(t,e)=>AR(YVe,t,e,!1),Zy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Nc[t]}.`)},Zae={fileNumber:Zy,generator:MU,asyncGenerator:MU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:WVe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},YVe={input:{...Zae,fileUrl:({value:t})=>({stream:Yae(t)}),filePath:({value:{file:t}})=>({stream:Yae(t)}),webStream:({value:t})=>({stream:Ky.fromWeb(t)}),iterable:({value:t})=>({stream:Ky.from(t)}),asyncIterable:({value:t})=>({stream:Ky.from(t)}),string:({value:t})=>({stream:Ky.from(t)}),uint8Array:({value:t})=>({stream:Ky.from(VVe.from(t))})},output:{...Zae,fileUrl:({value:t})=>({stream:Kae(t)}),filePath:({value:{file:t,append:e}})=>({stream:Kae(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:HVe.fromWeb(t)}),iterable:Zy,asyncIterable:Zy,string:Zy,uint8Array:Zy}};import{on as KVe,once as Xae}from"events";import{PassThrough as ZVe,getDefaultHighWaterMark as JVe}from"stream";import{finished as tce}from"stream/promises";function zu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)zU(i);let e=t.some(({readableObjectMode:i})=>i),r=XVe(t,e),n=new FU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var XVe=(t,e)=>{if(t.length===0)return JVe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},FU=class extends ZVe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(zU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=QVe(this,this.#e,this.#o);let r=r4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(zU(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},QVe=async(t,e,r)=>{NR(t,Qae);let n=new AbortController;try{await Promise.race([e4e(t,n),t4e(t,e,r,n)])}finally{n.abort(),NR(t,-Qae)}},e4e=async(t,{signal:e})=>{try{await tce(t,{signal:e,cleanup:!0})}catch(r){throw rce(t,r),r}},t4e=async(t,e,r,{signal:n})=>{for await(let[i]of KVe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},zU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},r4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{NR(t,ece);let a=new AbortController;try{await Promise.race([n4e(o,e,a),i4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),o4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),NR(t,-ece)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?jU(t):s4e(t))},n4e=async(t,e,{signal:r})=>{try{await t,r.aborted||jU(e)}catch(n){r.aborted||rce(e,n)}},i4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await tce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;nce(s)?i.add(e):ice(t,s)}},o4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Xae(t,i,{signal:o}),!t.readable)return Xae(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},s4e=t=>{t.writable&&t.end()},rce=(t,e)=>{nce(e)?jU(t):ice(t,e)},nce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",jU=t=>{(t.readable||t.writable)&&t.destroy()},ice=(t,e)=>{t.destroyed||(t.once("error",a4e),t.destroy(e))},a4e=()=>{},NR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Qae=2,ece=1;import{finished as oce}from"stream/promises";var jp=(t,e)=>{t.pipe(e),c4e(t,e),l4e(t,e)},c4e=async(t,e)=>{if(!(co(t)||co(e))){try{await oce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}BU(e)}},BU=t=>{t.writable&&t.end()},l4e=async(t,e)=>{if(!(co(t)||co(e))){try{await oce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}qU(t)}},qU=t=>{t.readable&&t.destroy()};var sce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Pi.has(c)))u4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Pi.has(c)))f4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:zu(o);jp(s,i)}},u4e=(t,e,r,n)=>{r==="output"?jp(t.stdio[n],e):jp(e,t.stdio[n]);let i=d4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},d4e=["stdin","stdout","stderr"],f4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;p4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},p4e=(t,{signal:e})=>{co(t)&&$u(t,h4e,e)},h4e=2;import{addAbortListener as _4e}from"events";var ju=[];ju.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ju.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ju.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var kR=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",GU=Symbol.for("signal-exit emitter"),VU=globalThis,m4e=Object.defineProperty.bind(Object),HU=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(VU[GU])return VU[GU];m4e(VU,GU,{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}},MR=class{},g4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),WU=class extends MR{onExit(){return()=>{}}load(){}unload(){}},YU=class extends MR{#e=KU.platform==="win32"?"SIGINT":"SIGHUP";#r=new HU;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ju)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(!kR(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 ju)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,ju.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 kR(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"&&kR(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)}},KU=globalThis.process,{onExit:ace,load:WLt,unload:YLt}=g4e(kR(KU)?new YU(KU):new WU);var cce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ace(()=>{t.kill()});_4e(n,()=>{i()})};var uce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Vx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=y4e(r,n,i),{sourceStream:d,sourceError:f}=E4e(t,l),{options:p,fileDescriptors:h}=as.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},y4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=S4e(t,e,...r),a=tR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},S4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(lce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||U1(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]=Dx(r,...n);return{destination:e(lce)(i,o,s),pipeOptions:s}}if(as.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},lce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),E4e=(t,e)=>{try{return{sourceStream:Mp(t,e)}}catch(r){return{sourceError:r}}};var fce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=v4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ZU({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},v4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return qU(t),n;if(e!==void 0)return BU(r),e},ZU=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Up({error:t,command:dce,escapedCommand:dce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),dce="source.pipe(destination)";var pce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as T4e}from"stream/promises";var hce=(t,e,r)=>{let n=DR.has(e)?w4e(t,e):b4e(t,e);return $u(t,x4e,r.signal),$u(e,R4e,r.signal),A4e(e),n},b4e=(t,e)=>{let r=zu([t]);return jp(r,e),DR.set(e,r),r},w4e=(t,e)=>{let r=DR.get(e);return r.add(t),r},A4e=async t=>{try{await T4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}DR.delete(t)},DR=new WeakMap,x4e=2,R4e=1;import{aborted as C4e}from"util";var mce=(t,e)=>t===void 0?[]:[I4e(t,e)],I4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await C4e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ZU({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var $R=(t,...e)=>{if(Jt(e[0]))return $R.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=uce(t,...e),i=P4e({...n,destination:r});return i.pipe=$R.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},P4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=O4e(t,i);fce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=hce(e,o,d);return await Promise.race([pce(u),...mce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},O4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as U4e}from"timers/promises";import{on as N4e}from"events";import{getDefaultHighWaterMark as k4e}from"stream";var LR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return M4e(e,s),_ce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},M4e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},JU=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;D4e(e,s,t);let a=t.readableObjectMode&&!o;return _ce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},D4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_ce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=N4e(t,"data",{signal:e.signal,highWaterMark:gce,highWatermark:gce});return $4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},XU=k4e(!0),gce=XU,$4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=L4e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Fu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Wy(a)}},L4e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[RR(t,r,!e),xR(t,i,!n,{})].filter(Boolean);var yce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=F4e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([z4e(t),d]);return}let f=IU(c,r),p=JU({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([j4e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},F4e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!PR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=JU({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Iae(a,t,r,o)},z4e=async t=>{await U4e(),t.readableFlowing===null&&t.resume()},j4e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await _R(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await yR(r,{maxBuffer:o})):await Lp(r,{maxBuffer:o})}catch(a){return Sce(Ise({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},QU=async t=>{try{return await t}catch(e){return Sce(e)}},Sce=({bufferedData:t})=>Vne(t)?new Uint8Array(t):t;import{finished as B4e}from"stream/promises";var Jy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=q4e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],B4e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||H4e(a,e,r,n)}finally{s.abort()}},q4e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&G4e(t,r,n),n},G4e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{V4e(e,r),n.call(t,...i)}},V4e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},H4e=(t,e,r,n)=>{if(!W4e(t,e,r,n))throw t},W4e=(t,e,r,n=!0)=>r.propagating?Ece(t)||UR(t):(r.propagating=!0,eF(r,e)===n?Ece(t):UR(t)),eF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",UR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ece=t=>t?.code==="EPIPE";var vce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>tF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),tF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Jy(t,e,l);if(eF(l,e)){await u;return}let[d]=await Promise.all([yce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Tce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?zu([t,e].filter(Boolean)):void 0,bce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>tF({...Y4e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:K4e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Y4e=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},K4e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Z4e}from"events";var wce=t=>Ip(t,"ipc"),Ace=(t,e)=>{let r=Gx(t);os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var xce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=wce(o),a=pa(e,"ipc"),c=pa(r,"ipc");for await(let l of UU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Pse(t,i,c),i.push(l)),s&&Ace(l,o);return i},Rce=async(t,e)=>(await Promise.allSettled([t]),e);var Cce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:S})=>{let E=Mae(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},b=vce({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}),x=[],I=xce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),C=J4e(m,t,T),k=X4e(h,T);try{return await Promise.race([Promise.all([{},$ae(E),Promise.all(b),w,I,cse(t,d),...C,...k]),g,Q4e(t,S),...nse(t,o,f,S),...woe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...tse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},E,Promise.all(b.map(v=>QU(v))),QU(w),Rce(I,x),Promise.allSettled(C),Promise.allSettled(k)])}},J4e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Jy(n,i,r)),X4e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>fo(o,{checkOpen:!1})&&!co(o)).map(({type:i,value:o,stream:s=o})=>Jy(s,n,e,{isSameDirection:Pi.has(i),stopOnExit:i==="native"}))),Q4e=async(t,{signal:e})=>{let[r]=await Z4e(t,"error",{signal:e});throw r};var Ice=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Xy=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ss();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Bp=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as eHe}from"stream";import{callbackify as tHe}from"util";import{finished as Pce}from"stream/promises";var rF=async t=>{if(t!==void 0)try{await nF(t)}catch{}},Oce=async t=>{if(t!==void 0)try{await iF(t)}catch{}},nF=async t=>{await Pce(t,{cleanup:!0,readable:!1,writable:!0})},iF=async t=>{await Pce(t,{cleanup:!0,readable:!0,writable:!1})},FR=async(t,e)=>{if(await t,e)throw e},zR=(t,e,r)=>{r&&!UR(r)?t.destroy(r):e&&t.destroy()};var Nce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ti.has(r),{subprocessStdout:a,waitReadableDestroy:c}=oF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=sF(a,s),{read:f,onStdoutDataDone:p}=aF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new eHe({read:f,destroy:tHe(lF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return cF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},oF=(t,e,r)=>{let n=Mp(t,e),i=Xy(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:XU},aF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ss(),s=LR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){rHe(this,s,o)},onStdoutDataDone:o}},rHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},cF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await iF(t),await n,await rF(i),await e,r.readable&&r.push(null)}catch(o){await rF(i),kce(r,o)}},lF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Bp(r,e)&&(kce(t,n),await FR(e,n))},kce=(t,e)=>{zR(t,t.readable,e)};import{Writable as nHe}from"stream";import{callbackify as Mce}from"util";var Dce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=uF(t,r,e),s=new nHe({...dF(n,t,i),destroy:Mce(pF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return fF(n,s),s},uF=(t,e,r)=>{let n=tR(t,e),i=Xy(r,n,"writableFinal"),o=Xy(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},dF=(t,e,r)=>({write:iHe.bind(void 0,t),final:Mce(oHe.bind(void 0,t,e,r))}),iHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},oHe=async(t,e,r)=>{await Bp(r,e)&&(t.writable&&t.end(),await e)},fF=async(t,e,r)=>{try{await nF(t),e.writable&&e.end()}catch(n){await Oce(r),$ce(e,n)}},pF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Bp(r,e),await Bp(n,e)&&($ce(t,i),await FR(e,i))},$ce=(t,e)=>{zR(t,t.writable,e)};import{Duplex as sHe}from"stream";import{callbackify as aHe}from"util";var Lce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ti.has(r),{subprocessStdout:c,waitReadableDestroy:l}=oF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=uF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=sF(c,a),{read:g,onStdoutDataDone:S}=aF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),E=new sHe({read:g,...dF(u,t,d),destroy:aHe(cHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return cF({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),fF(u,E,c),E},cHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([lF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),pF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var hF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ti.has(e),s=Mp(t,r),a=LR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return lHe(a,s,t)},lHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Uce=(t,{encoding:e})=>{let r=Ice();t.readable=Nce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Dce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Lce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=hF.bind(void 0,t,e),t[Symbol.asyncIterator]=hF.bind(void 0,t,e,{})};var Fce=(t,e)=>{for(let[r,n]of dHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},uHe=(async()=>{})().constructor.prototype,dHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(uHe,t)]);var zce=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=hHe(t,e,r),{subprocess:f,promise:p}=gHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=$R.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Fce(f,p),as.set(f,{options:u,fileDescriptors:d}),f},hHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Hx(t,e,r),{file:a,commandArguments:c,options:l}=fR(t,e,r),u=mHe(l),d=Jae(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},mHe=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},gHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=pHe(...pR(t,e,r))}catch(h){return Wae({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;fHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];sce(c,a,l),cce(c,r,l);let d={},f=ss();c.kill=Toe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Tce(c,r),Uce(c,r),Gae(c,r);let p=_He({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},_He=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Cce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((b,w)=>ma(b,e,w)),E=ma(m,e,"all"),T=yHe({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Fp(T,n,e)},yHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Hy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof cs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):vR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var jR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,SHe(n,t[n],i)]));return{...t,...r}},SHe=(t,e,r)=>EHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,EHe=new Set(["env",...G1]);var kc=(t,e,r,n)=>{let i=(s,a,c)=>kc(s,a,r,c),o=(...s)=>vHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},vHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,jR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=THe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Uae(a,c,l):zce(a,c,l,i)},THe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Jne(e)?Xne(e,r):[e,...r],[s,a,c]=Dx(...o),l=jR(jR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var jce=({file:t,commandArguments:e})=>qce(t,e),Bce=({file:t,commandArguments:e})=>({...qce(t,e),isSync:!0}),qce=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=bHe(t);return{file:r,commandArguments:n}},bHe=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(wHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wHe=/ +/g;var Gce=(t,e,r)=>{t.sync=e(AHe,r),t.s=t.sync},Vce=({options:t})=>Hce(t),AHe=({options:t})=>({...Hce(t),isSync:!0}),Hce=t=>({options:{...xHe(t),...t}}),xHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Wce={preferLocal:!0};var Yce=kc(()=>({})),LFt=kc(()=>({isSync:!0})),Kce=kc(jce),UFt=kc(Bce),FFt=kc(ose),zFt=kc(Vce,{},Wce,Gce),{sendMessage:jFt,getOneMessage:BFt,getEachMessage:qFt,getCancelSignal:GFt}=Vae();var Zce=!1,Jce,RHe=t=>{Jce??=t},Xce=t=>{Zce=!0,RHe(t)},ri=()=>Zce,Mc=()=>Jce,Qce=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Qy=null,ele=t=>(Qy&&Qy.destroy(),Qy=new po({totalAllowedTime:t}),Qy),tle=()=>Qy;var po=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&ri())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 Ax({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 rle={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 OHe=IHe(import.meta.url),NHe=ga.dirname(OHe),kHe=PHe(import.meta.url),qp=oe("shell"),mF=new Set,nle={preferLocal:!0},Mt=(t,e,r)=>{let[n,i]=MHe(e,r),o={...nle,...i},s=Yce(t,n,o);ole(s,o),cle(s);let a=r?.idleTimeout;return a&&a>0&&ale(s,a),s},ile=(t,e)=>{let r={...nle,...e},n=Kce(t,r);return ole(n,r),cle(n),e?.idleTimeout&&e.idleTimeout>0&&ale(n,e.idleTimeout),n},MHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ole=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||us.env.NETLIFY_LOCAL_QUIET==="true")return;if(us.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Cy).pipe(us.stdout),t.stderr?.pipe(new Cy).pipe(us.stderr);return}t.stdout?.pipe(us.stdout),t.stderr?.pipe(us.stderr)},gF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(us.kill(-t.pid,e),qp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qp.error("Error killing process:",r),!1}},sle=t=>gF(t,"SIGKILL"),ale=(t,e)=>{let r=null,n=()=>{qp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),gF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qp.log(`Force killing idle process ${t.pid}`),sle(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)},cle=t=>{mF.add(t);let e=tle();if(e){let r=e.onTimesUp(()=>{qp.log(`Global timer expired, killing process ${t.pid}`),gF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qp.log(`Force killing process ${t.pid} after timeout`),sle(t))},5e3)});t.on("exit",()=>{mF.delete(t),r()}),t.on("error",()=>{mF.delete(t),r()})}};function ds(t,e){if(!us.env.NETLIFY_LOCAL_MODE)try{let i=kHe.resolve(rle.name),o=ga.dirname(i);for(;o!==ga.dirname(o);){let s=ga.dirname(o);if(ga.basename(s)==="node_modules"){let a=ga.join(s,".bin",e);if(BR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(us.env.NODE_PATH){let i=ga.join(us.env.NODE_PATH,".bin",e);if(BR.existsSync(i))return i}let r=ga.join(t,"node_modules",".bin",e);if(BR.existsSync(r))return r;let n=ga.join(NHe,"..","node_modules",".bin",e);if(BR.existsSync(n))return n}var lle=oe("repo"),ple="runner-diffs-",VR=t=>`${ple}${t}-`,hle=async t=>{let e=fle.tmpdir(),r;try{r=await qR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(ple)&&!n.startsWith(VR(t))).map(n=>qR.rm(GR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>Mt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),HR=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{lle.info("Getting runner diffs");let n=await EF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=TF(o);await BHe(l,r)}lle.info("Changes after processing"),await SF(r);let s=await eS(o,r);if(await yF(s,r),i=await FHe(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await qR.mkdtemp(GR.join(fle.tmpdir(),VR(t.sessionId))),c=await _F({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await LHe(r),c.hasChanges&&q.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},_F=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=GR.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:E}=await qR.stat(g);return{path:g,size:E}},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 dle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await dle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},ule=async t=>{let e=DHe("sha256");for await(let r of $He(t))e.update(r);return e.digest("hex")},dle=async(t,e)=>t.size===e.size&&await ule(t.path)===await ule(e.path),LHe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},yF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},SF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},mle=/.. (.+)?\.log$/,UHe=[mle],EF=async(t=process.cwd())=>{let e=await SF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
145
|
+
if (condition) { yield value; }`)};import{Buffer as VGe}from"buffer";import{StringDecoder as HGe}from"string_decoder";var RR=(t,e,r)=>{if(r)return;if(t)return{transform:WGe.bind(void 0,new TextEncoder)};let n=new HGe(e);return{transform:YGe.bind(void 0,n),final:KGe.bind(void 0,n)}},WGe=function*(t,e){VGe.isBuffer(e)?yield fa(e):typeof e=="string"?yield t.encode(e):yield e},YGe=function*(t,e){yield dr(e)?t.write(e):e},KGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Tae}from"util";var NU=Tae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),CR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=JGe}=e[r];for await(let i of n(t))yield*CR(i,e,r+1)},bae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ZGe(r,Number(e),t)},ZGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*CR(n,r,e+1)},wae=Tae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),JGe=function*(t){yield t};var kU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Aae=(t,e)=>[...e.flatMap(r=>[...Fu(r,t,0)]),...Wy(t)],Fu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QGe}=e[r];for(let i of n(t))yield*Fu(i,e,r+1)},Wy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XGe(r,Number(e),t)},XGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Fu(n,r,e+1)},QGe=function*(t){yield t};var MU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Rae(t,s,o),l=Uu(e),u=Uu(r),d=l?NU.bind(void 0,CR,a):kU.bind(void 0,Fu),f=l||u?NU.bind(void 0,bae,a):kU.bind(void 0,Wy),p=l||u?wae.bind(void 0,a):void 0;return{stream:new eVe({writableObjectMode:n,writableHighWaterMark:xae(n),readableObjectMode:i,readableHighWaterMark:xae(i),transform(m,g,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},IR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Rae(s,r,a);t=Aae(c,t)}return t},Rae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Sae(n,a)},RR(r,s,n),xR(r,o,n,c),{transform:t,final:e},{transform:Eae(i,a)},yae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Cae=(t,e)=>{for(let r of tVe(t))rVe(t,r,e)},tVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),rVe=(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 ${Nc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>nVe(a,n));r.input=Ly(s)},nVe=(t,e)=>{let r=IR(t,e,"utf8",!0);return iVe(r),Ly(r)},iVe=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 cVe,appendFileSync as lVe}from"fs";var PR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ip(r,n)&&!ti.has(e)&&oVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&sVe.has(o))||t.every(({type:i})=>Pi.has(i))),oVe=t=>t===1||t===2,sVe=new Set(["pipe","overlapped"]),Iae=async(t,e,r,n)=>{for await(let i of t)aVe(e)||Oae(i,r,n)},Pae=(t,e,r)=>{for(let n of t)Oae(n,e,r)},aVe=t=>t._readableState.pipes.length>0,Oae=(t,e,r)=>{let n=Gx(t);os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Nae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>uVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},uVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=kse(t,o,d),p=fa(f),{stdioItems:h,objectMode:m}=e[r],g=dVe([p],h,c,n),{serializedResult:S,finalResult:E=S}=fVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});pVe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?E:void 0;try{return n.error===void 0&&hVe(S,h,i),T}catch(b){return n.error=b,T}},dVe=(t,e,r,n)=>{try{return IR(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:Ly(t)};let s=Wne(t,r);return n[o]?{serializedResult:s,finalResult:OU(s,!i[o],e)}:{serializedResult:s}},pVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!PR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=OU(t,!1,s);try{Pae(a,e,n)}catch(c){r.error??=c}},hVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>wR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?lVe(n,t):(r.add(o),cVe(n,t))}};var kae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ma(e,r,"all")]:Array.isArray(e)?[ma(t,r,"all"),...e]:dr(t)&&dr(e)?z1([t,e]):`${t}${e}`};import{once as DU}from"events";var Mae=async(t,e)=>{let[r,n]=await mVe(t);return e.isForcefullyTerminated??=!1,[r,n]},mVe=async t=>{let[e,r]=await Promise.allSettled([DU(t,"spawn"),DU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Dae(t):r.value},Dae=async t=>{try{return await DU(t,"exit")}catch{return Dae(t)}},$ae=async t=>{let[e,r]=await t;if(!gVe(e,r)&&$U(e,r))throw new lo;return[e,r]},gVe=(t,e)=>t===void 0&&e===void 0,$U=(t,e)=>t!==0||e!==null;var Lae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=_Ve(t,e,r),s=o?.code==="ETIMEDOUT",a=Nse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},_Ve=(t,e,r)=>t!==void 0?t:$U(e,r)?new lo:void 0;var Uae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=SVe(t,e,r),d=TVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Fp(d,c,l)},SVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Hx(t,e,r),a=EVe(r),{file:c,commandArguments:l,options:u}=fR(t,e,a);vVe(u);let d=hae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},EVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&OR("ipcInput"),t&&OR("ipc: true"),r&&OR("detached: true"),n&&OR("cancelSignal")},OR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},TVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=bVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Lae(c,r),{output:h,error:m=l}=Nae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((E,T)=>ma(E,r,T)),S=ma(kae(h,r),r,"all");return AVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:S,options:r,command:n,escapedCommand:i,startTime:a})},bVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Cae(o,r);let a=wVe(r);return yVe(...pR(t,e,a))}catch(a){return Up({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:ER(e)}),AVe=({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?vR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Hy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as fHe}from"events";import{spawn as pHe}from"child_process";import qae from"process";import{once as LU,on as xVe}from"events";var Fae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Np({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:sR(t)}),RVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),RVe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{rR(e,i);let o=Oc(t,e,r),s=new AbortController;try{return await Promise.race([CVe(o,n,s),IVe(o,r,s),PVe(o,r,s)])}catch(a){throw kp(t),a}finally{s.abort(),nR(e,i)}},CVe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await LU(t,"message",{signal:r});return n}for await(let[n]of xVe(t,"message",{signal:r}))if(e(n))return n},IVe=async(t,e,{signal:r})=>{await LU(t,"disconnect",{signal:r}),Aoe(e)},PVe=async(t,e,{signal:r})=>{let[n]=await LU(t,"strict:error",{signal:r});throw Qx(n,e)};import{once as jae,on as OVe}from"events";var Bae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>UU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),UU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Np({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:sR(t)}),rR(e,o);let s=Oc(t,e,r),a=new AbortController,c={};return NVe(t,s,a),kVe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),MVe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},NVe=async(t,e,r)=>{try{await jae(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kVe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await jae(t,"strict:error",{signal:r.signal});n.error=Qx(i,e),r.abort()}catch{}},MVe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of OVe(r,"message",{signal:o.signal}))zae(s),yield c}catch{zae(s)}finally{o.abort(),nR(e,a),n||kp(t),i&&await t}},zae=({error:t})=>{if(t)throw t};var Gae=(t,{ipc:e})=>{Object.assign(t,Hae(t,!1,e))},Vae=()=>{let t=qae,e=!0,r=qae.channel!==void 0;return{...Hae(t,e,r),getCancelSignal:Xoe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Hae=(t,e,r)=>({sendMessage:uR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Fae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Bae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as DVe}from"child_process";import{PassThrough as $Ve,Readable as LVe,Writable as UVe,Duplex as FVe}from"stream";var Wae=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{CU(n);let a=new DVe;zVe(a,n),Object.assign(a,{readable:jVe,writable:BVe,duplex:qVe});let c=Up({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=GVe(c,s,i);return{subprocess:a,promise:l}},zVe=(t,e)=>{let r=Yy(),n=Yy(),i=Yy(),o=Array.from({length:e.length-3},Yy),s=Yy(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Yy=()=>{let t=new $Ve;return t.end(),t},jVe=()=>new LVe({read(){}}),BVe=()=>new UVe({write(){}}),qVe=()=>new FVe({read(){},write(){}}),GVe=async(t,e,r)=>Fp(t,e,r);import{createReadStream as Yae,createWriteStream as Kae}from"fs";import{Buffer as VVe}from"buffer";import{Readable as Ky,Writable as HVe,Duplex as WVe}from"stream";var Jae=(t,e)=>AR(YVe,t,e,!1),Zy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Nc[t]}.`)},Zae={fileNumber:Zy,generator:MU,asyncGenerator:MU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:WVe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},YVe={input:{...Zae,fileUrl:({value:t})=>({stream:Yae(t)}),filePath:({value:{file:t}})=>({stream:Yae(t)}),webStream:({value:t})=>({stream:Ky.fromWeb(t)}),iterable:({value:t})=>({stream:Ky.from(t)}),asyncIterable:({value:t})=>({stream:Ky.from(t)}),string:({value:t})=>({stream:Ky.from(t)}),uint8Array:({value:t})=>({stream:Ky.from(VVe.from(t))})},output:{...Zae,fileUrl:({value:t})=>({stream:Kae(t)}),filePath:({value:{file:t,append:e}})=>({stream:Kae(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:HVe.fromWeb(t)}),iterable:Zy,asyncIterable:Zy,string:Zy,uint8Array:Zy}};import{on as KVe,once as Xae}from"events";import{PassThrough as ZVe,getDefaultHighWaterMark as JVe}from"stream";import{finished as tce}from"stream/promises";function zu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)zU(i);let e=t.some(({readableObjectMode:i})=>i),r=XVe(t,e),n=new FU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var XVe=(t,e)=>{if(t.length===0)return JVe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},FU=class extends ZVe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(zU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=QVe(this,this.#e,this.#o);let r=r4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(zU(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},QVe=async(t,e,r)=>{NR(t,Qae);let n=new AbortController;try{await Promise.race([e4e(t,n),t4e(t,e,r,n)])}finally{n.abort(),NR(t,-Qae)}},e4e=async(t,{signal:e})=>{try{await tce(t,{signal:e,cleanup:!0})}catch(r){throw rce(t,r),r}},t4e=async(t,e,r,{signal:n})=>{for await(let[i]of KVe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},zU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},r4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{NR(t,ece);let a=new AbortController;try{await Promise.race([n4e(o,e,a),i4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),o4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),NR(t,-ece)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?jU(t):s4e(t))},n4e=async(t,e,{signal:r})=>{try{await t,r.aborted||jU(e)}catch(n){r.aborted||rce(e,n)}},i4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await tce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;nce(s)?i.add(e):ice(t,s)}},o4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Xae(t,i,{signal:o}),!t.readable)return Xae(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},s4e=t=>{t.writable&&t.end()},rce=(t,e)=>{nce(e)?jU(t):ice(t,e)},nce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",jU=t=>{(t.readable||t.writable)&&t.destroy()},ice=(t,e)=>{t.destroyed||(t.once("error",a4e),t.destroy(e))},a4e=()=>{},NR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Qae=2,ece=1;import{finished as oce}from"stream/promises";var jp=(t,e)=>{t.pipe(e),c4e(t,e),l4e(t,e)},c4e=async(t,e)=>{if(!(co(t)||co(e))){try{await oce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}BU(e)}},BU=t=>{t.writable&&t.end()},l4e=async(t,e)=>{if(!(co(t)||co(e))){try{await oce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}qU(t)}},qU=t=>{t.readable&&t.destroy()};var sce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Pi.has(c)))u4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Pi.has(c)))f4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:zu(o);jp(s,i)}},u4e=(t,e,r,n)=>{r==="output"?jp(t.stdio[n],e):jp(e,t.stdio[n]);let i=d4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},d4e=["stdin","stdout","stderr"],f4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;p4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},p4e=(t,{signal:e})=>{co(t)&&$u(t,h4e,e)},h4e=2;import{addAbortListener as _4e}from"events";var ju=[];ju.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ju.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ju.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var kR=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",GU=Symbol.for("signal-exit emitter"),VU=globalThis,m4e=Object.defineProperty.bind(Object),HU=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(VU[GU])return VU[GU];m4e(VU,GU,{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}},MR=class{},g4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),WU=class extends MR{onExit(){return()=>{}}load(){}unload(){}},YU=class extends MR{#e=KU.platform==="win32"?"SIGINT":"SIGHUP";#r=new HU;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ju)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(!kR(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 ju)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,ju.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 kR(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"&&kR(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)}},KU=globalThis.process,{onExit:ace,load:WLt,unload:YLt}=g4e(kR(KU)?new YU(KU):new WU);var cce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ace(()=>{t.kill()});_4e(n,()=>{i()})};var uce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Vx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=y4e(r,n,i),{sourceStream:d,sourceError:f}=E4e(t,l),{options:p,fileDescriptors:h}=as.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},y4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=S4e(t,e,...r),a=tR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},S4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(lce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||U1(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]=Dx(r,...n);return{destination:e(lce)(i,o,s),pipeOptions:s}}if(as.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},lce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),E4e=(t,e)=>{try{return{sourceStream:Mp(t,e)}}catch(r){return{sourceError:r}}};var fce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=v4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ZU({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},v4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return qU(t),n;if(e!==void 0)return BU(r),e},ZU=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Up({error:t,command:dce,escapedCommand:dce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),dce="source.pipe(destination)";var pce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as T4e}from"stream/promises";var hce=(t,e,r)=>{let n=DR.has(e)?w4e(t,e):b4e(t,e);return $u(t,x4e,r.signal),$u(e,R4e,r.signal),A4e(e),n},b4e=(t,e)=>{let r=zu([t]);return jp(r,e),DR.set(e,r),r},w4e=(t,e)=>{let r=DR.get(e);return r.add(t),r},A4e=async t=>{try{await T4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}DR.delete(t)},DR=new WeakMap,x4e=2,R4e=1;import{aborted as C4e}from"util";var mce=(t,e)=>t===void 0?[]:[I4e(t,e)],I4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await C4e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ZU({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var $R=(t,...e)=>{if(Jt(e[0]))return $R.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=uce(t,...e),i=P4e({...n,destination:r});return i.pipe=$R.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},P4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=O4e(t,i);fce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=hce(e,o,d);return await Promise.race([pce(u),...mce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},O4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as U4e}from"timers/promises";import{on as N4e}from"events";import{getDefaultHighWaterMark as k4e}from"stream";var LR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return M4e(e,s),_ce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},M4e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},JU=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;D4e(e,s,t);let a=t.readableObjectMode&&!o;return _ce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},D4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_ce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=N4e(t,"data",{signal:e.signal,highWaterMark:gce,highWatermark:gce});return $4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},XU=k4e(!0),gce=XU,$4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=L4e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Fu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Wy(a)}},L4e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[RR(t,r,!e),xR(t,i,!n,{})].filter(Boolean);var yce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=F4e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([z4e(t),d]);return}let f=IU(c,r),p=JU({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([j4e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},F4e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!PR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=JU({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Iae(a,t,r,o)},z4e=async t=>{await U4e(),t.readableFlowing===null&&t.resume()},j4e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await _R(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await yR(r,{maxBuffer:o})):await Lp(r,{maxBuffer:o})}catch(a){return Sce(Ise({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},QU=async t=>{try{return await t}catch(e){return Sce(e)}},Sce=({bufferedData:t})=>Vne(t)?new Uint8Array(t):t;import{finished as B4e}from"stream/promises";var Jy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=q4e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],B4e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||H4e(a,e,r,n)}finally{s.abort()}},q4e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&G4e(t,r,n),n},G4e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{V4e(e,r),n.call(t,...i)}},V4e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},H4e=(t,e,r,n)=>{if(!W4e(t,e,r,n))throw t},W4e=(t,e,r,n=!0)=>r.propagating?Ece(t)||UR(t):(r.propagating=!0,eF(r,e)===n?Ece(t):UR(t)),eF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",UR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ece=t=>t?.code==="EPIPE";var vce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>tF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),tF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Jy(t,e,l);if(eF(l,e)){await u;return}let[d]=await Promise.all([yce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Tce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?zu([t,e].filter(Boolean)):void 0,bce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>tF({...Y4e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:K4e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Y4e=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},K4e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Z4e}from"events";var wce=t=>Ip(t,"ipc"),Ace=(t,e)=>{let r=Gx(t);os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var xce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=wce(o),a=pa(e,"ipc"),c=pa(r,"ipc");for await(let l of UU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Pse(t,i,c),i.push(l)),s&&Ace(l,o);return i},Rce=async(t,e)=>(await Promise.allSettled([t]),e);var Cce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:S})=>{let E=Mae(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},b=vce({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}),x=[],I=xce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),C=J4e(m,t,T),k=X4e(h,T);try{return await Promise.race([Promise.all([{},$ae(E),Promise.all(b),w,I,cse(t,d),...C,...k]),g,Q4e(t,S),...nse(t,o,f,S),...woe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...tse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},E,Promise.all(b.map(v=>QU(v))),QU(w),Rce(I,x),Promise.allSettled(C),Promise.allSettled(k)])}},J4e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Jy(n,i,r)),X4e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>fo(o,{checkOpen:!1})&&!co(o)).map(({type:i,value:o,stream:s=o})=>Jy(s,n,e,{isSameDirection:Pi.has(i),stopOnExit:i==="native"}))),Q4e=async(t,{signal:e})=>{let[r]=await Z4e(t,"error",{signal:e});throw r};var Ice=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Xy=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ss();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Bp=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as eHe}from"stream";import{callbackify as tHe}from"util";import{finished as Pce}from"stream/promises";var rF=async t=>{if(t!==void 0)try{await nF(t)}catch{}},Oce=async t=>{if(t!==void 0)try{await iF(t)}catch{}},nF=async t=>{await Pce(t,{cleanup:!0,readable:!1,writable:!0})},iF=async t=>{await Pce(t,{cleanup:!0,readable:!0,writable:!1})},FR=async(t,e)=>{if(await t,e)throw e},zR=(t,e,r)=>{r&&!UR(r)?t.destroy(r):e&&t.destroy()};var Nce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ti.has(r),{subprocessStdout:a,waitReadableDestroy:c}=oF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=sF(a,s),{read:f,onStdoutDataDone:p}=aF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new eHe({read:f,destroy:tHe(lF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return cF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},oF=(t,e,r)=>{let n=Mp(t,e),i=Xy(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:XU},aF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ss(),s=LR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){rHe(this,s,o)},onStdoutDataDone:o}},rHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},cF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await iF(t),await n,await rF(i),await e,r.readable&&r.push(null)}catch(o){await rF(i),kce(r,o)}},lF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Bp(r,e)&&(kce(t,n),await FR(e,n))},kce=(t,e)=>{zR(t,t.readable,e)};import{Writable as nHe}from"stream";import{callbackify as Mce}from"util";var Dce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=uF(t,r,e),s=new nHe({...dF(n,t,i),destroy:Mce(pF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return fF(n,s),s},uF=(t,e,r)=>{let n=tR(t,e),i=Xy(r,n,"writableFinal"),o=Xy(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},dF=(t,e,r)=>({write:iHe.bind(void 0,t),final:Mce(oHe.bind(void 0,t,e,r))}),iHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},oHe=async(t,e,r)=>{await Bp(r,e)&&(t.writable&&t.end(),await e)},fF=async(t,e,r)=>{try{await nF(t),e.writable&&e.end()}catch(n){await Oce(r),$ce(e,n)}},pF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Bp(r,e),await Bp(n,e)&&($ce(t,i),await FR(e,i))},$ce=(t,e)=>{zR(t,t.writable,e)};import{Duplex as sHe}from"stream";import{callbackify as aHe}from"util";var Lce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ti.has(r),{subprocessStdout:c,waitReadableDestroy:l}=oF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=uF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=sF(c,a),{read:g,onStdoutDataDone:S}=aF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),E=new sHe({read:g,...dF(u,t,d),destroy:aHe(cHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return cF({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),fF(u,E,c),E},cHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([lF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),pF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var hF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ti.has(e),s=Mp(t,r),a=LR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return lHe(a,s,t)},lHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Uce=(t,{encoding:e})=>{let r=Ice();t.readable=Nce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Dce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Lce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=hF.bind(void 0,t,e),t[Symbol.asyncIterator]=hF.bind(void 0,t,e,{})};var Fce=(t,e)=>{for(let[r,n]of dHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},uHe=(async()=>{})().constructor.prototype,dHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(uHe,t)]);var zce=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=hHe(t,e,r),{subprocess:f,promise:p}=gHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=$R.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Fce(f,p),as.set(f,{options:u,fileDescriptors:d}),f},hHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Hx(t,e,r),{file:a,commandArguments:c,options:l}=fR(t,e,r),u=mHe(l),d=Jae(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},mHe=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},gHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=pHe(...pR(t,e,r))}catch(h){return Wae({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;fHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];sce(c,a,l),cce(c,r,l);let d={},f=ss();c.kill=Toe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Tce(c,r),Uce(c,r),Gae(c,r);let p=_He({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},_He=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Cce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((b,w)=>ma(b,e,w)),E=ma(m,e,"all"),T=yHe({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Fp(T,n,e)},yHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Hy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof cs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):vR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var jR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,SHe(n,t[n],i)]));return{...t,...r}},SHe=(t,e,r)=>EHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,EHe=new Set(["env",...G1]);var kc=(t,e,r,n)=>{let i=(s,a,c)=>kc(s,a,r,c),o=(...s)=>vHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},vHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,jR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=THe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Uae(a,c,l):zce(a,c,l,i)},THe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Jne(e)?Xne(e,r):[e,...r],[s,a,c]=Dx(...o),l=jR(jR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var jce=({file:t,commandArguments:e})=>qce(t,e),Bce=({file:t,commandArguments:e})=>({...qce(t,e),isSync:!0}),qce=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=bHe(t);return{file:r,commandArguments:n}},bHe=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(wHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wHe=/ +/g;var Gce=(t,e,r)=>{t.sync=e(AHe,r),t.s=t.sync},Vce=({options:t})=>Hce(t),AHe=({options:t})=>({...Hce(t),isSync:!0}),Hce=t=>({options:{...xHe(t),...t}}),xHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Wce={preferLocal:!0};var Yce=kc(()=>({})),LFt=kc(()=>({isSync:!0})),Kce=kc(jce),UFt=kc(Bce),FFt=kc(ose),zFt=kc(Vce,{},Wce,Gce),{sendMessage:jFt,getOneMessage:BFt,getEachMessage:qFt,getCancelSignal:GFt}=Vae();var Zce=!1,Jce,RHe=t=>{Jce??=t},Xce=t=>{Zce=!0,RHe(t)},ri=()=>Zce,Mc=()=>Jce,Qce=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Qy=null,ele=t=>(Qy&&Qy.destroy(),Qy=new po({totalAllowedTime:t}),Qy),tle=()=>Qy;var po=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&ri())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 Ax({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 rle={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 OHe=IHe(import.meta.url),NHe=ga.dirname(OHe),kHe=PHe(import.meta.url),qp=oe("shell"),mF=new Set,nle={preferLocal:!0},Mt=(t,e,r)=>{let[n,i]=MHe(e,r),o={...nle,...i},s=Yce(t,n,o);ole(s,o),cle(s);let a=r?.idleTimeout;return a&&a>0&&ale(s,a),s},ile=(t,e)=>{let r={...nle,...e},n=Kce(t,r);return ole(n,r),cle(n),e?.idleTimeout&&e.idleTimeout>0&&ale(n,e.idleTimeout),n},MHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ole=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||us.env.NETLIFY_LOCAL_QUIET==="true")return;if(us.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Cy).pipe(us.stdout),t.stderr?.pipe(new Cy).pipe(us.stderr);return}t.stdout?.pipe(us.stdout),t.stderr?.pipe(us.stderr)},gF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(us.kill(-t.pid,e),qp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qp.error("Error killing process:",r),!1}},sle=t=>gF(t,"SIGKILL"),ale=(t,e)=>{let r=null,n=()=>{qp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),gF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qp.log(`Force killing idle process ${t.pid}`),sle(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)},cle=t=>{mF.add(t);let e=tle();if(e){let r=e.onTimesUp(()=>{qp.log(`Global timer expired, killing process ${t.pid}`),gF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qp.log(`Force killing process ${t.pid} after timeout`),sle(t))},5e3)});t.on("exit",()=>{mF.delete(t),r()}),t.on("error",()=>{mF.delete(t),r()})}};function ds(t,e){if(!us.env.NETLIFY_LOCAL_MODE)try{let i=kHe.resolve(rle.name),o=ga.dirname(i);for(;o!==ga.dirname(o);){let s=ga.dirname(o);if(ga.basename(s)==="node_modules"){let a=ga.join(s,".bin",e);if(BR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(us.env.NODE_PATH){let i=ga.join(us.env.NODE_PATH,".bin",e);if(BR.existsSync(i))return i}let r=ga.join(t,"node_modules",".bin",e);if(BR.existsSync(r))return r;let n=ga.join(NHe,"..","node_modules",".bin",e);if(BR.existsSync(n))return n}var lle=oe("repo"),ple="runner-diffs-",VR=t=>`${ple}${t}-`,hle=async t=>{let e=fle.tmpdir(),r;try{r=await qR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(ple)&&!n.startsWith(VR(t))).map(n=>qR.rm(GR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>Mt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),HR=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{lle.info("Getting runner diffs");let n=await EF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=TF(o);await BHe(l,r)}lle.info("Changes after processing"),await SF(r);let s=await eS(o,r);if(await yF(s,r),i=await FHe(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await qR.mkdtemp(GR.join(fle.tmpdir(),VR(t.sessionId))),c=await _F({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await LHe(r),c.hasChanges&&q.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},_F=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=GR.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:E}=await qR.stat(g);return{path:g,size:E}},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 dle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await dle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},ule=async t=>{let e=DHe("sha256");for await(let r of $He(t))e.update(r);return e.digest("hex")},dle=async(t,e)=>t.size===e.size&&await ule(t.path)===await ule(e.path),LHe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},yF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},SF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},mle=/.. (.+)?\.log$/,UHe=[mle],EF=async(t=process.cwd())=>{let e=await SF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
146
146
|
`).filter(i=>UHe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},FHe=async(t=process.cwd())=>{try{return await Xt(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},vF=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},zHe=1,jHe=async t=>{try{return await Xt(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===zHe)return!1;throw e}},gle=async(t=process.cwd())=>{if(!await jHe(t))return!0;let{stdout:e}=await Xt(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},_le=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},eS=async(t,e=process.cwd())=>{t||=await SF(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
147
147
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${GR.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(mle)?.[1];o&&n.push(`:!${o}.log`)}),n},yle=async(t=process.cwd())=>{await Xt(["reset","--hard","HEAD"],{cwd:t})},Sle=async(t=process.cwd())=>{let e=await Xt(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
148
148
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},TF=t=>{let e=t.split(`
|
|
@@ -500,13 +500,21 @@ ${t}
|
|
|
500
500
|
Earlier turns in this session ran in "Ask mode". Those restrictions no longer apply; ignore them and follow the instructions below instead:
|
|
501
501
|
${Ube({netlifyFolder:t,resultsFilename:la})}
|
|
502
502
|
${zbe(e,n)}${Gbe(r)}
|
|
503
|
-
</mode_reminder>`,Ybe=({dirPath:t,config:e,skillsDir:r,cliPath:n})=>e.mode==="ask"?Xct(Vct.basename(t)):e.previousSession?.mode==="ask"?Qct({netlifyFolder:t,skillsDir:r,cliPath:n,runner:e.runner}):"",Kbe=({
|
|
503
|
+
</mode_reminder>`,Ybe=({dirPath:t,config:e,skillsDir:r,cliPath:n})=>e.mode==="ask"?Xct(Vct.basename(t)):e.previousSession?.mode==="ask"?Qct({netlifyFolder:t,skillsDir:r,cliPath:n,runner:e.runner}):"",Kbe=({userRequestLast:t=!1,sanitizedPrompt:e,buildErrorContextText:r,assetsSection:n,modeReminder:i})=>t?`
|
|
504
|
+
${n}${i}
|
|
504
505
|
<request>
|
|
506
|
+
${r}
|
|
505
507
|
<user_request>
|
|
506
|
-
${
|
|
508
|
+
${e}
|
|
507
509
|
</user_request>
|
|
508
|
-
|
|
509
|
-
|
|
510
|
+
</request>
|
|
511
|
+
`.trim():`
|
|
512
|
+
<request>
|
|
513
|
+
<user_request>
|
|
514
|
+
${e}
|
|
515
|
+
</user_request>
|
|
516
|
+
${r}
|
|
517
|
+
</request>${n}${i}
|
|
510
518
|
`.trim();var Gn=oe("context"),rlt=tlt(import.meta.url),nlt=ut.dirname(rlt),Zbe={claude:ut.join(_O.homedir(),".claude","skills"),gemini:ut.join(_O.homedir(),".agents","skills"),codex:ut.join(_O.homedir(),".agents","skills"),opencode:ut.join(_O.homedir(),".agents","skills")},ilt=ut.join(nlt,"skills"),Jbe=t=>t.replace(/<\/user_request/gi,"</user_request"),SO=t=>typeof t=="string"&&/^[A-Za-z0-9_-]+$/.test(t)?t:null,Xbe=(t,e,r)=>{let n=` <user_request>
|
|
511
519
|
${Jbe(t)}
|
|
512
520
|
</user_request>`,i=` ${e}`;return`<request>
|
|
@@ -555,16 +563,16 @@ ${C}
|
|
|
555
563
|
${m.models.map(g=>`- \`${g}\``).join(`
|
|
556
564
|
`)}`).join(`
|
|
557
565
|
|
|
558
|
-
`);f=f.replace("<!-- AVAILABLE_MODELS -->",p),await ar.writeFile(d,f,"utf-8"),Gn.log("Injected dynamic model list into AI Gateway skill",{modelList:p})}}catch(u){Gn.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&&(Gn.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})),Q3={key:c,skills:l},l},dlt=t=>{let e=t?.constants||{};return{siteId:e.SITE_ID,accountId:ks.env.NETLIFY_TEAM_ID,userId:ks.env.NETLIFY_AGENT_RUNNER_USER_ID,siteSlug:ks.env.SITE_NAME,apiHost:e.NETLIFY_API_HOST,functionsDir:e.FUNCTIONS_DIST}},flt=10,plt=async t=>{let{name:e,ext:r}=ut.parse(t),n=t,i=ut.join(ks.cwd(),$r,n),o=0;for(;await hlt(i);){if(o>=flt)throw new Error("Failed to generate context file");n=`${e}-${elt.randomUUID().slice(0,5)}${r}`,i=ut.join(ks.cwd(),$r,n),o+=1}return n},hlt=async t=>{try{return await ar.access(t),!0}catch{return!1}},yO=async t=>{try{return(await ar.readdir(t)).length>0}catch{return!1}},ewe=async({cliPath:t,netlify:e,config:r,buildErrorContext:n,additionalContext:i,resumePrompt:o,preserveResultsFile:s})=>{let a=dlt(e),c=await plt(tne),l=ut.join(ks.cwd(),$r);await ar.mkdir(l,{recursive:!0});let u=ut.join($r,c),d=ut.join(ks.cwd(),u);if(!s){let x=ut.join(ks.cwd(),$r,la);try{await ar.unlink(x),Gn.log(`Deleted old results file: ${x}`)}catch{}}let f=Wbe(n),p=r.skillsTargetDir||Zbe[r.runner];
|
|
566
|
+
`);f=f.replace("<!-- AVAILABLE_MODELS -->",p),await ar.writeFile(d,f,"utf-8"),Gn.log("Injected dynamic model list into AI Gateway skill",{modelList:p})}}catch(u){Gn.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&&(Gn.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})),Q3={key:c,skills:l},l},dlt=t=>{let e=t?.constants||{};return{siteId:e.SITE_ID,accountId:ks.env.NETLIFY_TEAM_ID,userId:ks.env.NETLIFY_AGENT_RUNNER_USER_ID,siteSlug:ks.env.SITE_NAME,apiHost:e.NETLIFY_API_HOST,functionsDir:e.FUNCTIONS_DIST}},flt=10,plt=async t=>{let{name:e,ext:r}=ut.parse(t),n=t,i=ut.join(ks.cwd(),$r,n),o=0;for(;await hlt(i);){if(o>=flt)throw new Error("Failed to generate context file");n=`${e}-${elt.randomUUID().slice(0,5)}${r}`,i=ut.join(ks.cwd(),$r,n),o+=1}return n},hlt=async t=>{try{return await ar.access(t),!0}catch{return!1}},yO=async t=>{try{return(await ar.readdir(t)).length>0}catch{return!1}},ewe=async({cliPath:t,netlify:e,config:r,buildErrorContext:n,additionalContext:i,resumePrompt:o,preserveResultsFile:s})=>{let a=dlt(e),c=await plt(tne),l=ut.join(ks.cwd(),$r);await ar.mkdir(l,{recursive:!0});let u=ut.join($r,c),d=ut.join(ks.cwd(),u);if(!s){let x=ut.join(ks.cwd(),$r,la);try{await ar.unlink(x),Gn.log(`Deleted old results file: ${x}`)}catch{}}let f=Wbe(n),p=r.skillsTargetDir||Zbe[r.runner];r.runner&&await ult(r.runner,{targetDir:r.skillsTargetDir,mode:r.mode});let h=Je().promptImprovementsEnabled;if(o){let x=SO(r.sessionId),I=x?ut.join(l,ao,x):null,C=I&&await yO(I)?`
|
|
559
567
|
<attachments>
|
|
560
568
|
New uploads for this request are in ${I}/
|
|
561
|
-
</attachments>`:"",k=Ybe({dirPath:l,config:r,skillsDir:p,cliPath:t}),L=Kbe({sanitizedPrompt:Jbe(r.prompt),buildErrorContextText:f,assetsSection:C,modeReminder:k});return await ar.writeFile(d,L,"utf-8"),Gn.log(`Generated minimal resume prompt at: ${d}`),L}let
|
|
569
|
+
</attachments>`:"",k=Ybe({dirPath:l,config:r,skillsDir:p,cliPath:t}),L=Kbe({userRequestLast:h,sanitizedPrompt:Jbe(r.prompt),buildErrorContextText:f,assetsSection:C,modeReminder:k});return await ar.writeFile(d,L,"utf-8"),Gn.log(`Generated minimal resume prompt at: ${d}`),L}let m="";r.siteContext&&r.siteContext.length!==0&&(m=`
|
|
562
570
|
<project_rules>
|
|
563
571
|
${r.siteContext.filter(I=>I.site_context).map(I=>typeof I.site_context=="string"?I.site_context:typeof I.site_context=="object"?JSON.stringify(I.site_context):"").join(`
|
|
564
572
|
|
|
565
573
|
`)}
|
|
566
574
|
</project_rules>
|
|
567
|
-
`);let
|
|
575
|
+
`);let g="";if(r.sessionHistoryContext?.length){let x=ut.join(ks.cwd(),$r,x1);await ar.mkdir(x,{recursive:!0});let I=await Promise.all(r.sessionHistoryContext.map(async(C,k)=>{let L=k+1,v=`attempt-${L}.md`,Z=ut.join(x,v),M=ut.join($r,x1,v),_=SO(C.id),A=_?` ID ${_}`:"",O="";if(_){let W=ut.resolve(l,ao),le=ut.resolve(W,_);le.startsWith(W+ut.sep)&&await yO(le)&&(O=`
|
|
568
576
|
---
|
|
569
577
|
|
|
570
578
|
## Assets: ${le}/
|
|
@@ -578,7 +586,7 @@ ${C.request}
|
|
|
578
586
|
## Response - what the agent replied with after its work
|
|
579
587
|
|
|
580
588
|
${C.response}
|
|
581
|
-
${O}`;return await ar.writeFile(Z,Q,"utf-8"),Gn.log(`Created history file: ${M}`),M}));
|
|
589
|
+
${O}`;return await ar.writeFile(Z,Q,"utf-8"),Gn.log(`Created history file: ${M}`),M}));g+=`
|
|
582
590
|
<session_history_context>
|
|
583
591
|
History of prior work on this task.
|
|
584
592
|
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.
|
|
@@ -587,13 +595,13 @@ ${O}`;return await ar.writeFile(Z,Q,"utf-8"),Gn.log(`Created history file: ${M}`
|
|
|
587
595
|
`)}
|
|
588
596
|
|
|
589
597
|
</session_history_context>
|
|
590
|
-
`}let
|
|
598
|
+
`}let S=SO(r.sessionId),E=S?ut.join(l,ao,S):null,T=!!E&&await yO(E),b=await yO(ut.join(l,ao)),w=olt({userRequest:r.prompt,userRequestLast:h,buildErrorContextText:f,projectContext:m,sessionHistoryContextText:g,additionalContext:i,netlifyInfo:a,cliPath:t,skillsDir:p,netlifyFolder:l,resultsFilename:la,assetsFolder:ao,sessionId:r.sessionId,currentSessionHasAssets:T,hasAnyAssets:b,mode:r.mode,runner:r.runner});if(await ar.writeFile(d,w,"utf-8"),Gn.log(`Generated agent context document at: ${d}`),w.length>5e5){let x=Xbe(r.prompt,f,h);w=`
|
|
591
599
|
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.
|
|
592
600
|
|
|
593
|
-
${
|
|
601
|
+
${h?"":`${x}
|
|
594
602
|
|
|
595
603
|
`}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.
|
|
596
|
-
${
|
|
604
|
+
${h?`
|
|
597
605
|
${x}
|
|
598
606
|
`:""}`}return w};var mlt=oe("prompt"),twe=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:o,preserveResultsFile:s})=>{let a=await ewe({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:o,preserveResultsFile:s});return process.env.AGENT_RUNNER_DEBUG&&mlt.log("Contextful Prompt:",a),{prompt:a}};var rwe=oe("session_manager"),eW=null;var glt,tW,_lt=0,ylt,Slt;var rW=()=>glt,nW=()=>eW!==null,nwe=()=>_lt,iwe=()=>Slt,owe=()=>ylt,iW=async(t,e)=>{if(!Je().idleTimeoutEnabled||!t||t===e)return;let r=Zm[t];if(r)try{await r.clean(),rwe.info(`Wiped previous agent state (${t}) on switch to ${e}`)}catch(n){rwe.warn(`Failed to clean previous agent ${t} on switch`,{error:n?.message||n})}finally{tW=void 0}},EO=t=>{tW=t};var swe=t=>{let e=t.previousSession?.nativeSessionId;return!!e&&e===tW},awe=async()=>{if(eW)try{await eW}catch{}};var cwe=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 vlt}from"crypto";var oW=oe("interactions"),lwe="question",uwe="authorization",Tlt=["answered","skipped","dismissed"],dwe=async(t,e,r)=>{let n=vlt(),{authorization:i}=e,[o,s]=i?[{type:uwe,status:"pending",payload:{...i}},G.Authorization]:[{type:lwe,status:"pending",payload:e.questions},G.Question];return await Ar(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},fwe=(t,e,r)=>{if(t.authorization){oW.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;oW.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)},pwe=async t=>{let e;try{e=await Ap(t.id,t.sessionId)}catch(s){return oW.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),!!Tlt.includes(a.status??""))){if(a.type===uwe){let c=a.payload??{};n.push({refId:s,questions:[],responses:[],authorization:{service:c.service,granted:a.status==="answered"}});return}a.type===lwe&&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},hwe=()=>({counted:!1}),blt=(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=blt(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)},gwe=(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(`
|
|
599
607
|
|