@netlify/agent-runner-cli 1.189.4 → 1.190.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +2 -2
- package/dist/bin.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +2 -2
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},UGe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},FGe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:UGe};import{Buffer as zGe}from"buffer";var Eae=(t,e)=>t?void 0:jGe.bind(void 0,e),jGe=function*(t,e){if(typeof e!="string"&&!dr(e)&&!zGe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},vae=(t,e)=>t?BGe.bind(void 0,e):qGe.bind(void 0,e),BGe=function*(t,e){Tae(t,e),yield e},qGe=function*(t,e){if(Tae(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},Tae=(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 GGe}from"buffer";import{StringDecoder as VGe}from"string_decoder";var RR=(t,e,r)=>{if(r)return;if(t)return{transform:HGe.bind(void 0,new TextEncoder)};let n=new VGe(e);return{transform:WGe.bind(void 0,n),final:YGe.bind(void 0,n)}},HGe=function*(t,e){GGe.isBuffer(e)?yield fa(e):typeof e=="string"?yield t.encode(e):yield e},WGe=function*(t,e){yield dr(e)?t.write(e):e},YGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as bae}from"util";var NU=bae(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=ZGe}=e[r];for await(let i of n(t))yield*CR(i,e,r+1)},wae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*KGe(r,Number(e),t)},KGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*CR(n,r,e+1)},Aae=bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),ZGe=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)}},xae=(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=XGe}=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*JGe(r,Number(e),t)},JGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Fu(n,r,e+1)},XGe=function*(t){yield t};var MU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Cae(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,wae,a):kU.bind(void 0,Wy),p=l||u?Aae.bind(void 0,a):void 0;return{stream:new QGe({writableObjectMode:n,writableHighWaterMark:Rae(n),readableObjectMode:i,readableHighWaterMark:Rae(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=Cae(s,r,a);t=xae(c,t)}return t},Cae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Eae(n,a)},RR(r,s,n),xR(r,o,n,c),{transform:t,final:e},{transform:vae(i,a)},Sae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Iae=(t,e)=>{for(let r of eVe(t))tVe(t,r,e)},eVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),tVe=(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=>rVe(a,n));r.input=Ly(s)},rVe=(t,e)=>{let r=IR(t,e,"utf8",!0);return nVe(r),Ly(r)},nVe=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 aVe,appendFileSync as cVe}from"fs";var PR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ip(r,n)&&!ti.has(e)&&iVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&oVe.has(o))||t.every(({type:i})=>Pi.has(i))),iVe=t=>t===1||t===2,oVe=new Set(["pipe","overlapped"]),Pae=async(t,e,r,n)=>{for await(let i of t)sVe(e)||Nae(i,r,n)},Oae=(t,e,r)=>{for(let n of t)Nae(n,e,r)},sVe=t=>t._readableState.pipes.length>0,Nae=(t,e,r)=>{let n=Gx(t);os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var kae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>lVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},lVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Mse(t,o,d),p=fa(f),{stdioItems:h,objectMode:m}=e[r],g=uVe([p],h,c,n),{serializedResult:S,finalResult:E=S}=dVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});fVe({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&&pVe(S,h,i),T}catch(b){return n.error=b,T}},uVe=(t,e,r,n)=>{try{return IR(t,e,r,!1)}catch(i){return n.error=i,t}},dVe=({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=Yne(t,r);return n[o]?{serializedResult:s,finalResult:OU(s,!i[o],e)}:{serializedResult:s}},fVe=({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{Oae(a,e,n)}catch(c){r.error??=c}},pVe=(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)?cVe(n,t):(r.add(o),aVe(n,t))}};var Mae=([,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 Dae=async(t,e)=>{let[r,n]=await hVe(t);return e.isForcefullyTerminated??=!1,[r,n]},hVe=async t=>{let[e,r]=await Promise.allSettled([DU(t,"spawn"),DU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$ae(t):r.value},$ae=async t=>{try{return await DU(t,"exit")}catch{return $ae(t)}},Lae=async t=>{let[e,r]=await t;if(!mVe(e,r)&&$U(e,r))throw new lo;return[e,r]},mVe=(t,e)=>t===void 0&&e===void 0,$U=(t,e)=>t!==0||e!==null;var Uae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=gVe(t,e,r),s=o?.code==="ETIMEDOUT",a=kse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},gVe=(t,e,r)=>t!==void 0?t:$U(e,r)?new lo:void 0;var Fae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=yVe(t,e,r),d=vVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Fp(d,c,l)},yVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Hx(t,e,r),a=SVe(r),{file:c,commandArguments:l,options:u}=fR(t,e,a);EVe(u);let d=mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},SVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,EVe=({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.`)},vVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=TVe({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}=Uae(c,r),{output:h,error:m=l}=kae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((E,T)=>ma(E,r,T)),S=ma(Mae(h,r),r,"all");return wVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:S,options:r,command:n,escapedCommand:i,startTime:a})},TVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Iae(o,r);let a=bVe(r);return _Ve(...pR(t,e,a))}catch(a){return Up({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},bVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:ER(e)}),wVe=({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 dHe}from"events";import{spawn as fHe}from"child_process";import Gae from"process";import{once as LU,on as AVe}from"events";var zae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Np({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:sR(t)}),xVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),xVe=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([RVe(o,n,s),CVe(o,r,s),IVe(o,r,s)])}catch(a){throw kp(t),a}finally{s.abort(),nR(e,i)}},RVe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await LU(t,"message",{signal:r});return n}for await(let[n]of AVe(t,"message",{signal:r}))if(e(n))return n},CVe=async(t,e,{signal:r})=>{await LU(t,"disconnect",{signal:r}),xoe(e)},IVe=async(t,e,{signal:r})=>{let[n]=await LU(t,"strict:error",{signal:r});throw Qx(n,e)};import{once as Bae,on as PVe}from"events";var qae=({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 OVe(t,s,a),NVe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),kVe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},OVe=async(t,e,r)=>{try{await Bae(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},NVe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Bae(t,"strict:error",{signal:r.signal});n.error=Qx(i,e),r.abort()}catch{}},kVe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of PVe(r,"message",{signal:o.signal}))jae(s),yield c}catch{jae(s)}finally{o.abort(),nR(e,a),n||kp(t),i&&await t}},jae=({error:t})=>{if(t)throw t};var Vae=(t,{ipc:e})=>{Object.assign(t,Wae(t,!1,e))},Hae=()=>{let t=Gae,e=!0,r=Gae.channel!==void 0;return{...Wae(t,e,r),getCancelSignal:Qoe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Wae=(t,e,r)=>({sendMessage:uR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:zae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:qae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as MVe}from"child_process";import{PassThrough as DVe,Readable as $Ve,Writable as LVe,Duplex as UVe}from"stream";var Yae=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{CU(n);let a=new MVe;FVe(a,n),Object.assign(a,{readable:zVe,writable:jVe,duplex:BVe});let c=Up({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=qVe(c,s,i);return{subprocess:a,promise:l}},FVe=(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 DVe;return t.end(),t},zVe=()=>new $Ve({read(){}}),jVe=()=>new LVe({write(){}}),BVe=()=>new UVe({read(){},write(){}}),qVe=async(t,e,r)=>Fp(t,e,r);import{createReadStream as Kae,createWriteStream as Zae}from"fs";import{Buffer as GVe}from"buffer";import{Readable as Ky,Writable as VVe,Duplex as HVe}from"stream";var Xae=(t,e)=>AR(WVe,t,e,!1),Zy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Nc[t]}.`)},Jae={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:HVe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},WVe={input:{...Jae,fileUrl:({value:t})=>({stream:Kae(t)}),filePath:({value:{file:t}})=>({stream:Kae(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(GVe.from(t))})},output:{...Jae,fileUrl:({value:t})=>({stream:Zae(t)}),filePath:({value:{file:t,append:e}})=>({stream:Zae(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:VVe.fromWeb(t)}),iterable:Zy,asyncIterable:Zy,string:Zy,uint8Array:Zy}};import{on as YVe,once as Qae}from"events";import{PassThrough as KVe,getDefaultHighWaterMark as ZVe}from"stream";import{finished as rce}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=JVe(t,e),n=new FU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var JVe=(t,e)=>{if(t.length===0)return ZVe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},FU=class extends KVe{#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??=XVe(this,this.#e,this.#o);let r=t4e({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)}},XVe=async(t,e,r)=>{NR(t,ece);let n=new AbortController;try{await Promise.race([QVe(t,n),e4e(t,e,r,n)])}finally{n.abort(),NR(t,-ece)}},QVe=async(t,{signal:e})=>{try{await rce(t,{signal:e,cleanup:!0})}catch(r){throw nce(t,r),r}},e4e=async(t,e,r,{signal:n})=>{for await(let[i]of YVe(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}\`.`)},t4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{NR(t,tce);let a=new AbortController;try{await Promise.race([r4e(o,e,a),n4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),i4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),NR(t,-tce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?jU(t):o4e(t))},r4e=async(t,e,{signal:r})=>{try{await t,r.aborted||jU(e)}catch(n){r.aborted||nce(e,n)}},n4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await rce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;ice(s)?i.add(e):oce(t,s)}},i4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Qae(t,i,{signal:o}),!t.readable)return Qae(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},o4e=t=>{t.writable&&t.end()},nce=(t,e)=>{ice(e)?jU(t):oce(t,e)},ice=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",jU=t=>{(t.readable||t.writable)&&t.destroy()},oce=(t,e)=>{t.destroyed||(t.once("error",s4e),t.destroy(e))},s4e=()=>{},NR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ece=2,tce=1;import{finished as sce}from"stream/promises";var jp=(t,e)=>{t.pipe(e),a4e(t,e),c4e(t,e)},a4e=async(t,e)=>{if(!(co(t)||co(e))){try{await sce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}BU(e)}},BU=t=>{t.writable&&t.end()},c4e=async(t,e)=>{if(!(co(t)||co(e))){try{await sce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}qU(t)}},qU=t=>{t.readable&&t.destroy()};var ace=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Pi.has(c)))l4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Pi.has(c)))d4e({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)}},l4e=(t,e,r,n)=>{r==="output"?jp(t.stdio[n],e):jp(e,t.stdio[n]);let i=u4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},u4e=["stdin","stdout","stderr"],d4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;f4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},f4e=(t,{signal:e})=>{co(t)&&$u(t,p4e,e)},p4e=2;import{addAbortListener as g4e}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,h4e=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];h4e(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{},m4e=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:cce,load:HLt,unload:WLt}=m4e(kR(KU)?new YU(KU):new WU);var lce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=cce(()=>{t.kill()});g4e(n,()=>{i()})};var dce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Vx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=_4e(r,n,i),{sourceStream:d,sourceError:f}=S4e(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}},_4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=y4e(t,e,...r),a=tR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},y4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(uce,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(uce)(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}`)},uce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),S4e=(t,e)=>{try{return{sourceStream:Mp(t,e)}}catch(r){return{sourceError:r}}};var pce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=E4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ZU({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},E4e=({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:fce,escapedCommand:fce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),fce="source.pipe(destination)";var hce=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 v4e}from"stream/promises";var mce=(t,e,r)=>{let n=DR.has(e)?b4e(t,e):T4e(t,e);return $u(t,A4e,r.signal),$u(e,x4e,r.signal),w4e(e),n},T4e=(t,e)=>{let r=zu([t]);return jp(r,e),DR.set(e,r),r},b4e=(t,e)=>{let r=DR.get(e);return r.add(t),r},w4e=async t=>{try{await v4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}DR.delete(t)},DR=new WeakMap,A4e=2,x4e=1;import{aborted as R4e}from"util";var gce=(t,e)=>t===void 0?[]:[C4e(t,e)],C4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await R4e(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}=dce(t,...e),i=I4e({...n,destination:r});return i.pipe=$R.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},I4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=P4e(t,i);pce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=mce(e,o,d);return await Promise.race([hce(u),...gce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},P4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as L4e}from"timers/promises";import{on as O4e}from"events";import{getDefaultHighWaterMark as N4e}from"stream";var LR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return k4e(e,s),yce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},k4e=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;M4e(e,s,t);let a=t.readableObjectMode&&!o;return yce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},M4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},yce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=O4e(t,"data",{signal:e.signal,highWaterMark:_ce,highWatermark:_ce});return D4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},XU=N4e(!0),_ce=XU,D4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=$4e({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)}},$4e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[RR(t,r,!e),xR(t,i,!n,{})].filter(Boolean);var Sce=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=U4e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([F4e(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([z4e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},U4e=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 Pae(a,t,r,o)},F4e=async t=>{await L4e(),t.readableFlowing===null&&t.resume()},z4e=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 Ece(Pse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},QU=async t=>{try{return await t}catch(e){return Ece(e)}},Ece=({bufferedData:t})=>Hne(t)?new Uint8Array(t):t;import{finished as j4e}from"stream/promises";var Jy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=B4e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],j4e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||V4e(a,e,r,n)}finally{s.abort()}},B4e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&q4e(t,r,n),n},q4e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{G4e(e,r),n.call(t,...i)}},G4e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},V4e=(t,e,r,n)=>{if(!H4e(t,e,r,n))throw t},H4e=(t,e,r,n=!0)=>r.propagating?vce(t)||UR(t):(r.propagating=!0,eF(r,e)===n?vce(t):UR(t)),eF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",UR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",vce=t=>t?.code==="EPIPE";var Tce=({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([Sce({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 bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?zu([t,e].filter(Boolean)):void 0,wce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>tF({...W4e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Y4e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),W4e=({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}},Y4e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as K4e}from"events";var Ace=t=>Ip(t,"ipc"),xce=(t,e)=>{let r=Gx(t);os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Rce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ace(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&&(Ose(t,i,c),i.push(l)),s&&xce(l,o);return i},Cce=async(t,e)=>(await Promise.allSettled([t]),e);var Ice=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=Dae(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},b=Tce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=wce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=[],P=Rce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),I=Z4e(m,t,T),N=J4e(h,T);try{return await Promise.race([Promise.all([{},Lae(E),Promise.all(b),w,P,lse(t,d),...I,...N]),g,X4e(t,S),...ise(t,o,f,S),...Aoe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...rse({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),Cce(P,x),Promise.allSettled(I),Promise.allSettled(N)])}},Z4e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Jy(n,i,r)),J4e=(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"}))),X4e=async(t,{signal:e})=>{let[r]=await K4e(t,"error",{signal:e});throw r};var Pce=()=>({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 Q4e}from"stream";import{callbackify as eHe}from"util";import{finished as Oce}from"stream/promises";var rF=async t=>{if(t!==void 0)try{await nF(t)}catch{}},Nce=async t=>{if(t!==void 0)try{await iF(t)}catch{}},nF=async t=>{await Oce(t,{cleanup:!0,readable:!1,writable:!0})},iF=async t=>{await Oce(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 kce=({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 Q4e({read:f,destroy:eHe(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(){tHe(this,s,o)},onStdoutDataDone:o}},tHe=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),Mce(r,o)}},lF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Bp(r,e)&&(Mce(t,n),await FR(e,n))},Mce=(t,e)=>{zR(t,t.readable,e)};import{Writable as rHe}from"stream";import{callbackify as Dce}from"util";var $ce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=uF(t,r,e),s=new rHe({...dF(n,t,i),destroy:Dce(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:nHe.bind(void 0,t),final:Dce(iHe.bind(void 0,t,e,r))}),nHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},iHe=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 Nce(r),Lce(e,n)}},pF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Bp(r,e),await Bp(n,e)&&(Lce(t,i),await FR(e,i))},Lce=(t,e)=>{zR(t,t.writable,e)};import{Duplex as oHe}from"stream";import{callbackify as sHe}from"util";var Uce=({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 oHe({read:g,...dF(u,t,d),destroy:sHe(aHe.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},aHe=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 cHe(a,s,t)},cHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Fce=(t,{encoding:e})=>{let r=Pce();t.readable=kce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$ce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Uce.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 zce=(t,e)=>{for(let[r,n]of uHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},lHe=(async()=>{})().constructor.prototype,uHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(lHe,t)]);var jce=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=pHe(t,e,r),{subprocess:f,promise:p}=mHe({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}),zce(f,p),as.set(f,{options:u,fileDescriptors:d}),f},pHe=(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=hHe(l),d=Xae(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},hHe=({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}},mHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=fHe(...pR(t,e,r))}catch(h){return Yae({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;dHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ace(c,a,l),lce(c,r,l);let d={},f=ss();c.kill=boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=bce(c,r),Fce(c,r),Vae(c,r);let p=gHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},gHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Ice({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=_He({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)},_He=({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,yHe(n,t[n],i)]));return{...t,...r}},yHe=(t,e,r)=>SHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,SHe=new Set(["env",...G1]);var kc=(t,e,r,n)=>{let i=(s,a,c)=>kc(s,a,r,c),o=(...s)=>EHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},EHe=({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}=vHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Fae(a,c,l):jce(a,c,l,i)},vHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Xne(e)?Qne(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 Bce=({file:t,commandArguments:e})=>Gce(t,e),qce=({file:t,commandArguments:e})=>({...Gce(t,e),isSync:!0}),Gce=(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]=THe(t);return{file:r,commandArguments:n}},THe=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(bHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},bHe=/ +/g;var Vce=(t,e,r)=>{t.sync=e(wHe,r),t.s=t.sync},Hce=({options:t})=>Wce(t),wHe=({options:t})=>({...Wce(t),isSync:!0}),Wce=t=>({options:{...AHe(t),...t}}),AHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Yce={preferLocal:!0};var Kce=kc(()=>({})),$Ft=kc(()=>({isSync:!0})),Zce=kc(Bce),LFt=kc(qce),UFt=kc(sse),FFt=kc(Hce,{},Yce,Vce),{sendMessage:zFt,getOneMessage:jFt,getEachMessage:BFt,getCancelSignal:qFt}=Hae();var Jce=!1,Xce,xHe=t=>{Xce??=t},Qce=t=>{Jce=!0,xHe(t)},ri=()=>Jce,Mc=()=>Xce,ele=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Qy=null,tle=t=>(Qy&&Qy.destroy(),Qy=new po({totalAllowedTime:t}),Qy),rle=()=>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 nle={name:"@netlify/agent-runner-cli",type:"module",version:"1.189.4",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var PHe=CHe(import.meta.url),OHe=ga.dirname(PHe),NHe=IHe(import.meta.url),qp=oe("shell"),mF=new Set,ile={preferLocal:!0},Mt=(t,e,r)=>{let[n,i]=kHe(e,r),o={...ile,...i},s=Kce(t,n,o);sle(s,o),lle(s);let a=r?.idleTimeout;return a&&a>0&&cle(s,a),s},ole=(t,e)=>{let r={...ile,...e},n=Zce(t,r);return sle(n,r),lle(n),e?.idleTimeout&&e.idleTimeout>0&&cle(n,e.idleTimeout),n},kHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},sle=(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}},ale=t=>gF(t,"SIGKILL"),cle=(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}`),ale(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},lle=t=>{mF.add(t);let e=rle();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`),ale(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=NHe.resolve(nle.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(OHe,"..","node_modules",".bin",e);if(BR.existsSync(n))return n}var ule=oe("repo"),hle="runner-diffs-",VR=t=>`${hle}${t}-`,mle=async t=>{let e=ple.tmpdir(),r;try{r=await qR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(hle)&&!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()})=>{ule.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 jHe(l,r)}ule.info("Changes after processing"),await SF(r);let s=await eS(o,r);if(await yF(s,r),i=await UHe(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await qR.mkdtemp(GR.join(ple.tmpdir(),VR(t.sessionId))),c=await _F({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await $He(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 fle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await fle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},dle=async t=>{let e=MHe("sha256");for await(let r of DHe(t))e.update(r);return e.digest("hex")},fle=async(t,e)=>t.size===e.size&&await dle(t.path)===await dle(e.path),$He=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??"")},gle=/.. (.+)?\.log$/,LHe=[gle],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 GGe}from"buffer";import{StringDecoder as VGe}from"string_decoder";var RR=(t,e,r)=>{if(r)return;if(t)return{transform:HGe.bind(void 0,new TextEncoder)};let n=new VGe(e);return{transform:WGe.bind(void 0,n),final:YGe.bind(void 0,n)}},HGe=function*(t,e){GGe.isBuffer(e)?yield fa(e):typeof e=="string"?yield t.encode(e):yield e},WGe=function*(t,e){yield dr(e)?t.write(e):e},YGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as bae}from"util";var NU=bae(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=ZGe}=e[r];for await(let i of n(t))yield*CR(i,e,r+1)},wae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*KGe(r,Number(e),t)},KGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*CR(n,r,e+1)},Aae=bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),ZGe=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)}},xae=(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=XGe}=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*JGe(r,Number(e),t)},JGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Fu(n,r,e+1)},XGe=function*(t){yield t};var MU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Cae(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,wae,a):kU.bind(void 0,Wy),p=l||u?Aae.bind(void 0,a):void 0;return{stream:new QGe({writableObjectMode:n,writableHighWaterMark:Rae(n),readableObjectMode:i,readableHighWaterMark:Rae(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=Cae(s,r,a);t=xae(c,t)}return t},Cae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Eae(n,a)},RR(r,s,n),xR(r,o,n,c),{transform:t,final:e},{transform:vae(i,a)},Sae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Iae=(t,e)=>{for(let r of eVe(t))tVe(t,r,e)},eVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),tVe=(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=>rVe(a,n));r.input=Ly(s)},rVe=(t,e)=>{let r=IR(t,e,"utf8",!0);return nVe(r),Ly(r)},nVe=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 aVe,appendFileSync as cVe}from"fs";var PR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ip(r,n)&&!ti.has(e)&&iVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&oVe.has(o))||t.every(({type:i})=>Pi.has(i))),iVe=t=>t===1||t===2,oVe=new Set(["pipe","overlapped"]),Pae=async(t,e,r,n)=>{for await(let i of t)sVe(e)||Nae(i,r,n)},Oae=(t,e,r)=>{for(let n of t)Nae(n,e,r)},sVe=t=>t._readableState.pipes.length>0,Nae=(t,e,r)=>{let n=Gx(t);os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var kae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>lVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},lVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Mse(t,o,d),p=fa(f),{stdioItems:h,objectMode:m}=e[r],g=uVe([p],h,c,n),{serializedResult:S,finalResult:E=S}=dVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});fVe({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&&pVe(S,h,i),T}catch(b){return n.error=b,T}},uVe=(t,e,r,n)=>{try{return IR(t,e,r,!1)}catch(i){return n.error=i,t}},dVe=({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=Yne(t,r);return n[o]?{serializedResult:s,finalResult:OU(s,!i[o],e)}:{serializedResult:s}},fVe=({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{Oae(a,e,n)}catch(c){r.error??=c}},pVe=(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)?cVe(n,t):(r.add(o),aVe(n,t))}};var Mae=([,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 Dae=async(t,e)=>{let[r,n]=await hVe(t);return e.isForcefullyTerminated??=!1,[r,n]},hVe=async t=>{let[e,r]=await Promise.allSettled([DU(t,"spawn"),DU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$ae(t):r.value},$ae=async t=>{try{return await DU(t,"exit")}catch{return $ae(t)}},Lae=async t=>{let[e,r]=await t;if(!mVe(e,r)&&$U(e,r))throw new lo;return[e,r]},mVe=(t,e)=>t===void 0&&e===void 0,$U=(t,e)=>t!==0||e!==null;var Uae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=gVe(t,e,r),s=o?.code==="ETIMEDOUT",a=kse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},gVe=(t,e,r)=>t!==void 0?t:$U(e,r)?new lo:void 0;var Fae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=yVe(t,e,r),d=vVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Fp(d,c,l)},yVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Hx(t,e,r),a=SVe(r),{file:c,commandArguments:l,options:u}=fR(t,e,a);EVe(u);let d=mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},SVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,EVe=({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.`)},vVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=TVe({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}=Uae(c,r),{output:h,error:m=l}=kae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((E,T)=>ma(E,r,T)),S=ma(Mae(h,r),r,"all");return wVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:S,options:r,command:n,escapedCommand:i,startTime:a})},TVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Iae(o,r);let a=bVe(r);return _Ve(...pR(t,e,a))}catch(a){return Up({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},bVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:ER(e)}),wVe=({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 dHe}from"events";import{spawn as fHe}from"child_process";import Gae from"process";import{once as LU,on as AVe}from"events";var zae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Np({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:sR(t)}),xVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),xVe=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([RVe(o,n,s),CVe(o,r,s),IVe(o,r,s)])}catch(a){throw kp(t),a}finally{s.abort(),nR(e,i)}},RVe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await LU(t,"message",{signal:r});return n}for await(let[n]of AVe(t,"message",{signal:r}))if(e(n))return n},CVe=async(t,e,{signal:r})=>{await LU(t,"disconnect",{signal:r}),xoe(e)},IVe=async(t,e,{signal:r})=>{let[n]=await LU(t,"strict:error",{signal:r});throw Qx(n,e)};import{once as Bae,on as PVe}from"events";var qae=({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 OVe(t,s,a),NVe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),kVe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},OVe=async(t,e,r)=>{try{await Bae(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},NVe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Bae(t,"strict:error",{signal:r.signal});n.error=Qx(i,e),r.abort()}catch{}},kVe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of PVe(r,"message",{signal:o.signal}))jae(s),yield c}catch{jae(s)}finally{o.abort(),nR(e,a),n||kp(t),i&&await t}},jae=({error:t})=>{if(t)throw t};var Vae=(t,{ipc:e})=>{Object.assign(t,Wae(t,!1,e))},Hae=()=>{let t=Gae,e=!0,r=Gae.channel!==void 0;return{...Wae(t,e,r),getCancelSignal:Qoe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Wae=(t,e,r)=>({sendMessage:uR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:zae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:qae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as MVe}from"child_process";import{PassThrough as DVe,Readable as $Ve,Writable as LVe,Duplex as UVe}from"stream";var Yae=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{CU(n);let a=new MVe;FVe(a,n),Object.assign(a,{readable:zVe,writable:jVe,duplex:BVe});let c=Up({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=qVe(c,s,i);return{subprocess:a,promise:l}},FVe=(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 DVe;return t.end(),t},zVe=()=>new $Ve({read(){}}),jVe=()=>new LVe({write(){}}),BVe=()=>new UVe({read(){},write(){}}),qVe=async(t,e,r)=>Fp(t,e,r);import{createReadStream as Kae,createWriteStream as Zae}from"fs";import{Buffer as GVe}from"buffer";import{Readable as Ky,Writable as VVe,Duplex as HVe}from"stream";var Xae=(t,e)=>AR(WVe,t,e,!1),Zy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Nc[t]}.`)},Jae={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:HVe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},WVe={input:{...Jae,fileUrl:({value:t})=>({stream:Kae(t)}),filePath:({value:{file:t}})=>({stream:Kae(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(GVe.from(t))})},output:{...Jae,fileUrl:({value:t})=>({stream:Zae(t)}),filePath:({value:{file:t,append:e}})=>({stream:Zae(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:VVe.fromWeb(t)}),iterable:Zy,asyncIterable:Zy,string:Zy,uint8Array:Zy}};import{on as YVe,once as Qae}from"events";import{PassThrough as KVe,getDefaultHighWaterMark as ZVe}from"stream";import{finished as rce}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=JVe(t,e),n=new FU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var JVe=(t,e)=>{if(t.length===0)return ZVe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},FU=class extends KVe{#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??=XVe(this,this.#e,this.#o);let r=t4e({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)}},XVe=async(t,e,r)=>{NR(t,ece);let n=new AbortController;try{await Promise.race([QVe(t,n),e4e(t,e,r,n)])}finally{n.abort(),NR(t,-ece)}},QVe=async(t,{signal:e})=>{try{await rce(t,{signal:e,cleanup:!0})}catch(r){throw nce(t,r),r}},e4e=async(t,e,r,{signal:n})=>{for await(let[i]of YVe(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}\`.`)},t4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{NR(t,tce);let a=new AbortController;try{await Promise.race([r4e(o,e,a),n4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),i4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),NR(t,-tce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?jU(t):o4e(t))},r4e=async(t,e,{signal:r})=>{try{await t,r.aborted||jU(e)}catch(n){r.aborted||nce(e,n)}},n4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await rce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;ice(s)?i.add(e):oce(t,s)}},i4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Qae(t,i,{signal:o}),!t.readable)return Qae(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},o4e=t=>{t.writable&&t.end()},nce=(t,e)=>{ice(e)?jU(t):oce(t,e)},ice=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",jU=t=>{(t.readable||t.writable)&&t.destroy()},oce=(t,e)=>{t.destroyed||(t.once("error",s4e),t.destroy(e))},s4e=()=>{},NR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ece=2,tce=1;import{finished as sce}from"stream/promises";var jp=(t,e)=>{t.pipe(e),a4e(t,e),c4e(t,e)},a4e=async(t,e)=>{if(!(co(t)||co(e))){try{await sce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}BU(e)}},BU=t=>{t.writable&&t.end()},c4e=async(t,e)=>{if(!(co(t)||co(e))){try{await sce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}qU(t)}},qU=t=>{t.readable&&t.destroy()};var ace=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Pi.has(c)))l4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Pi.has(c)))d4e({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)}},l4e=(t,e,r,n)=>{r==="output"?jp(t.stdio[n],e):jp(e,t.stdio[n]);let i=u4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},u4e=["stdin","stdout","stderr"],d4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;f4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},f4e=(t,{signal:e})=>{co(t)&&$u(t,p4e,e)},p4e=2;import{addAbortListener as g4e}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,h4e=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];h4e(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{},m4e=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:cce,load:HLt,unload:WLt}=m4e(kR(KU)?new YU(KU):new WU);var lce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=cce(()=>{t.kill()});g4e(n,()=>{i()})};var dce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Vx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=_4e(r,n,i),{sourceStream:d,sourceError:f}=S4e(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}},_4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=y4e(t,e,...r),a=tR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},y4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(uce,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(uce)(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}`)},uce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),S4e=(t,e)=>{try{return{sourceStream:Mp(t,e)}}catch(r){return{sourceError:r}}};var pce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=E4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ZU({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},E4e=({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:fce,escapedCommand:fce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),fce="source.pipe(destination)";var hce=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 v4e}from"stream/promises";var mce=(t,e,r)=>{let n=DR.has(e)?b4e(t,e):T4e(t,e);return $u(t,A4e,r.signal),$u(e,x4e,r.signal),w4e(e),n},T4e=(t,e)=>{let r=zu([t]);return jp(r,e),DR.set(e,r),r},b4e=(t,e)=>{let r=DR.get(e);return r.add(t),r},w4e=async t=>{try{await v4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}DR.delete(t)},DR=new WeakMap,A4e=2,x4e=1;import{aborted as R4e}from"util";var gce=(t,e)=>t===void 0?[]:[C4e(t,e)],C4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await R4e(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}=dce(t,...e),i=I4e({...n,destination:r});return i.pipe=$R.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},I4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=P4e(t,i);pce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=mce(e,o,d);return await Promise.race([hce(u),...gce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},P4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as L4e}from"timers/promises";import{on as O4e}from"events";import{getDefaultHighWaterMark as N4e}from"stream";var LR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return k4e(e,s),yce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},k4e=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;M4e(e,s,t);let a=t.readableObjectMode&&!o;return yce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},M4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},yce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=O4e(t,"data",{signal:e.signal,highWaterMark:_ce,highWatermark:_ce});return D4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},XU=N4e(!0),_ce=XU,D4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=$4e({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)}},$4e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[RR(t,r,!e),xR(t,i,!n,{})].filter(Boolean);var Sce=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=U4e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([F4e(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([z4e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},U4e=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 Pae(a,t,r,o)},F4e=async t=>{await L4e(),t.readableFlowing===null&&t.resume()},z4e=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 Ece(Pse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},QU=async t=>{try{return await t}catch(e){return Ece(e)}},Ece=({bufferedData:t})=>Hne(t)?new Uint8Array(t):t;import{finished as j4e}from"stream/promises";var Jy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=B4e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],j4e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||V4e(a,e,r,n)}finally{s.abort()}},B4e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&q4e(t,r,n),n},q4e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{G4e(e,r),n.call(t,...i)}},G4e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},V4e=(t,e,r,n)=>{if(!H4e(t,e,r,n))throw t},H4e=(t,e,r,n=!0)=>r.propagating?vce(t)||UR(t):(r.propagating=!0,eF(r,e)===n?vce(t):UR(t)),eF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",UR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",vce=t=>t?.code==="EPIPE";var Tce=({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([Sce({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 bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?zu([t,e].filter(Boolean)):void 0,wce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>tF({...W4e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Y4e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),W4e=({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}},Y4e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as K4e}from"events";var Ace=t=>Ip(t,"ipc"),xce=(t,e)=>{let r=Gx(t);os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Rce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ace(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&&(Ose(t,i,c),i.push(l)),s&&xce(l,o);return i},Cce=async(t,e)=>(await Promise.allSettled([t]),e);var Ice=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=Dae(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},b=Tce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=wce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=[],P=Rce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),I=Z4e(m,t,T),N=J4e(h,T);try{return await Promise.race([Promise.all([{},Lae(E),Promise.all(b),w,P,lse(t,d),...I,...N]),g,X4e(t,S),...ise(t,o,f,S),...Aoe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...rse({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),Cce(P,x),Promise.allSettled(I),Promise.allSettled(N)])}},Z4e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Jy(n,i,r)),J4e=(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"}))),X4e=async(t,{signal:e})=>{let[r]=await K4e(t,"error",{signal:e});throw r};var Pce=()=>({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 Q4e}from"stream";import{callbackify as eHe}from"util";import{finished as Oce}from"stream/promises";var rF=async t=>{if(t!==void 0)try{await nF(t)}catch{}},Nce=async t=>{if(t!==void 0)try{await iF(t)}catch{}},nF=async t=>{await Oce(t,{cleanup:!0,readable:!1,writable:!0})},iF=async t=>{await Oce(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 kce=({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 Q4e({read:f,destroy:eHe(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(){tHe(this,s,o)},onStdoutDataDone:o}},tHe=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),Mce(r,o)}},lF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Bp(r,e)&&(Mce(t,n),await FR(e,n))},Mce=(t,e)=>{zR(t,t.readable,e)};import{Writable as rHe}from"stream";import{callbackify as Dce}from"util";var $ce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=uF(t,r,e),s=new rHe({...dF(n,t,i),destroy:Dce(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:nHe.bind(void 0,t),final:Dce(iHe.bind(void 0,t,e,r))}),nHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},iHe=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 Nce(r),Lce(e,n)}},pF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Bp(r,e),await Bp(n,e)&&(Lce(t,i),await FR(e,i))},Lce=(t,e)=>{zR(t,t.writable,e)};import{Duplex as oHe}from"stream";import{callbackify as sHe}from"util";var Uce=({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 oHe({read:g,...dF(u,t,d),destroy:sHe(aHe.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},aHe=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 cHe(a,s,t)},cHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Fce=(t,{encoding:e})=>{let r=Pce();t.readable=kce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$ce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Uce.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 zce=(t,e)=>{for(let[r,n]of uHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},lHe=(async()=>{})().constructor.prototype,uHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(lHe,t)]);var jce=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=pHe(t,e,r),{subprocess:f,promise:p}=mHe({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}),zce(f,p),as.set(f,{options:u,fileDescriptors:d}),f},pHe=(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=hHe(l),d=Xae(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},hHe=({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}},mHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=fHe(...pR(t,e,r))}catch(h){return Yae({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;dHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ace(c,a,l),lce(c,r,l);let d={},f=ss();c.kill=boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=bce(c,r),Fce(c,r),Vae(c,r);let p=gHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},gHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Ice({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=_He({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)},_He=({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,yHe(n,t[n],i)]));return{...t,...r}},yHe=(t,e,r)=>SHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,SHe=new Set(["env",...G1]);var kc=(t,e,r,n)=>{let i=(s,a,c)=>kc(s,a,r,c),o=(...s)=>EHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},EHe=({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}=vHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Fae(a,c,l):jce(a,c,l,i)},vHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Xne(e)?Qne(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 Bce=({file:t,commandArguments:e})=>Gce(t,e),qce=({file:t,commandArguments:e})=>({...Gce(t,e),isSync:!0}),Gce=(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]=THe(t);return{file:r,commandArguments:n}},THe=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(bHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},bHe=/ +/g;var Vce=(t,e,r)=>{t.sync=e(wHe,r),t.s=t.sync},Hce=({options:t})=>Wce(t),wHe=({options:t})=>({...Wce(t),isSync:!0}),Wce=t=>({options:{...AHe(t),...t}}),AHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Yce={preferLocal:!0};var Kce=kc(()=>({})),$Ft=kc(()=>({isSync:!0})),Zce=kc(Bce),LFt=kc(qce),UFt=kc(sse),FFt=kc(Hce,{},Yce,Vce),{sendMessage:zFt,getOneMessage:jFt,getEachMessage:BFt,getCancelSignal:qFt}=Hae();var Jce=!1,Xce,xHe=t=>{Xce??=t},Qce=t=>{Jce=!0,xHe(t)},ri=()=>Jce,Mc=()=>Xce,ele=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Qy=null,tle=t=>(Qy&&Qy.destroy(),Qy=new po({totalAllowedTime:t}),Qy),rle=()=>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 nle={name:"@netlify/agent-runner-cli",type:"module",version:"1.190.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.18.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 PHe=CHe(import.meta.url),OHe=ga.dirname(PHe),NHe=IHe(import.meta.url),qp=oe("shell"),mF=new Set,ile={preferLocal:!0},Mt=(t,e,r)=>{let[n,i]=kHe(e,r),o={...ile,...i},s=Kce(t,n,o);sle(s,o),lle(s);let a=r?.idleTimeout;return a&&a>0&&cle(s,a),s},ole=(t,e)=>{let r={...ile,...e},n=Zce(t,r);return sle(n,r),lle(n),e?.idleTimeout&&e.idleTimeout>0&&cle(n,e.idleTimeout),n},kHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},sle=(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}},ale=t=>gF(t,"SIGKILL"),cle=(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}`),ale(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},lle=t=>{mF.add(t);let e=rle();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`),ale(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=NHe.resolve(nle.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(OHe,"..","node_modules",".bin",e);if(BR.existsSync(n))return n}var ule=oe("repo"),hle="runner-diffs-",VR=t=>`${hle}${t}-`,mle=async t=>{let e=ple.tmpdir(),r;try{r=await qR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(hle)&&!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()})=>{ule.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 jHe(l,r)}ule.info("Changes after processing"),await SF(r);let s=await eS(o,r);if(await yF(s,r),i=await UHe(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await qR.mkdtemp(GR.join(ple.tmpdir(),VR(t.sessionId))),c=await _F({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await $He(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 fle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await fle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},dle=async t=>{let e=MHe("sha256");for await(let r of DHe(t))e.update(r);return e.digest("hex")},fle=async(t,e)=>t.size===e.size&&await dle(t.path)===await dle(e.path),$He=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??"")},gle=/.. (.+)?\.log$/,LHe=[gle],EF=async(t=process.cwd())=>{let e=await SF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
146
146
|
`).filter(i=>LHe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},UHe=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()},FHe=1,zHe=async t=>{try{return await Xt(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===FHe)return!1;throw e}},_le=async(t=process.cwd())=>{if(!await zHe(t))return!0;let{stdout:e}=await Xt(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},yle=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(gle)?.[1];o&&n.push(`:!${o}.log`)}),n},Sle=async(t=process.cwd())=>{await Xt(["reset","--hard","HEAD"],{cwd:t})},Ele=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(`
|
|
@@ -374,7 +374,7 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
374
374
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
375
375
|
|
|
376
376
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
377
|
-
`);this.baseURL=c.baseURL,this.timeout=c.timeout??oH.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=k4(c.logLevel,"ClientOptions.logLevel",this)??k4(Sl("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??jI(),Re(this,mP,t_e,"f"),this._options=c,s&&(this._workloadIdentityAuth=new YI(s,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=o}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return se([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return u_e(e)}getUserAgent(){return`${this.constructor.name}/JS ${fl}`}defaultIdempotencyKey(){return`stainless-node-retry-${S4()}`}makeStatusError(e,r,n,i){return Wt.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof _e?n:new _e(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new _e(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!U(this,iH,"m",W_e).call(this)&&n||this.baseURL,o=Vge(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),s=this.defaultQuery(),a=Object.fromEntries(o.searchParams);return(!T4(s)||!T4(a))&&(r={...a,...s,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Ed(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,o=i.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(i);let{req:s,url:a,timeout:c}=await this.buildRequest(i,{retryCount:o-r});await this.prepareRequest(s,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(rr(this).debug(`[${l}] sending request`,Oa({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:s.headers})),i.signal?.aborted)throw new or;let f=new AbortController,p=await this.fetchWithAuth(a,s,c,f).catch(HE),h=Date.now();if(p instanceof globalThis.Error){let S=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new or;let E=VE(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return rr(this).info(`[${l}] connection ${E?"timed out":"failed"} - ${S}`),rr(this).debug(`[${l}] connection ${E?"timed out":"failed"} (${S})`,Oa({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw rr(this).info(`[${l}] connection ${E?"timed out":"failed"} - error; no more retries left`),rr(this).debug(`[${l}] connection ${E?"timed out":"failed"} (error; no more retries left)`,Oa({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof yd||p instanceof WE?p:E?new dl:new ul({cause:p})}let m=[...p.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,E])=>", "+S+": "+JSON.stringify(E)).join(""),g=`[${l}${u}${m}] ${s.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await A4(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let S=await this.shouldRetry(p);if(r&&S){let P=`retrying, ${r} attempts remaining`;return await A4(p.body),rr(this).info(`${g} - ${P}`),rr(this).debug(`[${l}] response error (${P})`,Oa({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let E=S?"error; no more retries left":"error; not retryable";rr(this).info(`${g} - ${E}`);let T=await p.text().catch(P=>HE(P).message),b=Yge(T),w=b?void 0:T;throw rr(this).debug(`[${l}] response error (${E})`,Oa({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:w,durationMs:Date.now()-d})),this.makeStatusError(p.status,b,w,p.headers)}return rr(this).info(g),rr(this).debug(`[${l}] response start`,Oa({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new QE(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let s=r.headers,a=s.get("Authorization");if(!a||a===`Bearer ${nH}`){let c=await this._workloadIdentityAuth.getToken();s.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:o,method:s,...a}=r||{},c=this._makeAbort(i);o&&o.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};s&&(d.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let o,s=i?.get("retry-after-ms");if(s){let c=parseFloat(s);Number.isNaN(c)||(o=c)}let a=i?.get("retry-after");if(a&&!o){let c=parseFloat(a);Number.isNaN(c)?o=Date.parse(a)-Date.now():o=c*1e3}if(o===void 0){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await bs(o),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let o=r-e,s=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return s*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:o,query:s,defaultBaseURL:a}=n,c=this.buildURL(o,s,a);"timeout"in n&&Wge("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let o={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let s=se([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Qge(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(s),s.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:r}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let n=se([r]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,o=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!o}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:BI(e),isStreamingBody:!0}:typeof e=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e),isStreamingBody:!1}:{...U(this,mP,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};oH=Ue,mP=new WeakMap,iH=new WeakSet,W_e=function(){return this.baseURL!=="https://api.openai.com/v1"};Ue.OpenAI=oH;Ue.DEFAULT_TIMEOUT=6e5;Ue.OpenAIError=_e;Ue.APIError=Wt;Ue.APIConnectionError=ul;Ue.APIConnectionTimeoutError=dl;Ue.APIUserAbortError=or;Ue.NotFoundError=im;Ue.ConflictError=om;Ue.RateLimitError=am;Ue.BadRequestError=tm;Ue.AuthenticationError=rm;Ue.InternalServerError=cm;Ue.PermissionDeniedError=nm;Ue.UnprocessableEntityError=sm;Ue.InvalidWebhookSignatureError=Ts;Ue.toFile=ZI;Ue.Completions=Id;Ue.Chat=gl;Ue.Embeddings=Od;Ue.Files=kd;Ue.Images=Ld;Ue.Audio=Rs;Ue.Moderations=Fd;Ue.Models=Ud;Ue.FineTuning=Ao;Ue.Graders=wl;Ue.VectorStores=Fa;Ue.Webhooks=Bd;Ue.Beta=wo;Ue.Batches=wd;Ue.Uploads=xl;Ue.Responses=La;Ue.Realtime=$a;Ue.Conversations=Tl;Ue.Evals=bl;Ue.Containers=vl;Ue.Skills=Ua;Ue.Videos=jd;var jn=oe("runner_codex"),gP="Codex CLI",Wm="gpt-5.6-sol";async function _et({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else r?await t.isModelAvailableForProvider("openai",r)||(jn.log(`Model '${r}' is not available for openai provider, proceeding without model specification`),q.inc("model.unavailable",1,{provider:"openai"}),n=void 0):!!Wm&&await t.isModelAvailableForProvider("openai",Wm)?(n=Wm,jn.log(`Using default model: ${Wm}`)):Wm&&jn.log(`Default model ${Wm} is not available, proceeding without model specification`);return n}var _P="netlify-ask-db",yet=`default_permissions = "${_P}"`,Eet=()=>Rl.join(za.env.XDG_CONFIG_HOME??Rl.join(hv.homedir(),".config"),"netlify"),vet=t=>["",`[permissions.${_P}]`,'description = "Ask mode: read-only filesystem, network access for database reads"','extends = ":read-only"',"",`[permissions.${_P}.filesystem]`,'":minimal" = "read"','"/" = "read"',`"${t}" = "write"`,"",`[permissions.${_P}.network]`,"enabled = true"];function Tet({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");za.env.OPENAI_API_KEY=e,za.env.OPENAI_BASE_URL=r}else if(!za.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function sH({config:t,persistSteps:e,sendSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:o,cwd:s=za.cwd(),abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let{prompt:u}=t,{model:d}=t;Tet({aiGateway:n});let f=await _et({config:t,aiGateway:n,model:d}),p=[],h=[],m=[],g={},S=new Set,E=0,T=0,b,w,x,P,I,N=Hp(t),L=`${za.env.NVM_BIN}/node`,v=Rl.join(hv.homedir(),".codex"),Z=Rl.join(v,"config.toml"),M=Rl.join(v,"auth.json");try{await pv.mkdir(v,{recursive:!0});let Te={OPENAI_API_KEY:za.env.OPENAI_API_KEY};await pv.writeFile(M,JSON.stringify(Te,null,2),"utf-8"),jn.log("Created Codex auth.json file");let fe=za.env.OPENAI_BASE_URL,K=['forced_login_method = "api"'],Se=ol({creditWrapUpTurn:l}),F=il(t,{creditWrapUpTurn:l});N&&K.push(yet),fe&&K.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${fe}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),Se&&K.push(...Tge()),F&&K.push(...bge(F));let k=[];N&&(k=vet(Eet()),K.push(...k)),await pv.writeFile(Z,`${K.join(`
|
|
377
|
+
`);this.baseURL=c.baseURL,this.timeout=c.timeout??oH.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=k4(c.logLevel,"ClientOptions.logLevel",this)??k4(Sl("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??jI(),Re(this,mP,t_e,"f"),this._options=c,s&&(this._workloadIdentityAuth=new YI(s,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=o}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return se([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return u_e(e)}getUserAgent(){return`${this.constructor.name}/JS ${fl}`}defaultIdempotencyKey(){return`stainless-node-retry-${S4()}`}makeStatusError(e,r,n,i){return Wt.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof _e?n:new _e(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new _e(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!U(this,iH,"m",W_e).call(this)&&n||this.baseURL,o=Vge(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),s=this.defaultQuery(),a=Object.fromEntries(o.searchParams);return(!T4(s)||!T4(a))&&(r={...a,...s,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Ed(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,o=i.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(i);let{req:s,url:a,timeout:c}=await this.buildRequest(i,{retryCount:o-r});await this.prepareRequest(s,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(rr(this).debug(`[${l}] sending request`,Oa({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:s.headers})),i.signal?.aborted)throw new or;let f=new AbortController,p=await this.fetchWithAuth(a,s,c,f).catch(HE),h=Date.now();if(p instanceof globalThis.Error){let S=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new or;let E=VE(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return rr(this).info(`[${l}] connection ${E?"timed out":"failed"} - ${S}`),rr(this).debug(`[${l}] connection ${E?"timed out":"failed"} (${S})`,Oa({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw rr(this).info(`[${l}] connection ${E?"timed out":"failed"} - error; no more retries left`),rr(this).debug(`[${l}] connection ${E?"timed out":"failed"} (error; no more retries left)`,Oa({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof yd||p instanceof WE?p:E?new dl:new ul({cause:p})}let m=[...p.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,E])=>", "+S+": "+JSON.stringify(E)).join(""),g=`[${l}${u}${m}] ${s.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await A4(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let S=await this.shouldRetry(p);if(r&&S){let P=`retrying, ${r} attempts remaining`;return await A4(p.body),rr(this).info(`${g} - ${P}`),rr(this).debug(`[${l}] response error (${P})`,Oa({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let E=S?"error; no more retries left":"error; not retryable";rr(this).info(`${g} - ${E}`);let T=await p.text().catch(P=>HE(P).message),b=Yge(T),w=b?void 0:T;throw rr(this).debug(`[${l}] response error (${E})`,Oa({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:w,durationMs:Date.now()-d})),this.makeStatusError(p.status,b,w,p.headers)}return rr(this).info(g),rr(this).debug(`[${l}] response start`,Oa({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new QE(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let s=r.headers,a=s.get("Authorization");if(!a||a===`Bearer ${nH}`){let c=await this._workloadIdentityAuth.getToken();s.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:o,method:s,...a}=r||{},c=this._makeAbort(i);o&&o.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};s&&(d.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let o,s=i?.get("retry-after-ms");if(s){let c=parseFloat(s);Number.isNaN(c)||(o=c)}let a=i?.get("retry-after");if(a&&!o){let c=parseFloat(a);Number.isNaN(c)?o=Date.parse(a)-Date.now():o=c*1e3}if(o===void 0){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await bs(o),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let o=r-e,s=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return s*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:o,query:s,defaultBaseURL:a}=n,c=this.buildURL(o,s,a);"timeout"in n&&Wge("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let o={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let s=se([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Qge(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(s),s.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:r}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let n=se([r]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,o=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!o}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:BI(e),isStreamingBody:!0}:typeof e=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e),isStreamingBody:!1}:{...U(this,mP,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};oH=Ue,mP=new WeakMap,iH=new WeakSet,W_e=function(){return this.baseURL!=="https://api.openai.com/v1"};Ue.OpenAI=oH;Ue.DEFAULT_TIMEOUT=6e5;Ue.OpenAIError=_e;Ue.APIError=Wt;Ue.APIConnectionError=ul;Ue.APIConnectionTimeoutError=dl;Ue.APIUserAbortError=or;Ue.NotFoundError=im;Ue.ConflictError=om;Ue.RateLimitError=am;Ue.BadRequestError=tm;Ue.AuthenticationError=rm;Ue.InternalServerError=cm;Ue.PermissionDeniedError=nm;Ue.UnprocessableEntityError=sm;Ue.InvalidWebhookSignatureError=Ts;Ue.toFile=ZI;Ue.Completions=Id;Ue.Chat=gl;Ue.Embeddings=Od;Ue.Files=kd;Ue.Images=Ld;Ue.Audio=Rs;Ue.Moderations=Fd;Ue.Models=Ud;Ue.FineTuning=Ao;Ue.Graders=wl;Ue.VectorStores=Fa;Ue.Webhooks=Bd;Ue.Beta=wo;Ue.Batches=wd;Ue.Uploads=xl;Ue.Responses=La;Ue.Realtime=$a;Ue.Conversations=Tl;Ue.Evals=bl;Ue.Containers=vl;Ue.Skills=Ua;Ue.Videos=jd;var jn=oe("runner_codex"),gP="Codex CLI",Wm="gpt-6.1-sol";async function _et({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else r?await t.isModelAvailableForProvider("openai",r)||(jn.log(`Model '${r}' is not available for openai provider, proceeding without model specification`),q.inc("model.unavailable",1,{provider:"openai"}),n=void 0):!!Wm&&await t.isModelAvailableForProvider("openai",Wm)?(n=Wm,jn.log(`Using default model: ${Wm}`)):Wm&&jn.log(`Default model ${Wm} is not available, proceeding without model specification`);return n}var _P="netlify-ask-db",yet=`default_permissions = "${_P}"`,Eet=()=>Rl.join(za.env.XDG_CONFIG_HOME??Rl.join(hv.homedir(),".config"),"netlify"),vet=t=>["",`[permissions.${_P}]`,'description = "Ask mode: read-only filesystem, network access for database reads"','extends = ":read-only"',"",`[permissions.${_P}.filesystem]`,'":minimal" = "read"','"/" = "read"',`"${t}" = "write"`,"",`[permissions.${_P}.network]`,"enabled = true"];function Tet({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");za.env.OPENAI_API_KEY=e,za.env.OPENAI_BASE_URL=r}else if(!za.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function sH({config:t,persistSteps:e,sendSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:o,cwd:s=za.cwd(),abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let{prompt:u}=t,{model:d}=t;Tet({aiGateway:n});let f=await _et({config:t,aiGateway:n,model:d}),p=[],h=[],m=[],g={},S=new Set,E=0,T=0,b,w,x,P,I,N=Hp(t),L=`${za.env.NVM_BIN}/node`,v=Rl.join(hv.homedir(),".codex"),Z=Rl.join(v,"config.toml"),M=Rl.join(v,"auth.json");try{await pv.mkdir(v,{recursive:!0});let Te={OPENAI_API_KEY:za.env.OPENAI_API_KEY};await pv.writeFile(M,JSON.stringify(Te,null,2),"utf-8"),jn.log("Created Codex auth.json file");let fe=za.env.OPENAI_BASE_URL,K=['forced_login_method = "api"'],Se=ol({creditWrapUpTurn:l}),F=il(t,{creditWrapUpTurn:l});N&&K.push(yet),fe&&K.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${fe}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),Se&&K.push(...Tge()),F&&K.push(...bge(F));let k=[];N&&(k=vet(Eet()),K.push(...k)),await pv.writeFile(Z,`${K.join(`
|
|
378
378
|
`)}
|
|
379
379
|
`,"utf-8"),jn.log("Wrote Codex config.toml",...k.length?[k.join(`
|
|
380
380
|
`)]:[])}catch(Te){let fe=Te instanceof Error?Te.message:String(Te);throw jn.warn("Failed to setup Codex config and credentials",{error:fe}),new Error(`Codex setup failed: ${fe}`)}let _=Gp("codex",t.effort);t.effort&&!_&&jn.log(`Effort '${t.effort}' is not available on ${gP}; using its default`);let A=l?"low":_,O=!!(i&&o),X="mode"in t&&t.mode==="ask",H=!!N,ue=[ds(s,"codex"),"exec",...X&&!H?["--sandbox","read-only"]:[],...O?["resume",o]:[],...X?[]:["--yolo"],"--json",...A?["-c",`model_reasoning_effort="${A}"`]:[],...f?["--model",f]:[]].filter(Boolean);jn.log(`Running ${L} ${ue.join(" ")}`);let Ce=Mt(L,ue,{all:!0,cwd:s,env:{...za.env},stdin:"pipe",idleTimeout:ua,cancelSignal:a});Ce.stdin?.end(u);let ve=Ic(()=>{e?.({steps:p,duration:T}),r?.({steps:h,duration:T}),h=[]},250),Ie=(Te,fe)=>{let K={...Te,id:E};E+=1,m.push(K),p.push(K),h.push(K),fe||ve.flush(),ve(),fe&&ve.flush()},Ne=f||"default";t.answeredInteraction||Ie({title:`Using ${gP} with ${Ne}`,category:G.Environment},!0);let Ge=get.createInterface({input:Ce.all});Ge.on("error",Te=>{jn.error("Readline interface error",{error:Te.message,stack:Te.stack})}),Ge.on("line",Te=>{let fe;try{fe=JSON.parse(Te)}catch{jn.log("Could not parse line",Te);return}if(fe?.duration_ms&&(T=fe.duration_ms),fe?.type==="thread.started"&&typeof fe?.thread_id=="string"&&(x=fe.thread_id,c?.(x)),fe?.type==="item.started"&&fe?.item?.type==="command_execution")g[fe.item.id]=fe.item;else if(fe?.type==="item.completed"&&fe?.item?.type==="command_execution"){let K=fe.item,Se=Aet(K);Se&&Ie(Se,!0);let F=K.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(F&&!S.has(F)){S.add(F);let k=is(F);da(jn,k),Ie({title:`Use ${k}`,category:G.Skill,type:F},!0)}}else if(fe?.type==="item.completed"&&fe?.item?.type==="reasoning"){let K={title:"Reasoning",message:fe.item.text,category:G.Reasoning};Ie(K,!0)}else if(fe?.type==="item.completed"&&fe?.item?.type==="agent_message")b=fe.item.text;else if(fe?.type==="item.started"&&fe?.item?.type==="mcp_tool_call"){let K=fe.item,Se=Ile(K.server)&&!I?Jh(K.tool,K.arguments,Cle):void 0;Se&&"interaction"in Se?(I=Se.interaction,Ce.kill()):Se&&(jn.warn("Ignoring malformed pause tool input",{toolUseId:K.id,tool:K.tool,issues:Se.issues}),q.inc(Se.metric,1))}else if(fe?.type==="turn.completed"&&fe.usage)P={input_tokens:fe.usage.input_tokens,output_tokens:fe.usage.output_tokens},Rc(P,f?{model:f}:{});else if(fe?.type==="turn.failed"&&fe?.error?.message)w=fe.error.message;else if(fe?.type==="local_shell_call"){let K=fe;g[K.call_id]=K}else if(fe?.type==="local_shell_call_output"){let K=fe,Se=g[K.call_id],F=xet(Se,K);F&&Ie(F,!0);let $=(Se?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if($&&!S.has($)){S.add($);let j=is($);da(jn,j),Ie({title:`Use ${j}`,category:G.Skill,type:$},!0)}}else fe?.type==="message"&&fe.role==="assistant"?b=fe.content?.map(K=>K.text).join(`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/agent-runner-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.190.0",
|
|
5
5
|
"description": "CLI tool for running Netlify agents",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@commitlint/config-conventional": "^20.0.0",
|
|
63
63
|
"@eslint/compat": "^2.0.0",
|
|
64
64
|
"@eslint/js": "^10.0.1",
|
|
65
|
-
"@netlify/axis": "^1.
|
|
65
|
+
"@netlify/axis": "^1.18.0",
|
|
66
66
|
"@netlify/eslint-config-node": "^7.0.1",
|
|
67
67
|
"@types/node": "^24.5.0",
|
|
68
68
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|