@netlify/agent-runner-cli 1.140.0 → 1.140.1-next.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 +3 -3
- package/dist/bin.js +3 -3
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -86,7 +86,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
86
86
|
`,LF:`
|
|
87
87
|
`,concatBytes:pI},kye=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Uye={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:kye};import{Buffer as Fye}from"buffer";var N4=(t,e)=>t?void 0:Bye.bind(void 0,e),Bye=function*(t,e){if(typeof e!="string"&&!_t(e)&&!Fye.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},M4=(t,e)=>t?$ye.bind(void 0,e):Gye.bind(void 0,e),$ye=function*(t,e){L4(t,e),yield e},Gye=function*(t,e){if(L4(t,e),typeof e!="string"&&!_t(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},L4=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
88
88
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
89
|
-
if (condition) { yield value; }`)};import{Buffer as qye}from"buffer";import{StringDecoder as Hye}from"string_decoder";var ZT=(t,e,r)=>{if(r)return;if(t)return{transform:Vye.bind(void 0,new TextEncoder)};let n=new Hye(e);return{transform:jye.bind(void 0,n),final:Wye.bind(void 0,n)}},Vye=function*(t,e){qye.isBuffer(e)?yield Ti(e):typeof e=="string"?yield t.encode(e):yield e},jye=function*(t,e){yield _t(e)?t.write(e):e},Wye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as D4}from"util";var gI=D4(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),eb=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Yye}=e[r];for await(let s of n(t))yield*eb(s,e,r+1)},k4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zye(r,Number(e),t)},zye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*eb(n,r,e+1)},U4=D4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Yye=function*(t){yield t};var _I=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},F4=(t,e)=>[...e.flatMap(r=>[...gc(r,t,0)]),...dm(t)],gc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Xye}=e[r];for(let s of n(t))yield*gc(s,e,r+1)},dm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kye(r,Number(e),t)},Kye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*gc(n,r,e+1)},Xye=function*(t){yield t};var SI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=$4(t,o,i),l=mc(e),u=mc(r),d=l?gI.bind(void 0,eb,a):_I.bind(void 0,gc),f=l||u?gI.bind(void 0,k4,a):_I.bind(void 0,dm),h=l||u?U4.bind(void 0,a):void 0;return{stream:new Qye({writableObjectMode:n,writableHighWaterMark:B4(n),readableObjectMode:s,readableHighWaterMark:B4(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},tb=(t,e,r,n)=>{let s=e.filter(({type:o})=>o==="generator"),i=n?s.reverse():s;for(let{value:o,optionName:a}of i){let c=$4(o,r,a);t=F4(c,t)}return t},$4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:N4(n,a)},ZT(r,o,n),JT(r,i,n,c),{transform:t,final:e},{transform:M4(s,a)},I4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var G4=(t,e)=>{for(let r of Jye(t))Zye(t,r,e)},Jye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Zye=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Mo[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>eTe(a,n));r.input=tm(o)},eTe=(t,e)=>{let r=tb(t,e,"utf8",!0);return tTe(r),tm(r)},tTe=t=>{let e=t.find(r=>typeof r!="string"&&!_t(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 iTe,appendFileSync as oTe}from"fs";var rb=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cu(r,n)&&!Fr.has(e)&&rTe(n)&&(t.some(({type:s,value:i})=>s==="native"&&nTe.has(i))||t.every(({type:s})=>pn.has(s))),rTe=t=>t===1||t===2,nTe=new Set(["pipe","overlapped"]),q4=async(t,e,r,n)=>{for await(let s of t)sTe(e)||V4(s,r,n)},H4=(t,e,r)=>{for(let n of t)V4(n,e,r)},sTe=t=>t._readableState.pipes.length>0,V4=(t,e,r)=>{let n=gT(t);Cs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var j4=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:s})=>{if(e===null)return{output:Array.from({length:3})};let i={},o=new Set([]);return{output:e.map((c,l)=>aTe({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},aTe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=WY(t,i,d),h=Ti(f),{stdioItems:p,objectMode:m}=e[r],E=cTe([h],p,c,n),{serializedResult:S,finalResult:A=S}=lTe({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uTe({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let v=a[r]?A:void 0;try{return n.error===void 0&&dTe(S,p,s),v}catch(T){return n.error=T,v}},cTe=(t,e,r,n)=>{try{return tb(t,e,r,!1)}catch(s){return n.error=s,t}},lTe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:tm(t)};let o=oW(t,r);return n[i]?{serializedResult:o,finalResult:mI(o,!s[i],e)}:{serializedResult:o}},uTe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!rb({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=mI(t,!1,o);try{H4(a,e,n)}catch(c){r.error??=c}},dTe=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>XT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?oTe(n,t):(r.add(i),iTe(n,t))}};var W4=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,vi(e,r,"all")]:Array.isArray(e)?[vi(t,r,"all"),...e]:_t(t)&&_t(e)?vO([t,e]):`${t}${e}`};import{once as EI}from"events";var z4=async(t,e)=>{let[r,n]=await fTe(t);return e.isForcefullyTerminated??=!1,[r,n]},fTe=async t=>{let[e,r]=await Promise.allSettled([EI(t,"spawn"),EI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Y4(t):r.value},Y4=async t=>{try{return await EI(t,"exit")}catch{return Y4(t)}},K4=async t=>{let[e,r]=await t;if(!hTe(e,r)&&yI(e,r))throw new jn;return[e,r]},hTe=(t,e)=>t===void 0&&e===void 0,yI=(t,e)=>t!==0||e!==null;var X4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=pTe(t,e,r),o=i?.code==="ETIMEDOUT",a=jY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},pTe=(t,e,r)=>t!==void 0?t:yI(e,r)?new jn:void 0;var Q4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gTe(t,e,r),d=ETe({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Uu(d,c,l)},gTe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=ST(t,e,r),a=_Te(r),{file:c,commandArguments:l,options:u}=FT(t,e,a);STe(u);let d=C4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},_Te=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,STe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&nb("ipcInput"),t&&nb("ipc: true"),r&&nb("detached: true"),n&&nb("cancelSignal")},nb=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},ETe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=yTe({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h}=X4(c,r),{output:p,error:m=l}=j4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((A,v)=>vi(A,r,v)),S=vi(W4(p,r),r,"all");return bTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},yTe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{G4(i,r);let a=TTe(r);return mTe(...BT(t,e,a))}catch(a){return ku({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},TTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:WT(e)}),bTe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:s,stdio:i,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?zT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):um({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:s,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:i,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as lAe}from"events";import{spawn as uAe}from"child_process";import r6 from"process";import{once as TI,on as ATe}from"events";var J4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Ou({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:NT(t)}),vTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),vTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{xT(e,s);let i=No(t,e,r),o=new AbortController;try{return await Promise.race([wTe(i,n,o),RTe(i,r,o),CTe(i,r,o)])}catch(a){throw Iu(t),a}finally{o.abort(),PT(e,s)}},wTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await TI(t,"message",{signal:r});return n}for await(let[n]of ATe(t,"message",{signal:r}))if(e(n))return n},RTe=async(t,e,{signal:r})=>{await TI(t,"disconnect",{signal:r}),Fz(e)},CTe=async(t,e,{signal:r})=>{let[n]=await TI(t,"strict:error",{signal:r});throw wT(n,e)};import{once as e6,on as xTe}from"events";var t6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>bI({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),bI=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Ou({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:NT(t)}),xT(e,i);let o=No(t,e,r),a=new AbortController,c={};return PTe(t,o,a),OTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),ITe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},PTe=async(t,e,r)=>{try{await e6(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},OTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await e6(t,"strict:error",{signal:r.signal});n.error=wT(s,e),r.abort()}catch{}},ITe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of xTe(r,"message",{signal:i.signal}))Z4(o),yield c}catch{Z4(o)}finally{i.abort(),PT(e,a),n||Iu(t),s&&await t}},Z4=({error:t})=>{if(t)throw t};var n6=(t,{ipc:e})=>{Object.assign(t,i6(t,!1,e))},s6=()=>{let t=r6,e=!0,r=r6.channel!==void 0;return{...i6(t,e,r),getCancelSignal:dY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},i6=(t,e,r)=>({sendMessage:kT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:J4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:t6.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as NTe}from"child_process";import{PassThrough as MTe,Readable as LTe,Writable as DTe,Duplex as kTe}from"stream";var o6=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{fI(n);let a=new NTe;UTe(a,n),Object.assign(a,{readable:FTe,writable:BTe,duplex:$Te});let c=ku({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=GTe(c,o,s);return{subprocess:a,promise:l}},UTe=(t,e)=>{let r=fm(),n=fm(),s=fm(),i=Array.from({length:e.length-3},fm),o=fm(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},fm=()=>{let t=new MTe;return t.end(),t},FTe=()=>new LTe({read(){}}),BTe=()=>new DTe({write(){}}),$Te=()=>new kTe({read(){},write(){}}),GTe=async(t,e,r)=>Uu(t,e,r);import{createReadStream as a6,createWriteStream as c6}from"fs";import{Buffer as qTe}from"buffer";import{Readable as hm,Writable as HTe,Duplex as VTe}from"stream";var u6=(t,e)=>QT(jTe,t,e,!1),pm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Mo[t]}.`)},l6={fileNumber:pm,generator:SI,asyncGenerator:SI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:VTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},jTe={input:{...l6,fileUrl:({value:t})=>({stream:a6(t)}),filePath:({value:{file:t}})=>({stream:a6(t)}),webStream:({value:t})=>({stream:hm.fromWeb(t)}),iterable:({value:t})=>({stream:hm.from(t)}),asyncIterable:({value:t})=>({stream:hm.from(t)}),string:({value:t})=>({stream:hm.from(t)}),uint8Array:({value:t})=>({stream:hm.from(qTe.from(t))})},output:{...l6,fileUrl:({value:t})=>({stream:c6(t)}),filePath:({value:{file:t,append:e}})=>({stream:c6(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:HTe.fromWeb(t)}),iterable:pm,asyncIterable:pm,string:pm,uint8Array:pm}};import{on as WTe,once as d6}from"events";import{PassThrough as zTe,getDefaultHighWaterMark as YTe}from"stream";import{finished as p6}from"stream/promises";function _c(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)vI(s);let e=t.some(({readableObjectMode:s})=>s),r=KTe(t,e),n=new AI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var KTe=(t,e)=>{if(t.length===0)return YTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AI=class extends zTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(vI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=XTe(this,this.#e,this.#i);let r=ZTe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(vI(e),!this.#e.has(e))return!1;let r=this.#s.get(e);return r===void 0?!1:(this.#s.delete(e),e.unpipe(this),await r,!0)}},XTe=async(t,e,r)=>{sb(t,f6);let n=new AbortController;try{await Promise.race([QTe(t,n),JTe(t,e,r,n)])}finally{n.abort(),sb(t,-f6)}},QTe=async(t,{signal:e})=>{try{await p6(t,{signal:e,cleanup:!0})}catch(r){throw m6(t,r),r}},JTe=async(t,e,r,{signal:n})=>{for await(let[s]of WTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},vI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ZTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{sb(t,h6);let a=new AbortController;try{await Promise.race([ebe(i,e,a),tbe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),rbe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),sb(t,-h6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?wI(t):nbe(t))},ebe=async(t,e,{signal:r})=>{try{await t,r.aborted||wI(e)}catch(n){r.aborted||m6(e,n)}},tbe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await p6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;g6(o)?s.add(e):_6(t,o)}},rbe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await d6(t,s,{signal:i}),!t.readable)return d6(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},nbe=t=>{t.writable&&t.end()},m6=(t,e)=>{g6(e)?wI(t):_6(t,e)},g6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",wI=t=>{(t.readable||t.writable)&&t.destroy()},_6=(t,e)=>{t.destroyed||(t.once("error",sbe),t.destroy(e))},sbe=()=>{},sb=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},f6=2,h6=1;import{finished as S6}from"stream/promises";var Bu=(t,e)=>{t.pipe(e),ibe(t,e),obe(t,e)},ibe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await S6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}RI(e)}},RI=t=>{t.writable&&t.end()},obe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await S6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}CI(t)}},CI=t=>{t.readable&&t.destroy()};var E6=(t,e,r)=>{let n=new Map;for(let[s,{stdioItems:i,direction:o}]of Object.entries(e)){for(let{stream:a}of i.filter(({type:c})=>pn.has(c)))abe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!pn.has(c)))lbe({subprocess:t,stream:a,direction:o,fdNumber:s,pipeGroups:n,controller:r})}for(let[s,i]of n.entries()){let o=i.length===1?i[0]:_c(i);Bu(o,s)}},abe=(t,e,r,n)=>{r==="output"?Bu(t.stdio[n],e):Bu(e,t.stdio[n]);let s=cbe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},cbe=["stdin","stdout","stderr"],lbe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;ube(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},ube=(t,{signal:e})=>{Vn(t)&&hc(t,dbe,e)},dbe=2;import{addAbortListener as pbe}from"events";var Sc=[];Sc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Sc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Sc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ib=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",xI=Symbol.for("signal-exit emitter"),PI=globalThis,fbe=Object.defineProperty.bind(Object),OI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(PI[xI])return PI[xI];fbe(PI,xI,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},ob=class{},hbe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),II=class extends ob{onExit(){return()=>{}}load(){}unload(){}},NI=class extends ob{#e=MI.platform==="win32"?"SIGINT":"SIGHUP";#r=new OI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of Sc)this.#s[r]=()=>{let n=this.#t.listeners(r),{count:s}=this.#r,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#i=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!ib(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Sc)try{let r=this.#s[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Sc.forEach(e=>{let r=this.#s[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.#i,this.#r.count-=1)}#a(e){return ib(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#i.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&ib(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let s=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),s}else return n.call(this.#t,e,...r)}},MI=globalThis.process,{onExit:y6,load:RJe,unload:CJe}=hbe(ib(MI)?new NI(MI):new II);var T6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=y6(()=>{t.kill()});pbe(n,()=>{s()})};var A6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=_T(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mbe(r,n,s),{sourceStream:d,sourceError:f}=_be(t,l),{options:h,fileDescriptors:p}=Ps.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},mbe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=gbe(t,e,...r),a=CT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},gbe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(b6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||bO(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[s,i,o]=aT(r,...n);return{destination:e(b6)(s,i,o),pipeOptions:o}}if(Ps.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}`)},b6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_be=(t,e)=>{try{return{sourceStream:Nu(t,e)}}catch(r){return{sourceError:r}}};var w6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=Sbe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw LI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},Sbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return CI(t),n;if(e!==void 0)return RI(r),e},LI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>ku({error:t,command:v6,escapedCommand:v6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),v6="source.pipe(destination)";var R6=async t=>{let[{status:e,reason:r,value:n=r},{status:s,reason:i,value:o=i}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),s==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as Ebe}from"stream/promises";var C6=(t,e,r)=>{let n=ab.has(e)?Tbe(t,e):ybe(t,e);return hc(t,Abe,r.signal),hc(e,vbe,r.signal),bbe(e),n},ybe=(t,e)=>{let r=_c([t]);return Bu(r,e),ab.set(e,r),r},Tbe=(t,e)=>{let r=ab.get(e);return r.add(t),r},bbe=async t=>{try{await Ebe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ab.delete(t)},ab=new WeakMap,Abe=2,vbe=1;import{aborted as wbe}from"util";var x6=(t,e)=>t===void 0?[]:[Rbe(t,e)],Rbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await wbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw LI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var cb=(t,...e)=>{if(ot(e[0]))return cb.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=A6(t,...e),s=Cbe({...n,destination:r});return s.pipe=cb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},Cbe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=xbe(t,s);w6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=C6(e,i,d);return await Promise.race([R6(u),...x6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},xbe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Dbe}from"timers/promises";import{on as Pbe}from"events";import{getDefaultHighWaterMark as Obe}from"stream";var lb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return Ibe(e,o),O6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},Ibe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},DI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;Nbe(e,o,t);let a=t.readableObjectMode&&!i;return O6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Nbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},O6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=Pbe(t,"data",{signal:e.signal,highWaterMark:P6,highWatermark:P6});return Mbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},kI=Obe(!0),P6=kI,Mbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Lbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*gc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*dm(a)}},Lbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[ZT(t,r,!e),JT(t,s,!n,{})].filter(Boolean);var I6=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=kbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([Ube(t),d]);return}let f=hI(c,r),h=DI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([Fbe({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},kbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!rb({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=DI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await q4(a,t,r,i)},Ube=async t=>{await Dbe(),t.readableFlowing===null&&t.resume()},Fbe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await HT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await VT(r,{maxBuffer:i})):await Du(r,{maxBuffer:i})}catch(a){return N6(qY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},UI=async t=>{try{return await t}catch(e){return N6(e)}},N6=({bufferedData:t})=>sW(t)?new Uint8Array(t):t;import{finished as Bbe}from"stream/promises";var mm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=$be(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Bbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Hbe(a,e,r,n)}finally{o.abort()}},$be=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Gbe(t,r,n),n},Gbe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{qbe(e,r),n.call(t,...s)}},qbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Hbe=(t,e,r,n)=>{if(!Vbe(t,e,r,n))throw t},Vbe=(t,e,r,n=!0)=>r.propagating?M6(t)||ub(t):(r.propagating=!0,FI(r,e)===n?M6(t):ub(t)),FI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ub=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",M6=t=>t?.code==="EPIPE";var L6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>BI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),BI=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=mm(t,e,l);if(FI(l,e)){await u;return}let[d]=await Promise.all([I6({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var D6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?_c([t,e].filter(Boolean)):void 0,k6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>BI({...jbe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:Wbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),jbe=({stdout:t,stderr:e,all:r},[,n,s])=>{let i=n||s;return i?n?s?{stream:r,buffer:i}:{stream:t,buffer:i}:{stream:e,buffer:i}:{stream:r,buffer:i}},Wbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as zbe}from"events";var U6=t=>Cu(t,"ipc"),F6=(t,e)=>{let r=gT(t);Cs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var B6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=U6(i),a=bi(e,"ipc"),c=bi(r,"ipc");for await(let l of bI({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(HY(t,s,c),s.push(l)),o&&F6(l,i);return s},$6=async(t,e)=>(await Promise.allSettled([t]),e);var G6=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:E,controller:S})=>{let A=z4(t,f),v={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:A,propagating:!1},T=L6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),k=k6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),x=[],N=B6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:h}),P=Ybe(m,t,v),C=Kbe(p,v);try{return await Promise.race([Promise.all([{},K4(A),Promise.all(T),k,N,TY(t,d),...P,...C]),E,Xbe(t,S),...gY(t,i,f,S),...Uz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...pY({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},A,Promise.all(T.map(_=>UI(_))),UI(k),$6(N,x),Promise.allSettled(P),Promise.allSettled(C)])}},Ybe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:mm(n,s,r)),Kbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>zn(i,{checkOpen:!1})&&!Vn(i)).map(({type:s,value:i,stream:o=i})=>mm(o,n,e,{isSameDirection:pn.has(s),stopOnExit:s==="native"}))),Xbe=async(t,{signal:e})=>{let[r]=await zbe(t,"error",{signal:e});throw r};var q6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),gm=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=xs();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},$u=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 Qbe}from"stream";import{callbackify as Jbe}from"util";import{finished as H6}from"stream/promises";var $I=async t=>{if(t!==void 0)try{await GI(t)}catch{}},V6=async t=>{if(t!==void 0)try{await qI(t)}catch{}},GI=async t=>{await H6(t,{cleanup:!0,readable:!1,writable:!0})},qI=async t=>{await H6(t,{cleanup:!0,readable:!0,writable:!1})},db=async(t,e)=>{if(await t,e)throw e},fb=(t,e,r)=>{r&&!ub(r)?t.destroy(r):e&&t.destroy()};var j6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Fr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=HI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=VI(a,o),{read:f,onStdoutDataDone:h}=jI({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Qbe({read:f,destroy:Jbe(zI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return WI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},HI=(t,e,r)=>{let n=Nu(t,e),s=gm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},VI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:kI},jI=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=xs(),o=lb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Zbe(this,o,i)},onStdoutDataDone:i}},Zbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},WI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await qI(t),await n,await $I(s),await e,r.readable&&r.push(null)}catch(i){await $I(s),W6(r,i)}},zI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await $u(r,e)&&(W6(t,n),await db(e,n))},W6=(t,e)=>{fb(t,t.readable,e)};import{Writable as eAe}from"stream";import{callbackify as z6}from"util";var Y6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=YI(t,r,e),o=new eAe({...KI(n,t,s),destroy:z6(QI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return XI(n,o),o},YI=(t,e,r)=>{let n=CT(t,e),s=gm(r,n,"writableFinal"),i=gm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},KI=(t,e,r)=>({write:tAe.bind(void 0,t),final:z6(rAe.bind(void 0,t,e,r))}),tAe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rAe=async(t,e,r)=>{await $u(r,e)&&(t.writable&&t.end(),await e)},XI=async(t,e,r)=>{try{await GI(t),e.writable&&e.end()}catch(n){await V6(r),K6(e,n)}},QI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await $u(r,e),await $u(n,e)&&(K6(t,s),await db(e,s))},K6=(t,e)=>{fb(t,t.writable,e)};import{Duplex as nAe}from"stream";import{callbackify as sAe}from"util";var X6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Fr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=HI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=YI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=VI(c,a),{read:E,onStdoutDataDone:S}=jI({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),A=new nAe({read:E,...KI(u,t,d),destroy:sAe(iAe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return WI({subprocessStdout:c,onStdoutDataDone:S,readable:A,subprocess:t,subprocessStdin:u}),XI(u,A,c),A},iAe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([zI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),QI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var JI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Fr.has(e),o=Nu(t,r),a=lb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return oAe(a,o,t)},oAe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Q6=(t,{encoding:e})=>{let r=q6();t.readable=j6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Y6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=X6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=JI.bind(void 0,t,e),t[Symbol.asyncIterator]=JI.bind(void 0,t,e,{})};var J6=(t,e)=>{for(let[r,n]of cAe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},aAe=(async()=>{})().constructor.prototype,cAe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aAe,t)]);var Z6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dAe(t,e,r),{subprocess:f,promise:h}=hAe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=cb.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),J6(f,h),Ps.set(f,{options:u,fileDescriptors:d}),f},dAe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=ST(t,e,r),{file:a,commandArguments:c,options:l}=FT(t,e,r),u=fAe(l),d=u6(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},fAe=({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}},hAe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uAe(...BT(t,e,r))}catch(p){return o6({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;lAe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];E6(c,a,l),T6(c,r,l);let d={},f=xs();c.kill=Dz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=D6(c,r),Q6(c,r),n6(c,r);let h=pAe({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:h}},pAe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,h],p,m,E]=await G6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((T,k)=>vi(T,e,k)),A=vi(m,e,"all"),v=mAe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:A,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Uu(v,n,e)},mAe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?um({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Os,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):zT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var hb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,gAe(n,t[n],s)]));return{...t,...r}},gAe=(t,e,r)=>_Ae.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,_Ae=new Set(["env",...xO]);var Lo=(t,e,r,n)=>{let s=(o,a,c)=>Lo(o,a,r,c),i=(...o)=>SAe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},SAe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,hb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=EAe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?Q4(a,c,l):Z6(a,c,l,s)},EAe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=uW(e)?dW(e,r):[e,...r],[o,a,c]=aT(...i),l=hb(hb(n,s),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:h}};var e8=({file:t,commandArguments:e})=>r8(t,e),t8=({file:t,commandArguments:e})=>({...r8(t,e),isSync:!0}),r8=(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]=yAe(t);return{file:r,commandArguments:n}},yAe=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(TAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},TAe=/ +/g;var n8=(t,e,r)=>{t.sync=e(bAe,r),t.s=t.sync},s8=({options:t})=>i8(t),bAe=({options:t})=>({...i8(t),isSync:!0}),i8=t=>({options:{...AAe(t),...t}}),AAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},o8={preferLocal:!0};var a8=Lo(()=>({})),_et=Lo(()=>({isSync:!0})),c8=Lo(e8),Eet=Lo(t8),yet=Lo(SY),Tet=Lo(s8,{},o8,n8),{sendMessage:bet,getOneMessage:Aet,getEachMessage:vet,getCancelSignal:wet}=s6();var vAe=!1;var Ns=()=>vAe;var _m=null,l8=t=>(_m&&_m.destroy(),_m=new wi({totalAllowedTime:t}),_m),u8=()=>_m;var wi=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&Ns())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let i=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await tT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),i(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var d8={name:"@netlify/agent-runner-cli",type:"module",version:"1.140.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:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.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.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0"}};var xAe=RAe(import.meta.url),PAe=Ri.dirname(xAe),OAe=CAe(import.meta.url),Gu=me("shell"),ZI=new Set,f8={preferLocal:!0},ar=(t,e,r)=>{let[n,s]=IAe(e,r),i={...f8,...s},o=a8(t,n,i);p8(o,i),_8(o);let a=r?.idleTimeout;return a&&a>0&&g8(o,a),o},h8=(t,e)=>{let r={...f8,...e},n=c8(t,r);return p8(n,r),_8(n),e?.idleTimeout&&e.idleTimeout>0&&g8(n,e.idleTimeout),n},IAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},p8=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ci.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Yp).pipe(Ci.stdout),t.stderr?.pipe(new Yp).pipe(Ci.stderr);return}t.stdout?.pipe(Ci.stdout),t.stderr?.pipe(Ci.stderr)},eN=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ci.kill(-t.pid,e),Gu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Gu.error("Error killing process:",r),!1}},m8=t=>eN(t,"SIGKILL"),g8=(t,e)=>{let r=null,n=()=>{Gu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Gu.log(`Force killing idle process ${t.pid}`),m8(t))},5e3)},s=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};s(),t.stdout?.on("data",s),t.stderr?.on("data",s);let i=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",i),t.on("error",i)},_8=t=>{ZI.add(t);let e=u8();if(e){let r=e.onTimesUp(()=>{Gu.log(`Global timer expired, killing process ${t.pid}`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Gu.log(`Force killing process ${t.pid} after timeout`),m8(t))},5e3)});t.on("exit",()=>{ZI.delete(t),r()}),t.on("error",()=>{ZI.delete(t),r()})}};function mb(t,e){return!!xi(t,e)}function xi(t,e){if(!Ci.env.NETLIFY_LOCAL_MODE)try{let s=OAe.resolve(d8.name),i=Ri.dirname(s);for(;i!==Ri.dirname(i);){let o=Ri.dirname(i);if(Ri.basename(o)==="node_modules"){let a=Ri.join(o,".bin",e);if(pb.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(Ci.env.NODE_PATH){let s=Ri.join(Ci.env.NODE_PATH,".bin",e);if(pb.existsSync(s))return s}let r=Ri.join(t,"node_modules",".bin",e);if(pb.existsSync(r))return r;let n=Ri.join(PAe,"..","node_modules",".bin",e);if(pb.existsSync(n))return n}var NAe=me("utils"),MAe=t=>new Promise(e=>{setTimeout(e,t)});var gb=(t,e=3e3)=>{let r=!1,n=null,s=[],i=null,o=(...a)=>{if(r)return n=a,new Promise(u=>{s.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return i=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await MAe(e),!n)return r=!1,i=null,u;let d=n,f=s;n=null,s=[],u=await t(...d),f.forEach(h=>{h(u)})}})(),l};return o.flush=async()=>{if((r||n)&&i)return await i,o.flush()},o.cancel=()=>{n=null,s.forEach(a=>a(void 0)),s=[]},o},qu=(t,e,r=!1)=>{let n=null,s=null,i=null,o=function(...a){s=a,i=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(i,s),s=null,i=null)},e),c&&(t.apply(i,s),s=null,i=null)};return o.cancel=()=>{clearTimeout(n),n=null,s=null,i=null},o.flush=()=>{if(n){clearTimeout(n);let a=s,c=i;n=null,s=null,i=null,t.apply(c,a)}},o},S8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):NAe.error("Could not parse JSON",n))}},LAe=t=>t.charAt(0).toUpperCase()+t.slice(1),Do=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():LAe(e)).join(" ");function Ec(t,e){e&&t.log(`Skill invoked: ${e}`)}var E8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),y8=(t,e,r=!1)=>{if(r)return;let n=60,s=55,i=".netlify.app",o="agent-",a=6;if(!e)return`${o}${t.slice(0,a)}`;let c=`--${e}${i}`;if(c.length>s)return"";let l=n-c.length;if(l<=0)return"";if(l>=o.length+a){let u=Math.min(l-o.length,t.length);return`${o}${t.slice(0,u)}`}return t.slice(0,l)};var tN=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},DAe=1e4,rN=(t,e=DAe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as T8}from"buffer";import kAe from"path";var b8=me("repo"),yr=(t,e={})=>ar("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),v8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{b8.info("Getting runner diffs");let n=await FAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=$Ae(i);await GAe(m,r)}b8.info("Changes after processing"),await sN(r);let o=await iN(i,r);if(await nN(o,r),s=await BAe(r),!s)return{hasChanges:!1,ignored:o};await yr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await yr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await A8(r),{hasChanges:!1,ignored:o};let u=await yr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await yr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await yr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=T8.from(S).toString("base64"))}await A8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=T8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},A8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await yr(["reset","--soft","HEAD~1"],{cwd:t})},nN=async(t=[],e=process.cwd())=>{await yr(["add",".",...t],{cwd:e})},sN=async(t=process.cwd())=>{let e=await yr(["status","-s"],{cwd:t});return String(e.stdout??"")},w8=/.. (.+)?\.log$/,UAe=[w8],FAe=async(t=process.cwd())=>{let e=await sN(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
89
|
+
if (condition) { yield value; }`)};import{Buffer as qye}from"buffer";import{StringDecoder as Hye}from"string_decoder";var ZT=(t,e,r)=>{if(r)return;if(t)return{transform:Vye.bind(void 0,new TextEncoder)};let n=new Hye(e);return{transform:jye.bind(void 0,n),final:Wye.bind(void 0,n)}},Vye=function*(t,e){qye.isBuffer(e)?yield Ti(e):typeof e=="string"?yield t.encode(e):yield e},jye=function*(t,e){yield _t(e)?t.write(e):e},Wye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as D4}from"util";var gI=D4(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),eb=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Yye}=e[r];for await(let s of n(t))yield*eb(s,e,r+1)},k4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zye(r,Number(e),t)},zye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*eb(n,r,e+1)},U4=D4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Yye=function*(t){yield t};var _I=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},F4=(t,e)=>[...e.flatMap(r=>[...gc(r,t,0)]),...dm(t)],gc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Xye}=e[r];for(let s of n(t))yield*gc(s,e,r+1)},dm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kye(r,Number(e),t)},Kye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*gc(n,r,e+1)},Xye=function*(t){yield t};var SI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=$4(t,o,i),l=mc(e),u=mc(r),d=l?gI.bind(void 0,eb,a):_I.bind(void 0,gc),f=l||u?gI.bind(void 0,k4,a):_I.bind(void 0,dm),h=l||u?U4.bind(void 0,a):void 0;return{stream:new Qye({writableObjectMode:n,writableHighWaterMark:B4(n),readableObjectMode:s,readableHighWaterMark:B4(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},tb=(t,e,r,n)=>{let s=e.filter(({type:o})=>o==="generator"),i=n?s.reverse():s;for(let{value:o,optionName:a}of i){let c=$4(o,r,a);t=F4(c,t)}return t},$4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:N4(n,a)},ZT(r,o,n),JT(r,i,n,c),{transform:t,final:e},{transform:M4(s,a)},I4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var G4=(t,e)=>{for(let r of Jye(t))Zye(t,r,e)},Jye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Zye=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Mo[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>eTe(a,n));r.input=tm(o)},eTe=(t,e)=>{let r=tb(t,e,"utf8",!0);return tTe(r),tm(r)},tTe=t=>{let e=t.find(r=>typeof r!="string"&&!_t(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 iTe,appendFileSync as oTe}from"fs";var rb=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cu(r,n)&&!Fr.has(e)&&rTe(n)&&(t.some(({type:s,value:i})=>s==="native"&&nTe.has(i))||t.every(({type:s})=>pn.has(s))),rTe=t=>t===1||t===2,nTe=new Set(["pipe","overlapped"]),q4=async(t,e,r,n)=>{for await(let s of t)sTe(e)||V4(s,r,n)},H4=(t,e,r)=>{for(let n of t)V4(n,e,r)},sTe=t=>t._readableState.pipes.length>0,V4=(t,e,r)=>{let n=gT(t);Cs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var j4=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:s})=>{if(e===null)return{output:Array.from({length:3})};let i={},o=new Set([]);return{output:e.map((c,l)=>aTe({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},aTe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=WY(t,i,d),h=Ti(f),{stdioItems:p,objectMode:m}=e[r],E=cTe([h],p,c,n),{serializedResult:S,finalResult:A=S}=lTe({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uTe({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let v=a[r]?A:void 0;try{return n.error===void 0&&dTe(S,p,s),v}catch(T){return n.error=T,v}},cTe=(t,e,r,n)=>{try{return tb(t,e,r,!1)}catch(s){return n.error=s,t}},lTe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:tm(t)};let o=oW(t,r);return n[i]?{serializedResult:o,finalResult:mI(o,!s[i],e)}:{serializedResult:o}},uTe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!rb({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=mI(t,!1,o);try{H4(a,e,n)}catch(c){r.error??=c}},dTe=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>XT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?oTe(n,t):(r.add(i),iTe(n,t))}};var W4=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,vi(e,r,"all")]:Array.isArray(e)?[vi(t,r,"all"),...e]:_t(t)&&_t(e)?vO([t,e]):`${t}${e}`};import{once as EI}from"events";var z4=async(t,e)=>{let[r,n]=await fTe(t);return e.isForcefullyTerminated??=!1,[r,n]},fTe=async t=>{let[e,r]=await Promise.allSettled([EI(t,"spawn"),EI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Y4(t):r.value},Y4=async t=>{try{return await EI(t,"exit")}catch{return Y4(t)}},K4=async t=>{let[e,r]=await t;if(!hTe(e,r)&&yI(e,r))throw new jn;return[e,r]},hTe=(t,e)=>t===void 0&&e===void 0,yI=(t,e)=>t!==0||e!==null;var X4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=pTe(t,e,r),o=i?.code==="ETIMEDOUT",a=jY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},pTe=(t,e,r)=>t!==void 0?t:yI(e,r)?new jn:void 0;var Q4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gTe(t,e,r),d=ETe({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Uu(d,c,l)},gTe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=ST(t,e,r),a=_Te(r),{file:c,commandArguments:l,options:u}=FT(t,e,a);STe(u);let d=C4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},_Te=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,STe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&nb("ipcInput"),t&&nb("ipc: true"),r&&nb("detached: true"),n&&nb("cancelSignal")},nb=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},ETe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=yTe({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h}=X4(c,r),{output:p,error:m=l}=j4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((A,v)=>vi(A,r,v)),S=vi(W4(p,r),r,"all");return bTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},yTe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{G4(i,r);let a=TTe(r);return mTe(...BT(t,e,a))}catch(a){return ku({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},TTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:WT(e)}),bTe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:s,stdio:i,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?zT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):um({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:s,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:i,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as lAe}from"events";import{spawn as uAe}from"child_process";import r6 from"process";import{once as TI,on as ATe}from"events";var J4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Ou({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:NT(t)}),vTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),vTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{xT(e,s);let i=No(t,e,r),o=new AbortController;try{return await Promise.race([wTe(i,n,o),RTe(i,r,o),CTe(i,r,o)])}catch(a){throw Iu(t),a}finally{o.abort(),PT(e,s)}},wTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await TI(t,"message",{signal:r});return n}for await(let[n]of ATe(t,"message",{signal:r}))if(e(n))return n},RTe=async(t,e,{signal:r})=>{await TI(t,"disconnect",{signal:r}),Fz(e)},CTe=async(t,e,{signal:r})=>{let[n]=await TI(t,"strict:error",{signal:r});throw wT(n,e)};import{once as e6,on as xTe}from"events";var t6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>bI({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),bI=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Ou({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:NT(t)}),xT(e,i);let o=No(t,e,r),a=new AbortController,c={};return PTe(t,o,a),OTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),ITe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},PTe=async(t,e,r)=>{try{await e6(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},OTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await e6(t,"strict:error",{signal:r.signal});n.error=wT(s,e),r.abort()}catch{}},ITe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of xTe(r,"message",{signal:i.signal}))Z4(o),yield c}catch{Z4(o)}finally{i.abort(),PT(e,a),n||Iu(t),s&&await t}},Z4=({error:t})=>{if(t)throw t};var n6=(t,{ipc:e})=>{Object.assign(t,i6(t,!1,e))},s6=()=>{let t=r6,e=!0,r=r6.channel!==void 0;return{...i6(t,e,r),getCancelSignal:dY.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},i6=(t,e,r)=>({sendMessage:kT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:J4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:t6.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as NTe}from"child_process";import{PassThrough as MTe,Readable as LTe,Writable as DTe,Duplex as kTe}from"stream";var o6=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{fI(n);let a=new NTe;UTe(a,n),Object.assign(a,{readable:FTe,writable:BTe,duplex:$Te});let c=ku({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=GTe(c,o,s);return{subprocess:a,promise:l}},UTe=(t,e)=>{let r=fm(),n=fm(),s=fm(),i=Array.from({length:e.length-3},fm),o=fm(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},fm=()=>{let t=new MTe;return t.end(),t},FTe=()=>new LTe({read(){}}),BTe=()=>new DTe({write(){}}),$Te=()=>new kTe({read(){},write(){}}),GTe=async(t,e,r)=>Uu(t,e,r);import{createReadStream as a6,createWriteStream as c6}from"fs";import{Buffer as qTe}from"buffer";import{Readable as hm,Writable as HTe,Duplex as VTe}from"stream";var u6=(t,e)=>QT(jTe,t,e,!1),pm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Mo[t]}.`)},l6={fileNumber:pm,generator:SI,asyncGenerator:SI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:VTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},jTe={input:{...l6,fileUrl:({value:t})=>({stream:a6(t)}),filePath:({value:{file:t}})=>({stream:a6(t)}),webStream:({value:t})=>({stream:hm.fromWeb(t)}),iterable:({value:t})=>({stream:hm.from(t)}),asyncIterable:({value:t})=>({stream:hm.from(t)}),string:({value:t})=>({stream:hm.from(t)}),uint8Array:({value:t})=>({stream:hm.from(qTe.from(t))})},output:{...l6,fileUrl:({value:t})=>({stream:c6(t)}),filePath:({value:{file:t,append:e}})=>({stream:c6(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:HTe.fromWeb(t)}),iterable:pm,asyncIterable:pm,string:pm,uint8Array:pm}};import{on as WTe,once as d6}from"events";import{PassThrough as zTe,getDefaultHighWaterMark as YTe}from"stream";import{finished as p6}from"stream/promises";function _c(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)vI(s);let e=t.some(({readableObjectMode:s})=>s),r=KTe(t,e),n=new AI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var KTe=(t,e)=>{if(t.length===0)return YTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AI=class extends zTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(vI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=XTe(this,this.#e,this.#i);let r=ZTe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(vI(e),!this.#e.has(e))return!1;let r=this.#s.get(e);return r===void 0?!1:(this.#s.delete(e),e.unpipe(this),await r,!0)}},XTe=async(t,e,r)=>{sb(t,f6);let n=new AbortController;try{await Promise.race([QTe(t,n),JTe(t,e,r,n)])}finally{n.abort(),sb(t,-f6)}},QTe=async(t,{signal:e})=>{try{await p6(t,{signal:e,cleanup:!0})}catch(r){throw m6(t,r),r}},JTe=async(t,e,r,{signal:n})=>{for await(let[s]of WTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},vI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ZTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{sb(t,h6);let a=new AbortController;try{await Promise.race([ebe(i,e,a),tbe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),rbe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),sb(t,-h6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?wI(t):nbe(t))},ebe=async(t,e,{signal:r})=>{try{await t,r.aborted||wI(e)}catch(n){r.aborted||m6(e,n)}},tbe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await p6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;g6(o)?s.add(e):_6(t,o)}},rbe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await d6(t,s,{signal:i}),!t.readable)return d6(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},nbe=t=>{t.writable&&t.end()},m6=(t,e)=>{g6(e)?wI(t):_6(t,e)},g6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",wI=t=>{(t.readable||t.writable)&&t.destroy()},_6=(t,e)=>{t.destroyed||(t.once("error",sbe),t.destroy(e))},sbe=()=>{},sb=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},f6=2,h6=1;import{finished as S6}from"stream/promises";var Bu=(t,e)=>{t.pipe(e),ibe(t,e),obe(t,e)},ibe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await S6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}RI(e)}},RI=t=>{t.writable&&t.end()},obe=async(t,e)=>{if(!(Vn(t)||Vn(e))){try{await S6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}CI(t)}},CI=t=>{t.readable&&t.destroy()};var E6=(t,e,r)=>{let n=new Map;for(let[s,{stdioItems:i,direction:o}]of Object.entries(e)){for(let{stream:a}of i.filter(({type:c})=>pn.has(c)))abe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!pn.has(c)))lbe({subprocess:t,stream:a,direction:o,fdNumber:s,pipeGroups:n,controller:r})}for(let[s,i]of n.entries()){let o=i.length===1?i[0]:_c(i);Bu(o,s)}},abe=(t,e,r,n)=>{r==="output"?Bu(t.stdio[n],e):Bu(e,t.stdio[n]);let s=cbe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},cbe=["stdin","stdout","stderr"],lbe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;ube(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},ube=(t,{signal:e})=>{Vn(t)&&hc(t,dbe,e)},dbe=2;import{addAbortListener as pbe}from"events";var Sc=[];Sc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Sc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Sc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ib=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",xI=Symbol.for("signal-exit emitter"),PI=globalThis,fbe=Object.defineProperty.bind(Object),OI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(PI[xI])return PI[xI];fbe(PI,xI,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},ob=class{},hbe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),II=class extends ob{onExit(){return()=>{}}load(){}unload(){}},NI=class extends ob{#e=MI.platform==="win32"?"SIGINT":"SIGHUP";#r=new OI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of Sc)this.#s[r]=()=>{let n=this.#t.listeners(r),{count:s}=this.#r,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#i=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!ib(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Sc)try{let r=this.#s[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Sc.forEach(e=>{let r=this.#s[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.#i,this.#r.count-=1)}#a(e){return ib(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#i.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&ib(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let s=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),s}else return n.call(this.#t,e,...r)}},MI=globalThis.process,{onExit:y6,load:RJe,unload:CJe}=hbe(ib(MI)?new NI(MI):new II);var T6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=y6(()=>{t.kill()});pbe(n,()=>{s()})};var A6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=_T(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mbe(r,n,s),{sourceStream:d,sourceError:f}=_be(t,l),{options:h,fileDescriptors:p}=Ps.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},mbe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=gbe(t,e,...r),a=CT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},gbe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(b6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||bO(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[s,i,o]=aT(r,...n);return{destination:e(b6)(s,i,o),pipeOptions:o}}if(Ps.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}`)},b6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_be=(t,e)=>{try{return{sourceStream:Nu(t,e)}}catch(r){return{sourceError:r}}};var w6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=Sbe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw LI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},Sbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return CI(t),n;if(e!==void 0)return RI(r),e},LI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>ku({error:t,command:v6,escapedCommand:v6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),v6="source.pipe(destination)";var R6=async t=>{let[{status:e,reason:r,value:n=r},{status:s,reason:i,value:o=i}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),s==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as Ebe}from"stream/promises";var C6=(t,e,r)=>{let n=ab.has(e)?Tbe(t,e):ybe(t,e);return hc(t,Abe,r.signal),hc(e,vbe,r.signal),bbe(e),n},ybe=(t,e)=>{let r=_c([t]);return Bu(r,e),ab.set(e,r),r},Tbe=(t,e)=>{let r=ab.get(e);return r.add(t),r},bbe=async t=>{try{await Ebe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ab.delete(t)},ab=new WeakMap,Abe=2,vbe=1;import{aborted as wbe}from"util";var x6=(t,e)=>t===void 0?[]:[Rbe(t,e)],Rbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await wbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw LI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var cb=(t,...e)=>{if(ot(e[0]))return cb.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=A6(t,...e),s=Cbe({...n,destination:r});return s.pipe=cb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},Cbe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=xbe(t,s);w6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=C6(e,i,d);return await Promise.race([R6(u),...x6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},xbe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Dbe}from"timers/promises";import{on as Pbe}from"events";import{getDefaultHighWaterMark as Obe}from"stream";var lb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return Ibe(e,o),O6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},Ibe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},DI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;Nbe(e,o,t);let a=t.readableObjectMode&&!i;return O6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Nbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},O6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=Pbe(t,"data",{signal:e.signal,highWaterMark:P6,highWatermark:P6});return Mbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},kI=Obe(!0),P6=kI,Mbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Lbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*gc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*dm(a)}},Lbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[ZT(t,r,!e),JT(t,s,!n,{})].filter(Boolean);var I6=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=kbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([Ube(t),d]);return}let f=hI(c,r),h=DI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([Fbe({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},kbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!rb({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=DI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await q4(a,t,r,i)},Ube=async t=>{await Dbe(),t.readableFlowing===null&&t.resume()},Fbe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await HT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await VT(r,{maxBuffer:i})):await Du(r,{maxBuffer:i})}catch(a){return N6(qY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},UI=async t=>{try{return await t}catch(e){return N6(e)}},N6=({bufferedData:t})=>sW(t)?new Uint8Array(t):t;import{finished as Bbe}from"stream/promises";var mm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=$be(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Bbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Hbe(a,e,r,n)}finally{o.abort()}},$be=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Gbe(t,r,n),n},Gbe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{qbe(e,r),n.call(t,...s)}},qbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Hbe=(t,e,r,n)=>{if(!Vbe(t,e,r,n))throw t},Vbe=(t,e,r,n=!0)=>r.propagating?M6(t)||ub(t):(r.propagating=!0,FI(r,e)===n?M6(t):ub(t)),FI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ub=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",M6=t=>t?.code==="EPIPE";var L6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>BI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),BI=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=mm(t,e,l);if(FI(l,e)){await u;return}let[d]=await Promise.all([I6({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var D6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?_c([t,e].filter(Boolean)):void 0,k6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>BI({...jbe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:Wbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),jbe=({stdout:t,stderr:e,all:r},[,n,s])=>{let i=n||s;return i?n?s?{stream:r,buffer:i}:{stream:t,buffer:i}:{stream:e,buffer:i}:{stream:r,buffer:i}},Wbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as zbe}from"events";var U6=t=>Cu(t,"ipc"),F6=(t,e)=>{let r=gT(t);Cs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var B6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=U6(i),a=bi(e,"ipc"),c=bi(r,"ipc");for await(let l of bI({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(HY(t,s,c),s.push(l)),o&&F6(l,i);return s},$6=async(t,e)=>(await Promise.allSettled([t]),e);var G6=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:E,controller:S})=>{let A=z4(t,f),v={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:A,propagating:!1},T=L6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),k=k6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:v}),x=[],N=B6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:h}),P=Ybe(m,t,v),C=Kbe(p,v);try{return await Promise.race([Promise.all([{},K4(A),Promise.all(T),k,N,TY(t,d),...P,...C]),E,Xbe(t,S),...gY(t,i,f,S),...Uz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...pY({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},A,Promise.all(T.map(_=>UI(_))),UI(k),$6(N,x),Promise.allSettled(P),Promise.allSettled(C)])}},Ybe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:mm(n,s,r)),Kbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>zn(i,{checkOpen:!1})&&!Vn(i)).map(({type:s,value:i,stream:o=i})=>mm(o,n,e,{isSameDirection:pn.has(s),stopOnExit:s==="native"}))),Xbe=async(t,{signal:e})=>{let[r]=await zbe(t,"error",{signal:e});throw r};var q6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),gm=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=xs();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},$u=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 Qbe}from"stream";import{callbackify as Jbe}from"util";import{finished as H6}from"stream/promises";var $I=async t=>{if(t!==void 0)try{await GI(t)}catch{}},V6=async t=>{if(t!==void 0)try{await qI(t)}catch{}},GI=async t=>{await H6(t,{cleanup:!0,readable:!1,writable:!0})},qI=async t=>{await H6(t,{cleanup:!0,readable:!0,writable:!1})},db=async(t,e)=>{if(await t,e)throw e},fb=(t,e,r)=>{r&&!ub(r)?t.destroy(r):e&&t.destroy()};var j6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Fr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=HI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=VI(a,o),{read:f,onStdoutDataDone:h}=jI({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Qbe({read:f,destroy:Jbe(zI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return WI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},HI=(t,e,r)=>{let n=Nu(t,e),s=gm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},VI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:kI},jI=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=xs(),o=lb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Zbe(this,o,i)},onStdoutDataDone:i}},Zbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},WI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await qI(t),await n,await $I(s),await e,r.readable&&r.push(null)}catch(i){await $I(s),W6(r,i)}},zI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await $u(r,e)&&(W6(t,n),await db(e,n))},W6=(t,e)=>{fb(t,t.readable,e)};import{Writable as eAe}from"stream";import{callbackify as z6}from"util";var Y6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=YI(t,r,e),o=new eAe({...KI(n,t,s),destroy:z6(QI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return XI(n,o),o},YI=(t,e,r)=>{let n=CT(t,e),s=gm(r,n,"writableFinal"),i=gm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},KI=(t,e,r)=>({write:tAe.bind(void 0,t),final:z6(rAe.bind(void 0,t,e,r))}),tAe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rAe=async(t,e,r)=>{await $u(r,e)&&(t.writable&&t.end(),await e)},XI=async(t,e,r)=>{try{await GI(t),e.writable&&e.end()}catch(n){await V6(r),K6(e,n)}},QI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await $u(r,e),await $u(n,e)&&(K6(t,s),await db(e,s))},K6=(t,e)=>{fb(t,t.writable,e)};import{Duplex as nAe}from"stream";import{callbackify as sAe}from"util";var X6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Fr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=HI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=YI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=VI(c,a),{read:E,onStdoutDataDone:S}=jI({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),A=new nAe({read:E,...KI(u,t,d),destroy:sAe(iAe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return WI({subprocessStdout:c,onStdoutDataDone:S,readable:A,subprocess:t,subprocessStdin:u}),XI(u,A,c),A},iAe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([zI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),QI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var JI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Fr.has(e),o=Nu(t,r),a=lb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return oAe(a,o,t)},oAe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Q6=(t,{encoding:e})=>{let r=q6();t.readable=j6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Y6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=X6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=JI.bind(void 0,t,e),t[Symbol.asyncIterator]=JI.bind(void 0,t,e,{})};var J6=(t,e)=>{for(let[r,n]of cAe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},aAe=(async()=>{})().constructor.prototype,cAe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aAe,t)]);var Z6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dAe(t,e,r),{subprocess:f,promise:h}=hAe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=cb.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),J6(f,h),Ps.set(f,{options:u,fileDescriptors:d}),f},dAe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=ST(t,e,r),{file:a,commandArguments:c,options:l}=FT(t,e,r),u=fAe(l),d=u6(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},fAe=({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}},hAe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uAe(...BT(t,e,r))}catch(p){return o6({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;lAe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];E6(c,a,l),T6(c,r,l);let d={},f=xs();c.kill=Dz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=D6(c,r),Q6(c,r),n6(c,r);let h=pAe({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:h}},pAe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,h],p,m,E]=await G6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((T,k)=>vi(T,e,k)),A=vi(m,e,"all"),v=mAe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:A,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Uu(v,n,e)},mAe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?um({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Os,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):zT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var hb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,gAe(n,t[n],s)]));return{...t,...r}},gAe=(t,e,r)=>_Ae.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,_Ae=new Set(["env",...xO]);var Lo=(t,e,r,n)=>{let s=(o,a,c)=>Lo(o,a,r,c),i=(...o)=>SAe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},SAe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,hb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=EAe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?Q4(a,c,l):Z6(a,c,l,s)},EAe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=uW(e)?dW(e,r):[e,...r],[o,a,c]=aT(...i),l=hb(hb(n,s),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:h}};var e8=({file:t,commandArguments:e})=>r8(t,e),t8=({file:t,commandArguments:e})=>({...r8(t,e),isSync:!0}),r8=(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]=yAe(t);return{file:r,commandArguments:n}},yAe=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(TAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},TAe=/ +/g;var n8=(t,e,r)=>{t.sync=e(bAe,r),t.s=t.sync},s8=({options:t})=>i8(t),bAe=({options:t})=>({...i8(t),isSync:!0}),i8=t=>({options:{...AAe(t),...t}}),AAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},o8={preferLocal:!0};var a8=Lo(()=>({})),_et=Lo(()=>({isSync:!0})),c8=Lo(e8),Eet=Lo(t8),yet=Lo(SY),Tet=Lo(s8,{},o8,n8),{sendMessage:bet,getOneMessage:Aet,getEachMessage:vet,getCancelSignal:wet}=s6();var vAe=!1;var Ns=()=>vAe;var _m=null,l8=t=>(_m&&_m.destroy(),_m=new wi({totalAllowedTime:t}),_m),u8=()=>_m;var wi=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&Ns())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let i=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await tT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),i(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var d8={name:"@netlify/agent-runner-cli",type:"module",version:"1.140.1-next.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:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.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.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0"}};var xAe=RAe(import.meta.url),PAe=Ri.dirname(xAe),OAe=CAe(import.meta.url),Gu=me("shell"),ZI=new Set,f8={preferLocal:!0},ar=(t,e,r)=>{let[n,s]=IAe(e,r),i={...f8,...s},o=a8(t,n,i);p8(o,i),_8(o);let a=r?.idleTimeout;return a&&a>0&&g8(o,a),o},h8=(t,e)=>{let r={...f8,...e},n=c8(t,r);return p8(n,r),_8(n),e?.idleTimeout&&e.idleTimeout>0&&g8(n,e.idleTimeout),n},IAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},p8=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ci.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Yp).pipe(Ci.stdout),t.stderr?.pipe(new Yp).pipe(Ci.stderr);return}t.stdout?.pipe(Ci.stdout),t.stderr?.pipe(Ci.stderr)},eN=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ci.kill(-t.pid,e),Gu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Gu.error("Error killing process:",r),!1}},m8=t=>eN(t,"SIGKILL"),g8=(t,e)=>{let r=null,n=()=>{Gu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Gu.log(`Force killing idle process ${t.pid}`),m8(t))},5e3)},s=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};s(),t.stdout?.on("data",s),t.stderr?.on("data",s);let i=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",i),t.on("error",i)},_8=t=>{ZI.add(t);let e=u8();if(e){let r=e.onTimesUp(()=>{Gu.log(`Global timer expired, killing process ${t.pid}`),eN(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Gu.log(`Force killing process ${t.pid} after timeout`),m8(t))},5e3)});t.on("exit",()=>{ZI.delete(t),r()}),t.on("error",()=>{ZI.delete(t),r()})}};function mb(t,e){return!!xi(t,e)}function xi(t,e){if(!Ci.env.NETLIFY_LOCAL_MODE)try{let s=OAe.resolve(d8.name),i=Ri.dirname(s);for(;i!==Ri.dirname(i);){let o=Ri.dirname(i);if(Ri.basename(o)==="node_modules"){let a=Ri.join(o,".bin",e);if(pb.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(Ci.env.NODE_PATH){let s=Ri.join(Ci.env.NODE_PATH,".bin",e);if(pb.existsSync(s))return s}let r=Ri.join(t,"node_modules",".bin",e);if(pb.existsSync(r))return r;let n=Ri.join(PAe,"..","node_modules",".bin",e);if(pb.existsSync(n))return n}var NAe=me("utils"),MAe=t=>new Promise(e=>{setTimeout(e,t)});var gb=(t,e=3e3)=>{let r=!1,n=null,s=[],i=null,o=(...a)=>{if(r)return n=a,new Promise(u=>{s.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return i=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await MAe(e),!n)return r=!1,i=null,u;let d=n,f=s;n=null,s=[],u=await t(...d),f.forEach(h=>{h(u)})}})(),l};return o.flush=async()=>{if((r||n)&&i)return await i,o.flush()},o.cancel=()=>{n=null,s.forEach(a=>a(void 0)),s=[]},o},qu=(t,e,r=!1)=>{let n=null,s=null,i=null,o=function(...a){s=a,i=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(i,s),s=null,i=null)},e),c&&(t.apply(i,s),s=null,i=null)};return o.cancel=()=>{clearTimeout(n),n=null,s=null,i=null},o.flush=()=>{if(n){clearTimeout(n);let a=s,c=i;n=null,s=null,i=null,t.apply(c,a)}},o},S8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):NAe.error("Could not parse JSON",n))}},LAe=t=>t.charAt(0).toUpperCase()+t.slice(1),Do=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():LAe(e)).join(" ");function Ec(t,e){e&&t.log(`Skill invoked: ${e}`)}var E8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),y8=(t,e,r=!1)=>{if(r)return;let n=60,s=55,i=".netlify.app",o="agent-",a=6;if(!e)return`${o}${t.slice(0,a)}`;let c=`--${e}${i}`;if(c.length>s)return"";let l=n-c.length;if(l<=0)return"";if(l>=o.length+a){let u=Math.min(l-o.length,t.length);return`${o}${t.slice(0,u)}`}return t.slice(0,l)};var tN=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},DAe=1e4,rN=(t,e=DAe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as T8}from"buffer";import kAe from"path";var b8=me("repo"),yr=(t,e={})=>ar("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),v8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{b8.info("Getting runner diffs");let n=await FAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=$Ae(i);await GAe(m,r)}b8.info("Changes after processing"),await sN(r);let o=await iN(i,r);if(await nN(o,r),s=await BAe(r),!s)return{hasChanges:!1,ignored:o};await yr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await yr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await A8(r),{hasChanges:!1,ignored:o};let u=await yr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await yr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await yr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=T8.from(S).toString("base64"))}await A8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=T8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},A8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await yr(["reset","--soft","HEAD~1"],{cwd:t})},nN=async(t=[],e=process.cwd())=>{await yr(["add",".",...t],{cwd:e})},sN=async(t=process.cwd())=>{let e=await yr(["status","-s"],{cwd:t});return String(e.stdout??"")},w8=/.. (.+)?\.log$/,UAe=[w8],FAe=async(t=process.cwd())=>{let e=await sN(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
90
90
|
`).filter(s=>UAe.some(o=>o instanceof RegExp?o.test(s):s===o)?!1:s[1]?.trim()!=="")).length!==0,status:e}},BAe=async(t=process.cwd())=>{try{return await yr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},Sm=async(t=process.cwd())=>{let{stdout:e}=await yr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},R8=async(t=process.cwd())=>{let{stdout:e}=await yr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},iN=async(t,e=process.cwd())=>{t||=await sN(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(`
|
|
91
91
|
`).forEach(s=>{r.forEach(o=>{let a=s===`?? ${o}`,c=s.startsWith(`?? ${o}/`)||s.startsWith(`?? ${o}${kAe.sep}`);(a||c)&&n.push(`:!${o}`)});let i=s.match(w8)?.[1];i&&n.push(`:!${i}.log`)}),n},oN=async(t=process.cwd())=>{await yr(["reset","--hard","HEAD"],{cwd:t})},C8=async(t=process.cwd())=>{let e=await yr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
92
92
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},$Ae=t=>{let e=t.split(`
|
|
@@ -177,9 +177,9 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
177
177
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
178
178
|
|
|
179
179
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
180
|
-
`);this.baseURL=c.baseURL,this.timeout=c.timeout??CM.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=tM(c.logLevel,"ClientOptions.logLevel",this)??tM(ea("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??Qb(),_e(this,wA,FK,"f"),this._options=c,o&&(this._workloadIdentityAuth=new sA(o,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=s,this.webhookSecret=i}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 J([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return zK(e)}getUserAgent(){return`${this.constructor.name}/JS ${zo}`}defaultIdempotencyKey(){return`stainless-node-retry-${GN()}`}makeStatusError(e,r,n,s){return nt.generate(e,r,n,s)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof le?n:new le(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new le(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let s=!L(this,RM,"m",O5).call(this)&&n||this.baseURL,i=xK(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(i.searchParams);return(!VN(o)||!VN(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(i.search=this.stringifyQuery(r)),i.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(s=>({method:e,path:r,...s})))}request(e,r=null){return new Lc(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let s=await e,i=s.maxRetries??this.maxRetries;r==null&&(r=i),await this.prepareOptions(s);let{req:o,url:a,timeout:c}=await this.buildRequest(s,{retryCount:i-r});await this.prepareRequest(o,{url:a,options:s});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(at(this).debug(`[${l}] sending request`,ki({retryOfRequestLogID:n,method:s.method,url:a,options:s,headers:o.headers})),s.signal?.aborted)throw new ut;let f=new AbortController,h=await this.fetchWithAuth(a,o,c,f).catch(zm),p=Date.now();if(h instanceof globalThis.Error){let S=`retrying, ${r} attempts remaining`;if(s.signal?.aborted)throw new ut;let A=Wm(h)||/timed? ?out/i.test(String(h)+("cause"in h?String(h.cause):""));if(r)return at(this).info(`[${l}] connection ${A?"timed out":"failed"} - ${S}`),at(this).debug(`[${l}] connection ${A?"timed out":"failed"} (${S})`,ki({retryOfRequestLogID:n,url:a,durationMs:p-d,message:h.message})),this.retryRequest(s,r,n??l);throw at(this).info(`[${l}] connection ${A?"timed out":"failed"} - error; no more retries left`),at(this).debug(`[${l}] connection ${A?"timed out":"failed"} (error; no more retries left)`,ki({retryOfRequestLogID:n,url:a,durationMs:p-d,message:h.message})),h instanceof Nc||h instanceof Ym?h:A?new Wo:new jo({cause:h})}let m=[...h.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,A])=>", "+S+": "+JSON.stringify(A)).join(""),E=`[${l}${u}${m}] ${o.method} ${a} ${h.ok?"succeeded":"failed"} with status ${h.status} in ${p-d}ms`;if(!h.ok){if(h.status===401&&this._workloadIdentityAuth&&!s.__metadata?.hasStreamingBody&&!s.__metadata?.workloadIdentityTokenRefreshed)return await zN(h.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...s,__metadata:{...s.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let S=await this.shouldRetry(h);if(r&&S){let N=`retrying, ${r} attempts remaining`;return await zN(h.body),at(this).info(`${E} - ${N}`),at(this).debug(`[${l}] response error (${N})`,ki({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,durationMs:p-d})),this.retryRequest(s,r,n??l,h.headers)}let A=S?"error; no more retries left":"error; not retryable";at(this).info(`${E} - ${A}`);let v=await h.text().catch(N=>zm(N).message),T=IK(v),k=T?void 0:v;throw at(this).debug(`[${l}] response error (${A})`,ki({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,message:k,durationMs:Date.now()-d})),this.makeStatusError(h.status,T,k,h.headers)}return at(this).info(E),at(this).debug(`[${l}] response start`,ki({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,durationMs:p-d})),{response:h,options:s,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(s=>({method:"get",path:e,...s})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new eg(this,n,e)}async fetchWithAuth(e,r,n,s){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${wM}`){let c=await this._workloadIdentityAuth.getToken();o.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,s)}async fetchWithTimeout(e,r,n,s){let{signal:i,method:o,...a}=r||{},c=this._makeAbort(s);i&&i.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:s.signal,...u?{duplex:"half"}:{},method:"GET",...a};o&&(d.method=o.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,s){let i,o=s?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(i=c)}let a=s?.get("retry-after");if(a&&!i){let c=parseFloat(a);Number.isNaN(c)?i=Date.parse(a)-Date.now():i=c*1e3}if(i===void 0){let c=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(r,c)}return await ks(i),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let i=r-e,o=Math.min(.5*Math.pow(2,i),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:s,path:i,query:o,defaultBaseURL:a}=n,c=this.buildURL(i,o,a);"timeout"in n&&OK("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:s,bodyHeaders:l,retryCount:r});return{req:{method:s,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:s}){let i={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let o=J([i,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...kK(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(o),o.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=J([r]),s=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,i=!s&&(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||s?{bodyHeaders:void 0,body:e,isStreamingBody:!i}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:Jb(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}:{...L(this,wA,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};CM=Te,wA=new WeakMap,RM=new WeakSet,O5=function(){return this.baseURL!=="https://api.openai.com/v1"};Te.OpenAI=CM;Te.DEFAULT_TIMEOUT=6e5;Te.OpenAIError=le;Te.APIError=nt;Te.APIConnectionError=jo;Te.APIConnectionTimeoutError=Wo;Te.APIUserAbortError=ut;Te.NotFoundError=Rd;Te.ConflictError=Cd;Te.RateLimitError=Pd;Te.BadRequestError=Ad;Te.AuthenticationError=vd;Te.InternalServerError=Od;Te.PermissionDeniedError=wd;Te.UnprocessableEntityError=xd;Te.InvalidWebhookSignatureError=Ds;Te.toFile=oA;Te.Completions=Hc;Te.Chat=Qo;Te.Embeddings=jc;Te.Files=zc;Te.Images=Qc;Te.Audio=$s;Te.Moderations=Zc;Te.Models=Jc;Te.FineTuning=Qn;Te.Graders=ia;Te.VectorStores=Vi;Te.Webhooks=rl;Te.Beta=Xn;Te.Batches=Fc;Te.Uploads=aa;Te.Responses=qi;Te.Realtime=Gi;Te.Conversations=na;Te.Evals=sa;Te.Containers=ra;Te.Skills=Hi;Te.Videos=tl;var br=me("runner_codex"),xM="Codex CLI",gf="gpt-5.6",LRe=({catchError:t,runCmd:e,error:r,result:n,runnerName:s})=>(br.log(`${s} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(br.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(br.log("Setting result to undefined because no valid result was captured"),{error:r||`${s} failed`,result:void 0}));async function I5({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let s=e.modelVersionOverrides?.codex?.[e.accountType];if(s){if(!await t.isModelAvailableForProvider("openai",s))throw new Error(`Model override '${s}' is not available for openai provider`);n=s}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!gf&&await t.isModelAvailableForProvider("openai",gf)?(n=gf,br.log(`Using default model: ${gf}`)):gf&&br.log(`Default model ${gf} is not available, proceeding without model specification`);return n}function N5({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");ca.env.OPENAI_API_KEY=e,ca.env.OPENAI_BASE_URL=r}else if(!ca.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function PM({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:s,continueSession:i,priorAgentSessionId:o,cwd:a=ca.cwd()}){let{prompt:c}=t,{model:l}=t;N5({aiGateway:s});let u=await I5({config:t,aiGateway:s,model:l}),d=[],f=[],h=[],p={},m=new Set,E=0,S=0,A,v,T,k=`${ca.env.NVM_BIN}/node`,x=_f.join(RA.homedir(),".codex"),N=_f.join(x,"config.toml"),P=_f.join(x,"auth.json");try{await pg.mkdir(x,{recursive:!0});let j={OPENAI_API_KEY:ca.env.OPENAI_API_KEY};await pg.writeFile(P,JSON.stringify(j,null,2),"utf-8"),br.log("Created Codex auth.json file");let $=ca.env.OPENAI_BASE_URL,X=['forced_login_method = "api"'];$&&X.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${$}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),await pg.writeFile(N,`${X.join(`
|
|
180
|
+
`);this.baseURL=c.baseURL,this.timeout=c.timeout??CM.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=tM(c.logLevel,"ClientOptions.logLevel",this)??tM(ea("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??Qb(),_e(this,wA,FK,"f"),this._options=c,o&&(this._workloadIdentityAuth=new sA(o,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=s,this.webhookSecret=i}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 J([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return zK(e)}getUserAgent(){return`${this.constructor.name}/JS ${zo}`}defaultIdempotencyKey(){return`stainless-node-retry-${GN()}`}makeStatusError(e,r,n,s){return nt.generate(e,r,n,s)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof le?n:new le(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new le(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let s=!L(this,RM,"m",O5).call(this)&&n||this.baseURL,i=xK(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(i.searchParams);return(!VN(o)||!VN(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(i.search=this.stringifyQuery(r)),i.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(s=>({method:e,path:r,...s})))}request(e,r=null){return new Lc(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let s=await e,i=s.maxRetries??this.maxRetries;r==null&&(r=i),await this.prepareOptions(s);let{req:o,url:a,timeout:c}=await this.buildRequest(s,{retryCount:i-r});await this.prepareRequest(o,{url:a,options:s});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(at(this).debug(`[${l}] sending request`,ki({retryOfRequestLogID:n,method:s.method,url:a,options:s,headers:o.headers})),s.signal?.aborted)throw new ut;let f=new AbortController,h=await this.fetchWithAuth(a,o,c,f).catch(zm),p=Date.now();if(h instanceof globalThis.Error){let S=`retrying, ${r} attempts remaining`;if(s.signal?.aborted)throw new ut;let A=Wm(h)||/timed? ?out/i.test(String(h)+("cause"in h?String(h.cause):""));if(r)return at(this).info(`[${l}] connection ${A?"timed out":"failed"} - ${S}`),at(this).debug(`[${l}] connection ${A?"timed out":"failed"} (${S})`,ki({retryOfRequestLogID:n,url:a,durationMs:p-d,message:h.message})),this.retryRequest(s,r,n??l);throw at(this).info(`[${l}] connection ${A?"timed out":"failed"} - error; no more retries left`),at(this).debug(`[${l}] connection ${A?"timed out":"failed"} (error; no more retries left)`,ki({retryOfRequestLogID:n,url:a,durationMs:p-d,message:h.message})),h instanceof Nc||h instanceof Ym?h:A?new Wo:new jo({cause:h})}let m=[...h.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,A])=>", "+S+": "+JSON.stringify(A)).join(""),E=`[${l}${u}${m}] ${o.method} ${a} ${h.ok?"succeeded":"failed"} with status ${h.status} in ${p-d}ms`;if(!h.ok){if(h.status===401&&this._workloadIdentityAuth&&!s.__metadata?.hasStreamingBody&&!s.__metadata?.workloadIdentityTokenRefreshed)return await zN(h.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...s,__metadata:{...s.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let S=await this.shouldRetry(h);if(r&&S){let N=`retrying, ${r} attempts remaining`;return await zN(h.body),at(this).info(`${E} - ${N}`),at(this).debug(`[${l}] response error (${N})`,ki({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,durationMs:p-d})),this.retryRequest(s,r,n??l,h.headers)}let A=S?"error; no more retries left":"error; not retryable";at(this).info(`${E} - ${A}`);let v=await h.text().catch(N=>zm(N).message),T=IK(v),k=T?void 0:v;throw at(this).debug(`[${l}] response error (${A})`,ki({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,message:k,durationMs:Date.now()-d})),this.makeStatusError(h.status,T,k,h.headers)}return at(this).info(E),at(this).debug(`[${l}] response start`,ki({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,durationMs:p-d})),{response:h,options:s,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(s=>({method:"get",path:e,...s})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new eg(this,n,e)}async fetchWithAuth(e,r,n,s){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${wM}`){let c=await this._workloadIdentityAuth.getToken();o.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,s)}async fetchWithTimeout(e,r,n,s){let{signal:i,method:o,...a}=r||{},c=this._makeAbort(s);i&&i.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:s.signal,...u?{duplex:"half"}:{},method:"GET",...a};o&&(d.method=o.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,s){let i,o=s?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(i=c)}let a=s?.get("retry-after");if(a&&!i){let c=parseFloat(a);Number.isNaN(c)?i=Date.parse(a)-Date.now():i=c*1e3}if(i===void 0){let c=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(r,c)}return await ks(i),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let i=r-e,o=Math.min(.5*Math.pow(2,i),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:s,path:i,query:o,defaultBaseURL:a}=n,c=this.buildURL(i,o,a);"timeout"in n&&OK("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:s,bodyHeaders:l,retryCount:r});return{req:{method:s,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:s}){let i={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let o=J([i,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...kK(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(o),o.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=J([r]),s=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,i=!s&&(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||s?{bodyHeaders:void 0,body:e,isStreamingBody:!i}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:Jb(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}:{...L(this,wA,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};CM=Te,wA=new WeakMap,RM=new WeakSet,O5=function(){return this.baseURL!=="https://api.openai.com/v1"};Te.OpenAI=CM;Te.DEFAULT_TIMEOUT=6e5;Te.OpenAIError=le;Te.APIError=nt;Te.APIConnectionError=jo;Te.APIConnectionTimeoutError=Wo;Te.APIUserAbortError=ut;Te.NotFoundError=Rd;Te.ConflictError=Cd;Te.RateLimitError=Pd;Te.BadRequestError=Ad;Te.AuthenticationError=vd;Te.InternalServerError=Od;Te.PermissionDeniedError=wd;Te.UnprocessableEntityError=xd;Te.InvalidWebhookSignatureError=Ds;Te.toFile=oA;Te.Completions=Hc;Te.Chat=Qo;Te.Embeddings=jc;Te.Files=zc;Te.Images=Qc;Te.Audio=$s;Te.Moderations=Zc;Te.Models=Jc;Te.FineTuning=Qn;Te.Graders=ia;Te.VectorStores=Vi;Te.Webhooks=rl;Te.Beta=Xn;Te.Batches=Fc;Te.Uploads=aa;Te.Responses=qi;Te.Realtime=Gi;Te.Conversations=na;Te.Evals=sa;Te.Containers=ra;Te.Skills=Hi;Te.Videos=tl;var br=me("runner_codex"),xM="Codex CLI",gf="gpt-5.6-sol",LRe=({catchError:t,runCmd:e,error:r,result:n,runnerName:s})=>(br.log(`${s} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(br.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(br.log("Setting result to undefined because no valid result was captured"),{error:r||`${s} failed`,result:void 0}));async function I5({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let s=e.modelVersionOverrides?.codex?.[e.accountType];if(s){if(!await t.isModelAvailableForProvider("openai",s))throw new Error(`Model override '${s}' is not available for openai provider`);n=s}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!gf&&await t.isModelAvailableForProvider("openai",gf)?(n=gf,br.log(`Using default model: ${gf}`)):gf&&br.log(`Default model ${gf} is not available, proceeding without model specification`);return n}function N5({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");ca.env.OPENAI_API_KEY=e,ca.env.OPENAI_BASE_URL=r}else if(!ca.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function PM({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:s,continueSession:i,priorAgentSessionId:o,cwd:a=ca.cwd()}){let{prompt:c}=t,{model:l}=t;N5({aiGateway:s});let u=await I5({config:t,aiGateway:s,model:l}),d=[],f=[],h=[],p={},m=new Set,E=0,S=0,A,v,T,k=`${ca.env.NVM_BIN}/node`,x=_f.join(RA.homedir(),".codex"),N=_f.join(x,"config.toml"),P=_f.join(x,"auth.json");try{await pg.mkdir(x,{recursive:!0});let j={OPENAI_API_KEY:ca.env.OPENAI_API_KEY};await pg.writeFile(P,JSON.stringify(j,null,2),"utf-8"),br.log("Created Codex auth.json file");let $=ca.env.OPENAI_BASE_URL,X=['forced_login_method = "api"'];$&&X.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${$}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),await pg.writeFile(N,`${X.join(`
|
|
181
181
|
`)}
|
|
182
|
-
`,"utf-8"),br.log("Wrote Codex config.toml")}catch(j){let $=j instanceof Error?j.message:String(j);throw br.warn("Failed to setup Codex config and credentials",{error:$}),new Error(`Codex setup failed: ${$}`)}let C=u==="gpt-5.6",D=!!(i&&o),_="mode"in t&&t.mode==="ask",Z=[xi(a,"codex"),"exec",..._?["--sandbox","read-only"]:[],...D?["resume",o]:[],..._?[]:["--yolo"],"--json",...C?["-c",'model_reasoning_effort="low"']:[],...u?["--model",u]:[]].filter(Boolean);br.log(`Running ${k} ${Z.join(" ")}`);let I=e.utils.run(k,Z,{all:!0,cwd:a,env:{...ca.env},stdin:"pipe",idleTimeout:dc});I.stdin?.end(c);let g=qu(()=>{r?.({steps:d,duration:S}),n?.({steps:f,duration:S}),f=[]},250),b=(j,$)=>{let X={...j,id:E};E+=1,h.push(X),d.push(X),f.push(X),$||g.flush(),g(),$&&g.flush()};b({title:`Using ${xM} with ${u||"default"}`,category:te.Environment},!0);let H=MRe.createInterface({input:I.all});return H.on("error",j=>{br.error("Readline interface error",{error:j.message,stack:j.stack})}),H.on("line",j=>{let $;try{$=JSON.parse(j)}catch{br.log("Could not parse line",j);return}if($?.duration_ms&&(S=$.duration_ms),$?.type==="thread.started"&&typeof $?.thread_id=="string"&&(T=$.thread_id),$?.type==="item.started"&&$?.item?.type==="command_execution")p[$.item.id]=$.item;else if($?.type==="item.completed"&&$?.item?.type==="command_execution"){let X=$.item,fe=URe(X);fe&&b(fe,!0);let de=X.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(de&&!m.has(de)){m.add(de);let re=Do(de);Ec(br,re),b({title:`Use ${re}`,category:te.Skill,type:de},!0)}}else if($?.type==="item.completed"&&$?.item?.type==="reasoning"){let X={title:"Reasoning",message:$.item.text,category:te.Reasoning};b(X,!0)}else if($?.type==="item.completed"&&$?.item?.type==="agent_message")A=$.item.text;else if($?.type==="local_shell_call"){let X=$;p[X.call_id]=X}else if($?.type==="local_shell_call_output"){let X=$,fe=p[X.call_id],de=FRe(fe,X);de&&b(de,!0);let Y=(fe?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(Y&&!m.has(Y)){m.add(Y);let se=Do(Y);Ec(br,se),b({title:`Use ${se}`,category:te.Skill,type:Y},!0)}}else $?.type==="message"&&$.role==="assistant"?A=$.content?.map(X=>X.text).join(`
|
|
182
|
+
`,"utf-8"),br.log("Wrote Codex config.toml")}catch(j){let $=j instanceof Error?j.message:String(j);throw br.warn("Failed to setup Codex config and credentials",{error:$}),new Error(`Codex setup failed: ${$}`)}let C=u==="gpt-5.6-sol",D=!!(i&&o),_="mode"in t&&t.mode==="ask",Z=[xi(a,"codex"),"exec",..._?["--sandbox","read-only"]:[],...D?["resume",o]:[],..._?[]:["--yolo"],"--json",...C?["-c",'model_reasoning_effort="low"']:[],...u?["--model",u]:[]].filter(Boolean);br.log(`Running ${k} ${Z.join(" ")}`);let I=e.utils.run(k,Z,{all:!0,cwd:a,env:{...ca.env},stdin:"pipe",idleTimeout:dc});I.stdin?.end(c);let g=qu(()=>{r?.({steps:d,duration:S}),n?.({steps:f,duration:S}),f=[]},250),b=(j,$)=>{let X={...j,id:E};E+=1,h.push(X),d.push(X),f.push(X),$||g.flush(),g(),$&&g.flush()};b({title:`Using ${xM} with ${u||"default"}`,category:te.Environment},!0);let H=MRe.createInterface({input:I.all});return H.on("error",j=>{br.error("Readline interface error",{error:j.message,stack:j.stack})}),H.on("line",j=>{let $;try{$=JSON.parse(j)}catch{br.log("Could not parse line",j);return}if($?.duration_ms&&(S=$.duration_ms),$?.type==="thread.started"&&typeof $?.thread_id=="string"&&(T=$.thread_id),$?.type==="item.started"&&$?.item?.type==="command_execution")p[$.item.id]=$.item;else if($?.type==="item.completed"&&$?.item?.type==="command_execution"){let X=$.item,fe=URe(X);fe&&b(fe,!0);let de=X.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(de&&!m.has(de)){m.add(de);let re=Do(de);Ec(br,re),b({title:`Use ${re}`,category:te.Skill,type:de},!0)}}else if($?.type==="item.completed"&&$?.item?.type==="reasoning"){let X={title:"Reasoning",message:$.item.text,category:te.Reasoning};b(X,!0)}else if($?.type==="item.completed"&&$?.item?.type==="agent_message")A=$.item.text;else if($?.type==="local_shell_call"){let X=$;p[X.call_id]=X}else if($?.type==="local_shell_call_output"){let X=$,fe=p[X.call_id],de=FRe(fe,X);de&&b(de,!0);let Y=(fe?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(Y&&!m.has(Y)){m.add(Y);let se=Do(Y);Ec(br,se),b({title:`Use ${se}`,category:te.Skill,type:Y},!0)}}else $?.type==="message"&&$.role==="assistant"?A=$.content?.map(X=>X.text).join(`
|
|
183
183
|
`):$?.type==="message"&&$.role==="system"&&(v=$.content?.map(X=>X.text).join(`
|
|
184
184
|
`))}),await I.catch(j=>{let $=LRe({catchError:j,runCmd:I,error:v,result:A,runnerName:"Codex"});v=$.error,A=$.result}),H.close(),g.flush(),{steps:h,duration:S,result:await Sd({initialResult:A,agentName:xM,hasError:!!v}),error:Ed({error:v,agentName:xM}),isRetryableError:yd(v),isProviderUnavailableError:Td(v),resolvedModel:u,effort:C?"low":"high",agentSessionId:T}}var M5=async()=>{let t=_f.join(RA.homedir(),".codex");await pg.rm(t,{recursive:!0,force:!0});let e=_f.join(RA.homedir(),".agents","skills");await pg.rm(e,{recursive:!0,force:!0})},L5={baseDir:_f.join(RA.homedir(),".codex"),include:["sessions"]},DRe=new Set(["bash","-lc"]),kRe=/^sed\s+-n\s+(?:'[^']*'|"[^"]*"|\S+)\s+(\S+)\s*$/,D5=t=>{if(Ic(t))return{title:"Generating the site",category:te.SiteGeneration};let e=t.match(kRe);return e?{title:`Reading \`${e[1]}\``,category:te.FileRead}:{title:`Running \`${t}\``,category:te.RunCommand}},URe=t=>{if(!t||t.type!=="command_execution")return null;let e=t.command;e=e.replace(/^(\/usr\/bin\/)?bash -lc ['"]/,"").replace(/['"]$/,"");let{command:r,heredocContent:n}=tN(e),{title:s,category:i}=D5(r),o=t.aggregated_output?.trim();return n?o=`\`\`\`
|
|
185
185
|
${n}
|