@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/index.js
CHANGED
|
@@ -85,7 +85,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
85
85
|
`,LF:`
|
|
86
86
|
`,concatBytes:lI},mye=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},gye={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:mye};import{Buffer as _ye}from"buffer";var E4=(t,e)=>t?void 0:Sye.bind(void 0,e),Sye=function*(t,e){if(typeof e!="string"&&!_t(e)&&!_ye.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},y4=(t,e)=>t?Eye.bind(void 0,e):yye.bind(void 0,e),Eye=function*(t,e){T4(t,e),yield e},yye=function*(t,e){if(T4(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},T4=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
87
87
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
88
|
-
if (condition) { yield value; }`)};import{Buffer as Tye}from"buffer";import{StringDecoder as bye}from"string_decoder";var YT=(t,e,r)=>{if(r)return;if(t)return{transform:Aye.bind(void 0,new TextEncoder)};let n=new bye(e);return{transform:vye.bind(void 0,n),final:wye.bind(void 0,n)}},Aye=function*(t,e){Tye.isBuffer(e)?yield Si(e):typeof e=="string"?yield t.encode(e):yield e},vye=function*(t,e){yield _t(e)?t.write(e):e},wye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as b4}from"util";var dI=b4(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),KT=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Cye}=e[r];for await(let s of n(t))yield*KT(s,e,r+1)},A4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Rye(r,Number(e),t)},Rye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*KT(n,r,e+1)},v4=b4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Cye=function*(t){yield t};var fI=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},w4=(t,e)=>[...e.flatMap(r=>[...hc(r,t,0)]),...cm(t)],hc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Pye}=e[r];for(let s of n(t))yield*hc(s,e,r+1)},cm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*xye(r,Number(e),t)},xye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*hc(n,r,e+1)},Pye=function*(t){yield t};var hI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=C4(t,o,i),l=fc(e),u=fc(r),d=l?dI.bind(void 0,KT,a):fI.bind(void 0,hc),f=l||u?dI.bind(void 0,A4,a):fI.bind(void 0,cm),h=l||u?v4.bind(void 0,a):void 0;return{stream:new Oye({writableObjectMode:n,writableHighWaterMark:R4(n),readableObjectMode:s,readableHighWaterMark:R4(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},XT=(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=C4(o,r,a);t=w4(c,t)}return t},C4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:E4(n,a)},YT(r,o,n),zT(r,i,n,c),{transform:t,final:e},{transform:y4(s,a)},S4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var x4=(t,e)=>{for(let r of Iye(t))Nye(t,r,e)},Iye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Nye=(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 ${Po[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Mye(a,n));r.input=Jp(o)},Mye=(t,e)=>{let r=XT(t,e,"utf8",!0);return Lye(r),Jp(r)},Lye=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 Fye,appendFileSync as Bye}from"fs";var QT=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&vu(r,n)&&!Dr.has(e)&&Dye(n)&&(t.some(({type:s,value:i})=>s==="native"&&kye.has(i))||t.every(({type:s})=>dn.has(s))),Dye=t=>t===1||t===2,kye=new Set(["pipe","overlapped"]),P4=async(t,e,r,n)=>{for await(let s of t)Uye(e)||I4(s,r,n)},O4=(t,e,r)=>{for(let n of t)I4(n,e,r)},Uye=t=>t._readableState.pipes.length>0,I4=(t,e,r)=>{let n=dT(t);vs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var N4=({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)=>$ye({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},$ye=({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=MY(t,i,d),h=Si(f),{stdioItems:p,objectMode:m}=e[r],E=Gye([h],p,c,n),{serializedResult:S,finalResult:b=S}=qye({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Hye({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let R=a[r]?b:void 0;try{return n.error===void 0&&Vye(S,p,s),R}catch(A){return n.error=A,R}},Gye=(t,e,r,n)=>{try{return XT(t,e,r,!1)}catch(s){return n.error=s,t}},qye=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Jp(t)};let o=z3(t,r);return n[i]?{serializedResult:o,finalResult:uI(o,!s[i],e)}:{serializedResult:o}},Hye=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!QT({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=uI(t,!1,o);try{O4(a,e,n)}catch(c){r.error??=c}},Vye=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>jT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?Bye(n,t):(r.add(i),Fye(n,t))}};var M4=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ti(e,r,"all")]:Array.isArray(e)?[Ti(t,r,"all"),...e]:_t(t)&&_t(e)?EO([t,e]):`${t}${e}`};import{once as pI}from"events";var L4=async(t,e)=>{let[r,n]=await jye(t);return e.isForcefullyTerminated??=!1,[r,n]},jye=async t=>{let[e,r]=await Promise.allSettled([pI(t,"spawn"),pI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?D4(t):r.value},D4=async t=>{try{return await pI(t,"exit")}catch{return D4(t)}},k4=async t=>{let[e,r]=await t;if(!Wye(e,r)&&mI(e,r))throw new qn;return[e,r]},Wye=(t,e)=>t===void 0&&e===void 0,mI=(t,e)=>t!==0||e!==null;var U4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=zye(t,e,r),o=i?.code==="ETIMEDOUT",a=NY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},zye=(t,e,r)=>t!==void 0?t:mI(e,r)?new qn:void 0;var F4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Kye(t,e,r),d=Jye({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Lu(d,c,l)},Kye=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=hT(t,e,r),a=Xye(r),{file:c,commandArguments:l,options:u}=MT(t,e,a);Qye(u);let d=p4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},Xye=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Qye=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&JT("ipcInput"),t&&JT("ipc: true"),r&&JT("detached: true"),n&&JT("cancelSignal")},JT=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Jye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Zye({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}=U4(c,r),{output:p,error:m=l}=N4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((b,R)=>Ti(b,r,R)),S=Ti(M4(p,r),r,"all");return tTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},Zye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{x4(i,r);let a=eTe(r);return Yye(...LT(t,e,a))}catch(a){return Mu({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},eTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:GT(e)}),tTe=({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?qT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):am({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 qbe}from"events";import{spawn as Hbe}from"child_process";import H4 from"process";import{once as gI,on as rTe}from"events";var B4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Cu({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),nTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),nTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{AT(e,s);let i=xo(t,e,r),o=new AbortController;try{return await Promise.race([sTe(i,n,o),iTe(i,r,o),oTe(i,r,o)])}catch(a){throw xu(t),a}finally{o.abort(),vT(e,s)}},sTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await gI(t,"message",{signal:r});return n}for await(let[n]of rTe(t,"message",{signal:r}))if(e(n))return n},iTe=async(t,e,{signal:r})=>{await gI(t,"disconnect",{signal:r}),wz(e)},oTe=async(t,e,{signal:r})=>{let[n]=await gI(t,"strict:error",{signal:r});throw yT(n,e)};import{once as G4,on as aTe}from"events";var q4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>_I({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),_I=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Cu({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),AT(e,i);let o=xo(t,e,r),a=new AbortController,c={};return cTe(t,o,a),lTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),uTe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},cTe=async(t,e,r)=>{try{await G4(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},lTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await G4(t,"strict:error",{signal:r.signal});n.error=yT(s,e),r.abort()}catch{}},uTe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of aTe(r,"message",{signal:i.signal}))$4(o),yield c}catch{$4(o)}finally{i.abort(),vT(e,a),n||xu(t),s&&await t}},$4=({error:t})=>{if(t)throw t};var V4=(t,{ipc:e})=>{Object.assign(t,W4(t,!1,e))},j4=()=>{let t=H4,e=!0,r=H4.channel!==void 0;return{...W4(t,e,r),getCancelSignal:Jz.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},W4=(t,e,r)=>({sendMessage:IT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:B4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:q4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as dTe}from"child_process";import{PassThrough as fTe,Readable as hTe,Writable as pTe,Duplex as mTe}from"stream";var z4=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{aI(n);let a=new dTe;gTe(a,n),Object.assign(a,{readable:_Te,writable:STe,duplex:ETe});let c=Mu({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=yTe(c,o,s);return{subprocess:a,promise:l}},gTe=(t,e)=>{let r=lm(),n=lm(),s=lm(),i=Array.from({length:e.length-3},lm),o=lm(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},lm=()=>{let t=new fTe;return t.end(),t},_Te=()=>new hTe({read(){}}),STe=()=>new pTe({write(){}}),ETe=()=>new mTe({read(){},write(){}}),yTe=async(t,e,r)=>Lu(t,e,r);import{createReadStream as Y4,createWriteStream as K4}from"fs";import{Buffer as TTe}from"buffer";import{Readable as um,Writable as bTe,Duplex as ATe}from"stream";var Q4=(t,e)=>WT(vTe,t,e,!1),dm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Po[t]}.`)},X4={fileNumber:dm,generator:hI,asyncGenerator:hI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ATe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},vTe={input:{...X4,fileUrl:({value:t})=>({stream:Y4(t)}),filePath:({value:{file:t}})=>({stream:Y4(t)}),webStream:({value:t})=>({stream:um.fromWeb(t)}),iterable:({value:t})=>({stream:um.from(t)}),asyncIterable:({value:t})=>({stream:um.from(t)}),string:({value:t})=>({stream:um.from(t)}),uint8Array:({value:t})=>({stream:um.from(TTe.from(t))})},output:{...X4,fileUrl:({value:t})=>({stream:K4(t)}),filePath:({value:{file:t,append:e}})=>({stream:K4(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:bTe.fromWeb(t)}),iterable:dm,asyncIterable:dm,string:dm,uint8Array:dm}};import{on as wTe,once as J4}from"events";import{PassThrough as RTe,getDefaultHighWaterMark as CTe}from"stream";import{finished as t6}from"stream/promises";function pc(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)EI(s);let e=t.some(({readableObjectMode:s})=>s),r=xTe(t,e),n=new SI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var xTe=(t,e)=>{if(t.length===0)return CTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},SI=class extends RTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(EI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=PTe(this,this.#e,this.#i);let r=NTe({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(EI(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)}},PTe=async(t,e,r)=>{ZT(t,Z4);let n=new AbortController;try{await Promise.race([OTe(t,n),ITe(t,e,r,n)])}finally{n.abort(),ZT(t,-Z4)}},OTe=async(t,{signal:e})=>{try{await t6(t,{signal:e,cleanup:!0})}catch(r){throw r6(t,r),r}},ITe=async(t,e,r,{signal:n})=>{for await(let[s]of wTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},EI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},NTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{ZT(t,e6);let a=new AbortController;try{await Promise.race([MTe(i,e,a),LTe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),DTe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),ZT(t,-e6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?yI(t):kTe(t))},MTe=async(t,e,{signal:r})=>{try{await t,r.aborted||yI(e)}catch(n){r.aborted||r6(e,n)}},LTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await t6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;n6(o)?s.add(e):s6(t,o)}},DTe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await J4(t,s,{signal:i}),!t.readable)return J4(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},kTe=t=>{t.writable&&t.end()},r6=(t,e)=>{n6(e)?yI(t):s6(t,e)},n6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yI=t=>{(t.readable||t.writable)&&t.destroy()},s6=(t,e)=>{t.destroyed||(t.once("error",UTe),t.destroy(e))},UTe=()=>{},ZT=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Z4=2,e6=1;import{finished as i6}from"stream/promises";var ku=(t,e)=>{t.pipe(e),FTe(t,e),BTe(t,e)},FTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await i6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}TI(e)}},TI=t=>{t.writable&&t.end()},BTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await i6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}bI(t)}},bI=t=>{t.readable&&t.destroy()};var o6=(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})=>dn.has(c)))$Te(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!dn.has(c)))qTe({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]:pc(i);ku(o,s)}},$Te=(t,e,r,n)=>{r==="output"?ku(t.stdio[n],e):ku(e,t.stdio[n]);let s=GTe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},GTe=["stdin","stdout","stderr"],qTe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;HTe(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},HTe=(t,{signal:e})=>{Gn(t)&&uc(t,VTe,e)},VTe=2;import{addAbortListener as zTe}from"events";var mc=[];mc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&mc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&mc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var eb=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",AI=Symbol.for("signal-exit emitter"),vI=globalThis,jTe=Object.defineProperty.bind(Object),wI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vI[AI])return vI[AI];jTe(vI,AI,{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}},tb=class{},WTe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),RI=class extends tb{onExit(){return()=>{}}load(){}unload(){}},CI=class extends tb{#e=xI.platform==="win32"?"SIGINT":"SIGHUP";#r=new wI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of mc)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(!eb(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 mc)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,mc.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 eb(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"&&eb(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)}},xI=globalThis.process,{onExit:a6,load:oJe,unload:aJe}=WTe(eb(xI)?new CI(xI):new RI);var c6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=a6(()=>{t.kill()});zTe(n,()=>{s()})};var u6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=fT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=YTe(r,n,s),{sourceStream:d,sourceError:f}=XTe(t,l),{options:h,fileDescriptors:p}=Rs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},YTe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=KTe(t,e,...r),a=bT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},KTe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(l6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||_O(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]=rT(r,...n);return{destination:e(l6)(s,i,o),pipeOptions:o}}if(Rs.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}`)},l6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),XTe=(t,e)=>{try{return{sourceStream:Pu(t,e)}}catch(r){return{sourceError:r}}};var f6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=QTe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw PI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},QTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return bI(t),n;if(e!==void 0)return TI(r),e},PI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mu({error:t,command:d6,escapedCommand:d6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),d6="source.pipe(destination)";var h6=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 JTe}from"stream/promises";var p6=(t,e,r)=>{let n=rb.has(e)?ebe(t,e):ZTe(t,e);return uc(t,rbe,r.signal),uc(e,nbe,r.signal),tbe(e),n},ZTe=(t,e)=>{let r=pc([t]);return ku(r,e),rb.set(e,r),r},ebe=(t,e)=>{let r=rb.get(e);return r.add(t),r},tbe=async t=>{try{await JTe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rb.delete(t)},rb=new WeakMap,rbe=2,nbe=1;import{aborted as sbe}from"util";var m6=(t,e)=>t===void 0?[]:[ibe(t,e)],ibe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await sbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw PI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var nb=(t,...e)=>{if(ot(e[0]))return nb.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=u6(t,...e),s=obe({...n,destination:r});return s.pipe=nb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},obe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=abe(t,s);f6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=p6(e,i,d);return await Promise.race([h6(u),...m6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},abe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as pbe}from"timers/promises";import{on as cbe}from"events";import{getDefaultHighWaterMark as lbe}from"stream";var sb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return ube(e,o),_6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},ube=async(t,e)=>{try{await t}catch{}finally{e.abort()}},OI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;dbe(e,o,t);let a=t.readableObjectMode&&!i;return _6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},dbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=cbe(t,"data",{signal:e.signal,highWaterMark:g6,highWatermark:g6});return fbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},II=lbe(!0),g6=II,fbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=hbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*hc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cm(a)}},hbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[YT(t,r,!e),zT(t,s,!n,{})].filter(Boolean);var S6=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=mbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([gbe(t),d]);return}let f=cI(c,r),h=OI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([_be({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},mbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!QT({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=OI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await P4(a,t,r,i)},gbe=async t=>{await pbe(),t.readableFlowing===null&&t.resume()},_be=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await FT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await BT(r,{maxBuffer:i})):await Nu(r,{maxBuffer:i})}catch(a){return E6(PY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},NI=async t=>{try{return await t}catch(e){return E6(e)}},E6=({bufferedData:t})=>j3(t)?new Uint8Array(t):t;import{finished as Sbe}from"stream/promises";var fm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Ebe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Sbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||bbe(a,e,r,n)}finally{o.abort()}},Ebe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&ybe(t,r,n),n},ybe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Tbe(e,r),n.call(t,...s)}},Tbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},bbe=(t,e,r,n)=>{if(!Abe(t,e,r,n))throw t},Abe=(t,e,r,n=!0)=>r.propagating?y6(t)||ib(t):(r.propagating=!0,MI(r,e)===n?y6(t):ib(t)),MI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ib=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",y6=t=>t?.code==="EPIPE";var T6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>LI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),LI=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=fm(t,e,l);if(MI(l,e)){await u;return}let[d]=await Promise.all([S6({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 b6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?pc([t,e].filter(Boolean)):void 0,A6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>LI({...vbe(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}),vbe=({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 Rbe}from"events";var v6=t=>vu(t,"ipc"),w6=(t,e)=>{let r=dT(t);vs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var R6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=v6(i),a=Ei(e,"ipc"),c=Ei(r,"ipc");for await(let l of _I({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(OY(t,s,c),s.push(l)),o&&w6(l,i);return s},C6=async(t,e)=>(await Promise.allSettled([t]),e);var x6=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 b=L4(t,f),R={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:b,propagating:!1},A=T6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),B=A6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),O=[],U=R6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:h}),P=Cbe(m,t,R),I=xbe(p,R);try{return await Promise.race([Promise.all([{},k4(b),Promise.all(A),B,U,cY(t,d),...P,...I]),E,Pbe(t,S),...nY(t,i,f,S),...vz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...tY({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},b,Promise.all(A.map(_=>NI(_))),NI(B),C6(U,O),Promise.allSettled(P),Promise.allSettled(I)])}},Cbe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:fm(n,s,r)),xbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>Vn(i,{checkOpen:!1})&&!Gn(i)).map(({type:s,value:i,stream:o=i})=>fm(o,n,e,{isSameDirection:dn.has(s),stopOnExit:s==="native"}))),Pbe=async(t,{signal:e})=>{let[r]=await Rbe(t,"error",{signal:e});throw r};var P6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),hm=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=ws();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Uu=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 Obe}from"stream";import{callbackify as Ibe}from"util";import{finished as O6}from"stream/promises";var DI=async t=>{if(t!==void 0)try{await kI(t)}catch{}},I6=async t=>{if(t!==void 0)try{await UI(t)}catch{}},kI=async t=>{await O6(t,{cleanup:!0,readable:!1,writable:!0})},UI=async t=>{await O6(t,{cleanup:!0,readable:!0,writable:!1})},ob=async(t,e)=>{if(await t,e)throw e},ab=(t,e,r)=>{r&&!ib(r)?t.destroy(r):e&&t.destroy()};var N6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Dr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=FI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=BI(a,o),{read:f,onStdoutDataDone:h}=$I({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Obe({read:f,destroy:Ibe(qI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return GI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},FI=(t,e,r)=>{let n=Pu(t,e),s=hm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},BI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:II},$I=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=ws(),o=sb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Nbe(this,o,i)},onStdoutDataDone:i}},Nbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},GI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await UI(t),await n,await DI(s),await e,r.readable&&r.push(null)}catch(i){await DI(s),M6(r,i)}},qI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Uu(r,e)&&(M6(t,n),await ob(e,n))},M6=(t,e)=>{ab(t,t.readable,e)};import{Writable as Mbe}from"stream";import{callbackify as L6}from"util";var D6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=HI(t,r,e),o=new Mbe({...VI(n,t,s),destroy:L6(WI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return jI(n,o),o},HI=(t,e,r)=>{let n=bT(t,e),s=hm(r,n,"writableFinal"),i=hm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},VI=(t,e,r)=>({write:Lbe.bind(void 0,t),final:L6(Dbe.bind(void 0,t,e,r))}),Lbe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Dbe=async(t,e,r)=>{await Uu(r,e)&&(t.writable&&t.end(),await e)},jI=async(t,e,r)=>{try{await kI(t),e.writable&&e.end()}catch(n){await I6(r),k6(e,n)}},WI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Uu(r,e),await Uu(n,e)&&(k6(t,s),await ob(e,s))},k6=(t,e)=>{ab(t,t.writable,e)};import{Duplex as kbe}from"stream";import{callbackify as Ube}from"util";var U6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Dr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=FI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=HI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=BI(c,a),{read:E,onStdoutDataDone:S}=$I({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new kbe({read:E,...VI(u,t,d),destroy:Ube(Fbe.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 GI({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),jI(u,b,c),b},Fbe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([qI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),WI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var zI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Dr.has(e),o=Pu(t,r),a=sb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return Bbe(a,o,t)},Bbe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var F6=(t,{encoding:e})=>{let r=P6();t.readable=N6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=D6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=U6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zI.bind(void 0,t,e),t[Symbol.asyncIterator]=zI.bind(void 0,t,e,{})};var B6=(t,e)=>{for(let[r,n]of Gbe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},$be=(async()=>{})().constructor.prototype,Gbe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor($be,t)]);var $6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Vbe(t,e,r),{subprocess:f,promise:h}=Wbe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=nb.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),B6(f,h),Rs.set(f,{options:u,fileDescriptors:d}),f},Vbe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=hT(t,e,r),{file:a,commandArguments:c,options:l}=MT(t,e,r),u=jbe(l),d=Q4(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},jbe=({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}},Wbe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Hbe(...LT(t,e,r))}catch(p){return z4({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;qbe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];o6(c,a,l),c6(c,r,l);let d={},f=ws();c.kill=bz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=b6(c,r),F6(c,r),V4(c,r);let h=zbe({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}},zbe=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 x6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((A,B)=>Ti(A,e,B)),b=Ti(m,e,"all"),R=Ybe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:b,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Lu(R,n,e)},Ybe=({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?am({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 Cs,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):qT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var cb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,Kbe(n,t[n],s)]));return{...t,...r}},Kbe=(t,e,r)=>Xbe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,Xbe=new Set(["env",...AO]);var Oo=(t,e,r,n)=>{let s=(o,a,c)=>Oo(o,a,r,c),i=(...o)=>Qbe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Qbe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,cb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=Jbe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?F4(a,c,l):$6(a,c,l,s)},Jbe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=Q3(e)?J3(e,r):[e,...r],[o,a,c]=rT(...i),l=cb(cb(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 G6=({file:t,commandArguments:e})=>H6(t,e),q6=({file:t,commandArguments:e})=>({...H6(t,e),isSync:!0}),H6=(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]=Zbe(t);return{file:r,commandArguments:n}},Zbe=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(eAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},eAe=/ +/g;var V6=(t,e,r)=>{t.sync=e(tAe,r),t.s=t.sync},j6=({options:t})=>W6(t),tAe=({options:t})=>({...W6(t),isSync:!0}),W6=t=>({options:{...rAe(t),...t}}),rAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},z6={preferLocal:!0};var Y6=Oo(()=>({})),XZe=Oo(()=>({isSync:!0})),K6=Oo(G6),QZe=Oo(q6),JZe=Oo(iY),ZZe=Oo(j6,{},z6,V6),{sendMessage:eet,getOneMessage:tet,getEachMessage:ret,getCancelSignal:net}=j4();var nAe=!1;var Ps=()=>nAe;var pm=null,X6=t=>(pm&&pm.destroy(),pm=new bi({totalAllowedTime:t}),pm),Q6=()=>pm;var bi=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&&Ps())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 Xy({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 J6={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 aAe=iAe(import.meta.url),cAe=Ai.dirname(aAe),lAe=oAe(import.meta.url),Fu=me("shell"),YI=new Set,Z6={preferLocal:!0},kr=(t,e,r)=>{let[n,s]=uAe(e,r),i={...Z6,...s},o=Y6(t,n,i);t8(o,i),s8(o);let a=r?.idleTimeout;return a&&a>0&&n8(o,a),o},e8=(t,e)=>{let r={...Z6,...e},n=K6(t,r);return t8(n,r),s8(n),e?.idleTimeout&&e.idleTimeout>0&&n8(n,e.idleTimeout),n},uAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},t8=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vi.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new jp).pipe(vi.stdout),t.stderr?.pipe(new jp).pipe(vi.stderr);return}t.stdout?.pipe(vi.stdout),t.stderr?.pipe(vi.stderr)},KI=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vi.kill(-t.pid,e),Fu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Fu.error("Error killing process:",r),!1}},r8=t=>KI(t,"SIGKILL"),n8=(t,e)=>{let r=null,n=()=>{Fu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fu.log(`Force killing idle process ${t.pid}`),r8(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)},s8=t=>{YI.add(t);let e=Q6();if(e){let r=e.onTimesUp(()=>{Fu.log(`Global timer expired, killing process ${t.pid}`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fu.log(`Force killing process ${t.pid} after timeout`),r8(t))},5e3)});t.on("exit",()=>{YI.delete(t),r()}),t.on("error",()=>{YI.delete(t),r()})}};function Io(t,e){if(!vi.env.NETLIFY_LOCAL_MODE)try{let s=lAe.resolve(J6.name),i=Ai.dirname(s);for(;i!==Ai.dirname(i);){let o=Ai.dirname(i);if(Ai.basename(o)==="node_modules"){let a=Ai.join(o,".bin",e);if(lb.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(vi.env.NODE_PATH){let s=Ai.join(vi.env.NODE_PATH,".bin",e);if(lb.existsSync(s))return s}let r=Ai.join(t,"node_modules",".bin",e);if(lb.existsSync(r))return r;let n=Ai.join(cAe,"..","node_modules",".bin",e);if(lb.existsSync(n))return n}var dAe=me("utils"),fAe=t=>new Promise(e=>{setTimeout(e,t)});var ub=(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 fAe(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},Bu=(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},i8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):dAe.error("Could not parse JSON",n))}},hAe=t=>t.charAt(0).toUpperCase()+t.slice(1),No=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():hAe(e)).join(" ");function gc(t,e){e&&t.log(`Skill invoked: ${e}`)}var o8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),a8=(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 XI=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}},pAe=1e4,QI=(t,e=pAe)=>{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 c8}from"buffer";import mAe from"path";var l8=me("repo"),gr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),d8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{l8.info("Getting runner diffs");let n=await _Ae(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=EAe(i);await yAe(m,r)}l8.info("Changes after processing"),await ZI(r);let o=await tN(i,r);if(await JI(o,r),s=await SAe(r),!s)return{hasChanges:!1,ignored:o};await gr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await gr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await u8(r),{hasChanges:!1,ignored:o};let u=await gr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await gr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await gr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=c8.from(S).toString("base64"))}await u8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=c8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},u8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await gr(["reset","--soft","HEAD~1"],{cwd:t})},JI=async(t=[],e=process.cwd())=>{await gr(["add",".",...t],{cwd:e})},ZI=async(t=process.cwd())=>{let e=await gr(["status","-s"],{cwd:t});return String(e.stdout??"")},f8=/.. (.+)?\.log$/,gAe=[f8],_Ae=async(t=process.cwd())=>{let e=await ZI(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
88
|
+
if (condition) { yield value; }`)};import{Buffer as Tye}from"buffer";import{StringDecoder as bye}from"string_decoder";var YT=(t,e,r)=>{if(r)return;if(t)return{transform:Aye.bind(void 0,new TextEncoder)};let n=new bye(e);return{transform:vye.bind(void 0,n),final:wye.bind(void 0,n)}},Aye=function*(t,e){Tye.isBuffer(e)?yield Si(e):typeof e=="string"?yield t.encode(e):yield e},vye=function*(t,e){yield _t(e)?t.write(e):e},wye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as b4}from"util";var dI=b4(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),KT=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Cye}=e[r];for await(let s of n(t))yield*KT(s,e,r+1)},A4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Rye(r,Number(e),t)},Rye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*KT(n,r,e+1)},v4=b4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Cye=function*(t){yield t};var fI=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},w4=(t,e)=>[...e.flatMap(r=>[...hc(r,t,0)]),...cm(t)],hc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Pye}=e[r];for(let s of n(t))yield*hc(s,e,r+1)},cm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*xye(r,Number(e),t)},xye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*hc(n,r,e+1)},Pye=function*(t){yield t};var hI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=C4(t,o,i),l=fc(e),u=fc(r),d=l?dI.bind(void 0,KT,a):fI.bind(void 0,hc),f=l||u?dI.bind(void 0,A4,a):fI.bind(void 0,cm),h=l||u?v4.bind(void 0,a):void 0;return{stream:new Oye({writableObjectMode:n,writableHighWaterMark:R4(n),readableObjectMode:s,readableHighWaterMark:R4(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},XT=(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=C4(o,r,a);t=w4(c,t)}return t},C4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:E4(n,a)},YT(r,o,n),zT(r,i,n,c),{transform:t,final:e},{transform:y4(s,a)},S4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var x4=(t,e)=>{for(let r of Iye(t))Nye(t,r,e)},Iye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Nye=(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 ${Po[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Mye(a,n));r.input=Jp(o)},Mye=(t,e)=>{let r=XT(t,e,"utf8",!0);return Lye(r),Jp(r)},Lye=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 Fye,appendFileSync as Bye}from"fs";var QT=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&vu(r,n)&&!Dr.has(e)&&Dye(n)&&(t.some(({type:s,value:i})=>s==="native"&&kye.has(i))||t.every(({type:s})=>dn.has(s))),Dye=t=>t===1||t===2,kye=new Set(["pipe","overlapped"]),P4=async(t,e,r,n)=>{for await(let s of t)Uye(e)||I4(s,r,n)},O4=(t,e,r)=>{for(let n of t)I4(n,e,r)},Uye=t=>t._readableState.pipes.length>0,I4=(t,e,r)=>{let n=dT(t);vs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var N4=({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)=>$ye({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},$ye=({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=MY(t,i,d),h=Si(f),{stdioItems:p,objectMode:m}=e[r],E=Gye([h],p,c,n),{serializedResult:S,finalResult:b=S}=qye({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Hye({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let R=a[r]?b:void 0;try{return n.error===void 0&&Vye(S,p,s),R}catch(A){return n.error=A,R}},Gye=(t,e,r,n)=>{try{return XT(t,e,r,!1)}catch(s){return n.error=s,t}},qye=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Jp(t)};let o=z3(t,r);return n[i]?{serializedResult:o,finalResult:uI(o,!s[i],e)}:{serializedResult:o}},Hye=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!QT({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=uI(t,!1,o);try{O4(a,e,n)}catch(c){r.error??=c}},Vye=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>jT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?Bye(n,t):(r.add(i),Fye(n,t))}};var M4=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ti(e,r,"all")]:Array.isArray(e)?[Ti(t,r,"all"),...e]:_t(t)&&_t(e)?EO([t,e]):`${t}${e}`};import{once as pI}from"events";var L4=async(t,e)=>{let[r,n]=await jye(t);return e.isForcefullyTerminated??=!1,[r,n]},jye=async t=>{let[e,r]=await Promise.allSettled([pI(t,"spawn"),pI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?D4(t):r.value},D4=async t=>{try{return await pI(t,"exit")}catch{return D4(t)}},k4=async t=>{let[e,r]=await t;if(!Wye(e,r)&&mI(e,r))throw new qn;return[e,r]},Wye=(t,e)=>t===void 0&&e===void 0,mI=(t,e)=>t!==0||e!==null;var U4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=zye(t,e,r),o=i?.code==="ETIMEDOUT",a=NY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},zye=(t,e,r)=>t!==void 0?t:mI(e,r)?new qn:void 0;var F4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Kye(t,e,r),d=Jye({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Lu(d,c,l)},Kye=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=hT(t,e,r),a=Xye(r),{file:c,commandArguments:l,options:u}=MT(t,e,a);Qye(u);let d=p4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},Xye=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Qye=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&JT("ipcInput"),t&&JT("ipc: true"),r&&JT("detached: true"),n&&JT("cancelSignal")},JT=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Jye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Zye({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}=U4(c,r),{output:p,error:m=l}=N4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((b,R)=>Ti(b,r,R)),S=Ti(M4(p,r),r,"all");return tTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},Zye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{x4(i,r);let a=eTe(r);return Yye(...LT(t,e,a))}catch(a){return Mu({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},eTe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:GT(e)}),tTe=({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?qT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):am({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 qbe}from"events";import{spawn as Hbe}from"child_process";import H4 from"process";import{once as gI,on as rTe}from"events";var B4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Cu({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),nTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),nTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{AT(e,s);let i=xo(t,e,r),o=new AbortController;try{return await Promise.race([sTe(i,n,o),iTe(i,r,o),oTe(i,r,o)])}catch(a){throw xu(t),a}finally{o.abort(),vT(e,s)}},sTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await gI(t,"message",{signal:r});return n}for await(let[n]of rTe(t,"message",{signal:r}))if(e(n))return n},iTe=async(t,e,{signal:r})=>{await gI(t,"disconnect",{signal:r}),wz(e)},oTe=async(t,e,{signal:r})=>{let[n]=await gI(t,"strict:error",{signal:r});throw yT(n,e)};import{once as G4,on as aTe}from"events";var q4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>_I({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),_I=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Cu({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:CT(t)}),AT(e,i);let o=xo(t,e,r),a=new AbortController,c={};return cTe(t,o,a),lTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),uTe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},cTe=async(t,e,r)=>{try{await G4(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},lTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await G4(t,"strict:error",{signal:r.signal});n.error=yT(s,e),r.abort()}catch{}},uTe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of aTe(r,"message",{signal:i.signal}))$4(o),yield c}catch{$4(o)}finally{i.abort(),vT(e,a),n||xu(t),s&&await t}},$4=({error:t})=>{if(t)throw t};var V4=(t,{ipc:e})=>{Object.assign(t,W4(t,!1,e))},j4=()=>{let t=H4,e=!0,r=H4.channel!==void 0;return{...W4(t,e,r),getCancelSignal:Jz.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},W4=(t,e,r)=>({sendMessage:IT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:B4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:q4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as dTe}from"child_process";import{PassThrough as fTe,Readable as hTe,Writable as pTe,Duplex as mTe}from"stream";var z4=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{aI(n);let a=new dTe;gTe(a,n),Object.assign(a,{readable:_Te,writable:STe,duplex:ETe});let c=Mu({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=yTe(c,o,s);return{subprocess:a,promise:l}},gTe=(t,e)=>{let r=lm(),n=lm(),s=lm(),i=Array.from({length:e.length-3},lm),o=lm(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},lm=()=>{let t=new fTe;return t.end(),t},_Te=()=>new hTe({read(){}}),STe=()=>new pTe({write(){}}),ETe=()=>new mTe({read(){},write(){}}),yTe=async(t,e,r)=>Lu(t,e,r);import{createReadStream as Y4,createWriteStream as K4}from"fs";import{Buffer as TTe}from"buffer";import{Readable as um,Writable as bTe,Duplex as ATe}from"stream";var Q4=(t,e)=>WT(vTe,t,e,!1),dm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Po[t]}.`)},X4={fileNumber:dm,generator:hI,asyncGenerator:hI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ATe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},vTe={input:{...X4,fileUrl:({value:t})=>({stream:Y4(t)}),filePath:({value:{file:t}})=>({stream:Y4(t)}),webStream:({value:t})=>({stream:um.fromWeb(t)}),iterable:({value:t})=>({stream:um.from(t)}),asyncIterable:({value:t})=>({stream:um.from(t)}),string:({value:t})=>({stream:um.from(t)}),uint8Array:({value:t})=>({stream:um.from(TTe.from(t))})},output:{...X4,fileUrl:({value:t})=>({stream:K4(t)}),filePath:({value:{file:t,append:e}})=>({stream:K4(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:bTe.fromWeb(t)}),iterable:dm,asyncIterable:dm,string:dm,uint8Array:dm}};import{on as wTe,once as J4}from"events";import{PassThrough as RTe,getDefaultHighWaterMark as CTe}from"stream";import{finished as t6}from"stream/promises";function pc(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)EI(s);let e=t.some(({readableObjectMode:s})=>s),r=xTe(t,e),n=new SI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var xTe=(t,e)=>{if(t.length===0)return CTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},SI=class extends RTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(EI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=PTe(this,this.#e,this.#i);let r=NTe({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(EI(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)}},PTe=async(t,e,r)=>{ZT(t,Z4);let n=new AbortController;try{await Promise.race([OTe(t,n),ITe(t,e,r,n)])}finally{n.abort(),ZT(t,-Z4)}},OTe=async(t,{signal:e})=>{try{await t6(t,{signal:e,cleanup:!0})}catch(r){throw r6(t,r),r}},ITe=async(t,e,r,{signal:n})=>{for await(let[s]of wTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},EI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},NTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{ZT(t,e6);let a=new AbortController;try{await Promise.race([MTe(i,e,a),LTe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),DTe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),ZT(t,-e6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?yI(t):kTe(t))},MTe=async(t,e,{signal:r})=>{try{await t,r.aborted||yI(e)}catch(n){r.aborted||r6(e,n)}},LTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await t6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;n6(o)?s.add(e):s6(t,o)}},DTe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await J4(t,s,{signal:i}),!t.readable)return J4(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},kTe=t=>{t.writable&&t.end()},r6=(t,e)=>{n6(e)?yI(t):s6(t,e)},n6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yI=t=>{(t.readable||t.writable)&&t.destroy()},s6=(t,e)=>{t.destroyed||(t.once("error",UTe),t.destroy(e))},UTe=()=>{},ZT=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Z4=2,e6=1;import{finished as i6}from"stream/promises";var ku=(t,e)=>{t.pipe(e),FTe(t,e),BTe(t,e)},FTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await i6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}TI(e)}},TI=t=>{t.writable&&t.end()},BTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await i6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}bI(t)}},bI=t=>{t.readable&&t.destroy()};var o6=(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})=>dn.has(c)))$Te(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!dn.has(c)))qTe({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]:pc(i);ku(o,s)}},$Te=(t,e,r,n)=>{r==="output"?ku(t.stdio[n],e):ku(e,t.stdio[n]);let s=GTe[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},GTe=["stdin","stdout","stderr"],qTe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;HTe(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},HTe=(t,{signal:e})=>{Gn(t)&&uc(t,VTe,e)},VTe=2;import{addAbortListener as zTe}from"events";var mc=[];mc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&mc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&mc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var eb=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",AI=Symbol.for("signal-exit emitter"),vI=globalThis,jTe=Object.defineProperty.bind(Object),wI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vI[AI])return vI[AI];jTe(vI,AI,{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}},tb=class{},WTe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),RI=class extends tb{onExit(){return()=>{}}load(){}unload(){}},CI=class extends tb{#e=xI.platform==="win32"?"SIGINT":"SIGHUP";#r=new wI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of mc)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(!eb(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 mc)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,mc.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 eb(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"&&eb(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)}},xI=globalThis.process,{onExit:a6,load:oJe,unload:aJe}=WTe(eb(xI)?new CI(xI):new RI);var c6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=a6(()=>{t.kill()});zTe(n,()=>{s()})};var u6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=fT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=YTe(r,n,s),{sourceStream:d,sourceError:f}=XTe(t,l),{options:h,fileDescriptors:p}=Rs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},YTe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=KTe(t,e,...r),a=bT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},KTe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(l6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||_O(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]=rT(r,...n);return{destination:e(l6)(s,i,o),pipeOptions:o}}if(Rs.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}`)},l6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),XTe=(t,e)=>{try{return{sourceStream:Pu(t,e)}}catch(r){return{sourceError:r}}};var f6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=QTe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw PI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},QTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return bI(t),n;if(e!==void 0)return TI(r),e},PI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mu({error:t,command:d6,escapedCommand:d6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),d6="source.pipe(destination)";var h6=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 JTe}from"stream/promises";var p6=(t,e,r)=>{let n=rb.has(e)?ebe(t,e):ZTe(t,e);return uc(t,rbe,r.signal),uc(e,nbe,r.signal),tbe(e),n},ZTe=(t,e)=>{let r=pc([t]);return ku(r,e),rb.set(e,r),r},ebe=(t,e)=>{let r=rb.get(e);return r.add(t),r},tbe=async t=>{try{await JTe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rb.delete(t)},rb=new WeakMap,rbe=2,nbe=1;import{aborted as sbe}from"util";var m6=(t,e)=>t===void 0?[]:[ibe(t,e)],ibe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await sbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw PI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var nb=(t,...e)=>{if(ot(e[0]))return nb.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=u6(t,...e),s=obe({...n,destination:r});return s.pipe=nb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},obe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=abe(t,s);f6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=p6(e,i,d);return await Promise.race([h6(u),...m6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},abe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as pbe}from"timers/promises";import{on as cbe}from"events";import{getDefaultHighWaterMark as lbe}from"stream";var sb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return ube(e,o),_6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},ube=async(t,e)=>{try{await t}catch{}finally{e.abort()}},OI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;dbe(e,o,t);let a=t.readableObjectMode&&!i;return _6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},dbe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=cbe(t,"data",{signal:e.signal,highWaterMark:g6,highWatermark:g6});return fbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},II=lbe(!0),g6=II,fbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=hbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*hc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cm(a)}},hbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[YT(t,r,!e),zT(t,s,!n,{})].filter(Boolean);var S6=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=mbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([gbe(t),d]);return}let f=cI(c,r),h=OI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([_be({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},mbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!QT({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=OI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await P4(a,t,r,i)},gbe=async t=>{await pbe(),t.readableFlowing===null&&t.resume()},_be=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await FT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await BT(r,{maxBuffer:i})):await Nu(r,{maxBuffer:i})}catch(a){return E6(PY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},NI=async t=>{try{return await t}catch(e){return E6(e)}},E6=({bufferedData:t})=>j3(t)?new Uint8Array(t):t;import{finished as Sbe}from"stream/promises";var fm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Ebe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Sbe(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||bbe(a,e,r,n)}finally{o.abort()}},Ebe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&ybe(t,r,n),n},ybe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Tbe(e,r),n.call(t,...s)}},Tbe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},bbe=(t,e,r,n)=>{if(!Abe(t,e,r,n))throw t},Abe=(t,e,r,n=!0)=>r.propagating?y6(t)||ib(t):(r.propagating=!0,MI(r,e)===n?y6(t):ib(t)),MI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ib=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",y6=t=>t?.code==="EPIPE";var T6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>LI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),LI=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=fm(t,e,l);if(MI(l,e)){await u;return}let[d]=await Promise.all([S6({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 b6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?pc([t,e].filter(Boolean)):void 0,A6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>LI({...vbe(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}),vbe=({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 Rbe}from"events";var v6=t=>vu(t,"ipc"),w6=(t,e)=>{let r=dT(t);vs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var R6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=v6(i),a=Ei(e,"ipc"),c=Ei(r,"ipc");for await(let l of _I({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(OY(t,s,c),s.push(l)),o&&w6(l,i);return s},C6=async(t,e)=>(await Promise.allSettled([t]),e);var x6=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 b=L4(t,f),R={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:b,propagating:!1},A=T6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),B=A6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),O=[],U=R6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:h}),P=Cbe(m,t,R),I=xbe(p,R);try{return await Promise.race([Promise.all([{},k4(b),Promise.all(A),B,U,cY(t,d),...P,...I]),E,Pbe(t,S),...nY(t,i,f,S),...vz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...tY({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},b,Promise.all(A.map(_=>NI(_))),NI(B),C6(U,O),Promise.allSettled(P),Promise.allSettled(I)])}},Cbe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:fm(n,s,r)),xbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>Vn(i,{checkOpen:!1})&&!Gn(i)).map(({type:s,value:i,stream:o=i})=>fm(o,n,e,{isSameDirection:dn.has(s),stopOnExit:s==="native"}))),Pbe=async(t,{signal:e})=>{let[r]=await Rbe(t,"error",{signal:e});throw r};var P6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),hm=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=ws();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Uu=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 Obe}from"stream";import{callbackify as Ibe}from"util";import{finished as O6}from"stream/promises";var DI=async t=>{if(t!==void 0)try{await kI(t)}catch{}},I6=async t=>{if(t!==void 0)try{await UI(t)}catch{}},kI=async t=>{await O6(t,{cleanup:!0,readable:!1,writable:!0})},UI=async t=>{await O6(t,{cleanup:!0,readable:!0,writable:!1})},ob=async(t,e)=>{if(await t,e)throw e},ab=(t,e,r)=>{r&&!ib(r)?t.destroy(r):e&&t.destroy()};var N6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Dr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=FI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=BI(a,o),{read:f,onStdoutDataDone:h}=$I({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Obe({read:f,destroy:Ibe(qI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return GI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},FI=(t,e,r)=>{let n=Pu(t,e),s=hm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},BI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:II},$I=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=ws(),o=sb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Nbe(this,o,i)},onStdoutDataDone:i}},Nbe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},GI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await UI(t),await n,await DI(s),await e,r.readable&&r.push(null)}catch(i){await DI(s),M6(r,i)}},qI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Uu(r,e)&&(M6(t,n),await ob(e,n))},M6=(t,e)=>{ab(t,t.readable,e)};import{Writable as Mbe}from"stream";import{callbackify as L6}from"util";var D6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=HI(t,r,e),o=new Mbe({...VI(n,t,s),destroy:L6(WI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return jI(n,o),o},HI=(t,e,r)=>{let n=bT(t,e),s=hm(r,n,"writableFinal"),i=hm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},VI=(t,e,r)=>({write:Lbe.bind(void 0,t),final:L6(Dbe.bind(void 0,t,e,r))}),Lbe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Dbe=async(t,e,r)=>{await Uu(r,e)&&(t.writable&&t.end(),await e)},jI=async(t,e,r)=>{try{await kI(t),e.writable&&e.end()}catch(n){await I6(r),k6(e,n)}},WI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Uu(r,e),await Uu(n,e)&&(k6(t,s),await ob(e,s))},k6=(t,e)=>{ab(t,t.writable,e)};import{Duplex as kbe}from"stream";import{callbackify as Ube}from"util";var U6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Dr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=FI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=HI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=BI(c,a),{read:E,onStdoutDataDone:S}=$I({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new kbe({read:E,...VI(u,t,d),destroy:Ube(Fbe.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 GI({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),jI(u,b,c),b},Fbe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([qI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),WI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var zI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Dr.has(e),o=Pu(t,r),a=sb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return Bbe(a,o,t)},Bbe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var F6=(t,{encoding:e})=>{let r=P6();t.readable=N6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=D6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=U6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zI.bind(void 0,t,e),t[Symbol.asyncIterator]=zI.bind(void 0,t,e,{})};var B6=(t,e)=>{for(let[r,n]of Gbe){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},$be=(async()=>{})().constructor.prototype,Gbe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor($be,t)]);var $6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Vbe(t,e,r),{subprocess:f,promise:h}=Wbe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=nb.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),B6(f,h),Rs.set(f,{options:u,fileDescriptors:d}),f},Vbe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=hT(t,e,r),{file:a,commandArguments:c,options:l}=MT(t,e,r),u=jbe(l),d=Q4(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},jbe=({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}},Wbe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Hbe(...LT(t,e,r))}catch(p){return z4({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;qbe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];o6(c,a,l),c6(c,r,l);let d={},f=ws();c.kill=bz.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=b6(c,r),F6(c,r),V4(c,r);let h=zbe({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}},zbe=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 x6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((A,B)=>Ti(A,e,B)),b=Ti(m,e,"all"),R=Ybe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:b,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Lu(R,n,e)},Ybe=({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?am({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 Cs,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):qT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var cb=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,Kbe(n,t[n],s)]));return{...t,...r}},Kbe=(t,e,r)=>Xbe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,Xbe=new Set(["env",...AO]);var Oo=(t,e,r,n)=>{let s=(o,a,c)=>Oo(o,a,r,c),i=(...o)=>Qbe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Qbe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,cb(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=Jbe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?F4(a,c,l):$6(a,c,l,s)},Jbe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=Q3(e)?J3(e,r):[e,...r],[o,a,c]=rT(...i),l=cb(cb(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 G6=({file:t,commandArguments:e})=>H6(t,e),q6=({file:t,commandArguments:e})=>({...H6(t,e),isSync:!0}),H6=(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]=Zbe(t);return{file:r,commandArguments:n}},Zbe=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(eAe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},eAe=/ +/g;var V6=(t,e,r)=>{t.sync=e(tAe,r),t.s=t.sync},j6=({options:t})=>W6(t),tAe=({options:t})=>({...W6(t),isSync:!0}),W6=t=>({options:{...rAe(t),...t}}),rAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},z6={preferLocal:!0};var Y6=Oo(()=>({})),XZe=Oo(()=>({isSync:!0})),K6=Oo(G6),QZe=Oo(q6),JZe=Oo(iY),ZZe=Oo(j6,{},z6,V6),{sendMessage:eet,getOneMessage:tet,getEachMessage:ret,getCancelSignal:net}=j4();var nAe=!1;var Ps=()=>nAe;var pm=null,X6=t=>(pm&&pm.destroy(),pm=new bi({totalAllowedTime:t}),pm),Q6=()=>pm;var bi=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&&Ps())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 Xy({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 J6={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 aAe=iAe(import.meta.url),cAe=Ai.dirname(aAe),lAe=oAe(import.meta.url),Fu=me("shell"),YI=new Set,Z6={preferLocal:!0},kr=(t,e,r)=>{let[n,s]=uAe(e,r),i={...Z6,...s},o=Y6(t,n,i);t8(o,i),s8(o);let a=r?.idleTimeout;return a&&a>0&&n8(o,a),o},e8=(t,e)=>{let r={...Z6,...e},n=K6(t,r);return t8(n,r),s8(n),e?.idleTimeout&&e.idleTimeout>0&&n8(n,e.idleTimeout),n},uAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},t8=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vi.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new jp).pipe(vi.stdout),t.stderr?.pipe(new jp).pipe(vi.stderr);return}t.stdout?.pipe(vi.stdout),t.stderr?.pipe(vi.stderr)},KI=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vi.kill(-t.pid,e),Fu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Fu.error("Error killing process:",r),!1}},r8=t=>KI(t,"SIGKILL"),n8=(t,e)=>{let r=null,n=()=>{Fu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fu.log(`Force killing idle process ${t.pid}`),r8(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)},s8=t=>{YI.add(t);let e=Q6();if(e){let r=e.onTimesUp(()=>{Fu.log(`Global timer expired, killing process ${t.pid}`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Fu.log(`Force killing process ${t.pid} after timeout`),r8(t))},5e3)});t.on("exit",()=>{YI.delete(t),r()}),t.on("error",()=>{YI.delete(t),r()})}};function Io(t,e){if(!vi.env.NETLIFY_LOCAL_MODE)try{let s=lAe.resolve(J6.name),i=Ai.dirname(s);for(;i!==Ai.dirname(i);){let o=Ai.dirname(i);if(Ai.basename(o)==="node_modules"){let a=Ai.join(o,".bin",e);if(lb.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(vi.env.NODE_PATH){let s=Ai.join(vi.env.NODE_PATH,".bin",e);if(lb.existsSync(s))return s}let r=Ai.join(t,"node_modules",".bin",e);if(lb.existsSync(r))return r;let n=Ai.join(cAe,"..","node_modules",".bin",e);if(lb.existsSync(n))return n}var dAe=me("utils"),fAe=t=>new Promise(e=>{setTimeout(e,t)});var ub=(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 fAe(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},Bu=(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},i8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):dAe.error("Could not parse JSON",n))}},hAe=t=>t.charAt(0).toUpperCase()+t.slice(1),No=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():hAe(e)).join(" ");function gc(t,e){e&&t.log(`Skill invoked: ${e}`)}var o8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),a8=(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 XI=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}},pAe=1e4,QI=(t,e=pAe)=>{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 c8}from"buffer";import mAe from"path";var l8=me("repo"),gr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),d8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{l8.info("Getting runner diffs");let n=await _Ae(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=EAe(i);await yAe(m,r)}l8.info("Changes after processing"),await ZI(r);let o=await tN(i,r);if(await JI(o,r),s=await SAe(r),!s)return{hasChanges:!1,ignored:o};await gr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await gr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await u8(r),{hasChanges:!1,ignored:o};let u=await gr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await gr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await gr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=c8.from(S).toString("base64"))}await u8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=c8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},u8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await gr(["reset","--soft","HEAD~1"],{cwd:t})},JI=async(t=[],e=process.cwd())=>{await gr(["add",".",...t],{cwd:e})},ZI=async(t=process.cwd())=>{let e=await gr(["status","-s"],{cwd:t});return String(e.stdout??"")},f8=/.. (.+)?\.log$/,gAe=[f8],_Ae=async(t=process.cwd())=>{let e=await ZI(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
89
89
|
`).filter(s=>gAe.some(o=>o instanceof RegExp?o.test(s):s===o)?!1:s[1]?.trim()!=="")).length!==0,status:e}},SAe=async(t=process.cwd())=>{try{return await gr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},eN=async(t=process.cwd())=>{let{stdout:e}=await gr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},h8=async(t=process.cwd())=>{let{stdout:e}=await gr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},tN=async(t,e=process.cwd())=>{t||=await ZI(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(`
|
|
90
90
|
`).forEach(s=>{r.forEach(o=>{let a=s===`?? ${o}`,c=s.startsWith(`?? ${o}/`)||s.startsWith(`?? ${o}${mAe.sep}`);(a||c)&&n.push(`:!${o}`)});let i=s.match(f8)?.[1];i&&n.push(`:!${i}.log`)}),n},rN=async(t=process.cwd())=>{await gr(["reset","--hard","HEAD"],{cwd:t})},p8=async(t=process.cwd())=>{let e=await gr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
91
91
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},EAe=t=>{let e=t.split(`
|
|
@@ -176,9 +176,9 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
176
176
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
177
177
|
|
|
178
178
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
179
|
-
`);this.baseURL=c.baseURL,this.timeout=c.timeout??AM.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=QN(c.logLevel,"ClientOptions.logLevel",this)??QN(Qo("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??jb(),_e(this,EA,wK,"f"),this._options=c,o&&(this._workloadIdentityAuth=new Jb(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 LK(e)}getUserAgent(){return`${this.constructor.name}/JS ${Vo}`}defaultIdempotencyKey(){return`stainless-node-retry-${UN()}`}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=!M(this,bM,"m",_5).call(this)&&n||this.baseURL,i=mK(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(i.searchParams);return(!$N(o)||!$N(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 Ic(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`,Ni({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(Hm),p=Date.now();if(h instanceof globalThis.Error){let S=`retrying, ${r} attempts remaining`;if(s.signal?.aborted)throw new ut;let b=qm(h)||/timed? ?out/i.test(String(h)+("cause"in h?String(h.cause):""));if(r)return at(this).info(`[${l}] connection ${b?"timed out":"failed"} - ${S}`),at(this).debug(`[${l}] connection ${b?"timed out":"failed"} (${S})`,Ni({retryOfRequestLogID:n,url:a,durationMs:p-d,message:h.message})),this.retryRequest(s,r,n??l);throw at(this).info(`[${l}] connection ${b?"timed out":"failed"} - error; no more retries left`),at(this).debug(`[${l}] connection ${b?"timed out":"failed"} (error; no more retries left)`,Ni({retryOfRequestLogID:n,url:a,durationMs:p-d,message:h.message})),h instanceof Pc||h instanceof Vm?h:b?new Ho:new qo({cause:h})}let m=[...h.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,b])=>", "+S+": "+JSON.stringify(b)).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 HN(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 U=`retrying, ${r} attempts remaining`;return await HN(h.body),at(this).info(`${E} - ${U}`),at(this).debug(`[${l}] response error (${U})`,Ni({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,durationMs:p-d})),this.retryRequest(s,r,n??l,h.headers)}let b=S?"error; no more retries left":"error; not retryable";at(this).info(`${E} - ${b}`);let R=await h.text().catch(U=>Hm(U).message),A=SK(R),B=A?void 0:R;throw at(this).debug(`[${l}] response error (${b})`,Ni({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,message:B,durationMs:Date.now()-d})),this.makeStatusError(h.status,A,B,h.headers)}return at(this).info(E),at(this).debug(`[${l}] response start`,Ni({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 Xm(this,n,e)}async fetchWithAuth(e,r,n,s){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${TM}`){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 Ms(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&&_K("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))}:{},...AK(),"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:Wb(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}:{...M(this,EA,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};AM=Te,EA=new WeakMap,bM=new WeakSet,_5=function(){return this.baseURL!=="https://api.openai.com/v1"};Te.OpenAI=AM;Te.DEFAULT_TIMEOUT=6e5;Te.OpenAIError=le;Te.APIError=nt;Te.APIConnectionError=qo;Te.APIConnectionTimeoutError=Ho;Te.APIUserAbortError=ut;Te.NotFoundError=Ad;Te.ConflictError=vd;Te.RateLimitError=Rd;Te.BadRequestError=yd;Te.AuthenticationError=Td;Te.InternalServerError=Cd;Te.PermissionDeniedError=bd;Te.UnprocessableEntityError=wd;Te.InvalidWebhookSignatureError=Ns;Te.toFile=eA;Te.Completions=$c;Te.Chat=Yo;Te.Embeddings=qc;Te.Files=Vc;Te.Images=Yc;Te.Audio=Us;Te.Moderations=Xc;Te.Models=Kc;Te.FineTuning=Yn;Te.Graders=ra;Te.VectorStores=$i;Te.Webhooks=Zc;Te.Beta=zn;Te.Batches=Dc;Te.Uploads=sa;Te.Responses=Fi;Te.Realtime=Ui;Te.Conversations=ea;Te.Evals=ta;Te.Containers=Zo;Te.Skills=Bi;Te.Videos=Jc;var Sr=me("runner_codex"),vM="Codex CLI",hf="gpt-5.6",hRe=({catchError:t,runCmd:e,error:r,result:n,runnerName:s})=>(Sr.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?(Sr.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}):(Sr.log("Setting result to undefined because no valid result was captured"),{error:r||`${s} failed`,result:void 0}));async function S5({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!!hf&&await t.isModelAvailableForProvider("openai",hf)?(n=hf,Sr.log(`Using default model: ${hf}`)):hf&&Sr.log(`Default model ${hf} is not available, proceeding without model specification`);return n}function E5({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");ia.env.OPENAI_API_KEY=e,ia.env.OPENAI_BASE_URL=r}else if(!ia.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function wM({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:s,continueSession:i,priorAgentSessionId:o,cwd:a=ia.cwd()}){let{prompt:c}=t,{model:l}=t;E5({aiGateway:s});let u=await S5({config:t,aiGateway:s,model:l}),d=[],f=[],h=[],p={},m=new Set,E=0,S=0,b,R,A,B=`${ia.env.NVM_BIN}/node`,O=pf.join(yA.homedir(),".codex"),U=pf.join(O,"config.toml"),P=pf.join(O,"auth.json");try{await ug.mkdir(O,{recursive:!0});let j={OPENAI_API_KEY:ia.env.OPENAI_API_KEY};await ug.writeFile(P,JSON.stringify(j,null,2),"utf-8"),Sr.log("Created Codex auth.json file");let $=ia.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 ug.writeFile(U,`${X.join(`
|
|
179
|
+
`);this.baseURL=c.baseURL,this.timeout=c.timeout??AM.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=QN(c.logLevel,"ClientOptions.logLevel",this)??QN(Qo("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??jb(),_e(this,EA,wK,"f"),this._options=c,o&&(this._workloadIdentityAuth=new Jb(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 LK(e)}getUserAgent(){return`${this.constructor.name}/JS ${Vo}`}defaultIdempotencyKey(){return`stainless-node-retry-${UN()}`}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=!M(this,bM,"m",_5).call(this)&&n||this.baseURL,i=mK(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(i.searchParams);return(!$N(o)||!$N(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 Ic(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`,Ni({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(Hm),p=Date.now();if(h instanceof globalThis.Error){let S=`retrying, ${r} attempts remaining`;if(s.signal?.aborted)throw new ut;let b=qm(h)||/timed? ?out/i.test(String(h)+("cause"in h?String(h.cause):""));if(r)return at(this).info(`[${l}] connection ${b?"timed out":"failed"} - ${S}`),at(this).debug(`[${l}] connection ${b?"timed out":"failed"} (${S})`,Ni({retryOfRequestLogID:n,url:a,durationMs:p-d,message:h.message})),this.retryRequest(s,r,n??l);throw at(this).info(`[${l}] connection ${b?"timed out":"failed"} - error; no more retries left`),at(this).debug(`[${l}] connection ${b?"timed out":"failed"} (error; no more retries left)`,Ni({retryOfRequestLogID:n,url:a,durationMs:p-d,message:h.message})),h instanceof Pc||h instanceof Vm?h:b?new Ho:new qo({cause:h})}let m=[...h.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,b])=>", "+S+": "+JSON.stringify(b)).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 HN(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 U=`retrying, ${r} attempts remaining`;return await HN(h.body),at(this).info(`${E} - ${U}`),at(this).debug(`[${l}] response error (${U})`,Ni({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,durationMs:p-d})),this.retryRequest(s,r,n??l,h.headers)}let b=S?"error; no more retries left":"error; not retryable";at(this).info(`${E} - ${b}`);let R=await h.text().catch(U=>Hm(U).message),A=SK(R),B=A?void 0:R;throw at(this).debug(`[${l}] response error (${b})`,Ni({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,message:B,durationMs:Date.now()-d})),this.makeStatusError(h.status,A,B,h.headers)}return at(this).info(E),at(this).debug(`[${l}] response start`,Ni({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 Xm(this,n,e)}async fetchWithAuth(e,r,n,s){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${TM}`){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 Ms(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&&_K("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))}:{},...AK(),"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:Wb(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}:{...M(this,EA,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};AM=Te,EA=new WeakMap,bM=new WeakSet,_5=function(){return this.baseURL!=="https://api.openai.com/v1"};Te.OpenAI=AM;Te.DEFAULT_TIMEOUT=6e5;Te.OpenAIError=le;Te.APIError=nt;Te.APIConnectionError=qo;Te.APIConnectionTimeoutError=Ho;Te.APIUserAbortError=ut;Te.NotFoundError=Ad;Te.ConflictError=vd;Te.RateLimitError=Rd;Te.BadRequestError=yd;Te.AuthenticationError=Td;Te.InternalServerError=Cd;Te.PermissionDeniedError=bd;Te.UnprocessableEntityError=wd;Te.InvalidWebhookSignatureError=Ns;Te.toFile=eA;Te.Completions=$c;Te.Chat=Yo;Te.Embeddings=qc;Te.Files=Vc;Te.Images=Yc;Te.Audio=Us;Te.Moderations=Xc;Te.Models=Kc;Te.FineTuning=Yn;Te.Graders=ra;Te.VectorStores=$i;Te.Webhooks=Zc;Te.Beta=zn;Te.Batches=Dc;Te.Uploads=sa;Te.Responses=Fi;Te.Realtime=Ui;Te.Conversations=ea;Te.Evals=ta;Te.Containers=Zo;Te.Skills=Bi;Te.Videos=Jc;var Sr=me("runner_codex"),vM="Codex CLI",hf="gpt-5.6-sol",hRe=({catchError:t,runCmd:e,error:r,result:n,runnerName:s})=>(Sr.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?(Sr.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}):(Sr.log("Setting result to undefined because no valid result was captured"),{error:r||`${s} failed`,result:void 0}));async function S5({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!!hf&&await t.isModelAvailableForProvider("openai",hf)?(n=hf,Sr.log(`Using default model: ${hf}`)):hf&&Sr.log(`Default model ${hf} is not available, proceeding without model specification`);return n}function E5({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");ia.env.OPENAI_API_KEY=e,ia.env.OPENAI_BASE_URL=r}else if(!ia.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function wM({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:s,continueSession:i,priorAgentSessionId:o,cwd:a=ia.cwd()}){let{prompt:c}=t,{model:l}=t;E5({aiGateway:s});let u=await S5({config:t,aiGateway:s,model:l}),d=[],f=[],h=[],p={},m=new Set,E=0,S=0,b,R,A,B=`${ia.env.NVM_BIN}/node`,O=pf.join(yA.homedir(),".codex"),U=pf.join(O,"config.toml"),P=pf.join(O,"auth.json");try{await ug.mkdir(O,{recursive:!0});let j={OPENAI_API_KEY:ia.env.OPENAI_API_KEY};await ug.writeFile(P,JSON.stringify(j,null,2),"utf-8"),Sr.log("Created Codex auth.json file");let $=ia.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 ug.writeFile(U,`${X.join(`
|
|
180
180
|
`)}
|
|
181
|
-
`,"utf-8"),Sr.log("Wrote Codex config.toml")}catch(j){let $=j instanceof Error?j.message:String(j);throw Sr.warn("Failed to setup Codex config and credentials",{error:$}),new Error(`Codex setup failed: ${$}`)}let I=u==="gpt-5.6",D=!!(i&&o),_="mode"in t&&t.mode==="ask",Z=[Io(a,"codex"),"exec",..._?["--sandbox","read-only"]:[],...D?["resume",o]:[],..._?[]:["--yolo"],"--json",...I?["-c",'model_reasoning_effort="low"']:[],...u?["--model",u]:[]].filter(Boolean);Sr.log(`Running ${B} ${Z.join(" ")}`);let x=e.utils.run(B,Z,{all:!0,cwd:a,env:{...ia.env},stdin:"pipe",idleTimeout:cc});x.stdin?.end(c);let g=Bu(()=>{r?.({steps:d,duration:S}),n?.({steps:f,duration:S}),f=[]},250),T=(j,$)=>{let X={...j,id:E};E+=1,h.push(X),d.push(X),f.push(X),$||g.flush(),g(),$&&g.flush()};T({title:`Using ${vM} with ${u||"default"}`,category:te.Environment},!0);let H=fRe.createInterface({input:x.all});return H.on("error",j=>{Sr.error("Readline interface error",{error:j.message,stack:j.stack})}),H.on("line",j=>{let $;try{$=JSON.parse(j)}catch{Sr.log("Could not parse line",j);return}if($?.duration_ms&&(S=$.duration_ms),$?.type==="thread.started"&&typeof $?.thread_id=="string"&&(A=$.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=gRe(X);fe&&T(fe,!0);let de=X.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(de&&!m.has(de)){m.add(de);let re=No(de);gc(Sr,re),T({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};T(X,!0)}else if($?.type==="item.completed"&&$?.item?.type==="agent_message")b=$.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=_Re(fe,X);de&&T(de,!0);let Y=(fe?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(Y&&!m.has(Y)){m.add(Y);let se=No(Y);gc(Sr,se),T({title:`Use ${se}`,category:te.Skill,type:Y},!0)}}else $?.type==="message"&&$.role==="assistant"?b=$.content?.map(X=>X.text).join(`
|
|
181
|
+
`,"utf-8"),Sr.log("Wrote Codex config.toml")}catch(j){let $=j instanceof Error?j.message:String(j);throw Sr.warn("Failed to setup Codex config and credentials",{error:$}),new Error(`Codex setup failed: ${$}`)}let I=u==="gpt-5.6-sol",D=!!(i&&o),_="mode"in t&&t.mode==="ask",Z=[Io(a,"codex"),"exec",..._?["--sandbox","read-only"]:[],...D?["resume",o]:[],..._?[]:["--yolo"],"--json",...I?["-c",'model_reasoning_effort="low"']:[],...u?["--model",u]:[]].filter(Boolean);Sr.log(`Running ${B} ${Z.join(" ")}`);let x=e.utils.run(B,Z,{all:!0,cwd:a,env:{...ia.env},stdin:"pipe",idleTimeout:cc});x.stdin?.end(c);let g=Bu(()=>{r?.({steps:d,duration:S}),n?.({steps:f,duration:S}),f=[]},250),T=(j,$)=>{let X={...j,id:E};E+=1,h.push(X),d.push(X),f.push(X),$||g.flush(),g(),$&&g.flush()};T({title:`Using ${vM} with ${u||"default"}`,category:te.Environment},!0);let H=fRe.createInterface({input:x.all});return H.on("error",j=>{Sr.error("Readline interface error",{error:j.message,stack:j.stack})}),H.on("line",j=>{let $;try{$=JSON.parse(j)}catch{Sr.log("Could not parse line",j);return}if($?.duration_ms&&(S=$.duration_ms),$?.type==="thread.started"&&typeof $?.thread_id=="string"&&(A=$.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=gRe(X);fe&&T(fe,!0);let de=X.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(de&&!m.has(de)){m.add(de);let re=No(de);gc(Sr,re),T({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};T(X,!0)}else if($?.type==="item.completed"&&$?.item?.type==="agent_message")b=$.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=_Re(fe,X);de&&T(de,!0);let Y=(fe?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(Y&&!m.has(Y)){m.add(Y);let se=No(Y);gc(Sr,se),T({title:`Use ${se}`,category:te.Skill,type:Y},!0)}}else $?.type==="message"&&$.role==="assistant"?b=$.content?.map(X=>X.text).join(`
|
|
182
182
|
`):$?.type==="message"&&$.role==="system"&&(R=$.content?.map(X=>X.text).join(`
|
|
183
183
|
`))}),await x.catch(j=>{let $=hRe({catchError:j,runCmd:x,error:R,result:b,runnerName:"Codex"});R=$.error,b=$.result}),H.close(),g.flush(),{steps:h,duration:S,result:await md({initialResult:b,agentName:vM,hasError:!!R}),error:gd({error:R,agentName:vM}),isRetryableError:_d(R),isProviderUnavailableError:Sd(R),resolvedModel:u,effort:I?"low":"high",agentSessionId:A}}var y5=async()=>{let t=pf.join(yA.homedir(),".codex");await ug.rm(t,{recursive:!0,force:!0});let e=pf.join(yA.homedir(),".agents","skills");await ug.rm(e,{recursive:!0,force:!0})},T5={baseDir:pf.join(yA.homedir(),".codex"),include:["sessions"]},pRe=new Set(["bash","-lc"]),mRe=/^sed\s+-n\s+(?:'[^']*'|"[^"]*"|\S+)\s+(\S+)\s*$/,b5=t=>{if(xc(t))return{title:"Generating the site",category:te.SiteGeneration};let e=t.match(mRe);return e?{title:`Reading \`${e[1]}\``,category:te.FileRead}:{title:`Running \`${t}\``,category:te.RunCommand}},gRe=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}=XI(e),{title:s,category:i}=b5(r),o=t.aggregated_output?.trim();return n?o=`\`\`\`
|
|
184
184
|
${n}
|