@netlify/agent-runner-cli 1.189.4 → 1.190.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin-local.js CHANGED
@@ -143,7 +143,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
143
143
  `,LF:`
144
144
  `,concatBytes:qU},dVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},fVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:dVe};import{Buffer as pVe}from"buffer";var Fae=(t,e)=>t?void 0:hVe.bind(void 0,e),hVe=function*(t,e){if(typeof e!="string"&&!dr(e)&&!pVe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},zae=(t,e)=>t?mVe.bind(void 0,e):gVe.bind(void 0,e),mVe=function*(t,e){jae(t,e),yield e},gVe=function*(t,e){if(jae(t,e),typeof e!="string"&&!dr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},jae=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
145
145
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
146
- if (condition) { yield value; }`)};import{Buffer as _Ve}from"buffer";import{StringDecoder as yVe}from"string_decoder";var $R=(t,e,r)=>{if(r)return;if(t)return{transform:SVe.bind(void 0,new TextEncoder)};let n=new yVe(e);return{transform:EVe.bind(void 0,n),final:vVe.bind(void 0,n)}},SVe=function*(t,e){_Ve.isBuffer(e)?yield _a(e):typeof e=="string"?yield t.encode(e):yield e},EVe=function*(t,e){yield dr(e)?t.write(e):e},vVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Bae}from"util";var VU=Bae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),LR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bVe}=e[r];for await(let i of n(t))yield*LR(i,e,r+1)},qae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*TVe(r,Number(e),t)},TVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*LR(n,r,e+1)},Gae=Bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bVe=function*(t){yield t};var HU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Vae=(t,e)=>[...e.flatMap(r=>[...Gu(r,t,0)]),...Qy(t)],Gu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=AVe}=e[r];for(let i of n(t))yield*Gu(i,e,r+1)},Qy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wVe(r,Number(e),t)},wVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Gu(n,r,e+1)},AVe=function*(t){yield t};var WU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Wae(t,s,o),l=qu(e),u=qu(r),d=l?VU.bind(void 0,LR,a):HU.bind(void 0,Gu),f=l||u?VU.bind(void 0,qae,a):HU.bind(void 0,Qy),p=l||u?Gae.bind(void 0,a):void 0;return{stream:new xVe({writableObjectMode:n,writableHighWaterMark:Hae(n),readableObjectMode:i,readableHighWaterMark:Hae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},UR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Wae(s,r,a);t=Vae(c,t)}return t},Wae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Fae(n,a)},$R(r,s,n),DR(r,o,n,c),{transform:t,final:e},{transform:zae(i,a)},Uae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Yae=(t,e)=>{for(let r of RVe(t))CVe(t,r,e)},RVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),CVe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Lc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>IVe(a,n));r.input=qy(s)},IVe=(t,e)=>{let r=UR(t,e,"utf8",!0);return PVe(r),qy(r)},PVe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as MVe,appendFileSync as DVe}from"fs";var FR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Dp(r,n)&&!ii.has(e)&&OVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&NVe.has(o))||t.every(({type:i})=>ki.has(i))),OVe=t=>t===1||t===2,NVe=new Set(["pipe","overlapped"]),Kae=async(t,e,r,n)=>{for await(let i of t)kVe(e)||Jae(i,r,n)},Zae=(t,e,r)=>{for(let n of t)Jae(n,e,r)},kVe=t=>t._readableState.pipes.length>0,Jae=(t,e,r)=>{let n=Qx(t);us({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Xae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>$Ve({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},$Ve=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Qse(t,o,d),p=_a(f),{stdioItems:h,objectMode:m}=e[r],g=LVe([p],h,c,n),{serializedResult:_,finalResult:v=_}=UVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});FVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?v:void 0;try{return n.error===void 0&&zVe(_,h,i),T}catch(y){return n.error=y,T}},LVe=(t,e,r,n)=>{try{return UR(t,e,r,!1)}catch(i){return n.error=i,t}},UVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qy(t)};let s=pie(t,r);return n[o]?{serializedResult:s,finalResult:GU(s,!i[o],e)}:{serializedResult:s}},FVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!FR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=GU(t,!1,s);try{Zae(a,e,n)}catch(c){r.error??=c}},zVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>kR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?DVe(n,t):(r.add(o),MVe(n,t))}};var Qae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ea(e,r,"all")]:Array.isArray(e)?[Ea(t,r,"all"),...e]:dr(t)&&dr(e)?Q1([t,e]):`${t}${e}`};import{once as YU}from"events";var ece=async(t,e)=>{let[r,n]=await jVe(t);return e.isForcefullyTerminated??=!1,[r,n]},jVe=async t=>{let[e,r]=await Promise.allSettled([YU(t,"spawn"),YU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?tce(t):r.value},tce=async t=>{try{return await YU(t,"exit")}catch{return tce(t)}},rce=async t=>{let[e,r]=await t;if(!BVe(e,r)&&KU(e,r))throw new ho;return[e,r]},BVe=(t,e)=>t===void 0&&e===void 0,KU=(t,e)=>t!==0||e!==null;var nce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=qVe(t,e,r),s=o?.code==="ETIMEDOUT",a=Xse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},qVe=(t,e,r)=>t!==void 0?t:KU(e,r)?new ho:void 0;var ice=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=VVe(t,e,r),d=YVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Vp(d,c,l)},VVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),a=HVe(r),{file:c,commandArguments:l,options:u}=vR(t,e,a);WVe(u);let d=Mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},HVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,WVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&zR("ipcInput"),t&&zR("ipc: true"),r&&zR("detached: true"),n&&zR("cancelSignal")},zR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},YVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=KVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=nce(c,r),{output:h,error:m=l}=Xae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,T)=>Ea(v,r,T)),_=Ea(Qae(h,r),r,"all");return JVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},KVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Yae(o,r);let a=ZVe(r);return GVe(...TR(t,e,a))}catch(a){return Gp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},ZVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:IR(e)}),JVe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?PR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Xy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as UHe}from"events";import{spawn as FHe}from"child_process";import lce from"process";import{once as ZU,on as XVe}from"events";var oce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Up({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),QVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),QVe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{dR(e,i);let o=$c(t,e,r),s=new AbortController;try{return await Promise.race([e4e(o,n,s),t4e(o,r,s),r4e(o,r,s)])}catch(a){throw Fp(t),a}finally{s.abort(),fR(e,i)}},e4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await ZU(t,"message",{signal:r});return n}for await(let[n]of XVe(t,"message",{signal:r}))if(e(n))return n},t4e=async(t,e,{signal:r})=>{await ZU(t,"disconnect",{signal:r}),Voe(e)},r4e=async(t,e,{signal:r})=>{let[n]=await ZU(t,"strict:error",{signal:r});throw cR(n,e)};import{once as ace,on as n4e}from"events";var cce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>JU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),JU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Up({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),dR(e,o);let s=$c(t,e,r),a=new AbortController,c={};return i4e(t,s,a),o4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),s4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},i4e=async(t,e,r)=>{try{await ace(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},o4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ace(t,"strict:error",{signal:r.signal});n.error=cR(i,e),r.abort()}catch{}},s4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of n4e(r,"message",{signal:o.signal}))sce(s),yield c}catch{sce(s)}finally{o.abort(),fR(e,a),n||Fp(t),i&&await t}},sce=({error:t})=>{if(t)throw t};var uce=(t,{ipc:e})=>{Object.assign(t,fce(t,!1,e))},dce=()=>{let t=lce,e=!0,r=lce.channel!==void 0;return{...fce(t,e,r),getCancelSignal:yse.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},fce=(t,e,r)=>({sendMessage:SR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:oce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:cce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as a4e}from"child_process";import{PassThrough as c4e,Readable as l4e,Writable as u4e,Duplex as d4e}from"stream";var pce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{jU(n);let a=new a4e;f4e(a,n),Object.assign(a,{readable:p4e,writable:h4e,duplex:m4e});let c=Gp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=g4e(c,s,i);return{subprocess:a,promise:l}},f4e=(t,e)=>{let r=eS(),n=eS(),i=eS(),o=Array.from({length:e.length-3},eS),s=eS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},eS=()=>{let t=new c4e;return t.end(),t},p4e=()=>new l4e({read(){}}),h4e=()=>new u4e({write(){}}),m4e=()=>new d4e({read(){},write(){}}),g4e=async(t,e,r)=>Vp(t,e,r);import{createReadStream as hce,createWriteStream as mce}from"fs";import{Buffer as _4e}from"buffer";import{Readable as tS,Writable as y4e,Duplex as S4e}from"stream";var _ce=(t,e)=>MR(E4e,t,e,!1),rS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Lc[t]}.`)},gce={fileNumber:rS,generator:WU,asyncGenerator:WU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:S4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},E4e={input:{...gce,fileUrl:({value:t})=>({stream:hce(t)}),filePath:({value:{file:t}})=>({stream:hce(t)}),webStream:({value:t})=>({stream:tS.fromWeb(t)}),iterable:({value:t})=>({stream:tS.from(t)}),asyncIterable:({value:t})=>({stream:tS.from(t)}),string:({value:t})=>({stream:tS.from(t)}),uint8Array:({value:t})=>({stream:tS.from(_4e.from(t))})},output:{...gce,fileUrl:({value:t})=>({stream:mce(t)}),filePath:({value:{file:t,append:e}})=>({stream:mce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:y4e.fromWeb(t)}),iterable:rS,asyncIterable:rS,string:rS,uint8Array:rS}};import{on as v4e,once as yce}from"events";import{PassThrough as T4e,getDefaultHighWaterMark as b4e}from"stream";import{finished as vce}from"stream/promises";function Vu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)QU(i);let e=t.some(({readableObjectMode:i})=>i),r=w4e(t,e),n=new XU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var w4e=(t,e)=>{if(t.length===0)return b4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},XU=class extends T4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(QU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=A4e(this,this.#e,this.#o);let r=C4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(QU(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},A4e=async(t,e,r)=>{jR(t,Sce);let n=new AbortController;try{await Promise.race([x4e(t,n),R4e(t,e,r,n)])}finally{n.abort(),jR(t,-Sce)}},x4e=async(t,{signal:e})=>{try{await vce(t,{signal:e,cleanup:!0})}catch(r){throw Tce(t,r),r}},R4e=async(t,e,r,{signal:n})=>{for await(let[i]of v4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},QU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},C4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{jR(t,Ece);let a=new AbortController;try{await Promise.race([I4e(o,e,a),P4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),O4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),jR(t,-Ece)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?eF(t):N4e(t))},I4e=async(t,e,{signal:r})=>{try{await t,r.aborted||eF(e)}catch(n){r.aborted||Tce(e,n)}},P4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await vce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;bce(s)?i.add(e):wce(t,s)}},O4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await yce(t,i,{signal:o}),!t.readable)return yce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},N4e=t=>{t.writable&&t.end()},Tce=(t,e)=>{bce(e)?eF(t):wce(t,e)},bce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",eF=t=>{(t.readable||t.writable)&&t.destroy()},wce=(t,e)=>{t.destroyed||(t.once("error",k4e),t.destroy(e))},k4e=()=>{},jR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Sce=2,Ece=1;import{finished as Ace}from"stream/promises";var Wp=(t,e)=>{t.pipe(e),M4e(t,e),D4e(t,e)},M4e=async(t,e)=>{if(!(po(t)||po(e))){try{await Ace(t,{cleanup:!0,readable:!0,writable:!1})}catch{}tF(e)}},tF=t=>{t.writable&&t.end()},D4e=async(t,e)=>{if(!(po(t)||po(e))){try{await Ace(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rF(t)}},rF=t=>{t.readable&&t.destroy()};var xce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>ki.has(c)))$4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ki.has(c)))U4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Vu(o);Wp(s,i)}},$4e=(t,e,r,n)=>{r==="output"?Wp(t.stdio[n],e):Wp(e,t.stdio[n]);let i=L4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},L4e=["stdin","stdout","stderr"],U4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;F4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},F4e=(t,{signal:e})=>{po(t)&&ju(t,z4e,e)},z4e=2;import{addAbortListener as q4e}from"events";var Hu=[];Hu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Hu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Hu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var BR=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",nF=Symbol.for("signal-exit emitter"),iF=globalThis,j4e=Object.defineProperty.bind(Object),oF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(iF[nF])return iF[nF];j4e(iF,nF,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},qR=class{},B4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),sF=class extends qR{onExit(){return()=>{}}load(){}unload(){}},aF=class extends qR{#e=cF.platform==="win32"?"SIGINT":"SIGHUP";#r=new oF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Hu)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!BR(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of Hu)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Hu.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return BR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&BR(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},cF=globalThis.process,{onExit:Rce,load:m1t,unload:g1t}=B4e(BR(cF)?new aF(cF):new sF);var Cce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Rce(()=>{t.kill()});q4e(n,()=>{i()})};var Pce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=eR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=G4e(r,n,i),{sourceStream:d,sourceError:f}=H4e(t,l),{options:p,fileDescriptors:h}=fs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},G4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=V4e(t,e,...r),a=uR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},V4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Ice,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||J1(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=Gx(r,...n);return{destination:e(Ice)(i,o,s),pipeOptions:s}}if(fs.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Ice=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),H4e=(t,e)=>{try{return{sourceStream:zp(t,e)}}catch(r){return{sourceError:r}}};var Nce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=W4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw lF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},W4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return rF(t),n;if(e!==void 0)return tF(r),e},lF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Gp({error:t,command:Oce,escapedCommand:Oce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Oce="source.pipe(destination)";var kce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as Y4e}from"stream/promises";var Mce=(t,e,r)=>{let n=GR.has(e)?Z4e(t,e):K4e(t,e);return ju(t,X4e,r.signal),ju(e,Q4e,r.signal),J4e(e),n},K4e=(t,e)=>{let r=Vu([t]);return Wp(r,e),GR.set(e,r),r},Z4e=(t,e)=>{let r=GR.get(e);return r.add(t),r},J4e=async t=>{try{await Y4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}GR.delete(t)},GR=new WeakMap,X4e=2,Q4e=1;import{aborted as eHe}from"util";var Dce=(t,e)=>t===void 0?[]:[tHe(t,e)],tHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await eHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw lF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var VR=(t,...e)=>{if(Jt(e[0]))return VR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Pce(t,...e),i=rHe({...n,destination:r});return i.pipe=VR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},rHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=nHe(t,i);Nce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Mce(e,o,d);return await Promise.race([kce(u),...Dce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},nHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as uHe}from"timers/promises";import{on as iHe}from"events";import{getDefaultHighWaterMark as oHe}from"stream";var HR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return sHe(e,s),Lce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},sHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},uF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;aHe(e,s,t);let a=t.readableObjectMode&&!o;return Lce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},aHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Lce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=iHe(t,"data",{signal:e.signal,highWaterMark:$ce,highWatermark:$ce});return cHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},dF=oHe(!0),$ce=dF,cHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=lHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Gu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Qy(a)}},lHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[$R(t,r,!e),DR(t,i,!n,{})].filter(Boolean);var Uce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=dHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([fHe(t),d]);return}let f=BU(c,r),p=uF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([pHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},dHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!FR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=uF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Kae(a,t,r,o)},fHe=async t=>{await uHe(),t.readableFlowing===null&&t.resume()},pHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await xR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await RR(r,{maxBuffer:o})):await qp(r,{maxBuffer:o})}catch(a){return Fce(Kse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},fF=async t=>{try{return await t}catch(e){return Fce(e)}},Fce=({bufferedData:t})=>die(t)?new Uint8Array(t):t;import{finished as hHe}from"stream/promises";var nS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=mHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],hHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||yHe(a,e,r,n)}finally{s.abort()}},mHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&gHe(t,r,n),n},gHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{_He(e,r),n.call(t,...i)}},_He=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},yHe=(t,e,r,n)=>{if(!SHe(t,e,r,n))throw t},SHe=(t,e,r,n=!0)=>r.propagating?zce(t)||WR(t):(r.propagating=!0,pF(r,e)===n?zce(t):WR(t)),pF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",WR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",zce=t=>t?.code==="EPIPE";var jce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>hF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),hF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=nS(t,e,l);if(pF(l,e)){await u;return}let[d]=await Promise.all([Uce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Vu([t,e].filter(Boolean)):void 0,qce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>hF({...EHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:vHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),EHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},vHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as THe}from"events";var Gce=t=>Dp(t,"ipc"),Vce=(t,e)=>{let r=Qx(t);us({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Hce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Gce(o),a=ya(e,"ipc"),c=ya(r,"ipc");for await(let l of JU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Zse(t,i,c),i.push(l)),s&&Vce(l,o);return i},Wce=async(t,e)=>(await Promise.allSettled([t]),e);var Yce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let v=ece(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},y=jce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=qce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),A=[],R=Hce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),I=bHe(m,t,T),O=wHe(h,T);try{return await Promise.race([Promise.all([{},rce(v),Promise.all(y),w,R,Cse(t,d),...I,...O]),g,AHe(t,_),...bse(t,o,f,_),...Goe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...vse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},v,Promise.all(y.map(b=>fF(b))),fF(w),Wce(R,A),Promise.allSettled(I),Promise.allSettled(O)])}},bHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:nS(n,i,r)),wHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>go(o,{checkOpen:!1})&&!po(o)).map(({type:i,value:o,stream:s=o})=>nS(s,n,e,{isSameDirection:ki.has(i),stopOnExit:i==="native"}))),AHe=async(t,{signal:e})=>{let[r]=await THe(t,"error",{signal:e});throw r};var Kce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),iS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ds();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Yp=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as xHe}from"stream";import{callbackify as RHe}from"util";import{finished as Zce}from"stream/promises";var mF=async t=>{if(t!==void 0)try{await gF(t)}catch{}},Jce=async t=>{if(t!==void 0)try{await _F(t)}catch{}},gF=async t=>{await Zce(t,{cleanup:!0,readable:!1,writable:!0})},_F=async t=>{await Zce(t,{cleanup:!0,readable:!0,writable:!1})},YR=async(t,e)=>{if(await t,e)throw e},KR=(t,e,r)=>{r&&!WR(r)?t.destroy(r):e&&t.destroy()};var Xce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ii.has(r),{subprocessStdout:a,waitReadableDestroy:c}=yF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=SF(a,s),{read:f,onStdoutDataDone:p}=EF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new xHe({read:f,destroy:RHe(TF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return vF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},yF=(t,e,r)=>{let n=zp(t,e),i=iS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},SF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:dF},EF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ds(),s=HR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){CHe(this,s,o)},onStdoutDataDone:o}},CHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},vF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await _F(t),await n,await mF(i),await e,r.readable&&r.push(null)}catch(o){await mF(i),Qce(r,o)}},TF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Yp(r,e)&&(Qce(t,n),await YR(e,n))},Qce=(t,e)=>{KR(t,t.readable,e)};import{Writable as IHe}from"stream";import{callbackify as ele}from"util";var tle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=bF(t,r,e),s=new IHe({...wF(n,t,i),destroy:ele(xF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return AF(n,s),s},bF=(t,e,r)=>{let n=uR(t,e),i=iS(r,n,"writableFinal"),o=iS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},wF=(t,e,r)=>({write:PHe.bind(void 0,t),final:ele(OHe.bind(void 0,t,e,r))}),PHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},OHe=async(t,e,r)=>{await Yp(r,e)&&(t.writable&&t.end(),await e)},AF=async(t,e,r)=>{try{await gF(t),e.writable&&e.end()}catch(n){await Jce(r),rle(e,n)}},xF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Yp(r,e),await Yp(n,e)&&(rle(t,i),await YR(e,i))},rle=(t,e)=>{KR(t,t.writable,e)};import{Duplex as NHe}from"stream";import{callbackify as kHe}from"util";var nle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ii.has(r),{subprocessStdout:c,waitReadableDestroy:l}=yF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=bF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=SF(c,a),{read:g,onStdoutDataDone:_}=EF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new NHe({read:g,...wF(u,t,d),destroy:kHe(MHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return vF({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:t,subprocessStdin:u}),AF(u,v,c),v},MHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([TF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),xF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var RF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ii.has(e),s=zp(t,r),a=HR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return DHe(a,s,t)},DHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var ile=(t,{encoding:e})=>{let r=Kce();t.readable=Xce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=tle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=nle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=RF.bind(void 0,t,e),t[Symbol.asyncIterator]=RF.bind(void 0,t,e,{})};var ole=(t,e)=>{for(let[r,n]of LHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},$He=(async()=>{})().constructor.prototype,LHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor($He,t)]);var sle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=zHe(t,e,r),{subprocess:f,promise:p}=BHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=VR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ole(f,p),fs.set(f,{options:u,fileDescriptors:d}),f},zHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),{file:a,commandArguments:c,options:l}=vR(t,e,r),u=jHe(l),d=_ce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},jHe=({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}},BHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=FHe(...TR(t,e,r))}catch(h){return pce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;UHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];xce(c,a,l),Cce(c,r,l);let d={},f=ds();c.kill=Boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Bce(c,r),ile(c,r),uce(c,r);let p=qHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},qHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Yce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((y,w)=>Ea(y,e,w)),v=Ea(m,e,"all"),T=GHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Vp(T,n,e)},GHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Xy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ps,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):PR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var ZR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,VHe(n,t[n],i)]));return{...t,...r}},VHe=(t,e,r)=>HHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,HHe=new Set(["env",...nU]);var Uc=(t,e,r,n)=>{let i=(s,a,c)=>Uc(s,a,r,c),o=(...s)=>WHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},WHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,ZR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=YHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?ice(a,c,l):sle(a,c,l,i)},YHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=_ie(e)?yie(e,r):[e,...r],[s,a,c]=Gx(...o),l=ZR(ZR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var ale=({file:t,commandArguments:e})=>lle(t,e),cle=({file:t,commandArguments:e})=>({...lle(t,e),isSync:!0}),lle=(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]=KHe(t);return{file:r,commandArguments:n}},KHe=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(ZHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},ZHe=/ +/g;var ule=(t,e,r)=>{t.sync=e(JHe,r),t.s=t.sync},dle=({options:t})=>fle(t),JHe=({options:t})=>({...fle(t),isSync:!0}),fle=t=>({options:{...XHe(t),...t}}),XHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},ple={preferLocal:!0};var hle=Uc(()=>({})),ozt=Uc(()=>({isSync:!0})),mle=Uc(ale),szt=Uc(cle),azt=Uc(Ase),czt=Uc(dle,{},ple,ule),{sendMessage:lzt,getOneMessage:uzt,getEachMessage:dzt,getCancelSignal:fzt}=dce();var gle=!1,_le,QHe=t=>{_le??=t},yle=t=>{gle=!0,QHe(t)},oi=()=>gle,Fc=()=>_le,Sle=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var oS=null,Ele=t=>(oS&&oS.destroy(),oS=new _o({totalAllowedTime:t}),oS),vle=()=>oS;var _o=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&oi())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await kx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{q.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Tle={name:"@netlify/agent-runner-cli",type:"module",version:"1.189.4",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var n6e=t6e(import.meta.url),i6e=va.dirname(n6e),o6e=r6e(import.meta.url),Kp=oe("shell"),CF=new Set,ble={preferLocal:!0},It=(t,e,r)=>{let[n,i]=s6e(e,r),o={...ble,...i},s=hle(t,n,o);Ale(s,o),Cle(s);let a=r?.idleTimeout;return a&&a>0&&Rle(s,a),s},wle=(t,e)=>{let r={...ble,...e},n=mle(t,r);return Ale(n,r),Cle(n),e?.idleTimeout&&e.idleTimeout>0&&Rle(n,e.idleTimeout),n},s6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ale=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ms.env.NETLIFY_LOCAL_QUIET==="true")return;if(ms.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new My).pipe(ms.stdout),t.stderr?.pipe(new My).pipe(ms.stderr);return}t.stdout?.pipe(ms.stdout),t.stderr?.pipe(ms.stderr)},IF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ms.kill(-t.pid,e),Kp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Kp.error("Error killing process:",r),!1}},xle=t=>IF(t,"SIGKILL"),Rle=(t,e)=>{let r=null,n=()=>{Kp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing idle process ${t.pid}`),xle(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Cle=t=>{CF.add(t);let e=vle();if(e){let r=e.onTimesUp(()=>{Kp.log(`Global timer expired, killing process ${t.pid}`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing process ${t.pid} after timeout`),xle(t))},5e3)});t.on("exit",()=>{CF.delete(t),r()}),t.on("error",()=>{CF.delete(t),r()})}};function XR(t,e){return!!yo(t,e)}function yo(t,e){if(!ms.env.NETLIFY_LOCAL_MODE)try{let i=o6e.resolve(Tle.name),o=va.dirname(i);for(;o!==va.dirname(o);){let s=va.dirname(o);if(va.basename(s)==="node_modules"){let a=va.join(s,".bin",e);if(JR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ms.env.NODE_PATH){let i=va.join(ms.env.NODE_PATH,".bin",e);if(JR.existsSync(i))return i}let r=va.join(t,"node_modules",".bin",e);if(JR.existsSync(r))return r;let n=va.join(i6e,"..","node_modules",".bin",e);if(JR.existsSync(n))return n}var Ile=oe("repo"),kle="runner-diffs-",tC=t=>`${kle}${t}-`,Mle=async t=>{let e=Nle.tmpdir(),r;try{r=await QR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(kle)&&!n.startsWith(tC(t))).map(n=>QR.rm(eC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>It("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),rC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Ile.info("Getting runner diffs");let n=await kF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=MF(o);await h6e(l,r)}Ile.info("Changes after processing"),await NF(r);let s=await aS(o,r);if(await OF(s,r),i=await d6e(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await QR.mkdtemp(eC.join(Nle.tmpdir(),tC(t.sessionId))),c=await PF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await l6e(r),c.hasChanges&&q.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},PF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=eC.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:v}=await QR.stat(g);return{path:g,size:v}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Ole(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Ole(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Ple=async t=>{let e=a6e("sha256");for await(let r of c6e(t))e.update(r);return e.digest("hex")},Ole=async(t,e)=>t.size===e.size&&await Ple(t.path)===await Ple(e.path),l6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},OF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},NF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},Dle=/.. (.+)?\.log$/,u6e=[Dle],kF=async(t=process.cwd())=>{let e=await NF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
146
+ if (condition) { yield value; }`)};import{Buffer as _Ve}from"buffer";import{StringDecoder as yVe}from"string_decoder";var $R=(t,e,r)=>{if(r)return;if(t)return{transform:SVe.bind(void 0,new TextEncoder)};let n=new yVe(e);return{transform:EVe.bind(void 0,n),final:vVe.bind(void 0,n)}},SVe=function*(t,e){_Ve.isBuffer(e)?yield _a(e):typeof e=="string"?yield t.encode(e):yield e},EVe=function*(t,e){yield dr(e)?t.write(e):e},vVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Bae}from"util";var VU=Bae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),LR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bVe}=e[r];for await(let i of n(t))yield*LR(i,e,r+1)},qae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*TVe(r,Number(e),t)},TVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*LR(n,r,e+1)},Gae=Bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bVe=function*(t){yield t};var HU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Vae=(t,e)=>[...e.flatMap(r=>[...Gu(r,t,0)]),...Qy(t)],Gu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=AVe}=e[r];for(let i of n(t))yield*Gu(i,e,r+1)},Qy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wVe(r,Number(e),t)},wVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Gu(n,r,e+1)},AVe=function*(t){yield t};var WU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Wae(t,s,o),l=qu(e),u=qu(r),d=l?VU.bind(void 0,LR,a):HU.bind(void 0,Gu),f=l||u?VU.bind(void 0,qae,a):HU.bind(void 0,Qy),p=l||u?Gae.bind(void 0,a):void 0;return{stream:new xVe({writableObjectMode:n,writableHighWaterMark:Hae(n),readableObjectMode:i,readableHighWaterMark:Hae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},UR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Wae(s,r,a);t=Vae(c,t)}return t},Wae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Fae(n,a)},$R(r,s,n),DR(r,o,n,c),{transform:t,final:e},{transform:zae(i,a)},Uae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Yae=(t,e)=>{for(let r of RVe(t))CVe(t,r,e)},RVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),CVe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Lc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>IVe(a,n));r.input=qy(s)},IVe=(t,e)=>{let r=UR(t,e,"utf8",!0);return PVe(r),qy(r)},PVe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as MVe,appendFileSync as DVe}from"fs";var FR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Dp(r,n)&&!ii.has(e)&&OVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&NVe.has(o))||t.every(({type:i})=>ki.has(i))),OVe=t=>t===1||t===2,NVe=new Set(["pipe","overlapped"]),Kae=async(t,e,r,n)=>{for await(let i of t)kVe(e)||Jae(i,r,n)},Zae=(t,e,r)=>{for(let n of t)Jae(n,e,r)},kVe=t=>t._readableState.pipes.length>0,Jae=(t,e,r)=>{let n=Qx(t);us({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Xae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>$Ve({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},$Ve=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Qse(t,o,d),p=_a(f),{stdioItems:h,objectMode:m}=e[r],g=LVe([p],h,c,n),{serializedResult:_,finalResult:v=_}=UVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});FVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?v:void 0;try{return n.error===void 0&&zVe(_,h,i),T}catch(y){return n.error=y,T}},LVe=(t,e,r,n)=>{try{return UR(t,e,r,!1)}catch(i){return n.error=i,t}},UVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qy(t)};let s=pie(t,r);return n[o]?{serializedResult:s,finalResult:GU(s,!i[o],e)}:{serializedResult:s}},FVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!FR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=GU(t,!1,s);try{Zae(a,e,n)}catch(c){r.error??=c}},zVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>kR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?DVe(n,t):(r.add(o),MVe(n,t))}};var Qae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ea(e,r,"all")]:Array.isArray(e)?[Ea(t,r,"all"),...e]:dr(t)&&dr(e)?Q1([t,e]):`${t}${e}`};import{once as YU}from"events";var ece=async(t,e)=>{let[r,n]=await jVe(t);return e.isForcefullyTerminated??=!1,[r,n]},jVe=async t=>{let[e,r]=await Promise.allSettled([YU(t,"spawn"),YU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?tce(t):r.value},tce=async t=>{try{return await YU(t,"exit")}catch{return tce(t)}},rce=async t=>{let[e,r]=await t;if(!BVe(e,r)&&KU(e,r))throw new ho;return[e,r]},BVe=(t,e)=>t===void 0&&e===void 0,KU=(t,e)=>t!==0||e!==null;var nce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=qVe(t,e,r),s=o?.code==="ETIMEDOUT",a=Xse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},qVe=(t,e,r)=>t!==void 0?t:KU(e,r)?new ho:void 0;var ice=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=VVe(t,e,r),d=YVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Vp(d,c,l)},VVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),a=HVe(r),{file:c,commandArguments:l,options:u}=vR(t,e,a);WVe(u);let d=Mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},HVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,WVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&zR("ipcInput"),t&&zR("ipc: true"),r&&zR("detached: true"),n&&zR("cancelSignal")},zR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},YVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=KVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=nce(c,r),{output:h,error:m=l}=Xae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,T)=>Ea(v,r,T)),_=Ea(Qae(h,r),r,"all");return JVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},KVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Yae(o,r);let a=ZVe(r);return GVe(...TR(t,e,a))}catch(a){return Gp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},ZVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:IR(e)}),JVe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?PR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Xy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as UHe}from"events";import{spawn as FHe}from"child_process";import lce from"process";import{once as ZU,on as XVe}from"events";var oce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Up({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),QVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),QVe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{dR(e,i);let o=$c(t,e,r),s=new AbortController;try{return await Promise.race([e4e(o,n,s),t4e(o,r,s),r4e(o,r,s)])}catch(a){throw Fp(t),a}finally{s.abort(),fR(e,i)}},e4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await ZU(t,"message",{signal:r});return n}for await(let[n]of XVe(t,"message",{signal:r}))if(e(n))return n},t4e=async(t,e,{signal:r})=>{await ZU(t,"disconnect",{signal:r}),Voe(e)},r4e=async(t,e,{signal:r})=>{let[n]=await ZU(t,"strict:error",{signal:r});throw cR(n,e)};import{once as ace,on as n4e}from"events";var cce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>JU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),JU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Up({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),dR(e,o);let s=$c(t,e,r),a=new AbortController,c={};return i4e(t,s,a),o4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),s4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},i4e=async(t,e,r)=>{try{await ace(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},o4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ace(t,"strict:error",{signal:r.signal});n.error=cR(i,e),r.abort()}catch{}},s4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of n4e(r,"message",{signal:o.signal}))sce(s),yield c}catch{sce(s)}finally{o.abort(),fR(e,a),n||Fp(t),i&&await t}},sce=({error:t})=>{if(t)throw t};var uce=(t,{ipc:e})=>{Object.assign(t,fce(t,!1,e))},dce=()=>{let t=lce,e=!0,r=lce.channel!==void 0;return{...fce(t,e,r),getCancelSignal:yse.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},fce=(t,e,r)=>({sendMessage:SR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:oce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:cce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as a4e}from"child_process";import{PassThrough as c4e,Readable as l4e,Writable as u4e,Duplex as d4e}from"stream";var pce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{jU(n);let a=new a4e;f4e(a,n),Object.assign(a,{readable:p4e,writable:h4e,duplex:m4e});let c=Gp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=g4e(c,s,i);return{subprocess:a,promise:l}},f4e=(t,e)=>{let r=eS(),n=eS(),i=eS(),o=Array.from({length:e.length-3},eS),s=eS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},eS=()=>{let t=new c4e;return t.end(),t},p4e=()=>new l4e({read(){}}),h4e=()=>new u4e({write(){}}),m4e=()=>new d4e({read(){},write(){}}),g4e=async(t,e,r)=>Vp(t,e,r);import{createReadStream as hce,createWriteStream as mce}from"fs";import{Buffer as _4e}from"buffer";import{Readable as tS,Writable as y4e,Duplex as S4e}from"stream";var _ce=(t,e)=>MR(E4e,t,e,!1),rS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Lc[t]}.`)},gce={fileNumber:rS,generator:WU,asyncGenerator:WU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:S4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},E4e={input:{...gce,fileUrl:({value:t})=>({stream:hce(t)}),filePath:({value:{file:t}})=>({stream:hce(t)}),webStream:({value:t})=>({stream:tS.fromWeb(t)}),iterable:({value:t})=>({stream:tS.from(t)}),asyncIterable:({value:t})=>({stream:tS.from(t)}),string:({value:t})=>({stream:tS.from(t)}),uint8Array:({value:t})=>({stream:tS.from(_4e.from(t))})},output:{...gce,fileUrl:({value:t})=>({stream:mce(t)}),filePath:({value:{file:t,append:e}})=>({stream:mce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:y4e.fromWeb(t)}),iterable:rS,asyncIterable:rS,string:rS,uint8Array:rS}};import{on as v4e,once as yce}from"events";import{PassThrough as T4e,getDefaultHighWaterMark as b4e}from"stream";import{finished as vce}from"stream/promises";function Vu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)QU(i);let e=t.some(({readableObjectMode:i})=>i),r=w4e(t,e),n=new XU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var w4e=(t,e)=>{if(t.length===0)return b4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},XU=class extends T4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(QU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=A4e(this,this.#e,this.#o);let r=C4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(QU(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},A4e=async(t,e,r)=>{jR(t,Sce);let n=new AbortController;try{await Promise.race([x4e(t,n),R4e(t,e,r,n)])}finally{n.abort(),jR(t,-Sce)}},x4e=async(t,{signal:e})=>{try{await vce(t,{signal:e,cleanup:!0})}catch(r){throw Tce(t,r),r}},R4e=async(t,e,r,{signal:n})=>{for await(let[i]of v4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},QU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},C4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{jR(t,Ece);let a=new AbortController;try{await Promise.race([I4e(o,e,a),P4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),O4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),jR(t,-Ece)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?eF(t):N4e(t))},I4e=async(t,e,{signal:r})=>{try{await t,r.aborted||eF(e)}catch(n){r.aborted||Tce(e,n)}},P4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await vce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;bce(s)?i.add(e):wce(t,s)}},O4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await yce(t,i,{signal:o}),!t.readable)return yce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},N4e=t=>{t.writable&&t.end()},Tce=(t,e)=>{bce(e)?eF(t):wce(t,e)},bce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",eF=t=>{(t.readable||t.writable)&&t.destroy()},wce=(t,e)=>{t.destroyed||(t.once("error",k4e),t.destroy(e))},k4e=()=>{},jR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Sce=2,Ece=1;import{finished as Ace}from"stream/promises";var Wp=(t,e)=>{t.pipe(e),M4e(t,e),D4e(t,e)},M4e=async(t,e)=>{if(!(po(t)||po(e))){try{await Ace(t,{cleanup:!0,readable:!0,writable:!1})}catch{}tF(e)}},tF=t=>{t.writable&&t.end()},D4e=async(t,e)=>{if(!(po(t)||po(e))){try{await Ace(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rF(t)}},rF=t=>{t.readable&&t.destroy()};var xce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>ki.has(c)))$4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ki.has(c)))U4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Vu(o);Wp(s,i)}},$4e=(t,e,r,n)=>{r==="output"?Wp(t.stdio[n],e):Wp(e,t.stdio[n]);let i=L4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},L4e=["stdin","stdout","stderr"],U4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;F4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},F4e=(t,{signal:e})=>{po(t)&&ju(t,z4e,e)},z4e=2;import{addAbortListener as q4e}from"events";var Hu=[];Hu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Hu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Hu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var BR=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",nF=Symbol.for("signal-exit emitter"),iF=globalThis,j4e=Object.defineProperty.bind(Object),oF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(iF[nF])return iF[nF];j4e(iF,nF,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},qR=class{},B4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),sF=class extends qR{onExit(){return()=>{}}load(){}unload(){}},aF=class extends qR{#e=cF.platform==="win32"?"SIGINT":"SIGHUP";#r=new oF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Hu)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!BR(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of Hu)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Hu.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return BR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&BR(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},cF=globalThis.process,{onExit:Rce,load:m1t,unload:g1t}=B4e(BR(cF)?new aF(cF):new sF);var Cce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Rce(()=>{t.kill()});q4e(n,()=>{i()})};var Pce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=eR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=G4e(r,n,i),{sourceStream:d,sourceError:f}=H4e(t,l),{options:p,fileDescriptors:h}=fs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},G4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=V4e(t,e,...r),a=uR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},V4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Ice,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||J1(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=Gx(r,...n);return{destination:e(Ice)(i,o,s),pipeOptions:s}}if(fs.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Ice=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),H4e=(t,e)=>{try{return{sourceStream:zp(t,e)}}catch(r){return{sourceError:r}}};var Nce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=W4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw lF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},W4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return rF(t),n;if(e!==void 0)return tF(r),e},lF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Gp({error:t,command:Oce,escapedCommand:Oce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Oce="source.pipe(destination)";var kce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as Y4e}from"stream/promises";var Mce=(t,e,r)=>{let n=GR.has(e)?Z4e(t,e):K4e(t,e);return ju(t,X4e,r.signal),ju(e,Q4e,r.signal),J4e(e),n},K4e=(t,e)=>{let r=Vu([t]);return Wp(r,e),GR.set(e,r),r},Z4e=(t,e)=>{let r=GR.get(e);return r.add(t),r},J4e=async t=>{try{await Y4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}GR.delete(t)},GR=new WeakMap,X4e=2,Q4e=1;import{aborted as eHe}from"util";var Dce=(t,e)=>t===void 0?[]:[tHe(t,e)],tHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await eHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw lF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var VR=(t,...e)=>{if(Jt(e[0]))return VR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Pce(t,...e),i=rHe({...n,destination:r});return i.pipe=VR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},rHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=nHe(t,i);Nce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Mce(e,o,d);return await Promise.race([kce(u),...Dce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},nHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as uHe}from"timers/promises";import{on as iHe}from"events";import{getDefaultHighWaterMark as oHe}from"stream";var HR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return sHe(e,s),Lce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},sHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},uF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;aHe(e,s,t);let a=t.readableObjectMode&&!o;return Lce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},aHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Lce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=iHe(t,"data",{signal:e.signal,highWaterMark:$ce,highWatermark:$ce});return cHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},dF=oHe(!0),$ce=dF,cHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=lHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Gu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Qy(a)}},lHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[$R(t,r,!e),DR(t,i,!n,{})].filter(Boolean);var Uce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=dHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([fHe(t),d]);return}let f=BU(c,r),p=uF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([pHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},dHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!FR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=uF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Kae(a,t,r,o)},fHe=async t=>{await uHe(),t.readableFlowing===null&&t.resume()},pHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await xR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await RR(r,{maxBuffer:o})):await qp(r,{maxBuffer:o})}catch(a){return Fce(Kse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},fF=async t=>{try{return await t}catch(e){return Fce(e)}},Fce=({bufferedData:t})=>die(t)?new Uint8Array(t):t;import{finished as hHe}from"stream/promises";var nS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=mHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],hHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||yHe(a,e,r,n)}finally{s.abort()}},mHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&gHe(t,r,n),n},gHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{_He(e,r),n.call(t,...i)}},_He=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},yHe=(t,e,r,n)=>{if(!SHe(t,e,r,n))throw t},SHe=(t,e,r,n=!0)=>r.propagating?zce(t)||WR(t):(r.propagating=!0,pF(r,e)===n?zce(t):WR(t)),pF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",WR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",zce=t=>t?.code==="EPIPE";var jce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>hF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),hF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=nS(t,e,l);if(pF(l,e)){await u;return}let[d]=await Promise.all([Uce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Vu([t,e].filter(Boolean)):void 0,qce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>hF({...EHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:vHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),EHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},vHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as THe}from"events";var Gce=t=>Dp(t,"ipc"),Vce=(t,e)=>{let r=Qx(t);us({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Hce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Gce(o),a=ya(e,"ipc"),c=ya(r,"ipc");for await(let l of JU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Zse(t,i,c),i.push(l)),s&&Vce(l,o);return i},Wce=async(t,e)=>(await Promise.allSettled([t]),e);var Yce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let v=ece(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},y=jce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=qce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),A=[],R=Hce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),I=bHe(m,t,T),O=wHe(h,T);try{return await Promise.race([Promise.all([{},rce(v),Promise.all(y),w,R,Cse(t,d),...I,...O]),g,AHe(t,_),...bse(t,o,f,_),...Goe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...vse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},v,Promise.all(y.map(b=>fF(b))),fF(w),Wce(R,A),Promise.allSettled(I),Promise.allSettled(O)])}},bHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:nS(n,i,r)),wHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>go(o,{checkOpen:!1})&&!po(o)).map(({type:i,value:o,stream:s=o})=>nS(s,n,e,{isSameDirection:ki.has(i),stopOnExit:i==="native"}))),AHe=async(t,{signal:e})=>{let[r]=await THe(t,"error",{signal:e});throw r};var Kce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),iS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ds();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Yp=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as xHe}from"stream";import{callbackify as RHe}from"util";import{finished as Zce}from"stream/promises";var mF=async t=>{if(t!==void 0)try{await gF(t)}catch{}},Jce=async t=>{if(t!==void 0)try{await _F(t)}catch{}},gF=async t=>{await Zce(t,{cleanup:!0,readable:!1,writable:!0})},_F=async t=>{await Zce(t,{cleanup:!0,readable:!0,writable:!1})},YR=async(t,e)=>{if(await t,e)throw e},KR=(t,e,r)=>{r&&!WR(r)?t.destroy(r):e&&t.destroy()};var Xce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ii.has(r),{subprocessStdout:a,waitReadableDestroy:c}=yF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=SF(a,s),{read:f,onStdoutDataDone:p}=EF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new xHe({read:f,destroy:RHe(TF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return vF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},yF=(t,e,r)=>{let n=zp(t,e),i=iS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},SF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:dF},EF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ds(),s=HR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){CHe(this,s,o)},onStdoutDataDone:o}},CHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},vF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await _F(t),await n,await mF(i),await e,r.readable&&r.push(null)}catch(o){await mF(i),Qce(r,o)}},TF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Yp(r,e)&&(Qce(t,n),await YR(e,n))},Qce=(t,e)=>{KR(t,t.readable,e)};import{Writable as IHe}from"stream";import{callbackify as ele}from"util";var tle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=bF(t,r,e),s=new IHe({...wF(n,t,i),destroy:ele(xF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return AF(n,s),s},bF=(t,e,r)=>{let n=uR(t,e),i=iS(r,n,"writableFinal"),o=iS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},wF=(t,e,r)=>({write:PHe.bind(void 0,t),final:ele(OHe.bind(void 0,t,e,r))}),PHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},OHe=async(t,e,r)=>{await Yp(r,e)&&(t.writable&&t.end(),await e)},AF=async(t,e,r)=>{try{await gF(t),e.writable&&e.end()}catch(n){await Jce(r),rle(e,n)}},xF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Yp(r,e),await Yp(n,e)&&(rle(t,i),await YR(e,i))},rle=(t,e)=>{KR(t,t.writable,e)};import{Duplex as NHe}from"stream";import{callbackify as kHe}from"util";var nle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ii.has(r),{subprocessStdout:c,waitReadableDestroy:l}=yF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=bF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=SF(c,a),{read:g,onStdoutDataDone:_}=EF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new NHe({read:g,...wF(u,t,d),destroy:kHe(MHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return vF({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:t,subprocessStdin:u}),AF(u,v,c),v},MHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([TF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),xF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var RF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ii.has(e),s=zp(t,r),a=HR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return DHe(a,s,t)},DHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var ile=(t,{encoding:e})=>{let r=Kce();t.readable=Xce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=tle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=nle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=RF.bind(void 0,t,e),t[Symbol.asyncIterator]=RF.bind(void 0,t,e,{})};var ole=(t,e)=>{for(let[r,n]of LHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},$He=(async()=>{})().constructor.prototype,LHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor($He,t)]);var sle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=zHe(t,e,r),{subprocess:f,promise:p}=BHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=VR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ole(f,p),fs.set(f,{options:u,fileDescriptors:d}),f},zHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),{file:a,commandArguments:c,options:l}=vR(t,e,r),u=jHe(l),d=_ce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},jHe=({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}},BHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=FHe(...TR(t,e,r))}catch(h){return pce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;UHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];xce(c,a,l),Cce(c,r,l);let d={},f=ds();c.kill=Boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Bce(c,r),ile(c,r),uce(c,r);let p=qHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},qHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Yce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((y,w)=>Ea(y,e,w)),v=Ea(m,e,"all"),T=GHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Vp(T,n,e)},GHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Xy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ps,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):PR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var ZR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,VHe(n,t[n],i)]));return{...t,...r}},VHe=(t,e,r)=>HHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,HHe=new Set(["env",...nU]);var Uc=(t,e,r,n)=>{let i=(s,a,c)=>Uc(s,a,r,c),o=(...s)=>WHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},WHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,ZR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=YHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?ice(a,c,l):sle(a,c,l,i)},YHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=_ie(e)?yie(e,r):[e,...r],[s,a,c]=Gx(...o),l=ZR(ZR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var ale=({file:t,commandArguments:e})=>lle(t,e),cle=({file:t,commandArguments:e})=>({...lle(t,e),isSync:!0}),lle=(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]=KHe(t);return{file:r,commandArguments:n}},KHe=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(ZHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},ZHe=/ +/g;var ule=(t,e,r)=>{t.sync=e(JHe,r),t.s=t.sync},dle=({options:t})=>fle(t),JHe=({options:t})=>({...fle(t),isSync:!0}),fle=t=>({options:{...XHe(t),...t}}),XHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},ple={preferLocal:!0};var hle=Uc(()=>({})),ozt=Uc(()=>({isSync:!0})),mle=Uc(ale),szt=Uc(cle),azt=Uc(Ase),czt=Uc(dle,{},ple,ule),{sendMessage:lzt,getOneMessage:uzt,getEachMessage:dzt,getCancelSignal:fzt}=dce();var gle=!1,_le,QHe=t=>{_le??=t},yle=t=>{gle=!0,QHe(t)},oi=()=>gle,Fc=()=>_le,Sle=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var oS=null,Ele=t=>(oS&&oS.destroy(),oS=new _o({totalAllowedTime:t}),oS),vle=()=>oS;var _o=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&oi())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await kx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{q.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Tle={name:"@netlify/agent-runner-cli",type:"module",version:"1.190.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.18.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var n6e=t6e(import.meta.url),i6e=va.dirname(n6e),o6e=r6e(import.meta.url),Kp=oe("shell"),CF=new Set,ble={preferLocal:!0},It=(t,e,r)=>{let[n,i]=s6e(e,r),o={...ble,...i},s=hle(t,n,o);Ale(s,o),Cle(s);let a=r?.idleTimeout;return a&&a>0&&Rle(s,a),s},wle=(t,e)=>{let r={...ble,...e},n=mle(t,r);return Ale(n,r),Cle(n),e?.idleTimeout&&e.idleTimeout>0&&Rle(n,e.idleTimeout),n},s6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ale=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ms.env.NETLIFY_LOCAL_QUIET==="true")return;if(ms.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new My).pipe(ms.stdout),t.stderr?.pipe(new My).pipe(ms.stderr);return}t.stdout?.pipe(ms.stdout),t.stderr?.pipe(ms.stderr)},IF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ms.kill(-t.pid,e),Kp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Kp.error("Error killing process:",r),!1}},xle=t=>IF(t,"SIGKILL"),Rle=(t,e)=>{let r=null,n=()=>{Kp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing idle process ${t.pid}`),xle(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Cle=t=>{CF.add(t);let e=vle();if(e){let r=e.onTimesUp(()=>{Kp.log(`Global timer expired, killing process ${t.pid}`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing process ${t.pid} after timeout`),xle(t))},5e3)});t.on("exit",()=>{CF.delete(t),r()}),t.on("error",()=>{CF.delete(t),r()})}};function XR(t,e){return!!yo(t,e)}function yo(t,e){if(!ms.env.NETLIFY_LOCAL_MODE)try{let i=o6e.resolve(Tle.name),o=va.dirname(i);for(;o!==va.dirname(o);){let s=va.dirname(o);if(va.basename(s)==="node_modules"){let a=va.join(s,".bin",e);if(JR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ms.env.NODE_PATH){let i=va.join(ms.env.NODE_PATH,".bin",e);if(JR.existsSync(i))return i}let r=va.join(t,"node_modules",".bin",e);if(JR.existsSync(r))return r;let n=va.join(i6e,"..","node_modules",".bin",e);if(JR.existsSync(n))return n}var Ile=oe("repo"),kle="runner-diffs-",tC=t=>`${kle}${t}-`,Mle=async t=>{let e=Nle.tmpdir(),r;try{r=await QR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(kle)&&!n.startsWith(tC(t))).map(n=>QR.rm(eC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>It("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),rC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Ile.info("Getting runner diffs");let n=await kF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=MF(o);await h6e(l,r)}Ile.info("Changes after processing"),await NF(r);let s=await aS(o,r);if(await OF(s,r),i=await d6e(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await QR.mkdtemp(eC.join(Nle.tmpdir(),tC(t.sessionId))),c=await PF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await l6e(r),c.hasChanges&&q.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},PF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=eC.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:v}=await QR.stat(g);return{path:g,size:v}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Ole(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Ole(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Ple=async t=>{let e=a6e("sha256");for await(let r of c6e(t))e.update(r);return e.digest("hex")},Ole=async(t,e)=>t.size===e.size&&await Ple(t.path)===await Ple(e.path),l6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},OF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},NF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},Dle=/.. (.+)?\.log$/,u6e=[Dle],kF=async(t=process.cwd())=>{let e=await NF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
147
147
  `).filter(i=>u6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},d6e=async(t=process.cwd())=>{try{return await Xt(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},sS=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},f6e=1,p6e=async t=>{try{return await Xt(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===f6e)return!1;throw e}},$le=async(t=process.cwd())=>{if(!await p6e(t))return!0;let{stdout:e}=await Xt(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},Lle=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},aS=async(t,e=process.cwd())=>{t||=await NF(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
148
148
  `).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${eC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Dle)?.[1];o&&n.push(`:!${o}.log`)}),n},Ule=async(t=process.cwd())=>{await Xt(["reset","--hard","HEAD"],{cwd:t})},Fle=async(t=process.cwd())=>{let e=await Xt(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
149
149
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},MF=t=>{let e=t.split(`
@@ -375,7 +375,7 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
375
375
  new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
376
376
 
377
377
  https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
378
- `);this.baseURL=c.baseURL,this.timeout=c.timeout??_H.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=V4(c.logLevel,"ClientOptions.logLevel",this)??V4(wl("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??JI(),Re(this,AP,E_e,"f"),this._options=c,s&&(this._workloadIdentityAuth=new iP(s,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=o}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return se([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return I_e(e)}getUserAgent(){return`${this.constructor.name}/JS ${_l}`}defaultIdempotencyKey(){return`stainless-node-retry-${O4()}`}makeStatusError(e,r,n,i){return Wt.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof _e?n:new _e(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new _e(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!U(this,gH,"m",fye).call(this)&&n||this.baseURL,o=u_e(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),s=this.defaultQuery(),a=Object.fromEntries(o.searchParams);return(!M4(s)||!M4(a))&&(r={...a,...s,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Ad(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,o=i.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(i);let{req:s,url:a,timeout:c}=await this.buildRequest(i,{retryCount:o-r});await this.prepareRequest(s,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(rr(this).debug(`[${l}] sending request`,$a({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:s.headers})),i.signal?.aborted)throw new or;let f=new AbortController,p=await this.fetchWithAuth(a,s,c,f).catch(QE),h=Date.now();if(p instanceof globalThis.Error){let _=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new or;let v=XE(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return rr(this).info(`[${l}] connection ${v?"timed out":"failed"} - ${_}`),rr(this).debug(`[${l}] connection ${v?"timed out":"failed"} (${_})`,$a({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw rr(this).info(`[${l}] connection ${v?"timed out":"failed"} - error; no more retries left`),rr(this).debug(`[${l}] connection ${v?"timed out":"failed"} (error; no more retries left)`,$a({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof bd||p instanceof ev?p:v?new gl:new ml({cause:p})}let m=[...p.headers.entries()].filter(([_])=>_==="x-request-id").map(([_,v])=>", "+_+": "+JSON.stringify(v)).join(""),g=`[${l}${u}${m}] ${s.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await L4(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let _=await this.shouldRetry(p);if(r&&_){let R=`retrying, ${r} attempts remaining`;return await L4(p.body),rr(this).info(`${g} - ${R}`),rr(this).debug(`[${l}] response error (${R})`,$a({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let v=_?"error; no more retries left":"error; not retryable";rr(this).info(`${g} - ${v}`);let T=await p.text().catch(R=>QE(R).message),y=p_e(T),w=y?void 0:T;throw rr(this).debug(`[${l}] response error (${v})`,$a({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:w,durationMs:Date.now()-d})),this.makeStatusError(p.status,y,w,p.headers)}return rr(this).info(g),rr(this).debug(`[${l}] response start`,$a({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new sv(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let s=r.headers,a=s.get("Authorization");if(!a||a===`Bearer ${mH}`){let c=await this._workloadIdentityAuth.getToken();s.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:o,method:s,...a}=r||{},c=this._makeAbort(i);o&&o.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};s&&(d.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let o,s=i?.get("retry-after-ms");if(s){let c=parseFloat(s);Number.isNaN(c)||(o=c)}let a=i?.get("retry-after");if(a&&!o){let c=parseFloat(a);Number.isNaN(c)?o=Date.parse(a)-Date.now():o=c*1e3}if(o===void 0){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Rs(o),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let o=r-e,s=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return s*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:o,query:s,defaultBaseURL:a}=n,c=this.buildURL(o,s,a);"timeout"in n&&f_e("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let o={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let s=se([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...y_e(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(s),s.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:r}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let n=se([r]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,o=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!o}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:XI(e),isStreamingBody:!0}:typeof e=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e),isStreamingBody:!1}:{...U(this,AP,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};_H=Ue,AP=new WeakMap,gH=new WeakSet,fye=function(){return this.baseURL!=="https://api.openai.com/v1"};Ue.OpenAI=_H;Ue.DEFAULT_TIMEOUT=6e5;Ue.OpenAIError=_e;Ue.APIError=Wt;Ue.APIConnectionError=ml;Ue.APIConnectionTimeoutError=gl;Ue.APIUserAbortError=or;Ue.NotFoundError=um;Ue.ConflictError=dm;Ue.RateLimitError=pm;Ue.BadRequestError=am;Ue.AuthenticationError=cm;Ue.InternalServerError=hm;Ue.PermissionDeniedError=lm;Ue.UnprocessableEntityError=fm;Ue.InvalidWebhookSignatureError=xs;Ue.toFile=sP;Ue.Completions=Md;Ue.Chat=vl;Ue.Embeddings=$d;Ue.Files=Ud;Ue.Images=Bd;Ue.Audio=Os;Ue.Moderations=Gd;Ue.Models=qd;Ue.FineTuning=Po;Ue.Graders=Il;Ue.VectorStores=Ga;Ue.Webhooks=Wd;Ue.Beta=Io;Ue.Batches=Id;Ue.Uploads=Ol;Ue.Responses=Ba;Ue.Realtime=ja;Ue.Conversations=Rl;Ue.Evals=Cl;Ue.Containers=xl;Ue.Skills=qa;Ue.Videos=Hd;var Gn=oe("runner_codex"),xP="Codex CLI",Qm="gpt-5.6-sol";async function Vet({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else r?await t.isModelAvailableForProvider("openai",r)||(Gn.log(`Model '${r}' is not available for openai provider, proceeding without model specification`),q.inc("model.unavailable",1,{provider:"openai"}),n=void 0):!!Qm&&await t.isModelAvailableForProvider("openai",Qm)?(n=Qm,Gn.log(`Using default model: ${Qm}`)):Qm&&Gn.log(`Default model ${Qm} is not available, proceeding without model specification`);return n}var RP="netlify-ask-db",Het=`default_permissions = "${RP}"`,Wet=()=>Nl.join(Va.env.XDG_CONFIG_HOME??Nl.join(vv.homedir(),".config"),"netlify"),Yet=t=>["",`[permissions.${RP}]`,'description = "Ask mode: read-only filesystem, network access for database reads"','extends = ":read-only"',"",`[permissions.${RP}.filesystem]`,'":minimal" = "read"','"/" = "read"',`"${t}" = "write"`,"",`[permissions.${RP}.network]`,"enabled = true"];function Ket({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");Va.env.OPENAI_API_KEY=e,Va.env.OPENAI_BASE_URL=r}else if(!Va.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function yH({config:t,persistSteps:e,sendSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:o,cwd:s=Va.cwd(),abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let{prompt:u}=t,{model:d}=t;Ket({aiGateway:n});let f=await Vet({config:t,aiGateway:n,model:d}),p=[],h=[],m=[],g={},_=new Set,v=0,T=0,y,w,A,R,I,O=Xp(t),$=`${Va.env.NVM_BIN}/node`,b=Nl.join(vv.homedir(),".codex"),Z=Nl.join(b,"config.toml"),M=Nl.join(b,"auth.json");try{await Ev.mkdir(b,{recursive:!0});let Te={OPENAI_API_KEY:Va.env.OPENAI_API_KEY};await Ev.writeFile(M,JSON.stringify(Te,null,2),"utf-8"),Gn.log("Created Codex auth.json file");let fe=Va.env.OPENAI_BASE_URL,K=['forced_login_method = "api"'],Se=ul({creditWrapUpTurn:l}),F=ll(t,{creditWrapUpTurn:l});O&&K.push(Het),fe&&K.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${fe}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),Se&&K.push(...jge()),F&&K.push(...Bge(F));let k=[];O&&(k=Yet(Wet()),K.push(...k)),await Ev.writeFile(Z,`${K.join(`
378
+ `);this.baseURL=c.baseURL,this.timeout=c.timeout??_H.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=V4(c.logLevel,"ClientOptions.logLevel",this)??V4(wl("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??JI(),Re(this,AP,E_e,"f"),this._options=c,s&&(this._workloadIdentityAuth=new iP(s,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=o}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return se([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return I_e(e)}getUserAgent(){return`${this.constructor.name}/JS ${_l}`}defaultIdempotencyKey(){return`stainless-node-retry-${O4()}`}makeStatusError(e,r,n,i){return Wt.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof _e?n:new _e(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new _e(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!U(this,gH,"m",fye).call(this)&&n||this.baseURL,o=u_e(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),s=this.defaultQuery(),a=Object.fromEntries(o.searchParams);return(!M4(s)||!M4(a))&&(r={...a,...s,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Ad(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,o=i.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(i);let{req:s,url:a,timeout:c}=await this.buildRequest(i,{retryCount:o-r});await this.prepareRequest(s,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(rr(this).debug(`[${l}] sending request`,$a({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:s.headers})),i.signal?.aborted)throw new or;let f=new AbortController,p=await this.fetchWithAuth(a,s,c,f).catch(QE),h=Date.now();if(p instanceof globalThis.Error){let _=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new or;let v=XE(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return rr(this).info(`[${l}] connection ${v?"timed out":"failed"} - ${_}`),rr(this).debug(`[${l}] connection ${v?"timed out":"failed"} (${_})`,$a({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw rr(this).info(`[${l}] connection ${v?"timed out":"failed"} - error; no more retries left`),rr(this).debug(`[${l}] connection ${v?"timed out":"failed"} (error; no more retries left)`,$a({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof bd||p instanceof ev?p:v?new gl:new ml({cause:p})}let m=[...p.headers.entries()].filter(([_])=>_==="x-request-id").map(([_,v])=>", "+_+": "+JSON.stringify(v)).join(""),g=`[${l}${u}${m}] ${s.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await L4(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let _=await this.shouldRetry(p);if(r&&_){let R=`retrying, ${r} attempts remaining`;return await L4(p.body),rr(this).info(`${g} - ${R}`),rr(this).debug(`[${l}] response error (${R})`,$a({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let v=_?"error; no more retries left":"error; not retryable";rr(this).info(`${g} - ${v}`);let T=await p.text().catch(R=>QE(R).message),y=p_e(T),w=y?void 0:T;throw rr(this).debug(`[${l}] response error (${v})`,$a({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:w,durationMs:Date.now()-d})),this.makeStatusError(p.status,y,w,p.headers)}return rr(this).info(g),rr(this).debug(`[${l}] response start`,$a({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new sv(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let s=r.headers,a=s.get("Authorization");if(!a||a===`Bearer ${mH}`){let c=await this._workloadIdentityAuth.getToken();s.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:o,method:s,...a}=r||{},c=this._makeAbort(i);o&&o.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};s&&(d.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let o,s=i?.get("retry-after-ms");if(s){let c=parseFloat(s);Number.isNaN(c)||(o=c)}let a=i?.get("retry-after");if(a&&!o){let c=parseFloat(a);Number.isNaN(c)?o=Date.parse(a)-Date.now():o=c*1e3}if(o===void 0){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Rs(o),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let o=r-e,s=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return s*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:o,query:s,defaultBaseURL:a}=n,c=this.buildURL(o,s,a);"timeout"in n&&f_e("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let o={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let s=se([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...y_e(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(s),s.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:r}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let n=se([r]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,o=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!o}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:XI(e),isStreamingBody:!0}:typeof e=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e),isStreamingBody:!1}:{...U(this,AP,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};_H=Ue,AP=new WeakMap,gH=new WeakSet,fye=function(){return this.baseURL!=="https://api.openai.com/v1"};Ue.OpenAI=_H;Ue.DEFAULT_TIMEOUT=6e5;Ue.OpenAIError=_e;Ue.APIError=Wt;Ue.APIConnectionError=ml;Ue.APIConnectionTimeoutError=gl;Ue.APIUserAbortError=or;Ue.NotFoundError=um;Ue.ConflictError=dm;Ue.RateLimitError=pm;Ue.BadRequestError=am;Ue.AuthenticationError=cm;Ue.InternalServerError=hm;Ue.PermissionDeniedError=lm;Ue.UnprocessableEntityError=fm;Ue.InvalidWebhookSignatureError=xs;Ue.toFile=sP;Ue.Completions=Md;Ue.Chat=vl;Ue.Embeddings=$d;Ue.Files=Ud;Ue.Images=Bd;Ue.Audio=Os;Ue.Moderations=Gd;Ue.Models=qd;Ue.FineTuning=Po;Ue.Graders=Il;Ue.VectorStores=Ga;Ue.Webhooks=Wd;Ue.Beta=Io;Ue.Batches=Id;Ue.Uploads=Ol;Ue.Responses=Ba;Ue.Realtime=ja;Ue.Conversations=Rl;Ue.Evals=Cl;Ue.Containers=xl;Ue.Skills=qa;Ue.Videos=Hd;var Gn=oe("runner_codex"),xP="Codex CLI",Qm="gpt-6.1-sol";async function Vet({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else r?await t.isModelAvailableForProvider("openai",r)||(Gn.log(`Model '${r}' is not available for openai provider, proceeding without model specification`),q.inc("model.unavailable",1,{provider:"openai"}),n=void 0):!!Qm&&await t.isModelAvailableForProvider("openai",Qm)?(n=Qm,Gn.log(`Using default model: ${Qm}`)):Qm&&Gn.log(`Default model ${Qm} is not available, proceeding without model specification`);return n}var RP="netlify-ask-db",Het=`default_permissions = "${RP}"`,Wet=()=>Nl.join(Va.env.XDG_CONFIG_HOME??Nl.join(vv.homedir(),".config"),"netlify"),Yet=t=>["",`[permissions.${RP}]`,'description = "Ask mode: read-only filesystem, network access for database reads"','extends = ":read-only"',"",`[permissions.${RP}.filesystem]`,'":minimal" = "read"','"/" = "read"',`"${t}" = "write"`,"",`[permissions.${RP}.network]`,"enabled = true"];function Ket({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");Va.env.OPENAI_API_KEY=e,Va.env.OPENAI_BASE_URL=r}else if(!Va.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function yH({config:t,persistSteps:e,sendSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:o,cwd:s=Va.cwd(),abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let{prompt:u}=t,{model:d}=t;Ket({aiGateway:n});let f=await Vet({config:t,aiGateway:n,model:d}),p=[],h=[],m=[],g={},_=new Set,v=0,T=0,y,w,A,R,I,O=Xp(t),$=`${Va.env.NVM_BIN}/node`,b=Nl.join(vv.homedir(),".codex"),Z=Nl.join(b,"config.toml"),M=Nl.join(b,"auth.json");try{await Ev.mkdir(b,{recursive:!0});let Te={OPENAI_API_KEY:Va.env.OPENAI_API_KEY};await Ev.writeFile(M,JSON.stringify(Te,null,2),"utf-8"),Gn.log("Created Codex auth.json file");let fe=Va.env.OPENAI_BASE_URL,K=['forced_login_method = "api"'],Se=ul({creditWrapUpTurn:l}),F=ll(t,{creditWrapUpTurn:l});O&&K.push(Het),fe&&K.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${fe}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),Se&&K.push(...jge()),F&&K.push(...Bge(F));let k=[];O&&(k=Yet(Wet()),K.push(...k)),await Ev.writeFile(Z,`${K.join(`
379
379
  `)}
380
380
  `,"utf-8"),Gn.log("Wrote Codex config.toml",...k.length?[k.join(`
381
381
  `)]:[])}catch(Te){let fe=Te instanceof Error?Te.message:String(Te);throw Gn.warn("Failed to setup Codex config and credentials",{error:fe}),new Error(`Codex setup failed: ${fe}`)}let S=Zp("codex",t.effort);t.effort&&!S&&Gn.log(`Effort '${t.effort}' is not available on ${xP}; using its default`);let x=l?"low":S,N=!!(i&&o),X="mode"in t&&t.mode==="ask",H=!!O,ue=[yo(s,"codex"),"exec",...X&&!H?["--sandbox","read-only"]:[],...N?["resume",o]:[],...X?[]:["--yolo"],"--json",...x?["-c",`model_reasoning_effort="${x}"`]:[],...f?["--model",f]:[]].filter(Boolean);Gn.log(`Running ${$} ${ue.join(" ")}`);let Ce=It($,ue,{all:!0,cwd:s,env:{...Va.env},stdin:"pipe",idleTimeout:ha,cancelSignal:a});Ce.stdin?.end(u);let ve=Mc(()=>{e?.({steps:p,duration:T}),r?.({steps:h,duration:T}),h=[]},250),Ie=(Te,fe)=>{let K={...Te,id:v};v+=1,m.push(K),p.push(K),h.push(K),fe||ve.flush(),ve(),fe&&ve.flush()},Ne=f||"default";t.answeredInteraction||Ie({title:`Using ${xP} with ${Ne}`,category:G.Environment},!0);let Ge=Get.createInterface({input:Ce.all});Ge.on("error",Te=>{Gn.error("Readline interface error",{error:Te.message,stack:Te.stack})}),Ge.on("line",Te=>{let fe;try{fe=JSON.parse(Te)}catch{Gn.log("Could not parse line",Te);return}if(fe?.duration_ms&&(T=fe.duration_ms),fe?.type==="thread.started"&&typeof fe?.thread_id=="string"&&(A=fe.thread_id,c?.(A)),fe?.type==="item.started"&&fe?.item?.type==="command_execution")g[fe.item.id]=fe.item;else if(fe?.type==="item.completed"&&fe?.item?.type==="command_execution"){let K=fe.item,Se=Xet(K);Se&&Ie(Se,!0);let F=K.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(F&&!_.has(F)){_.add(F);let k=ls(F);ga(Gn,k),Ie({title:`Use ${k}`,category:G.Skill,type:F},!0)}}else if(fe?.type==="item.completed"&&fe?.item?.type==="reasoning"){let K={title:"Reasoning",message:fe.item.text,category:G.Reasoning};Ie(K,!0)}else if(fe?.type==="item.completed"&&fe?.item?.type==="agent_message")y=fe.item.text;else if(fe?.type==="item.started"&&fe?.item?.type==="mcp_tool_call"){let K=fe.item,Se=Yle(K.server)&&!I?nm(K.tool,K.arguments,Wle):void 0;Se&&"interaction"in Se?(I=Se.interaction,Ce.kill()):Se&&(Gn.warn("Ignoring malformed pause tool input",{toolUseId:K.id,tool:K.tool,issues:Se.issues}),q.inc(Se.metric,1))}else if(fe?.type==="turn.completed"&&fe.usage)R={input_tokens:fe.usage.input_tokens,output_tokens:fe.usage.output_tokens},Nc(R,f?{model:f}:{});else if(fe?.type==="turn.failed"&&fe?.error?.message)w=fe.error.message;else if(fe?.type==="local_shell_call"){let K=fe;g[K.call_id]=K}else if(fe?.type==="local_shell_call_output"){let K=fe,Se=g[K.call_id],F=Qet(Se,K);F&&Ie(F,!0);let L=(Se?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(L&&!_.has(L)){_.add(L);let j=ls(L);ga(Gn,j),Ie({title:`Use ${j}`,category:G.Skill,type:L},!0)}}else fe?.type==="message"&&fe.role==="assistant"?y=fe.content?.map(K=>K.text).join(`