@netlify/agent-runner-cli 2.18.0-smtp-3.0 → 2.18.0-smtp.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -396,7 +396,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
396
396
|
`,LF:`
|
|
397
397
|
`,concatBytes:y8},Pgt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Cgt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Pgt};import{Buffer as kgt}from"buffer";var iIe=(t,e)=>t?void 0:Ngt.bind(void 0,e),Ngt=function*(t,e){if(typeof e!="string"&&!Wr(e)&&!kgt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},oIe=(t,e)=>t?$gt.bind(void 0,e):Dgt.bind(void 0,e),$gt=function*(t,e){sIe(t,e),yield e},Dgt=function*(t,e){if(sIe(t,e),typeof e!="string"&&!Wr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},sIe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
398
398
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
399
|
-
if (condition) { yield value; }`)};import{Buffer as Mgt}from"buffer";import{StringDecoder as Lgt}from"string_decoder";var rL=(t,e,r)=>{if(r)return;if(t)return{transform:Ugt.bind(void 0,new TextEncoder)};let n=new Lgt(e);return{transform:Fgt.bind(void 0,n),final:zgt.bind(void 0,n)}},Ugt=function*(t,e){Mgt.isBuffer(e)?yield Iu(e):typeof e=="string"?yield t.encode(e):yield e},Fgt=function*(t,e){yield Wr(e)?t.write(e):e},zgt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as aIe}from"util";var v8=aIe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),nL=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=qgt}=e[r];for await(let i of n(t))yield*nL(i,e,r+1)},cIe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*jgt(r,Number(e),t)},jgt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*nL(n,r,e+1)},uIe=aIe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),qgt=function*(t){yield t};var E8=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},lIe=(t,e)=>[...e.flatMap(r=>[...am(r,t,0)]),...xR(t)],am=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Vgt}=e[r];for(let i of n(t))yield*am(i,e,r+1)},xR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Bgt(r,Number(e),t)},Bgt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*am(n,r,e+1)},Vgt=function*(t){yield t};var b8=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=fIe(t,s,o),u=sm(e),l=sm(r),d=u?v8.bind(void 0,nL,a):E8.bind(void 0,am),f=u||l?v8.bind(void 0,cIe,a):E8.bind(void 0,xR),p=u||l?uIe.bind(void 0,a):void 0;return{stream:new Ggt({writableObjectMode:n,writableHighWaterMark:dIe(n),readableObjectMode:i,readableHighWaterMark:dIe(i),transform(h,_,y){d([h,c,0],this,y)},flush(h){f([c],this,h)},destroy:p})}},iL=(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=fIe(s,r,a);t=lIe(c,t)}return t},fIe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:iIe(n,a)},rL(r,s,n),tL(r,o,n,c),{transform:t,final:e},{transform:oIe(i,a)},nIe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var pIe=(t,e)=>{for(let r of Hgt(t))Wgt(t,r,e)},Hgt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Wgt=(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 ${Sd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Kgt(a,n));r.input=_R(s)},Kgt=(t,e)=>{let r=iL(t,e,"utf8",!0);return Ygt(r),_R(r)},Ygt=t=>{let e=t.find(r=>typeof r!="string"&&!Wr(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 Qgt,appendFileSync as e_t}from"fs";var oL=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ny(r,n)&&!vo.has(e)&&Zgt(n)&&(t.some(({type:i,value:o})=>i==="native"&&Jgt.has(o))||t.every(({type:i})=>is.has(i))),Zgt=t=>t===1||t===2,Jgt=new Set(["pipe","overlapped"]),mIe=async(t,e,r,n)=>{for await(let i of t)Xgt(e)||gIe(i,r,n)},hIe=(t,e,r)=>{for(let n of t)gIe(n,e,r)},Xgt=t=>t._readableState.pipes.length>0,gIe=(t,e,r)=>{let n=SM(t);gc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var _Ie=({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,u)=>t_t({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},t_t=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=yxe(t,o,d),p=Iu(f),{stdioItems:m,objectMode:h}=e[r],_=r_t([p],m,c,n),{serializedResult:y,finalResult:b=y}=n_t({chunks:_,objectMode:h,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});i_t({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:m,objectMode:h});let T=a[r]?b:void 0;try{return n.error===void 0&&o_t(y,m,i),T}catch(S){return n.error=S,T}},r_t=(t,e,r,n)=>{try{return iL(t,e,r,!1)}catch(i){return n.error=i,t}},n_t=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:_R(t)};let s=kTe(t,r);return n[o]?{serializedResult:s,finalResult:S8(s,!i[o],e)}:{serializedResult:s}},i_t=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!oL({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=S8(t,!1,s);try{hIe(a,e,n)}catch(c){r.error??=c}},o_t=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>QM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?e_t(n,t):(r.add(o),Qgt(n,t))}};var yIe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Cu(e,r,"all")]:Array.isArray(e)?[Cu(t,r,"all"),...e]:Wr(t)&&Wr(e)?I5([t,e]):`${t}${e}`};import{once as w8}from"events";var SIe=async(t,e)=>{let[r,n]=await s_t(t);return e.isForcefullyTerminated??=!1,[r,n]},s_t=async t=>{let[e,r]=await Promise.allSettled([w8(t,"spawn"),w8(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?vIe(t):r.value},vIe=async t=>{try{return await w8(t,"exit")}catch{return vIe(t)}},EIe=async t=>{let[e,r]=await t;if(!a_t(e,r)&&T8(e,r))throw new _a;return[e,r]},a_t=(t,e)=>t===void 0&&e===void 0,T8=(t,e)=>t!==0||e!==null;var bIe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=c_t(t,e,r),s=o?.code==="ETIMEDOUT",a=_xe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},c_t=(t,e,r)=>t!==void 0?t:T8(e,r)?new _a:void 0;var wIe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=l_t(t,e,r),d=p_t({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return By(d,c,u)},l_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=EM(t,e,r),a=d_t(r),{file:c,commandArguments:u,options:l}=jM(t,e,a);f_t(l);let d=Qxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},d_t=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,f_t=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&sL("ipcInput"),t&&sL("ipc: true"),r&&sL("detached: true"),n&&sL("cancelSignal")},sL=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},p_t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=m_t({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=bIe(c,r),{output:m,error:h=u}=_Ie({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=m.map((b,T)=>Cu(b,r,T)),y=Cu(yIe(m,r),r,"all");return g_t({error:h,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},m_t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{pIe(o,r);let a=h_t(r);return u_t(...qM(t,e,a))}catch(a){return qy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},h_t=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:YM(e)}),g_t=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?ZM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):RR({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as nSt}from"events";import{spawn as iSt}from"child_process";import IIe from"process";import{once as A8,on as __t}from"events";var TIe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(My({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:DM(t)}),y_t({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),y_t=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{CM(e,i);let o=yd(t,e,r),s=new AbortController;try{return await Promise.race([S_t(o,n,s),v_t(o,r,s),E_t(o,r,s)])}catch(a){throw Ly(t),a}finally{s.abort(),kM(e,i)}},S_t=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await A8(t,"message",{signal:r});return n}for await(let[n]of __t(t,"message",{signal:r}))if(e(n))return n},v_t=async(t,e,{signal:r})=>{await A8(t,"disconnect",{signal:r}),lRe(e)},E_t=async(t,e,{signal:r})=>{let[n]=await A8(t,"strict:error",{signal:r});throw IM(n,e)};import{once as RIe,on as b_t}from"events";var xIe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>R8({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),R8=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{My({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:DM(t)}),CM(e,o);let s=yd(t,e,r),a=new AbortController,c={};return w_t(t,s,a),T_t({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),A_t({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},w_t=async(t,e,r)=>{try{await RIe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},T_t=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await RIe(t,"strict:error",{signal:r.signal});n.error=IM(i,e),r.abort()}catch{}},A_t=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of b_t(r,"message",{signal:o.signal}))AIe(s),yield c}catch{AIe(s)}finally{o.abort(),kM(e,a),n||Ly(t),i&&await t}},AIe=({error:t})=>{if(t)throw t};var OIe=(t,{ipc:e})=>{Object.assign(t,CIe(t,!1,e))},PIe=()=>{let t=IIe,e=!0,r=IIe.channel!==void 0;return{...CIe(t,e,r),getCancelSignal:LRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},CIe=(t,e,r)=>({sendMessage:FM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:TIe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:xIe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as R_t}from"child_process";import{PassThrough as x_t,Readable as I_t,Writable as O_t,Duplex as P_t}from"stream";var kIe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{g8(n);let a=new R_t;C_t(a,n),Object.assign(a,{readable:k_t,writable:N_t,duplex:$_t});let c=qy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=D_t(c,s,i);return{subprocess:a,promise:u}},C_t=(t,e)=>{let r=IR(),n=IR(),i=IR(),o=Array.from({length:e.length-3},IR),s=IR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},IR=()=>{let t=new x_t;return t.end(),t},k_t=()=>new I_t({read(){}}),N_t=()=>new O_t({write(){}}),$_t=()=>new P_t({read(){},write(){}}),D_t=async(t,e,r)=>By(t,e,r);import{createReadStream as NIe,createWriteStream as $Ie}from"fs";import{Buffer as M_t}from"buffer";import{Readable as OR,Writable as L_t,Duplex as U_t}from"stream";var MIe=(t,e)=>eL(F_t,t,e,!1),PR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Sd[t]}.`)},DIe={fileNumber:PR,generator:b8,asyncGenerator:b8,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:U_t.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},F_t={input:{...DIe,fileUrl:({value:t})=>({stream:NIe(t)}),filePath:({value:{file:t}})=>({stream:NIe(t)}),webStream:({value:t})=>({stream:OR.fromWeb(t)}),iterable:({value:t})=>({stream:OR.from(t)}),asyncIterable:({value:t})=>({stream:OR.from(t)}),string:({value:t})=>({stream:OR.from(t)}),uint8Array:({value:t})=>({stream:OR.from(M_t.from(t))})},output:{...DIe,fileUrl:({value:t})=>({stream:$Ie(t)}),filePath:({value:{file:t,append:e}})=>({stream:$Ie(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:L_t.fromWeb(t)}),iterable:PR,asyncIterable:PR,string:PR,uint8Array:PR}};import{on as z_t,once as LIe}from"events";import{PassThrough as j_t,getDefaultHighWaterMark as q_t}from"stream";import{finished as zIe}from"stream/promises";function cm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)I8(i);let e=t.some(({readableObjectMode:i})=>i),r=B_t(t,e),n=new x8({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var B_t=(t,e)=>{if(t.length===0)return q_t(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},x8=class extends j_t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(I8(e),this.#e.has(e))return;this.#e.add(e),this.#n??=V_t(this,this.#e,this.#o);let r=W_t({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(I8(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)}},V_t=async(t,e,r)=>{aL(t,UIe);let n=new AbortController;try{await Promise.race([G_t(t,n),H_t(t,e,r,n)])}finally{n.abort(),aL(t,-UIe)}},G_t=async(t,{signal:e})=>{try{await zIe(t,{signal:e,cleanup:!0})}catch(r){throw jIe(t,r),r}},H_t=async(t,e,r,{signal:n})=>{for await(let[i]of z_t(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},I8=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},W_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{aL(t,FIe);let a=new AbortController;try{await Promise.race([K_t(o,e,a),Y_t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Z_t({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),aL(t,-FIe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?O8(t):J_t(t))},K_t=async(t,e,{signal:r})=>{try{await t,r.aborted||O8(e)}catch(n){r.aborted||jIe(e,n)}},Y_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await zIe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;qIe(s)?i.add(e):BIe(t,s)}},Z_t=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await LIe(t,i,{signal:o}),!t.readable)return LIe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},J_t=t=>{t.writable&&t.end()},jIe=(t,e)=>{qIe(e)?O8(t):BIe(t,e)},qIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",O8=t=>{(t.readable||t.writable)&&t.destroy()},BIe=(t,e)=>{t.destroyed||(t.once("error",X_t),t.destroy(e))},X_t=()=>{},aL=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},UIe=2,FIe=1;import{finished as VIe}from"stream/promises";var Gy=(t,e)=>{t.pipe(e),Q_t(t,e),eyt(t,e)},Q_t=async(t,e)=>{if(!(ga(t)||ga(e))){try{await VIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}P8(e)}},P8=t=>{t.writable&&t.end()},eyt=async(t,e)=>{if(!(ga(t)||ga(e))){try{await VIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}C8(t)}},C8=t=>{t.readable&&t.destroy()};var GIe=(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})=>is.has(c)))tyt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!is.has(c)))nyt({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]:cm(o);Gy(s,i)}},tyt=(t,e,r,n)=>{r==="output"?Gy(t.stdio[n],e):Gy(e,t.stdio[n]);let i=ryt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},ryt=["stdin","stdout","stderr"],nyt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;iyt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},iyt=(t,{signal:e})=>{ga(t)&&im(t,oyt,e)},oyt=2;import{addAbortListener as cyt}from"events";var um=[];um.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&um.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&um.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var cL=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",k8=Symbol.for("signal-exit emitter"),N8=globalThis,syt=Object.defineProperty.bind(Object),$8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(N8[k8])return N8[k8];syt(N8,k8,{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}},uL=class{},ayt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),D8=class extends uL{onExit(){return()=>{}}load(){}unload(){}},M8=class extends uL{#e=L8.platform==="win32"?"SIGINT":"SIGHUP";#r=new $8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of um)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(!cL(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 um)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,um.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 cL(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"&&cL(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)}},L8=globalThis.process,{onExit:HIe,load:Jmr,unload:Xmr}=ayt(cL(L8)?new M8(L8):new D8);var WIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=HIe(()=>{t.kill()});cyt(n,()=>{i()})};var YIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=vM(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=uyt(r,n,i),{sourceStream:d,sourceError:f}=dyt(t,u),{options:p,fileDescriptors:m}=yc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:m,startTime:o}},uyt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=lyt(t,e,...r),a=PM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},lyt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(KIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||R5(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]=lM(r,...n);return{destination:e(KIe)(i,o,s),pipeOptions:s}}if(yc.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}`)},KIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),dyt=(t,e)=>{try{return{sourceStream:Uy(t,e)}}catch(r){return{sourceError:r}}};var JIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=fyt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw U8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},fyt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return C8(t),n;if(e!==void 0)return P8(r),e},U8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>qy({error:t,command:ZIe,escapedCommand:ZIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),ZIe="source.pipe(destination)";var XIe=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 pyt}from"stream/promises";var QIe=(t,e,r)=>{let n=lL.has(e)?hyt(t,e):myt(t,e);return im(t,_yt,r.signal),im(e,yyt,r.signal),gyt(e),n},myt=(t,e)=>{let r=cm([t]);return Gy(r,e),lL.set(e,r),r},hyt=(t,e)=>{let r=lL.get(e);return r.add(t),r},gyt=async t=>{try{await pyt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}lL.delete(t)},lL=new WeakMap,_yt=2,yyt=1;import{aborted as Syt}from"util";var eOe=(t,e)=>t===void 0?[]:[vyt(t,e)],vyt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Syt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw U8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var dL=(t,...e)=>{if(xr(e[0]))return dL.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=YIe(t,...e),i=Eyt({...n,destination:r});return i.pipe=dL.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Eyt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=byt(t,i);JIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=QIe(e,o,d);return await Promise.race([XIe(l),...eOe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},byt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Oyt}from"timers/promises";import{on as wyt}from"events";import{getDefaultHighWaterMark as Tyt}from"stream";var fL=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return Ayt(e,s),rOe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},Ayt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},F8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;Ryt(e,s,t);let a=t.readableObjectMode&&!o;return rOe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Ryt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},rOe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=wyt(t,"data",{signal:e.signal,highWaterMark:tOe,highWatermark:tOe});return xyt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},z8=Tyt(!0),tOe=z8,xyt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=Iyt({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*am(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*xR(a)}},Iyt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[rL(t,r,!e),tL(t,i,!n,{})].filter(Boolean);var nOe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=Pyt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([Cyt(t),d]);return}let f=_8(c,r),p=F8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[m]=await Promise.all([kyt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return m},Pyt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!oL({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=F8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await mIe(a,t,r,o)},Cyt=async t=>{await Oyt(),t.readableFlowing===null&&t.resume()},kyt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await HM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await WM(r,{maxBuffer:o})):await jy(r,{maxBuffer:o})}catch(a){return iOe(mxe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},j8=async t=>{try{return await t}catch(e){return iOe(e)}},iOe=({bufferedData:t})=>PTe(t)?new Uint8Array(t):t;import{finished as Nyt}from"stream/promises";var CR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=$yt(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Nyt(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Lyt(a,e,r,n)}finally{s.abort()}},$yt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Dyt(t,r,n),n},Dyt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Myt(e,r),n.call(t,...i)}},Myt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Lyt=(t,e,r,n)=>{if(!Uyt(t,e,r,n))throw t},Uyt=(t,e,r,n=!0)=>r.propagating?oOe(t)||pL(t):(r.propagating=!0,q8(r,e)===n?oOe(t):pL(t)),q8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",pL=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oOe=t=>t?.code==="EPIPE";var sOe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>B8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),B8=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=CR(t,e,u);if(q8(u,e)){await l;return}let[d]=await Promise.all([nOe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var aOe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?cm([t,e].filter(Boolean)):void 0,cOe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>B8({...Fyt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:zyt(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Fyt=({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}},zyt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as jyt}from"events";var uOe=t=>Ny(t,"ipc"),lOe=(t,e)=>{let r=SM(t);gc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var dOe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=uOe(o),a=Ou(e,"ipc"),c=Ou(r,"ipc");for await(let u of R8({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(hxe(t,i,c),i.push(u)),s&&lOe(u,o);return i},fOe=async(t,e)=>(await Promise.allSettled([t]),e);var pOe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:m,originalStreams:h,onInternalError:_,controller:y})=>{let b=SIe(t,f),T={originalStreams:h,fileDescriptors:m,subprocess:t,exitPromise:b,propagating:!1},S=sOe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),E=cOe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),v=[],R=dOe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:v,verboseInfo:p}),P=qyt(h,t,T),O=Byt(m,T);try{return await Promise.race([Promise.all([{},EIe(b),Promise.all(S),E,R,WRe(t,d),...P,...O]),_,Vyt(t,y),...qRe(t,o,f,y),...uRe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...zRe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},b,Promise.all(S.map(A=>j8(A))),j8(E),fOe(R,v),Promise.allSettled(P),Promise.allSettled(O)])}},qyt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:CR(n,i,r)),Byt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Sa(o,{checkOpen:!1})&&!ga(o)).map(({type:i,value:o,stream:s=o})=>CR(s,n,e,{isSameDirection:is.has(i),stopOnExit:i==="native"}))),Vyt=async(t,{signal:e})=>{let[r]=await jyt(t,"error",{signal:e});throw r};var mOe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),kR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=_c();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Hy=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 Gyt}from"stream";import{callbackify as Hyt}from"util";import{finished as hOe}from"stream/promises";var V8=async t=>{if(t!==void 0)try{await G8(t)}catch{}},gOe=async t=>{if(t!==void 0)try{await H8(t)}catch{}},G8=async t=>{await hOe(t,{cleanup:!0,readable:!1,writable:!0})},H8=async t=>{await hOe(t,{cleanup:!0,readable:!0,writable:!1})},mL=async(t,e)=>{if(await t,e)throw e},hL=(t,e,r)=>{r&&!pL(r)?t.destroy(r):e&&t.destroy()};var _Oe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||vo.has(r),{subprocessStdout:a,waitReadableDestroy:c}=W8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=K8(a,s),{read:f,onStdoutDataDone:p}=Y8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),m=new Gyt({read:f,destroy:Hyt(J8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return Z8({subprocessStdout:a,onStdoutDataDone:p,readable:m,subprocess:t}),m},W8=(t,e,r)=>{let n=Uy(t,e),i=kR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},K8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:z8},Y8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=_c(),s=fL({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Wyt(this,s,o)},onStdoutDataDone:o}},Wyt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Z8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await H8(t),await n,await V8(i),await e,r.readable&&r.push(null)}catch(o){await V8(i),yOe(r,o)}},J8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Hy(r,e)&&(yOe(t,n),await mL(e,n))},yOe=(t,e)=>{hL(t,t.readable,e)};import{Writable as Kyt}from"stream";import{callbackify as SOe}from"util";var vOe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=X8(t,r,e),s=new Kyt({...Q8(n,t,i),destroy:SOe(tZ.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return eZ(n,s),s},X8=(t,e,r)=>{let n=PM(t,e),i=kR(r,n,"writableFinal"),o=kR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Q8=(t,e,r)=>({write:Yyt.bind(void 0,t),final:SOe(Zyt.bind(void 0,t,e,r))}),Yyt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Zyt=async(t,e,r)=>{await Hy(r,e)&&(t.writable&&t.end(),await e)},eZ=async(t,e,r)=>{try{await G8(t),e.writable&&e.end()}catch(n){await gOe(r),EOe(e,n)}},tZ=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Hy(r,e),await Hy(n,e)&&(EOe(t,i),await mL(e,i))},EOe=(t,e)=>{hL(t,t.writable,e)};import{Duplex as Jyt}from"stream";import{callbackify as Xyt}from"util";var bOe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||vo.has(r),{subprocessStdout:c,waitReadableDestroy:u}=W8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=X8(t,i,e),{readableEncoding:p,readableObjectMode:m,readableHighWaterMark:h}=K8(c,a),{read:_,onStdoutDataDone:y}=Y8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new Jyt({read:_,...Q8(l,t,d),destroy:Xyt(Qyt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:h,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:m,writableObjectMode:l.writableObjectMode,encoding:p});return Z8({subprocessStdout:c,onStdoutDataDone:y,readable:b,subprocess:t,subprocessStdin:l}),eZ(l,b,c),b},Qyt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([J8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),tZ({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var rZ=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||vo.has(e),s=Uy(t,r),a=fL({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return eSt(a,s,t)},eSt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var wOe=(t,{encoding:e})=>{let r=mOe();t.readable=_Oe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=vOe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=bOe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=rZ.bind(void 0,t,e),t[Symbol.asyncIterator]=rZ.bind(void 0,t,e,{})};var TOe=(t,e)=>{for(let[r,n]of rSt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},tSt=(async()=>{})().constructor.prototype,rSt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(tSt,t)]);var AOe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=oSt(t,e,r),{subprocess:f,promise:p}=aSt({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=dL.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),TOe(f,p),yc.set(f,{options:l,fileDescriptors:d}),f},oSt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=EM(t,e,r),{file:a,commandArguments:c,options:u}=jM(t,e,r),l=sSt(u),d=MIe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},sSt=({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}},aSt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=iSt(...qM(t,e,r))}catch(m){return kIe({error:m,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;nSt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];GIe(c,a,u),WIe(c,r,u);let d={},f=_c();c.kill=aRe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=aOe(c,r),wOe(c,r),OIe(c,r);let p=cSt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},cSt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],m,h,_]=await pOe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=m.map((S,E)=>Cu(S,e,E)),b=Cu(h,e,"all"),T=uSt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:b,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return By(T,n,e)},uSt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?RR({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Sc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):ZM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var gL=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,lSt(n,t[n],i)]));return{...t,...r}},lSt=(t,e,r)=>dSt.has(t)&&xr(e)&&xr(r)?{...e,...r}:r,dSt=new Set(["env",...k5]);var vd=(t,e,r,n)=>{let i=(s,a,c)=>vd(s,a,r,c),o=(...s)=>fSt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},fSt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(xr(o))return i(t,gL(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=pSt({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?wIe(a,c,u):AOe(a,c,u,i)},pSt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=MTe(e)?LTe(e,r):[e,...r],[s,a,c]=lM(...o),u=gL(gL(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var ROe=({file:t,commandArguments:e})=>IOe(t,e),xOe=({file:t,commandArguments:e})=>({...IOe(t,e),isSync:!0}),IOe=(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]=mSt(t);return{file:r,commandArguments:n}},mSt=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(hSt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},hSt=/ +/g;var OOe=(t,e,r)=>{t.sync=e(gSt,r),t.s=t.sync},POe=({options:t})=>COe(t),gSt=({options:t})=>({...COe(t),isSync:!0}),COe=t=>({options:{..._St(t),...t}}),_St=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},kOe={preferLocal:!0};var NOe=vd(()=>({})),j_r=vd(()=>({isSync:!0})),$Oe=vd(ROe),q_r=vd(xOe),B_r=vd(VRe),V_r=vd(POe,{},kOe,OOe),{sendMessage:G_r,getOneMessage:H_r,getEachMessage:W_r,getCancelSignal:K_r}=PIe();var DOe=!1,MOe,ySt=t=>{MOe??=t},LOe=t=>{DOe=!0,ySt(t)},Kn=()=>DOe,ku=()=>MOe,UOe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var NR=null,FOe=t=>(NR&&NR.destroy(),NR=new os({totalAllowedTime:t}),NR),zOe=()=>NR;var os=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&&Kn())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((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await xk({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{Y.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),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 jOe={name:"@netlify/agent-runner-cli",type:"module",version:"2.18.0-smtp-3.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","build:bundle":"tsup --no-dts",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build:bundle 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:antigravity":"vitest run test/integration/antigravity.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",prompts:"LOG=0 vitest run --config vitest.prompts.config.js","site:build":"npm run prompts && node site/build.mjs","site:dev":"npm run site:build && netlify dev --dir site/dist",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.7","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.8.0","@opentelemetry/sdk-trace-base":"2.9.0","@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.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.3","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var bSt=vSt(import.meta.url),wSt=Nu.dirname(bSt),TSt=ESt(import.meta.url),Wy=ce("shell"),nZ=new Set,qOe={preferLocal:!0},Et=(t,e,r)=>{let[n,i]=ASt(e,r),o={...qOe,...i},s=NOe(t,n,o);VOe(s,o),WOe(s);let a=r?.idleTimeout;return a&&a>0&&HOe(s,a),s},BOe=(t,e)=>{let r={...qOe,...e},n=$Oe(t,r);return VOe(n,r),WOe(n),e?.idleTimeout&&e.idleTimeout>0&&HOe(n,e.idleTimeout),n},ASt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},VOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ec.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ec.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new nT).pipe(Ec.stdout),t.stderr?.pipe(new nT).pipe(Ec.stderr);return}t.stdout?.pipe(Ec.stdout),t.stderr?.pipe(Ec.stderr)},iZ=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ec.kill(-t.pid,e),Wy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Wy.error("Error killing process:",r),!1}},GOe=t=>iZ(t,"SIGKILL"),HOe=(t,e)=>{let r=null,n=()=>{Wy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),iZ(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Wy.log(`Force killing idle process ${t.pid}`),GOe(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)},WOe=t=>{nZ.add(t);let e=zOe();if(e){let r=e.onTimesUp(()=>{Wy.log(`Global timer expired, killing process ${t.pid}`),iZ(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Wy.log(`Force killing process ${t.pid} after timeout`),GOe(t))},5e3)});t.on("exit",()=>{nZ.delete(t),r()}),t.on("error",()=>{nZ.delete(t),r()})}};function yL(t,e){return!!va(t,e)}function va(t,e){if(!Ec.env.NETLIFY_LOCAL_MODE)try{let i=TSt.resolve(jOe.name),o=Nu.dirname(i);for(;o!==Nu.dirname(o);){let s=Nu.dirname(o);if(Nu.basename(s)==="node_modules"){let a=Nu.join(s,".bin",e);if(_L.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ec.env.NODE_PATH){let i=Nu.join(Ec.env.NODE_PATH,".bin",e);if(_L.existsSync(i))return i}let r=Nu.join(t,"node_modules",".bin",e);if(_L.existsSync(r))return r;let n=Nu.join(wSt,"..","node_modules",".bin",e);if(_L.existsSync(n))return n}var Ky=ce("repo"),tPe="runner-diffs-",oZ=t=>`${tPe}${t}-`,rPe=async t=>{let e=vL.tmpdir(),r;try{r=await Yn.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(tPe)&&!n.startsWith(oZ(t))).map(n=>Yn.rm(Eo.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},KOe=async t=>{let e=RSt("sha256");for await(let r of xSt(t))e.update(r);return e.digest("hex")},YOe=async(t,e)=>t.size===e.size&&await KOe(t.path)===await KOe(e.path),nPe=/.. (.+)?\.log$/,ISt=[nPe],OSt=1,ZOe=/^<<<<<<<( |$)/m,JOe=t=>{let e=t.split(`
|
|
399
|
+
if (condition) { yield value; }`)};import{Buffer as Mgt}from"buffer";import{StringDecoder as Lgt}from"string_decoder";var rL=(t,e,r)=>{if(r)return;if(t)return{transform:Ugt.bind(void 0,new TextEncoder)};let n=new Lgt(e);return{transform:Fgt.bind(void 0,n),final:zgt.bind(void 0,n)}},Ugt=function*(t,e){Mgt.isBuffer(e)?yield Iu(e):typeof e=="string"?yield t.encode(e):yield e},Fgt=function*(t,e){yield Wr(e)?t.write(e):e},zgt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as aIe}from"util";var v8=aIe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),nL=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=qgt}=e[r];for await(let i of n(t))yield*nL(i,e,r+1)},cIe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*jgt(r,Number(e),t)},jgt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*nL(n,r,e+1)},uIe=aIe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),qgt=function*(t){yield t};var E8=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},lIe=(t,e)=>[...e.flatMap(r=>[...am(r,t,0)]),...xR(t)],am=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Vgt}=e[r];for(let i of n(t))yield*am(i,e,r+1)},xR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Bgt(r,Number(e),t)},Bgt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*am(n,r,e+1)},Vgt=function*(t){yield t};var b8=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=fIe(t,s,o),u=sm(e),l=sm(r),d=u?v8.bind(void 0,nL,a):E8.bind(void 0,am),f=u||l?v8.bind(void 0,cIe,a):E8.bind(void 0,xR),p=u||l?uIe.bind(void 0,a):void 0;return{stream:new Ggt({writableObjectMode:n,writableHighWaterMark:dIe(n),readableObjectMode:i,readableHighWaterMark:dIe(i),transform(h,_,y){d([h,c,0],this,y)},flush(h){f([c],this,h)},destroy:p})}},iL=(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=fIe(s,r,a);t=lIe(c,t)}return t},fIe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:iIe(n,a)},rL(r,s,n),tL(r,o,n,c),{transform:t,final:e},{transform:oIe(i,a)},nIe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var pIe=(t,e)=>{for(let r of Hgt(t))Wgt(t,r,e)},Hgt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Wgt=(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 ${Sd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Kgt(a,n));r.input=_R(s)},Kgt=(t,e)=>{let r=iL(t,e,"utf8",!0);return Ygt(r),_R(r)},Ygt=t=>{let e=t.find(r=>typeof r!="string"&&!Wr(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 Qgt,appendFileSync as e_t}from"fs";var oL=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ny(r,n)&&!vo.has(e)&&Zgt(n)&&(t.some(({type:i,value:o})=>i==="native"&&Jgt.has(o))||t.every(({type:i})=>is.has(i))),Zgt=t=>t===1||t===2,Jgt=new Set(["pipe","overlapped"]),mIe=async(t,e,r,n)=>{for await(let i of t)Xgt(e)||gIe(i,r,n)},hIe=(t,e,r)=>{for(let n of t)gIe(n,e,r)},Xgt=t=>t._readableState.pipes.length>0,gIe=(t,e,r)=>{let n=SM(t);gc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var _Ie=({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,u)=>t_t({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},t_t=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=yxe(t,o,d),p=Iu(f),{stdioItems:m,objectMode:h}=e[r],_=r_t([p],m,c,n),{serializedResult:y,finalResult:b=y}=n_t({chunks:_,objectMode:h,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});i_t({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:m,objectMode:h});let T=a[r]?b:void 0;try{return n.error===void 0&&o_t(y,m,i),T}catch(S){return n.error=S,T}},r_t=(t,e,r,n)=>{try{return iL(t,e,r,!1)}catch(i){return n.error=i,t}},n_t=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:_R(t)};let s=kTe(t,r);return n[o]?{serializedResult:s,finalResult:S8(s,!i[o],e)}:{serializedResult:s}},i_t=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!oL({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=S8(t,!1,s);try{hIe(a,e,n)}catch(c){r.error??=c}},o_t=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>QM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?e_t(n,t):(r.add(o),Qgt(n,t))}};var yIe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Cu(e,r,"all")]:Array.isArray(e)?[Cu(t,r,"all"),...e]:Wr(t)&&Wr(e)?I5([t,e]):`${t}${e}`};import{once as w8}from"events";var SIe=async(t,e)=>{let[r,n]=await s_t(t);return e.isForcefullyTerminated??=!1,[r,n]},s_t=async t=>{let[e,r]=await Promise.allSettled([w8(t,"spawn"),w8(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?vIe(t):r.value},vIe=async t=>{try{return await w8(t,"exit")}catch{return vIe(t)}},EIe=async t=>{let[e,r]=await t;if(!a_t(e,r)&&T8(e,r))throw new _a;return[e,r]},a_t=(t,e)=>t===void 0&&e===void 0,T8=(t,e)=>t!==0||e!==null;var bIe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=c_t(t,e,r),s=o?.code==="ETIMEDOUT",a=_xe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},c_t=(t,e,r)=>t!==void 0?t:T8(e,r)?new _a:void 0;var wIe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=l_t(t,e,r),d=p_t({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return By(d,c,u)},l_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=EM(t,e,r),a=d_t(r),{file:c,commandArguments:u,options:l}=jM(t,e,a);f_t(l);let d=Qxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},d_t=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,f_t=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&sL("ipcInput"),t&&sL("ipc: true"),r&&sL("detached: true"),n&&sL("cancelSignal")},sL=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},p_t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=m_t({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=bIe(c,r),{output:m,error:h=u}=_Ie({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=m.map((b,T)=>Cu(b,r,T)),y=Cu(yIe(m,r),r,"all");return g_t({error:h,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},m_t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{pIe(o,r);let a=h_t(r);return u_t(...qM(t,e,a))}catch(a){return qy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},h_t=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:YM(e)}),g_t=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?ZM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):RR({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as nSt}from"events";import{spawn as iSt}from"child_process";import IIe from"process";import{once as A8,on as __t}from"events";var TIe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(My({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:DM(t)}),y_t({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),y_t=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{CM(e,i);let o=yd(t,e,r),s=new AbortController;try{return await Promise.race([S_t(o,n,s),v_t(o,r,s),E_t(o,r,s)])}catch(a){throw Ly(t),a}finally{s.abort(),kM(e,i)}},S_t=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await A8(t,"message",{signal:r});return n}for await(let[n]of __t(t,"message",{signal:r}))if(e(n))return n},v_t=async(t,e,{signal:r})=>{await A8(t,"disconnect",{signal:r}),lRe(e)},E_t=async(t,e,{signal:r})=>{let[n]=await A8(t,"strict:error",{signal:r});throw IM(n,e)};import{once as RIe,on as b_t}from"events";var xIe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>R8({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),R8=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{My({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:DM(t)}),CM(e,o);let s=yd(t,e,r),a=new AbortController,c={};return w_t(t,s,a),T_t({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),A_t({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},w_t=async(t,e,r)=>{try{await RIe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},T_t=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await RIe(t,"strict:error",{signal:r.signal});n.error=IM(i,e),r.abort()}catch{}},A_t=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of b_t(r,"message",{signal:o.signal}))AIe(s),yield c}catch{AIe(s)}finally{o.abort(),kM(e,a),n||Ly(t),i&&await t}},AIe=({error:t})=>{if(t)throw t};var OIe=(t,{ipc:e})=>{Object.assign(t,CIe(t,!1,e))},PIe=()=>{let t=IIe,e=!0,r=IIe.channel!==void 0;return{...CIe(t,e,r),getCancelSignal:LRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},CIe=(t,e,r)=>({sendMessage:FM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:TIe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:xIe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as R_t}from"child_process";import{PassThrough as x_t,Readable as I_t,Writable as O_t,Duplex as P_t}from"stream";var kIe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{g8(n);let a=new R_t;C_t(a,n),Object.assign(a,{readable:k_t,writable:N_t,duplex:$_t});let c=qy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=D_t(c,s,i);return{subprocess:a,promise:u}},C_t=(t,e)=>{let r=IR(),n=IR(),i=IR(),o=Array.from({length:e.length-3},IR),s=IR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},IR=()=>{let t=new x_t;return t.end(),t},k_t=()=>new I_t({read(){}}),N_t=()=>new O_t({write(){}}),$_t=()=>new P_t({read(){},write(){}}),D_t=async(t,e,r)=>By(t,e,r);import{createReadStream as NIe,createWriteStream as $Ie}from"fs";import{Buffer as M_t}from"buffer";import{Readable as OR,Writable as L_t,Duplex as U_t}from"stream";var MIe=(t,e)=>eL(F_t,t,e,!1),PR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Sd[t]}.`)},DIe={fileNumber:PR,generator:b8,asyncGenerator:b8,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:U_t.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},F_t={input:{...DIe,fileUrl:({value:t})=>({stream:NIe(t)}),filePath:({value:{file:t}})=>({stream:NIe(t)}),webStream:({value:t})=>({stream:OR.fromWeb(t)}),iterable:({value:t})=>({stream:OR.from(t)}),asyncIterable:({value:t})=>({stream:OR.from(t)}),string:({value:t})=>({stream:OR.from(t)}),uint8Array:({value:t})=>({stream:OR.from(M_t.from(t))})},output:{...DIe,fileUrl:({value:t})=>({stream:$Ie(t)}),filePath:({value:{file:t,append:e}})=>({stream:$Ie(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:L_t.fromWeb(t)}),iterable:PR,asyncIterable:PR,string:PR,uint8Array:PR}};import{on as z_t,once as LIe}from"events";import{PassThrough as j_t,getDefaultHighWaterMark as q_t}from"stream";import{finished as zIe}from"stream/promises";function cm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)I8(i);let e=t.some(({readableObjectMode:i})=>i),r=B_t(t,e),n=new x8({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var B_t=(t,e)=>{if(t.length===0)return q_t(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},x8=class extends j_t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(I8(e),this.#e.has(e))return;this.#e.add(e),this.#n??=V_t(this,this.#e,this.#o);let r=W_t({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(I8(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)}},V_t=async(t,e,r)=>{aL(t,UIe);let n=new AbortController;try{await Promise.race([G_t(t,n),H_t(t,e,r,n)])}finally{n.abort(),aL(t,-UIe)}},G_t=async(t,{signal:e})=>{try{await zIe(t,{signal:e,cleanup:!0})}catch(r){throw jIe(t,r),r}},H_t=async(t,e,r,{signal:n})=>{for await(let[i]of z_t(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},I8=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},W_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{aL(t,FIe);let a=new AbortController;try{await Promise.race([K_t(o,e,a),Y_t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Z_t({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),aL(t,-FIe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?O8(t):J_t(t))},K_t=async(t,e,{signal:r})=>{try{await t,r.aborted||O8(e)}catch(n){r.aborted||jIe(e,n)}},Y_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await zIe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;qIe(s)?i.add(e):BIe(t,s)}},Z_t=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await LIe(t,i,{signal:o}),!t.readable)return LIe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},J_t=t=>{t.writable&&t.end()},jIe=(t,e)=>{qIe(e)?O8(t):BIe(t,e)},qIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",O8=t=>{(t.readable||t.writable)&&t.destroy()},BIe=(t,e)=>{t.destroyed||(t.once("error",X_t),t.destroy(e))},X_t=()=>{},aL=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},UIe=2,FIe=1;import{finished as VIe}from"stream/promises";var Gy=(t,e)=>{t.pipe(e),Q_t(t,e),eyt(t,e)},Q_t=async(t,e)=>{if(!(ga(t)||ga(e))){try{await VIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}P8(e)}},P8=t=>{t.writable&&t.end()},eyt=async(t,e)=>{if(!(ga(t)||ga(e))){try{await VIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}C8(t)}},C8=t=>{t.readable&&t.destroy()};var GIe=(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})=>is.has(c)))tyt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!is.has(c)))nyt({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]:cm(o);Gy(s,i)}},tyt=(t,e,r,n)=>{r==="output"?Gy(t.stdio[n],e):Gy(e,t.stdio[n]);let i=ryt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},ryt=["stdin","stdout","stderr"],nyt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;iyt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},iyt=(t,{signal:e})=>{ga(t)&&im(t,oyt,e)},oyt=2;import{addAbortListener as cyt}from"events";var um=[];um.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&um.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&um.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var cL=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",k8=Symbol.for("signal-exit emitter"),N8=globalThis,syt=Object.defineProperty.bind(Object),$8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(N8[k8])return N8[k8];syt(N8,k8,{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}},uL=class{},ayt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),D8=class extends uL{onExit(){return()=>{}}load(){}unload(){}},M8=class extends uL{#e=L8.platform==="win32"?"SIGINT":"SIGHUP";#r=new $8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of um)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(!cL(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 um)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,um.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 cL(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"&&cL(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)}},L8=globalThis.process,{onExit:HIe,load:Jmr,unload:Xmr}=ayt(cL(L8)?new M8(L8):new D8);var WIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=HIe(()=>{t.kill()});cyt(n,()=>{i()})};var YIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=vM(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=uyt(r,n,i),{sourceStream:d,sourceError:f}=dyt(t,u),{options:p,fileDescriptors:m}=yc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:m,startTime:o}},uyt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=lyt(t,e,...r),a=PM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},lyt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(KIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||R5(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]=lM(r,...n);return{destination:e(KIe)(i,o,s),pipeOptions:s}}if(yc.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}`)},KIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),dyt=(t,e)=>{try{return{sourceStream:Uy(t,e)}}catch(r){return{sourceError:r}}};var JIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=fyt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw U8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},fyt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return C8(t),n;if(e!==void 0)return P8(r),e},U8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>qy({error:t,command:ZIe,escapedCommand:ZIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),ZIe="source.pipe(destination)";var XIe=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 pyt}from"stream/promises";var QIe=(t,e,r)=>{let n=lL.has(e)?hyt(t,e):myt(t,e);return im(t,_yt,r.signal),im(e,yyt,r.signal),gyt(e),n},myt=(t,e)=>{let r=cm([t]);return Gy(r,e),lL.set(e,r),r},hyt=(t,e)=>{let r=lL.get(e);return r.add(t),r},gyt=async t=>{try{await pyt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}lL.delete(t)},lL=new WeakMap,_yt=2,yyt=1;import{aborted as Syt}from"util";var eOe=(t,e)=>t===void 0?[]:[vyt(t,e)],vyt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Syt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw U8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var dL=(t,...e)=>{if(xr(e[0]))return dL.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=YIe(t,...e),i=Eyt({...n,destination:r});return i.pipe=dL.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Eyt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=byt(t,i);JIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=QIe(e,o,d);return await Promise.race([XIe(l),...eOe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},byt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Oyt}from"timers/promises";import{on as wyt}from"events";import{getDefaultHighWaterMark as Tyt}from"stream";var fL=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return Ayt(e,s),rOe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},Ayt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},F8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;Ryt(e,s,t);let a=t.readableObjectMode&&!o;return rOe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Ryt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},rOe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=wyt(t,"data",{signal:e.signal,highWaterMark:tOe,highWatermark:tOe});return xyt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},z8=Tyt(!0),tOe=z8,xyt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=Iyt({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*am(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*xR(a)}},Iyt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[rL(t,r,!e),tL(t,i,!n,{})].filter(Boolean);var nOe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=Pyt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([Cyt(t),d]);return}let f=_8(c,r),p=F8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[m]=await Promise.all([kyt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return m},Pyt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!oL({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=F8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await mIe(a,t,r,o)},Cyt=async t=>{await Oyt(),t.readableFlowing===null&&t.resume()},kyt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await HM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await WM(r,{maxBuffer:o})):await jy(r,{maxBuffer:o})}catch(a){return iOe(mxe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},j8=async t=>{try{return await t}catch(e){return iOe(e)}},iOe=({bufferedData:t})=>PTe(t)?new Uint8Array(t):t;import{finished as Nyt}from"stream/promises";var CR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=$yt(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Nyt(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Lyt(a,e,r,n)}finally{s.abort()}},$yt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Dyt(t,r,n),n},Dyt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Myt(e,r),n.call(t,...i)}},Myt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Lyt=(t,e,r,n)=>{if(!Uyt(t,e,r,n))throw t},Uyt=(t,e,r,n=!0)=>r.propagating?oOe(t)||pL(t):(r.propagating=!0,q8(r,e)===n?oOe(t):pL(t)),q8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",pL=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oOe=t=>t?.code==="EPIPE";var sOe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>B8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),B8=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=CR(t,e,u);if(q8(u,e)){await l;return}let[d]=await Promise.all([nOe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var aOe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?cm([t,e].filter(Boolean)):void 0,cOe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>B8({...Fyt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:zyt(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Fyt=({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}},zyt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as jyt}from"events";var uOe=t=>Ny(t,"ipc"),lOe=(t,e)=>{let r=SM(t);gc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var dOe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=uOe(o),a=Ou(e,"ipc"),c=Ou(r,"ipc");for await(let u of R8({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(hxe(t,i,c),i.push(u)),s&&lOe(u,o);return i},fOe=async(t,e)=>(await Promise.allSettled([t]),e);var pOe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:m,originalStreams:h,onInternalError:_,controller:y})=>{let b=SIe(t,f),T={originalStreams:h,fileDescriptors:m,subprocess:t,exitPromise:b,propagating:!1},S=sOe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),E=cOe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),v=[],R=dOe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:v,verboseInfo:p}),P=qyt(h,t,T),O=Byt(m,T);try{return await Promise.race([Promise.all([{},EIe(b),Promise.all(S),E,R,WRe(t,d),...P,...O]),_,Vyt(t,y),...qRe(t,o,f,y),...uRe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...zRe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},b,Promise.all(S.map(A=>j8(A))),j8(E),fOe(R,v),Promise.allSettled(P),Promise.allSettled(O)])}},qyt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:CR(n,i,r)),Byt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Sa(o,{checkOpen:!1})&&!ga(o)).map(({type:i,value:o,stream:s=o})=>CR(s,n,e,{isSameDirection:is.has(i),stopOnExit:i==="native"}))),Vyt=async(t,{signal:e})=>{let[r]=await jyt(t,"error",{signal:e});throw r};var mOe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),kR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=_c();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Hy=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 Gyt}from"stream";import{callbackify as Hyt}from"util";import{finished as hOe}from"stream/promises";var V8=async t=>{if(t!==void 0)try{await G8(t)}catch{}},gOe=async t=>{if(t!==void 0)try{await H8(t)}catch{}},G8=async t=>{await hOe(t,{cleanup:!0,readable:!1,writable:!0})},H8=async t=>{await hOe(t,{cleanup:!0,readable:!0,writable:!1})},mL=async(t,e)=>{if(await t,e)throw e},hL=(t,e,r)=>{r&&!pL(r)?t.destroy(r):e&&t.destroy()};var _Oe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||vo.has(r),{subprocessStdout:a,waitReadableDestroy:c}=W8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=K8(a,s),{read:f,onStdoutDataDone:p}=Y8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),m=new Gyt({read:f,destroy:Hyt(J8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return Z8({subprocessStdout:a,onStdoutDataDone:p,readable:m,subprocess:t}),m},W8=(t,e,r)=>{let n=Uy(t,e),i=kR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},K8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:z8},Y8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=_c(),s=fL({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Wyt(this,s,o)},onStdoutDataDone:o}},Wyt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Z8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await H8(t),await n,await V8(i),await e,r.readable&&r.push(null)}catch(o){await V8(i),yOe(r,o)}},J8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Hy(r,e)&&(yOe(t,n),await mL(e,n))},yOe=(t,e)=>{hL(t,t.readable,e)};import{Writable as Kyt}from"stream";import{callbackify as SOe}from"util";var vOe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=X8(t,r,e),s=new Kyt({...Q8(n,t,i),destroy:SOe(tZ.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return eZ(n,s),s},X8=(t,e,r)=>{let n=PM(t,e),i=kR(r,n,"writableFinal"),o=kR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Q8=(t,e,r)=>({write:Yyt.bind(void 0,t),final:SOe(Zyt.bind(void 0,t,e,r))}),Yyt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Zyt=async(t,e,r)=>{await Hy(r,e)&&(t.writable&&t.end(),await e)},eZ=async(t,e,r)=>{try{await G8(t),e.writable&&e.end()}catch(n){await gOe(r),EOe(e,n)}},tZ=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Hy(r,e),await Hy(n,e)&&(EOe(t,i),await mL(e,i))},EOe=(t,e)=>{hL(t,t.writable,e)};import{Duplex as Jyt}from"stream";import{callbackify as Xyt}from"util";var bOe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||vo.has(r),{subprocessStdout:c,waitReadableDestroy:u}=W8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=X8(t,i,e),{readableEncoding:p,readableObjectMode:m,readableHighWaterMark:h}=K8(c,a),{read:_,onStdoutDataDone:y}=Y8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new Jyt({read:_,...Q8(l,t,d),destroy:Xyt(Qyt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:h,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:m,writableObjectMode:l.writableObjectMode,encoding:p});return Z8({subprocessStdout:c,onStdoutDataDone:y,readable:b,subprocess:t,subprocessStdin:l}),eZ(l,b,c),b},Qyt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([J8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),tZ({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var rZ=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||vo.has(e),s=Uy(t,r),a=fL({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return eSt(a,s,t)},eSt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var wOe=(t,{encoding:e})=>{let r=mOe();t.readable=_Oe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=vOe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=bOe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=rZ.bind(void 0,t,e),t[Symbol.asyncIterator]=rZ.bind(void 0,t,e,{})};var TOe=(t,e)=>{for(let[r,n]of rSt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},tSt=(async()=>{})().constructor.prototype,rSt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(tSt,t)]);var AOe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=oSt(t,e,r),{subprocess:f,promise:p}=aSt({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=dL.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),TOe(f,p),yc.set(f,{options:l,fileDescriptors:d}),f},oSt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=EM(t,e,r),{file:a,commandArguments:c,options:u}=jM(t,e,r),l=sSt(u),d=MIe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},sSt=({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}},aSt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=iSt(...qM(t,e,r))}catch(m){return kIe({error:m,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;nSt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];GIe(c,a,u),WIe(c,r,u);let d={},f=_c();c.kill=aRe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=aOe(c,r),wOe(c,r),OIe(c,r);let p=cSt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},cSt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],m,h,_]=await pOe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=m.map((S,E)=>Cu(S,e,E)),b=Cu(h,e,"all"),T=uSt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:b,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return By(T,n,e)},uSt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?RR({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Sc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):ZM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var gL=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,lSt(n,t[n],i)]));return{...t,...r}},lSt=(t,e,r)=>dSt.has(t)&&xr(e)&&xr(r)?{...e,...r}:r,dSt=new Set(["env",...k5]);var vd=(t,e,r,n)=>{let i=(s,a,c)=>vd(s,a,r,c),o=(...s)=>fSt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},fSt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(xr(o))return i(t,gL(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=pSt({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?wIe(a,c,u):AOe(a,c,u,i)},pSt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=MTe(e)?LTe(e,r):[e,...r],[s,a,c]=lM(...o),u=gL(gL(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var ROe=({file:t,commandArguments:e})=>IOe(t,e),xOe=({file:t,commandArguments:e})=>({...IOe(t,e),isSync:!0}),IOe=(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]=mSt(t);return{file:r,commandArguments:n}},mSt=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(hSt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},hSt=/ +/g;var OOe=(t,e,r)=>{t.sync=e(gSt,r),t.s=t.sync},POe=({options:t})=>COe(t),gSt=({options:t})=>({...COe(t),isSync:!0}),COe=t=>({options:{..._St(t),...t}}),_St=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},kOe={preferLocal:!0};var NOe=vd(()=>({})),j_r=vd(()=>({isSync:!0})),$Oe=vd(ROe),q_r=vd(xOe),B_r=vd(VRe),V_r=vd(POe,{},kOe,OOe),{sendMessage:G_r,getOneMessage:H_r,getEachMessage:W_r,getCancelSignal:K_r}=PIe();var DOe=!1,MOe,ySt=t=>{MOe??=t},LOe=t=>{DOe=!0,ySt(t)},Kn=()=>DOe,ku=()=>MOe,UOe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var NR=null,FOe=t=>(NR&&NR.destroy(),NR=new os({totalAllowedTime:t}),NR),zOe=()=>NR;var os=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&&Kn())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((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await xk({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{Y.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),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 jOe={name:"@netlify/agent-runner-cli",type:"module",version:"2.18.0-smtp.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup","build:bundle":"tsup --no-dts",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build:bundle 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:antigravity":"vitest run test/integration/antigravity.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",prompts:"LOG=0 vitest run --config vitest.prompts.config.js","site:build":"npm run prompts && node site/build.mjs","site:dev":"npm run site:build && netlify dev --dir site/dist",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.7","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.8.0","@opentelemetry/sdk-trace-base":"2.9.0","@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.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.3","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var bSt=vSt(import.meta.url),wSt=Nu.dirname(bSt),TSt=ESt(import.meta.url),Wy=ce("shell"),nZ=new Set,qOe={preferLocal:!0},Et=(t,e,r)=>{let[n,i]=ASt(e,r),o={...qOe,...i},s=NOe(t,n,o);VOe(s,o),WOe(s);let a=r?.idleTimeout;return a&&a>0&&HOe(s,a),s},BOe=(t,e)=>{let r={...qOe,...e},n=$Oe(t,r);return VOe(n,r),WOe(n),e?.idleTimeout&&e.idleTimeout>0&&HOe(n,e.idleTimeout),n},ASt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},VOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ec.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ec.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new nT).pipe(Ec.stdout),t.stderr?.pipe(new nT).pipe(Ec.stderr);return}t.stdout?.pipe(Ec.stdout),t.stderr?.pipe(Ec.stderr)},iZ=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ec.kill(-t.pid,e),Wy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Wy.error("Error killing process:",r),!1}},GOe=t=>iZ(t,"SIGKILL"),HOe=(t,e)=>{let r=null,n=()=>{Wy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),iZ(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Wy.log(`Force killing idle process ${t.pid}`),GOe(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)},WOe=t=>{nZ.add(t);let e=zOe();if(e){let r=e.onTimesUp(()=>{Wy.log(`Global timer expired, killing process ${t.pid}`),iZ(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Wy.log(`Force killing process ${t.pid} after timeout`),GOe(t))},5e3)});t.on("exit",()=>{nZ.delete(t),r()}),t.on("error",()=>{nZ.delete(t),r()})}};function yL(t,e){return!!va(t,e)}function va(t,e){if(!Ec.env.NETLIFY_LOCAL_MODE)try{let i=TSt.resolve(jOe.name),o=Nu.dirname(i);for(;o!==Nu.dirname(o);){let s=Nu.dirname(o);if(Nu.basename(s)==="node_modules"){let a=Nu.join(s,".bin",e);if(_L.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ec.env.NODE_PATH){let i=Nu.join(Ec.env.NODE_PATH,".bin",e);if(_L.existsSync(i))return i}let r=Nu.join(t,"node_modules",".bin",e);if(_L.existsSync(r))return r;let n=Nu.join(wSt,"..","node_modules",".bin",e);if(_L.existsSync(n))return n}var Ky=ce("repo"),tPe="runner-diffs-",oZ=t=>`${tPe}${t}-`,rPe=async t=>{let e=vL.tmpdir(),r;try{r=await Yn.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(tPe)&&!n.startsWith(oZ(t))).map(n=>Yn.rm(Eo.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},KOe=async t=>{let e=RSt("sha256");for await(let r of xSt(t))e.update(r);return e.digest("hex")},YOe=async(t,e)=>t.size===e.size&&await KOe(t.path)===await KOe(e.path),nPe=/.. (.+)?\.log$/,ISt=[nPe],OSt=1,ZOe=/^<<<<<<<( |$)/m,JOe=t=>{let e=t.split(`
|
|
400
400
|
`).reduce((r,n)=>{if(!n)return r;let[i,o,,...s]=n,a=s.join(""),c=i.trim(),u=o.trim();return r[a]?r[a].change=u:r[a]={filePath:a,stage:c,change:u},r},{});return Object.values(e)},PSt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),XOe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return Pn(r?`${e}: ${r}`:e)},CSt=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),QOe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),kSt=(t,e)=>{try{let r=new URL(t),n=new URL(e);return["https:","http:"].includes(n.protocol)&&n.protocol===r.protocol&&n.host===r.host&&QOe(n)===QOe(r)&&n.password!==""}catch{return!1}},ePe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},SL=500,$R=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},Zn=class{constructor(e=process.cwd()){this.cwd=e}getRoot(){return this.root??=this.run(["rev-parse","--show-toplevel"],{stdout:"pipe"}).then(({stdout:e})=>String(e).trim()),this.root}async restorePausedWork(e){let r="restore";try{let n=await this.restorePausedFiles(e);r="stage",await this.stageBuildSetup();let i=await this.getRoot(),o=new Set(n.changedFiles),s=(await this.listIndexEntries(n.deletedFiles,{cwd:i})).filter(({filePath:a})=>!o.has(a));return await this.unstageFiles(n.changedFiles,{cwd:i}),s.length>0&&await Yn.writeFile(await this.getSetupMetadataPath(),JSON.stringify(s)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new $R(r,n)}}run(e,r={}){return Et("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){Ky.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!r){let u=JOe(o);await this.discardSetupOnlyChanges(u)}Ky.info("Changes after processing"),await this.getStatus();let s=await this.getIgnoredPathspecs(o);if(await this.stageFiles(s),await this.excludeUnchangedSetupDescendants(),i=await this.hasStagedChanges(),!i)return{hasChanges:!1,ignored:s};await this.run(["commit","-m","Agent runner [skip ci]"]);let a=await Yn.mkdtemp(Eo.join(vL.tmpdir(),oZ(e.sessionId))),c=await this.writeDiffFiles({config:e,diffDir:a,target:{commit:"HEAD"},ignored:s});return await this.rollbackIfLocal(),c.hasChanges&&Y.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c}async getStatus(){let e=await this.run(["-c","status.relativePaths=true","status","-s"]);return String(e.stdout??"")}async hasAgentChanges(){let e=await this.getStatus();return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
401
401
|
`).filter(i=>ISt.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}}async getCurrentCommitSha(){let{stdout:e}=await this.run(["rev-parse","HEAD"]);return String(e??"").trim()}async reset(){await this.run(["reset","--hard","HEAD"]),await Yn.rm(await this.getSetupMetadataPath(),{force:!0})}async discardSetupOnlyChanges(e){let r=e.filter(n=>n.stage&&!n.change).map(n=>n.filePath);r.length!==0&&await this.run(["restore","--staged","--worktree","--pathspec-from-file=-"],{input:r.join(`
|
|
402
402
|
`)})}async stageBuildSetup(){await Yn.rm(await this.getSetupMetadataPath(),{force:!0});let e=await this.getIgnoredPathspecs();await this.stageFiles(e)}async unstageSetupResolvedConflicts(e){let r=await this.getRoot(),{stdout:n}=await this.run(["diff","--no-relative","--name-only","-z","--text",`-G${ZOe.source}`,e,"HEAD"],{cwd:r,stdout:"pipe"}),i=String(n??"").split("\0").filter(Boolean),o=[];for(let s of i){let a=await Yn.readFile(Eo.join(r,s),"utf8").catch(()=>{});a!==void 0&&!ZOe.test(a)&&o.push(s)}return await this.unstageFiles(o,{cwd:r}),o}getSetupMetadataPath(){return this.setupMetadataPath??=this.getRoot().then(async e=>{let{stdout:r}=await this.run(["rev-parse","--git-path","netlify-agent-runner-setup.json"],{cwd:e,stdout:"pipe"});return Eo.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=SL){let o=e.slice(i,i+SL).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...ePe,...r});for(let a of String(s??"").split("\0").filter(Boolean))n.push({filePath:a.slice(a.indexOf(" ")+1),entry:a})}return n}async excludeUnchangedSetupDescendants(e){let r;try{r=JSON.parse(await Yn.readFile(await this.getSetupMetadataPath(),"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}let i={cwd:await this.getRoot(),env:e},o=new Map((await this.listIndexEntries(r.map(({filePath:a})=>a),i)).map(({filePath:a,entry:c})=>[a,c])),s=r.filter(({filePath:a,entry:c})=>o.get(a)===c);s.length!==0&&await this.run(["update-index","--force-remove","-z","--stdin"],{...i,input:s.map(({filePath:a})=>a).join("\0")})}async getIgnoredPathspecs(e){e||=await this.getStatus();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 e.split(`
|
package/dist/bin.js
CHANGED
|
@@ -602,7 +602,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
602
602
|
`,LF:`
|
|
603
603
|
`,concatBytes:E7},oBt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},aBt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:oBt};import{Buffer as cBt}from"buffer";var OMe=(t,e)=>t?void 0:uBt.bind(void 0,e),uBt=function*(t,e){if(typeof e!="string"&&!In(e)&&!cBt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},PMe=(t,e)=>t?lBt.bind(void 0,e):dBt.bind(void 0,e),lBt=function*(t,e){CMe(t,e),yield e},dBt=function*(t,e){if(CMe(t,e),typeof e!="string"&&!In(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},CMe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
604
604
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
605
|
-
if (condition) { yield value; }`)};import{Buffer as fBt}from"buffer";import{StringDecoder as pBt}from"string_decoder";var OU=(t,e,r)=>{if(r)return;if(t)return{transform:hBt.bind(void 0,new TextEncoder)};let n=new pBt(e);return{transform:mBt.bind(void 0,n),final:gBt.bind(void 0,n)}},hBt=function*(t,e){fBt.isBuffer(e)?yield kl(e):typeof e=="string"?yield t.encode(e):yield e},mBt=function*(t,e){yield In(e)?t.write(e):e},gBt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as kMe}from"util";var w7=kMe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),PU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=yBt}=e[r];for await(let i of n(t))yield*PU(i,e,r+1)},NMe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*_Bt(r,Number(e),t)},_Bt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*PU(n,r,e+1)},$Me=kMe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),yBt=function*(t){yield t};var T7=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},DMe=(t,e)=>[...e.flatMap(r=>[...zm(r,t,0)]),...Dx(t)],zm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=vBt}=e[r];for(let i of n(t))yield*zm(i,e,r+1)},Dx=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*SBt(r,Number(e),t)},SBt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*zm(n,r,e+1)},vBt=function*(t){yield t};var R7=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=MMe(t,o,s),u=jm(e),l=jm(r),d=u?w7.bind(void 0,PU,a):T7.bind(void 0,zm),f=u||l?w7.bind(void 0,NMe,a):T7.bind(void 0,Dx),p=u||l?$Me.bind(void 0,a):void 0;return{stream:new EBt({writableObjectMode:n,writableHighWaterMark:LMe(n),readableObjectMode:i,readableHighWaterMark:LMe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},CU=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=MMe(o,r,a);t=DMe(c,t)}return t},MMe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:OMe(n,a)},OU(r,o,n),xU(r,s,n,c),{transform:t,final:e},{transform:PMe(i,a)},xMe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var UMe=(t,e)=>{for(let r of bBt(t))wBt(t,r,e)},bBt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),wBt=(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 ${Ff[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>TBt(a,n));r.input=Rx(o)},TBt=(t,e)=>{let r=CU(t,e,"utf8",!0);return RBt(r),Rx(r)},RBt=t=>{let e=t.find(r=>typeof r!="string"&&!In(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 OBt,appendFileSync as PBt}from"fs";var kU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sv(r,n)&&!so.has(e)&&ABt(n)&&(t.some(({type:i,value:s})=>i==="native"&&IBt.has(s))||t.every(({type:i})=>na.has(i))),ABt=t=>t===1||t===2,IBt=new Set(["pipe","overlapped"]),FMe=async(t,e,r,n)=>{for await(let i of t)xBt(e)||zMe(i,r,n)},jMe=(t,e,r)=>{for(let n of t)zMe(n,e,r)},xBt=t=>t._readableState.pipes.length>0,zMe=(t,e,r)=>{let n=G1(t);uu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var qMe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>CBt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},CBt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=BLe(t,s,d),p=kl(f),{stdioItems:h,objectMode:m}=e[r],g=kBt([p],h,c,n),{serializedResult:y,finalResult:v=y}=NBt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});$Bt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&DBt(y,h,i),S}catch(_){return n.error=_,S}},kBt=(t,e,r,n)=>{try{return CU(t,e,r,!1)}catch(i){return n.error=i,t}},NBt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Rx(t)};let o=n$e(t,r);return n[s]?{serializedResult:o,finalResult:b7(o,!i[s],e)}:{serializedResult:o}},$Bt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!kU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=b7(t,!1,o);try{jMe(a,e,n)}catch(c){r.error??=c}},DBt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>AU.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?PBt(n,t):(r.add(s),OBt(n,t))}};var BMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Dl(e,r,"all")]:Array.isArray(e)?[Dl(t,r,"all"),...e]:In(t)&&In(e)?CQ([t,e]):`${t}${e}`};import{once as A7}from"events";var VMe=async(t,e)=>{let[r,n]=await LBt(t);return e.isForcefullyTerminated??=!1,[r,n]},LBt=async t=>{let[e,r]=await Promise.allSettled([A7(t,"spawn"),A7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?HMe(t):r.value},HMe=async t=>{try{return await A7(t,"exit")}catch{return HMe(t)}},GMe=async t=>{let[e,r]=await t;if(!MBt(e,r)&&I7(e,r))throw new tc;return[e,r]},MBt=(t,e)=>t===void 0&&e===void 0,I7=(t,e)=>t!==0||e!==null;var WMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=UBt(t,e,r),o=s?.code==="ETIMEDOUT",a=qLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},UBt=(t,e,r)=>t!==void 0?t:I7(e,r)?new tc:void 0;var KMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=jBt(t,e,r),d=BBt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return Ov(d,c,u)},jBt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=K1(t,e,r),a=zBt(r),{file:c,commandArguments:u,options:l}=hU(t,e,a);qBt(l);let d=TMe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},zBt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,qBt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&NU("ipcInput"),t&&NU("ipc: true"),r&&NU("detached: true"),n&&NU("cancelSignal")},NU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},BBt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=VBt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=WMe(c,r),{output:h,error:m=u}=qMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((v,S)=>Dl(v,r,S)),y=Dl(BMe(h,r),r,"all");return GBt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},VBt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{UMe(s,r);let a=HBt(r);return FBt(...mU(t,e,a))}catch(a){return xv({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},HBt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:bU(e)}),GBt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?wU({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):$x({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as NVt}from"events";import{spawn as $Vt}from"child_process";import QMe from"process";import{once as x7,on as WBt}from"events";var YMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(bv({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:cU(t)}),KBt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),KBt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{iU(e,i);let s=Uf(t,e,r),o=new AbortController;try{return await Promise.race([YBt(s,n,o),JBt(s,r,o),ZBt(s,r,o)])}catch(a){throw wv(t),a}finally{o.abort(),sU(e,i)}},YBt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await x7(t,"message",{signal:r});return n}for await(let[n]of WBt(t,"message",{signal:r}))if(e(n))return n},JBt=async(t,e,{signal:r})=>{await x7(t,"disconnect",{signal:r}),DDe(e)},ZBt=async(t,e,{signal:r})=>{let[n]=await x7(t,"strict:error",{signal:r});throw tU(n,e)};import{once as ZMe,on as XBt}from"events";var XMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>O7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),O7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{bv({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:cU(t)}),iU(e,s);let o=Uf(t,e,r),a=new AbortController,c={};return QBt(t,o,a),e2t({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),t2t({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},QBt=async(t,e,r)=>{try{await ZMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},e2t=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ZMe(t,"strict:error",{signal:r.signal});n.error=tU(i,e),r.abort()}catch{}},t2t=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of XBt(r,"message",{signal:s.signal}))JMe(o),yield c}catch{JMe(o)}finally{s.abort(),sU(e,a),n||wv(t),i&&await t}},JMe=({error:t})=>{if(t)throw t};var e1e=(t,{ipc:e})=>{Object.assign(t,r1e(t,!1,e))},t1e=()=>{let t=QMe,e=!0,r=QMe.channel!==void 0;return{...r1e(t,e,r),getCancelSignal:cLe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},r1e=(t,e,r)=>({sendMessage:fU.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:YMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:XMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as r2t}from"child_process";import{PassThrough as n2t,Readable as i2t,Writable as s2t,Duplex as o2t}from"stream";var n1e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{S7(n);let a=new r2t;a2t(a,n),Object.assign(a,{readable:c2t,writable:u2t,duplex:l2t});let c=xv({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=d2t(c,o,i);return{subprocess:a,promise:u}},a2t=(t,e)=>{let r=Lx(),n=Lx(),i=Lx(),s=Array.from({length:e.length-3},Lx),o=Lx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Lx=()=>{let t=new n2t;return t.end(),t},c2t=()=>new i2t({read(){}}),u2t=()=>new s2t({write(){}}),l2t=()=>new o2t({read(){},write(){}}),d2t=async(t,e,r)=>Ov(t,e,r);import{createReadStream as i1e,createWriteStream as s1e}from"fs";import{Buffer as f2t}from"buffer";import{Readable as Mx,Writable as p2t,Duplex as h2t}from"stream";var a1e=(t,e)=>IU(m2t,t,e,!1),Ux=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ff[t]}.`)},o1e={fileNumber:Ux,generator:R7,asyncGenerator:R7,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:h2t.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},m2t={input:{...o1e,fileUrl:({value:t})=>({stream:i1e(t)}),filePath:({value:{file:t}})=>({stream:i1e(t)}),webStream:({value:t})=>({stream:Mx.fromWeb(t)}),iterable:({value:t})=>({stream:Mx.from(t)}),asyncIterable:({value:t})=>({stream:Mx.from(t)}),string:({value:t})=>({stream:Mx.from(t)}),uint8Array:({value:t})=>({stream:Mx.from(f2t.from(t))})},output:{...o1e,fileUrl:({value:t})=>({stream:s1e(t)}),filePath:({value:{file:t,append:e}})=>({stream:s1e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:p2t.fromWeb(t)}),iterable:Ux,asyncIterable:Ux,string:Ux,uint8Array:Ux}};import{on as g2t,once as c1e}from"events";import{PassThrough as _2t,getDefaultHighWaterMark as y2t}from"stream";import{finished as d1e}from"stream/promises";function qm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)C7(i);let e=t.some(({readableObjectMode:i})=>i),r=S2t(t,e),n=new P7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var S2t=(t,e)=>{if(t.length===0)return y2t(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},P7=class extends _2t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(C7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=v2t(this,this.#e,this.#s);let r=w2t({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(C7(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)}},v2t=async(t,e,r)=>{$U(t,u1e);let n=new AbortController;try{await Promise.race([E2t(t,n),b2t(t,e,r,n)])}finally{n.abort(),$U(t,-u1e)}},E2t=async(t,{signal:e})=>{try{await d1e(t,{signal:e,cleanup:!0})}catch(r){throw f1e(t,r),r}},b2t=async(t,e,r,{signal:n})=>{for await(let[i]of g2t(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},C7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},w2t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{$U(t,l1e);let a=new AbortController;try{await Promise.race([T2t(s,e,a),R2t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),A2t({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),$U(t,-l1e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?k7(t):I2t(t))},T2t=async(t,e,{signal:r})=>{try{await t,r.aborted||k7(e)}catch(n){r.aborted||f1e(e,n)}},R2t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await d1e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;p1e(o)?i.add(e):h1e(t,o)}},A2t=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await c1e(t,i,{signal:s}),!t.readable)return c1e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},I2t=t=>{t.writable&&t.end()},f1e=(t,e)=>{p1e(e)?k7(t):h1e(t,e)},p1e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",k7=t=>{(t.readable||t.writable)&&t.destroy()},h1e=(t,e)=>{t.destroyed||(t.once("error",x2t),t.destroy(e))},x2t=()=>{},$U=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},u1e=2,l1e=1;import{finished as m1e}from"stream/promises";var Cv=(t,e)=>{t.pipe(e),O2t(t,e),P2t(t,e)},O2t=async(t,e)=>{if(!(ec(t)||ec(e))){try{await m1e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}N7(e)}},N7=t=>{t.writable&&t.end()},P2t=async(t,e)=>{if(!(ec(t)||ec(e))){try{await m1e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}$7(t)}},$7=t=>{t.readable&&t.destroy()};var g1e=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>na.has(c)))C2t(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!na.has(c)))N2t({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:qm(s);Cv(o,i)}},C2t=(t,e,r,n)=>{r==="output"?Cv(t.stdio[n],e):Cv(e,t.stdio[n]);let i=k2t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},k2t=["stdin","stdout","stderr"],N2t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;$2t(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},$2t=(t,{signal:e})=>{ec(t)&&Um(t,D2t,e)},D2t=2;import{addAbortListener as U2t}from"events";var Bm=[];Bm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var DU=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",D7=Symbol.for("signal-exit emitter"),L7=globalThis,L2t=Object.defineProperty.bind(Object),M7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(L7[D7])return L7[D7];L2t(L7,D7,{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 s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},LU=class{},M2t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),U7=class extends LU{onExit(){return()=>{}}load(){}unload(){}},F7=class extends LU{#e=j7.platform==="win32"?"SIGINT":"SIGHUP";#r=new M7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Bm)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!DU(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Bm)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.#o&&(this.#o=!1,Bm.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.#s,this.#r.count-=1)}#a(e){return DU(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&DU(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)}},j7=globalThis.process,{onExit:_1e,load:hHr,unload:mHr}=M2t(DU(j7)?new F7(j7):new U7);var y1e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=_1e(()=>{t.kill()});U2t(n,()=>{i()})};var v1e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=W1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=F2t(r,n,i),{sourceStream:d,sourceError:f}=z2t(t,u),{options:p,fileDescriptors:h}=du.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},F2t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=j2t(t,e,...r),a=nU(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},j2t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(S1e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||OQ(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,s,o]=M1(r,...n);return{destination:e(S1e)(i,s,o),pipeOptions:o}}if(du.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}`)},S1e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),z2t=(t,e)=>{try{return{sourceStream:Tv(t,e)}}catch(r){return{sourceError:r}}};var b1e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=q2t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw z7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},q2t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return $7(t),n;if(e!==void 0)return N7(r),e},z7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>xv({error:t,command:E1e,escapedCommand:E1e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),E1e="source.pipe(destination)";var w1e=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as B2t}from"stream/promises";var T1e=(t,e,r)=>{let n=MU.has(e)?H2t(t,e):V2t(t,e);return Um(t,W2t,r.signal),Um(e,K2t,r.signal),G2t(e),n},V2t=(t,e)=>{let r=qm([t]);return Cv(r,e),MU.set(e,r),r},H2t=(t,e)=>{let r=MU.get(e);return r.add(t),r},G2t=async t=>{try{await B2t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}MU.delete(t)},MU=new WeakMap,W2t=2,K2t=1;import{aborted as Y2t}from"util";var R1e=(t,e)=>t===void 0?[]:[J2t(t,e)],J2t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Y2t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw z7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var UU=(t,...e)=>{if(rn(e[0]))return UU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=v1e(t,...e),i=Z2t({...n,destination:r});return i.pipe=UU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Z2t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=X2t(t,i);b1e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=T1e(e,s,d);return await Promise.race([w1e(l),...R1e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},X2t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as sVt}from"timers/promises";import{on as Q2t}from"events";import{getDefaultHighWaterMark as eVt}from"stream";var FU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return tVt(e,o),I1e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},tVt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},q7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;rVt(e,o,t);let a=t.readableObjectMode&&!s;return I1e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},rVt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},I1e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=Q2t(t,"data",{signal:e.signal,highWaterMark:A1e,highWatermark:A1e});return nVt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},B7=eVt(!0),A1e=B7,nVt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=iVt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*zm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Dx(a)}},iVt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[OU(t,r,!e),xU(t,i,!n,{})].filter(Boolean);var x1e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=oVt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([aVt(t),d]);return}let f=v7(c,r),p=q7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([cVt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},oVt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!kU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=q7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await FMe(a,t,r,s)},aVt=async t=>{await sVt(),t.readableFlowing===null&&t.resume()},cVt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await SU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await vU(r,{maxBuffer:s})):await Iv(r,{maxBuffer:s})}catch(a){return O1e(FLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},V7=async t=>{try{return await t}catch(e){return O1e(e)}},O1e=({bufferedData:t})=>t$e(t)?new Uint8Array(t):t;import{finished as uVt}from"stream/promises";var Fx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=lVt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],uVt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||pVt(a,e,r,n)}finally{o.abort()}},lVt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&dVt(t,r,n),n},dVt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{fVt(e,r),n.call(t,...i)}},fVt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},pVt=(t,e,r,n)=>{if(!hVt(t,e,r,n))throw t},hVt=(t,e,r,n=!0)=>r.propagating?P1e(t)||jU(t):(r.propagating=!0,H7(r,e)===n?P1e(t):jU(t)),H7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",jU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",P1e=t=>t?.code==="EPIPE";var C1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>G7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),G7=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=Fx(t,e,u);if(H7(u,e)){await l;return}let[d]=await Promise.all([x1e({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var k1e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?qm([t,e].filter(Boolean)):void 0,N1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>G7({...mVt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:gVt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),mVt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},gVt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as _Vt}from"events";var $1e=t=>Sv(t,"ipc"),D1e=(t,e)=>{let r=G1(t);uu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var L1e=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=$1e(s),a=Nl(e,"ipc"),c=Nl(r,"ipc");for await(let u of O7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(jLe(t,i,c),i.push(u)),o&&D1e(u,s);return i},M1e=async(t,e)=>(await Promise.allSettled([t]),e);var U1e=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:y})=>{let v=VMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},_=C1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=N1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=L1e({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=yVt(m,t,S),x=SVt(h,S);try{return await Promise.race([Promise.all([{},GMe(v),Promise.all(_),w,R,yLe(t,d),...T,...x]),g,vVt(t,y),...pLe(t,s,f,y),...$De({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...dLe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},v,Promise.all(_.map(O=>V7(O))),V7(w),M1e(R,b),Promise.allSettled(T),Promise.allSettled(x)])}},yVt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Fx(n,i,r)),SVt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>nc(s,{checkOpen:!1})&&!ec(s)).map(({type:i,value:s,stream:o=s})=>Fx(o,n,e,{isSameDirection:na.has(i),stopOnExit:i==="native"}))),vVt=async(t,{signal:e})=>{let[r]=await _Vt(t,"error",{signal:e});throw r};var F1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),jx=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=lu();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},kv=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 EVt}from"stream";import{callbackify as bVt}from"util";import{finished as j1e}from"stream/promises";var W7=async t=>{if(t!==void 0)try{await K7(t)}catch{}},z1e=async t=>{if(t!==void 0)try{await Y7(t)}catch{}},K7=async t=>{await j1e(t,{cleanup:!0,readable:!1,writable:!0})},Y7=async t=>{await j1e(t,{cleanup:!0,readable:!0,writable:!1})},zU=async(t,e)=>{if(await t,e)throw e},qU=(t,e,r)=>{r&&!jU(r)?t.destroy(r):e&&t.destroy()};var q1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||so.has(r),{subprocessStdout:a,waitReadableDestroy:c}=J7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=Z7(a,o),{read:f,onStdoutDataDone:p}=X7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new EVt({read:f,destroy:bVt(eee.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return Q7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},J7=(t,e,r)=>{let n=Tv(t,e),i=jx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Z7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:B7},X7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=lu(),o=FU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){wVt(this,o,s)},onStdoutDataDone:s}},wVt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Q7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Y7(t),await n,await W7(i),await e,r.readable&&r.push(null)}catch(s){await W7(i),B1e(r,s)}},eee=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await kv(r,e)&&(B1e(t,n),await zU(e,n))},B1e=(t,e)=>{qU(t,t.readable,e)};import{Writable as TVt}from"stream";import{callbackify as V1e}from"util";var H1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=tee(t,r,e),o=new TVt({...ree(n,t,i),destroy:V1e(iee.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return nee(n,o),o},tee=(t,e,r)=>{let n=nU(t,e),i=jx(r,n,"writableFinal"),s=jx(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},ree=(t,e,r)=>({write:RVt.bind(void 0,t),final:V1e(AVt.bind(void 0,t,e,r))}),RVt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},AVt=async(t,e,r)=>{await kv(r,e)&&(t.writable&&t.end(),await e)},nee=async(t,e,r)=>{try{await K7(t),e.writable&&e.end()}catch(n){await z1e(r),G1e(e,n)}},iee=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await kv(r,e),await kv(n,e)&&(G1e(t,i),await zU(e,i))},G1e=(t,e)=>{qU(t,t.writable,e)};import{Duplex as IVt}from"stream";import{callbackify as xVt}from"util";var W1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||so.has(r),{subprocessStdout:c,waitReadableDestroy:u}=J7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=tee(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Z7(c,a),{read:g,onStdoutDataDone:y}=X7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new IVt({read:g,...ree(l,t,d),destroy:xVt(OVt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return Q7({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),nee(l,v,c),v},OVt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([eee({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),iee({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var see=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||so.has(e),o=Tv(t,r),a=FU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return PVt(a,o,t)},PVt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var K1e=(t,{encoding:e})=>{let r=F1e();t.readable=q1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=H1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=W1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=see.bind(void 0,t,e),t[Symbol.asyncIterator]=see.bind(void 0,t,e,{})};var Y1e=(t,e)=>{for(let[r,n]of kVt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},CVt=(async()=>{})().constructor.prototype,kVt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(CVt,t)]);var J1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=DVt(t,e,r),{subprocess:f,promise:p}=MVt({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=UU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Y1e(f,p),du.set(f,{options:l,fileDescriptors:d}),f},DVt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=K1(t,e,r),{file:a,commandArguments:c,options:u}=hU(t,e,r),l=LVt(u),d=a1e(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},LVt=({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}},MVt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=$Vt(...mU(t,e,r))}catch(h){return n1e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;NVt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];g1e(c,a,u),y1e(c,r,u);let d={},f=lu();c.kill=kDe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=k1e(c,r),K1e(c,r),e1e(c,r);let p=UVt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},UVt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,g]=await U1e({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((_,w)=>Dl(_,e,w)),v=Dl(m,e,"all"),S=FVt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ov(S,n,e)},FVt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?$x({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof fu,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):wU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var BU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,jVt(n,t[n],i)]));return{...t,...r}},jVt=(t,e,r)=>zVt.has(t)&&rn(e)&&rn(r)?{...e,...r}:r,zVt=new Set(["env",...DQ]);var jf=(t,e,r,n)=>{let i=(o,a,c)=>jf(o,a,r,c),s=(...o)=>qVt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},qVt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(rn(s))return i(t,BU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=BVt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?KMe(a,c,u):J1e(a,c,u,i)},BVt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=a$e(e)?c$e(e,r):[e,...r],[o,a,c]=M1(...s),u=BU(BU(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var Z1e=({file:t,commandArguments:e})=>Q1e(t,e),X1e=({file:t,commandArguments:e})=>({...Q1e(t,e),isSync:!0}),Q1e=(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]=VVt(t);return{file:r,commandArguments:n}},VVt=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(HVt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},HVt=/ +/g;var eUe=(t,e,r)=>{t.sync=e(GVt,r),t.s=t.sync},tUe=({options:t})=>rUe(t),GVt=({options:t})=>({...rUe(t),isSync:!0}),rUe=t=>({options:{...WVt(t),...t}}),WVt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},nUe={preferLocal:!0};var iUe=jf(()=>({})),i6r=jf(()=>({isSync:!0})),sUe=jf(Z1e),s6r=jf(X1e),o6r=jf(mLe),a6r=jf(tUe,{},nUe,eUe),{sendMessage:c6r,getOneMessage:u6r,getEachMessage:l6r,getCancelSignal:d6r}=t1e();import{Transform as KVt}from"stream";var YVt=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function JVt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...YVt])]}function ZVt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function XVt(){let e=JVt().map(r=>process.env[r]).filter(r=>!(!r||ZVt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function vi(t){if(typeof t!="string")return t;let e=XVt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(QVt(n),"g");r=r.replace(i,"******")}),r}function QVt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var zx=class extends KVt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=vi(i);n(null,s)}},VU=Symbol("maskedWrite");function oUe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[VU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?vi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[VU]=!0,process.stdout.write=r}if(!process.stderr.write[VU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?vi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[VU]=!0,process.stderr.write=r}}}var aUe=!1,cUe,oee=t=>{cUe??=t},uUe=t=>{aUe=!0,oee(t)},nn=()=>aUe,ia=()=>cUe,lUe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var qx=null,dUe=t=>(qx&&qx.destroy(),qx=new sa({totalAllowedTime:t}),qx),fUe=()=>qx;var sa=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&&nn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await zD({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var pUe={name:"@netlify/agent-runner-cli",type:"module",version:"2.18.0-smtp-3.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","build:bundle":"tsup --no-dts",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build:bundle 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:antigravity":"vitest run test/integration/antigravity.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",prompts:"LOG=0 vitest run --config vitest.prompts.config.js","site:build":"npm run prompts && node site/build.mjs","site:dev":"npm run site:build && netlify dev --dir site/dist",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.7","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.8.0","@opentelemetry/sdk-trace-base":"2.9.0","@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.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.3","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var nHt=tHt(import.meta.url),iHt=Ll.dirname(nHt),sHt=rHt(import.meta.url),Nv=he("shell"),aee=new Set,hUe={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=oHt(e,r),s={...hUe,...i},o=iUe(t,n,s);gUe(o,s),SUe(o);let a=r?.idleTimeout;return a&&a>0&&yUe(o,a),o},mUe=(t,e)=>{let r={...hUe,...e},n=sUe(t,r);return gUe(n,r),SUe(n),e?.idleTimeout&&e.idleTimeout>0&&yUe(n,e.idleTimeout),n},oHt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},gUe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||hu.env.NETLIFY_LOCAL_QUIET==="true")return;if(hu.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new zx).pipe(hu.stdout),t.stderr?.pipe(new zx).pipe(hu.stderr);return}t.stdout?.pipe(hu.stdout),t.stderr?.pipe(hu.stderr)},cee=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(hu.kill(-t.pid,e),Nv.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Nv.error("Error killing process:",r),!1}},_Ue=t=>cee(t,"SIGKILL"),yUe=(t,e)=>{let r=null,n=()=>{Nv.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),cee(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nv.log(`Force killing idle process ${t.pid}`),_Ue(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},SUe=t=>{aee.add(t);let e=fUe();if(e){let r=e.onTimesUp(()=>{Nv.log(`Global timer expired, killing process ${t.pid}`),cee(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nv.log(`Force killing process ${t.pid} after timeout`),_Ue(t))},5e3)});t.on("exit",()=>{aee.delete(t),r()}),t.on("error",()=>{aee.delete(t),r()})}};function mu(t,e){if(!hu.env.NETLIFY_LOCAL_MODE)try{let i=sHt.resolve(pUe.name),s=Ll.dirname(i);for(;s!==Ll.dirname(s);){let o=Ll.dirname(s);if(Ll.basename(o)==="node_modules"){let a=Ll.join(o,".bin",e);if(HU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(hu.env.NODE_PATH){let i=Ll.join(hu.env.NODE_PATH,".bin",e);if(HU.existsSync(i))return i}let r=Ll.join(t,"node_modules",".bin",e);if(HU.existsSync(r))return r;let n=Ll.join(iHt,"..","node_modules",".bin",e);if(HU.existsSync(n))return n}import Wq from"process";import{fileURLToPath as AQt}from"url";import{createRequire as IQt}from"module";import zO from"path";import{readFileSync as xQt}from"fs";var aHt="__netlify__getTracer",cHt="__netlify__shutdownTracers",Lt=(t,e)=>globalThis[aHt]?.(t,e),vUe=async()=>globalThis[cHt]?.();function Bx(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{createHash as pQt}from"crypto";import{setTimeout as hQt}from"timers/promises";Fe();import rGt from"process";Fe();var uHt=(t,e)=>{e.recordException(t),e.setStatus({code:Fn.ERROR})};var Ml=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=EUe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>bUe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=EUe(r,n,i),c=this._tracer.startSpan(e,s,o);return bUe(c,s,a)}};function EUe(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??ir.active(),{opts:n,ctx:i,fn:s}}function bUe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:uHt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Fe();var Dv=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var lee=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=kUe(e),n._asyncAttributesPending=e.filter(([i,s])=>Dv(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Dv(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=kUe(this._rawAttributes),this._schemaUrl=lHt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,Dv(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ge.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Dv(n)){ge.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=dHt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function dee(t,e){return lee.FromAttributeList(Object.entries(t),e)}function kUe(t){return t.map(([e,r])=>Dv(r)?[e,r.catch(n=>{ge.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function lHt(t){if(typeof t=="string"||t===void 0)return t;ge.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function dHt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ge.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Fe();var Vx=class{emit(e){}enabled(){return!1}},NUe=new Vx;var Hx=Symbol.for("io.opentelemetry.js.api.logs"),Lv=globalThis;function $Ue(t,e,r){return n=>n===t?e:r}var fee=1;var pee=class{getLogger(e,r,n){return new Vx}},KU=new pee;var YU=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):NUe}};var Gx=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new YU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:KU}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var JU=class t{constructor(){this._proxyLoggerProvider=new Gx}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Lv[Hx]?this.getLoggerProvider():(Lv[Hx]=$Ue(fee,e,KU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Lv[Hx])===null||e===void 0?void 0:e.call(Lv,fee))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Lv[Hx],this._proxyLoggerProvider=new Gx}};var DUe=JU.getInstance();function LUe(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function MUe(t){t.forEach(e=>e.disable())}function hee(t){let e=t.tracerProvider||jt.getTracerProvider(),r=t.meterProvider||VA.getMeterProvider(),n=t.loggerProvider||DUe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return LUe(i,e,r,n),()=>{MUe(i)}}Fe();var fHt=Un("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function UUe(t){return t.getValue(fHt)===!0}var Mv;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Mv||(Mv={}));Fe();var mee="[_0-9a-z-*/]",pHt=`[a-z]${mee}{0,255}`,hHt=`[a-z0-9]${mee}{0,240}@[a-z]${mee}{0,13}`,mHt=new RegExp(`^(?:${pHt}|${hHt})$`),gHt=/^[ -~]{0,255}[!-~]$/,_Ht=/,|=/;function gee(t){return mHt.test(t)}function _ee(t){return gHt.test(t)&&!_Ht.test(t)}var yHt=32,FUe=512,jUe=",",zUe="=",ZU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!gee(e)||!_ee(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>FUe)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=jUe+e),e=`${n[0]}${zUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(jUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(zUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!gee(a)||!_ee(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>FUe)&&(r.set(a,c),n=u,r.size>=yHt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var XU="traceparent",QU="tracestate",SHt="00",vHt="(?!ff)[\\da-f]{2}",EHt="(?![0]{32})[\\da-f]{32}",bHt="(?![0]{16})[\\da-f]{16}",wHt="[\\da-f]{2}",THt=new RegExp(`^\\s?(${vHt})-(${EHt})-(${bHt})-(${wHt})(-.*)?\\s?$`);function qUe(t){let e=THt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var zf=class{inject(e,r,n){let i=jt.getSpanContext(e);if(!i||UUe(e)||!Rs(i))return;let s=`${SHt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Cr.NONE).toString(16)}`;n.set(r,XU,s),i.traceState&&n.set(r,QU,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,XU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=qUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,QU);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new ZU(typeof c=="string"?c:void 0)}return jt.setSpanContext(e,o)}fields(){return[XU,QU]}};var eF=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var Wx=class{_isCalled=!1;_deferred=new eF;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var WF=bn(ste(),1);Fe();var jze=t=>{throw TypeError(t)},ute=(t,e,r)=>e.has(t)||jze("Cannot "+r),GF=(t,e,r)=>(ute(t,e,"read from private field"),r?r.call(t):e.get(t)),ote=(t,e,r)=>e.has(t)?jze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Mze=(t,e,r,n)=>(ute(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),tGt=(t,e,r)=>(ute(t,e,"access private method"),r),Uze="__netlify__getTracer",nGt="__netlify__shutdownTracers",iGt="__nfOTLPTrace",f0,p0,cte,zze,sGt=class{constructor(){ote(this,cte),ote(this,f0),ote(this,p0),Mze(this,f0,new Wx(tGt(this,cte,zze),this)),Mze(this,p0,ge.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(GF(this,p0).debug(`export ${t.length.toString()} spans`),GF(this,f0).isCalled){e({code:Mv.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(iGt,JSON.stringify(oGt(t))),e({code:Mv.SUCCESS})}shutdown(){return GF(this,f0).call()}};f0=new WeakMap;p0=new WeakMap;cte=new WeakSet;zze=function(){return GF(this,p0).debug("Shutting down"),Promise.resolve()};function oGt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:HF(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||Ka.SERVER,startTimeUnixNano:ate(e.startTime),endTimeUnixNano:ate(e.endTime),attributes:HF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:ate(n.time),attributes:HF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:HF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function HF(t){return Object.keys(t).map(e=>qze(e,t[e]))}function qze(t,e){return{key:t,value:Bze(e)}}function Bze(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(Bze)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>qze(r,n))}}:{}}function ate(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var Fze={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},Vze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Uze))return;let e=rGt.version.slice(1),r=dee({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[aGt()],i=new WF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new zf});let s=t.instrumentations??[];hee({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,Uze,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Ml(jt.getTracer(a,c)):new Ml(jt.getTracer(Fze.name,Fze.version))}}),Object.defineProperty(globalThis,nGt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},aGt=()=>new WF.SimpleSpanProcessor(new sGt);Fe();var Yv=bn(ste(),1);Fe();import*as KF from"diagnostics_channel";var Hze=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Fn.ERROR:Fn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Ml?t:new Ml(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){KF.subscribe(t,e);let r=()=>KF.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:Ka.CLIENT},ir.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Fn.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var NWe=bn(OWe(),1);Fe();ioe();var PWe=0;var dQt=3*1024*1024,fQt=t=>LO.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Hq=class{constructor(e,r=dQt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=fQt(c);i.length&&s+u>this.maxBytes&&(n.push(i),i=[],s=0),i.push(c),s+=u}i.length&&n.push(i);let o,a=c=>{if(c===n.length){r(o??{code:PWe});return}this.inner.export(n[c],u=>{u.code!==PWe&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var YE=he("tracing"),CWe=8e3,mQt=5e3,kWe=t=>t.length>CWe?`${t.slice(0,CWe)}\u2026`:t,JE={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},gQt=Math.ceil(JE.maxQueueSize/JE.maxExportBatchSize)+1,$We=0,aoe=()=>$We,_Qt=t=>{let e=0,r=new Hq(new NWe.OTLPTraceExporter({url:t,concurrencyLimit:gQt})),n=new Yv.BatchSpanProcessor({export:(i,s)=>{e=Math.max(0,e-i.length),r.export(i,s)},shutdown:()=>r.shutdown(),forceFlush:()=>r.forceFlush()},JE);return{onStart:(i,s)=>n.onStart(i,s),onEnd:i=>{i.spanContext().traceFlags&Cr.SAMPLED&&(e>=JE.maxQueueSize?$We+=1:e+=1),n.onEnd(i)},forceFlush:()=>n.forceFlush(),shutdown:()=>n.shutdown()}},Tg=async(t=mQt)=>{try{let e=Symbol("timed out");await Promise.race([vUe(),hQt(t,e)])===e&&YE.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){YE.warn("Failed to flush tracers on shutdown",e)}},DWe=async(t,e,r)=>{if(!Lt()){let n=[new Yv.SimpleSpanProcessor(new ooe),_Qt(r.exporterUrl)];await Vze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new Hze({skipHeaders:!0})]})}return r.traceparent?(Zi.setGlobalPropagator(new zf),Zi.extract(ir.active(),{traceparent:r.traceparent,isRemote:!0})):ir.active()};function gr(t,e,r){return YE.log(`\u23F3 TRACE: ${e} starting...`),Bx(t,e,r)}var ooe=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";YE.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&YE.log(` \u274C Error: ${e.status.message}`)}};function coe(){return He().captureLlmContentEnabled}function LWe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function Gq(t,e,r){let n={role:t,parts:[{type:"text",content:vi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var yQt=new Set([X.Task,X.RunCommand,X.Explore,X.FileRead,X.FileWrite,X.Notebook,X.Web,X.Todo,X.Skill,X.Tool,X.Memorize,X.Deployment,X.SiteGeneration]),SQt=new Set(["claude","codex"]),vQt=(t,e)=>JSON.stringify([t,e.operation,e.path??null]),EQt=t=>pQt("sha256").update(t.map(e=>Buffer.from(e)).sort(Buffer.compare).join(`
|
|
605
|
+
if (condition) { yield value; }`)};import{Buffer as fBt}from"buffer";import{StringDecoder as pBt}from"string_decoder";var OU=(t,e,r)=>{if(r)return;if(t)return{transform:hBt.bind(void 0,new TextEncoder)};let n=new pBt(e);return{transform:mBt.bind(void 0,n),final:gBt.bind(void 0,n)}},hBt=function*(t,e){fBt.isBuffer(e)?yield kl(e):typeof e=="string"?yield t.encode(e):yield e},mBt=function*(t,e){yield In(e)?t.write(e):e},gBt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as kMe}from"util";var w7=kMe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),PU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=yBt}=e[r];for await(let i of n(t))yield*PU(i,e,r+1)},NMe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*_Bt(r,Number(e),t)},_Bt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*PU(n,r,e+1)},$Me=kMe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),yBt=function*(t){yield t};var T7=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},DMe=(t,e)=>[...e.flatMap(r=>[...zm(r,t,0)]),...Dx(t)],zm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=vBt}=e[r];for(let i of n(t))yield*zm(i,e,r+1)},Dx=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*SBt(r,Number(e),t)},SBt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*zm(n,r,e+1)},vBt=function*(t){yield t};var R7=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=MMe(t,o,s),u=jm(e),l=jm(r),d=u?w7.bind(void 0,PU,a):T7.bind(void 0,zm),f=u||l?w7.bind(void 0,NMe,a):T7.bind(void 0,Dx),p=u||l?$Me.bind(void 0,a):void 0;return{stream:new EBt({writableObjectMode:n,writableHighWaterMark:LMe(n),readableObjectMode:i,readableHighWaterMark:LMe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},CU=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=MMe(o,r,a);t=DMe(c,t)}return t},MMe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:OMe(n,a)},OU(r,o,n),xU(r,s,n,c),{transform:t,final:e},{transform:PMe(i,a)},xMe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var UMe=(t,e)=>{for(let r of bBt(t))wBt(t,r,e)},bBt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),wBt=(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 ${Ff[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>TBt(a,n));r.input=Rx(o)},TBt=(t,e)=>{let r=CU(t,e,"utf8",!0);return RBt(r),Rx(r)},RBt=t=>{let e=t.find(r=>typeof r!="string"&&!In(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 OBt,appendFileSync as PBt}from"fs";var kU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sv(r,n)&&!so.has(e)&&ABt(n)&&(t.some(({type:i,value:s})=>i==="native"&&IBt.has(s))||t.every(({type:i})=>na.has(i))),ABt=t=>t===1||t===2,IBt=new Set(["pipe","overlapped"]),FMe=async(t,e,r,n)=>{for await(let i of t)xBt(e)||zMe(i,r,n)},jMe=(t,e,r)=>{for(let n of t)zMe(n,e,r)},xBt=t=>t._readableState.pipes.length>0,zMe=(t,e,r)=>{let n=G1(t);uu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var qMe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>CBt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},CBt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=BLe(t,s,d),p=kl(f),{stdioItems:h,objectMode:m}=e[r],g=kBt([p],h,c,n),{serializedResult:y,finalResult:v=y}=NBt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});$Bt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&DBt(y,h,i),S}catch(_){return n.error=_,S}},kBt=(t,e,r,n)=>{try{return CU(t,e,r,!1)}catch(i){return n.error=i,t}},NBt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Rx(t)};let o=n$e(t,r);return n[s]?{serializedResult:o,finalResult:b7(o,!i[s],e)}:{serializedResult:o}},$Bt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!kU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=b7(t,!1,o);try{jMe(a,e,n)}catch(c){r.error??=c}},DBt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>AU.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?PBt(n,t):(r.add(s),OBt(n,t))}};var BMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Dl(e,r,"all")]:Array.isArray(e)?[Dl(t,r,"all"),...e]:In(t)&&In(e)?CQ([t,e]):`${t}${e}`};import{once as A7}from"events";var VMe=async(t,e)=>{let[r,n]=await LBt(t);return e.isForcefullyTerminated??=!1,[r,n]},LBt=async t=>{let[e,r]=await Promise.allSettled([A7(t,"spawn"),A7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?HMe(t):r.value},HMe=async t=>{try{return await A7(t,"exit")}catch{return HMe(t)}},GMe=async t=>{let[e,r]=await t;if(!MBt(e,r)&&I7(e,r))throw new tc;return[e,r]},MBt=(t,e)=>t===void 0&&e===void 0,I7=(t,e)=>t!==0||e!==null;var WMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=UBt(t,e,r),o=s?.code==="ETIMEDOUT",a=qLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},UBt=(t,e,r)=>t!==void 0?t:I7(e,r)?new tc:void 0;var KMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=jBt(t,e,r),d=BBt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return Ov(d,c,u)},jBt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=K1(t,e,r),a=zBt(r),{file:c,commandArguments:u,options:l}=hU(t,e,a);qBt(l);let d=TMe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},zBt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,qBt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&NU("ipcInput"),t&&NU("ipc: true"),r&&NU("detached: true"),n&&NU("cancelSignal")},NU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},BBt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=VBt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=WMe(c,r),{output:h,error:m=u}=qMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((v,S)=>Dl(v,r,S)),y=Dl(BMe(h,r),r,"all");return GBt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},VBt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{UMe(s,r);let a=HBt(r);return FBt(...mU(t,e,a))}catch(a){return xv({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},HBt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:bU(e)}),GBt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?wU({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):$x({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as NVt}from"events";import{spawn as $Vt}from"child_process";import QMe from"process";import{once as x7,on as WBt}from"events";var YMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(bv({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:cU(t)}),KBt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),KBt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{iU(e,i);let s=Uf(t,e,r),o=new AbortController;try{return await Promise.race([YBt(s,n,o),JBt(s,r,o),ZBt(s,r,o)])}catch(a){throw wv(t),a}finally{o.abort(),sU(e,i)}},YBt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await x7(t,"message",{signal:r});return n}for await(let[n]of WBt(t,"message",{signal:r}))if(e(n))return n},JBt=async(t,e,{signal:r})=>{await x7(t,"disconnect",{signal:r}),DDe(e)},ZBt=async(t,e,{signal:r})=>{let[n]=await x7(t,"strict:error",{signal:r});throw tU(n,e)};import{once as ZMe,on as XBt}from"events";var XMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>O7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),O7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{bv({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:cU(t)}),iU(e,s);let o=Uf(t,e,r),a=new AbortController,c={};return QBt(t,o,a),e2t({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),t2t({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},QBt=async(t,e,r)=>{try{await ZMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},e2t=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ZMe(t,"strict:error",{signal:r.signal});n.error=tU(i,e),r.abort()}catch{}},t2t=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of XBt(r,"message",{signal:s.signal}))JMe(o),yield c}catch{JMe(o)}finally{s.abort(),sU(e,a),n||wv(t),i&&await t}},JMe=({error:t})=>{if(t)throw t};var e1e=(t,{ipc:e})=>{Object.assign(t,r1e(t,!1,e))},t1e=()=>{let t=QMe,e=!0,r=QMe.channel!==void 0;return{...r1e(t,e,r),getCancelSignal:cLe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},r1e=(t,e,r)=>({sendMessage:fU.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:YMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:XMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as r2t}from"child_process";import{PassThrough as n2t,Readable as i2t,Writable as s2t,Duplex as o2t}from"stream";var n1e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{S7(n);let a=new r2t;a2t(a,n),Object.assign(a,{readable:c2t,writable:u2t,duplex:l2t});let c=xv({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=d2t(c,o,i);return{subprocess:a,promise:u}},a2t=(t,e)=>{let r=Lx(),n=Lx(),i=Lx(),s=Array.from({length:e.length-3},Lx),o=Lx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Lx=()=>{let t=new n2t;return t.end(),t},c2t=()=>new i2t({read(){}}),u2t=()=>new s2t({write(){}}),l2t=()=>new o2t({read(){},write(){}}),d2t=async(t,e,r)=>Ov(t,e,r);import{createReadStream as i1e,createWriteStream as s1e}from"fs";import{Buffer as f2t}from"buffer";import{Readable as Mx,Writable as p2t,Duplex as h2t}from"stream";var a1e=(t,e)=>IU(m2t,t,e,!1),Ux=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ff[t]}.`)},o1e={fileNumber:Ux,generator:R7,asyncGenerator:R7,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:h2t.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},m2t={input:{...o1e,fileUrl:({value:t})=>({stream:i1e(t)}),filePath:({value:{file:t}})=>({stream:i1e(t)}),webStream:({value:t})=>({stream:Mx.fromWeb(t)}),iterable:({value:t})=>({stream:Mx.from(t)}),asyncIterable:({value:t})=>({stream:Mx.from(t)}),string:({value:t})=>({stream:Mx.from(t)}),uint8Array:({value:t})=>({stream:Mx.from(f2t.from(t))})},output:{...o1e,fileUrl:({value:t})=>({stream:s1e(t)}),filePath:({value:{file:t,append:e}})=>({stream:s1e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:p2t.fromWeb(t)}),iterable:Ux,asyncIterable:Ux,string:Ux,uint8Array:Ux}};import{on as g2t,once as c1e}from"events";import{PassThrough as _2t,getDefaultHighWaterMark as y2t}from"stream";import{finished as d1e}from"stream/promises";function qm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)C7(i);let e=t.some(({readableObjectMode:i})=>i),r=S2t(t,e),n=new P7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var S2t=(t,e)=>{if(t.length===0)return y2t(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},P7=class extends _2t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(C7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=v2t(this,this.#e,this.#s);let r=w2t({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(C7(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)}},v2t=async(t,e,r)=>{$U(t,u1e);let n=new AbortController;try{await Promise.race([E2t(t,n),b2t(t,e,r,n)])}finally{n.abort(),$U(t,-u1e)}},E2t=async(t,{signal:e})=>{try{await d1e(t,{signal:e,cleanup:!0})}catch(r){throw f1e(t,r),r}},b2t=async(t,e,r,{signal:n})=>{for await(let[i]of g2t(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},C7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},w2t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{$U(t,l1e);let a=new AbortController;try{await Promise.race([T2t(s,e,a),R2t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),A2t({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),$U(t,-l1e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?k7(t):I2t(t))},T2t=async(t,e,{signal:r})=>{try{await t,r.aborted||k7(e)}catch(n){r.aborted||f1e(e,n)}},R2t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await d1e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;p1e(o)?i.add(e):h1e(t,o)}},A2t=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await c1e(t,i,{signal:s}),!t.readable)return c1e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},I2t=t=>{t.writable&&t.end()},f1e=(t,e)=>{p1e(e)?k7(t):h1e(t,e)},p1e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",k7=t=>{(t.readable||t.writable)&&t.destroy()},h1e=(t,e)=>{t.destroyed||(t.once("error",x2t),t.destroy(e))},x2t=()=>{},$U=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},u1e=2,l1e=1;import{finished as m1e}from"stream/promises";var Cv=(t,e)=>{t.pipe(e),O2t(t,e),P2t(t,e)},O2t=async(t,e)=>{if(!(ec(t)||ec(e))){try{await m1e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}N7(e)}},N7=t=>{t.writable&&t.end()},P2t=async(t,e)=>{if(!(ec(t)||ec(e))){try{await m1e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}$7(t)}},$7=t=>{t.readable&&t.destroy()};var g1e=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>na.has(c)))C2t(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!na.has(c)))N2t({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:qm(s);Cv(o,i)}},C2t=(t,e,r,n)=>{r==="output"?Cv(t.stdio[n],e):Cv(e,t.stdio[n]);let i=k2t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},k2t=["stdin","stdout","stderr"],N2t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;$2t(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},$2t=(t,{signal:e})=>{ec(t)&&Um(t,D2t,e)},D2t=2;import{addAbortListener as U2t}from"events";var Bm=[];Bm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var DU=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",D7=Symbol.for("signal-exit emitter"),L7=globalThis,L2t=Object.defineProperty.bind(Object),M7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(L7[D7])return L7[D7];L2t(L7,D7,{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 s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},LU=class{},M2t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),U7=class extends LU{onExit(){return()=>{}}load(){}unload(){}},F7=class extends LU{#e=j7.platform==="win32"?"SIGINT":"SIGHUP";#r=new M7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Bm)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!DU(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Bm)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.#o&&(this.#o=!1,Bm.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.#s,this.#r.count-=1)}#a(e){return DU(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&DU(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)}},j7=globalThis.process,{onExit:_1e,load:hHr,unload:mHr}=M2t(DU(j7)?new F7(j7):new U7);var y1e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=_1e(()=>{t.kill()});U2t(n,()=>{i()})};var v1e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=W1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=F2t(r,n,i),{sourceStream:d,sourceError:f}=z2t(t,u),{options:p,fileDescriptors:h}=du.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},F2t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=j2t(t,e,...r),a=nU(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},j2t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(S1e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||OQ(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,s,o]=M1(r,...n);return{destination:e(S1e)(i,s,o),pipeOptions:o}}if(du.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}`)},S1e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),z2t=(t,e)=>{try{return{sourceStream:Tv(t,e)}}catch(r){return{sourceError:r}}};var b1e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=q2t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw z7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},q2t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return $7(t),n;if(e!==void 0)return N7(r),e},z7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>xv({error:t,command:E1e,escapedCommand:E1e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),E1e="source.pipe(destination)";var w1e=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as B2t}from"stream/promises";var T1e=(t,e,r)=>{let n=MU.has(e)?H2t(t,e):V2t(t,e);return Um(t,W2t,r.signal),Um(e,K2t,r.signal),G2t(e),n},V2t=(t,e)=>{let r=qm([t]);return Cv(r,e),MU.set(e,r),r},H2t=(t,e)=>{let r=MU.get(e);return r.add(t),r},G2t=async t=>{try{await B2t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}MU.delete(t)},MU=new WeakMap,W2t=2,K2t=1;import{aborted as Y2t}from"util";var R1e=(t,e)=>t===void 0?[]:[J2t(t,e)],J2t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Y2t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw z7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var UU=(t,...e)=>{if(rn(e[0]))return UU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=v1e(t,...e),i=Z2t({...n,destination:r});return i.pipe=UU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Z2t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=X2t(t,i);b1e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=T1e(e,s,d);return await Promise.race([w1e(l),...R1e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},X2t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as sVt}from"timers/promises";import{on as Q2t}from"events";import{getDefaultHighWaterMark as eVt}from"stream";var FU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return tVt(e,o),I1e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},tVt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},q7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;rVt(e,o,t);let a=t.readableObjectMode&&!s;return I1e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},rVt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},I1e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=Q2t(t,"data",{signal:e.signal,highWaterMark:A1e,highWatermark:A1e});return nVt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},B7=eVt(!0),A1e=B7,nVt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=iVt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*zm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Dx(a)}},iVt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[OU(t,r,!e),xU(t,i,!n,{})].filter(Boolean);var x1e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=oVt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([aVt(t),d]);return}let f=v7(c,r),p=q7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([cVt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},oVt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!kU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=q7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await FMe(a,t,r,s)},aVt=async t=>{await sVt(),t.readableFlowing===null&&t.resume()},cVt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await SU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await vU(r,{maxBuffer:s})):await Iv(r,{maxBuffer:s})}catch(a){return O1e(FLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},V7=async t=>{try{return await t}catch(e){return O1e(e)}},O1e=({bufferedData:t})=>t$e(t)?new Uint8Array(t):t;import{finished as uVt}from"stream/promises";var Fx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=lVt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],uVt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||pVt(a,e,r,n)}finally{o.abort()}},lVt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&dVt(t,r,n),n},dVt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{fVt(e,r),n.call(t,...i)}},fVt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},pVt=(t,e,r,n)=>{if(!hVt(t,e,r,n))throw t},hVt=(t,e,r,n=!0)=>r.propagating?P1e(t)||jU(t):(r.propagating=!0,H7(r,e)===n?P1e(t):jU(t)),H7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",jU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",P1e=t=>t?.code==="EPIPE";var C1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>G7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),G7=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=Fx(t,e,u);if(H7(u,e)){await l;return}let[d]=await Promise.all([x1e({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var k1e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?qm([t,e].filter(Boolean)):void 0,N1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>G7({...mVt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:gVt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),mVt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},gVt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as _Vt}from"events";var $1e=t=>Sv(t,"ipc"),D1e=(t,e)=>{let r=G1(t);uu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var L1e=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=$1e(s),a=Nl(e,"ipc"),c=Nl(r,"ipc");for await(let u of O7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(jLe(t,i,c),i.push(u)),o&&D1e(u,s);return i},M1e=async(t,e)=>(await Promise.allSettled([t]),e);var U1e=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:y})=>{let v=VMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},_=C1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=N1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=L1e({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=yVt(m,t,S),x=SVt(h,S);try{return await Promise.race([Promise.all([{},GMe(v),Promise.all(_),w,R,yLe(t,d),...T,...x]),g,vVt(t,y),...pLe(t,s,f,y),...$De({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...dLe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},v,Promise.all(_.map(O=>V7(O))),V7(w),M1e(R,b),Promise.allSettled(T),Promise.allSettled(x)])}},yVt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Fx(n,i,r)),SVt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>nc(s,{checkOpen:!1})&&!ec(s)).map(({type:i,value:s,stream:o=s})=>Fx(o,n,e,{isSameDirection:na.has(i),stopOnExit:i==="native"}))),vVt=async(t,{signal:e})=>{let[r]=await _Vt(t,"error",{signal:e});throw r};var F1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),jx=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=lu();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},kv=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 EVt}from"stream";import{callbackify as bVt}from"util";import{finished as j1e}from"stream/promises";var W7=async t=>{if(t!==void 0)try{await K7(t)}catch{}},z1e=async t=>{if(t!==void 0)try{await Y7(t)}catch{}},K7=async t=>{await j1e(t,{cleanup:!0,readable:!1,writable:!0})},Y7=async t=>{await j1e(t,{cleanup:!0,readable:!0,writable:!1})},zU=async(t,e)=>{if(await t,e)throw e},qU=(t,e,r)=>{r&&!jU(r)?t.destroy(r):e&&t.destroy()};var q1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||so.has(r),{subprocessStdout:a,waitReadableDestroy:c}=J7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=Z7(a,o),{read:f,onStdoutDataDone:p}=X7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new EVt({read:f,destroy:bVt(eee.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return Q7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},J7=(t,e,r)=>{let n=Tv(t,e),i=jx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Z7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:B7},X7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=lu(),o=FU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){wVt(this,o,s)},onStdoutDataDone:s}},wVt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Q7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Y7(t),await n,await W7(i),await e,r.readable&&r.push(null)}catch(s){await W7(i),B1e(r,s)}},eee=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await kv(r,e)&&(B1e(t,n),await zU(e,n))},B1e=(t,e)=>{qU(t,t.readable,e)};import{Writable as TVt}from"stream";import{callbackify as V1e}from"util";var H1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=tee(t,r,e),o=new TVt({...ree(n,t,i),destroy:V1e(iee.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return nee(n,o),o},tee=(t,e,r)=>{let n=nU(t,e),i=jx(r,n,"writableFinal"),s=jx(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},ree=(t,e,r)=>({write:RVt.bind(void 0,t),final:V1e(AVt.bind(void 0,t,e,r))}),RVt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},AVt=async(t,e,r)=>{await kv(r,e)&&(t.writable&&t.end(),await e)},nee=async(t,e,r)=>{try{await K7(t),e.writable&&e.end()}catch(n){await z1e(r),G1e(e,n)}},iee=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await kv(r,e),await kv(n,e)&&(G1e(t,i),await zU(e,i))},G1e=(t,e)=>{qU(t,t.writable,e)};import{Duplex as IVt}from"stream";import{callbackify as xVt}from"util";var W1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||so.has(r),{subprocessStdout:c,waitReadableDestroy:u}=J7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=tee(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Z7(c,a),{read:g,onStdoutDataDone:y}=X7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new IVt({read:g,...ree(l,t,d),destroy:xVt(OVt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return Q7({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),nee(l,v,c),v},OVt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([eee({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),iee({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var see=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||so.has(e),o=Tv(t,r),a=FU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return PVt(a,o,t)},PVt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var K1e=(t,{encoding:e})=>{let r=F1e();t.readable=q1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=H1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=W1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=see.bind(void 0,t,e),t[Symbol.asyncIterator]=see.bind(void 0,t,e,{})};var Y1e=(t,e)=>{for(let[r,n]of kVt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},CVt=(async()=>{})().constructor.prototype,kVt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(CVt,t)]);var J1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=DVt(t,e,r),{subprocess:f,promise:p}=MVt({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=UU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Y1e(f,p),du.set(f,{options:l,fileDescriptors:d}),f},DVt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=K1(t,e,r),{file:a,commandArguments:c,options:u}=hU(t,e,r),l=LVt(u),d=a1e(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},LVt=({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}},MVt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=$Vt(...mU(t,e,r))}catch(h){return n1e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;NVt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];g1e(c,a,u),y1e(c,r,u);let d={},f=lu();c.kill=kDe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=k1e(c,r),K1e(c,r),e1e(c,r);let p=UVt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},UVt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,g]=await U1e({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((_,w)=>Dl(_,e,w)),v=Dl(m,e,"all"),S=FVt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ov(S,n,e)},FVt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?$x({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof fu,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):wU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var BU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,jVt(n,t[n],i)]));return{...t,...r}},jVt=(t,e,r)=>zVt.has(t)&&rn(e)&&rn(r)?{...e,...r}:r,zVt=new Set(["env",...DQ]);var jf=(t,e,r,n)=>{let i=(o,a,c)=>jf(o,a,r,c),s=(...o)=>qVt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},qVt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(rn(s))return i(t,BU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=BVt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?KMe(a,c,u):J1e(a,c,u,i)},BVt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=a$e(e)?c$e(e,r):[e,...r],[o,a,c]=M1(...s),u=BU(BU(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var Z1e=({file:t,commandArguments:e})=>Q1e(t,e),X1e=({file:t,commandArguments:e})=>({...Q1e(t,e),isSync:!0}),Q1e=(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]=VVt(t);return{file:r,commandArguments:n}},VVt=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(HVt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},HVt=/ +/g;var eUe=(t,e,r)=>{t.sync=e(GVt,r),t.s=t.sync},tUe=({options:t})=>rUe(t),GVt=({options:t})=>({...rUe(t),isSync:!0}),rUe=t=>({options:{...WVt(t),...t}}),WVt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},nUe={preferLocal:!0};var iUe=jf(()=>({})),i6r=jf(()=>({isSync:!0})),sUe=jf(Z1e),s6r=jf(X1e),o6r=jf(mLe),a6r=jf(tUe,{},nUe,eUe),{sendMessage:c6r,getOneMessage:u6r,getEachMessage:l6r,getCancelSignal:d6r}=t1e();import{Transform as KVt}from"stream";var YVt=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function JVt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...YVt])]}function ZVt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function XVt(){let e=JVt().map(r=>process.env[r]).filter(r=>!(!r||ZVt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function vi(t){if(typeof t!="string")return t;let e=XVt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(QVt(n),"g");r=r.replace(i,"******")}),r}function QVt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var zx=class extends KVt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=vi(i);n(null,s)}},VU=Symbol("maskedWrite");function oUe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[VU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?vi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[VU]=!0,process.stdout.write=r}if(!process.stderr.write[VU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?vi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[VU]=!0,process.stderr.write=r}}}var aUe=!1,cUe,oee=t=>{cUe??=t},uUe=t=>{aUe=!0,oee(t)},nn=()=>aUe,ia=()=>cUe,lUe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var qx=null,dUe=t=>(qx&&qx.destroy(),qx=new sa({totalAllowedTime:t}),qx),fUe=()=>qx;var sa=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&&nn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await zD({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var pUe={name:"@netlify/agent-runner-cli",type:"module",version:"2.18.0-smtp.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup","build:bundle":"tsup --no-dts",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build:bundle 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:antigravity":"vitest run test/integration/antigravity.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",prompts:"LOG=0 vitest run --config vitest.prompts.config.js","site:build":"npm run prompts && node site/build.mjs","site:dev":"npm run site:build && netlify dev --dir site/dist",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.7","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.8.0","@opentelemetry/sdk-trace-base":"2.9.0","@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.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.3","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var nHt=tHt(import.meta.url),iHt=Ll.dirname(nHt),sHt=rHt(import.meta.url),Nv=he("shell"),aee=new Set,hUe={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=oHt(e,r),s={...hUe,...i},o=iUe(t,n,s);gUe(o,s),SUe(o);let a=r?.idleTimeout;return a&&a>0&&yUe(o,a),o},mUe=(t,e)=>{let r={...hUe,...e},n=sUe(t,r);return gUe(n,r),SUe(n),e?.idleTimeout&&e.idleTimeout>0&&yUe(n,e.idleTimeout),n},oHt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},gUe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||hu.env.NETLIFY_LOCAL_QUIET==="true")return;if(hu.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new zx).pipe(hu.stdout),t.stderr?.pipe(new zx).pipe(hu.stderr);return}t.stdout?.pipe(hu.stdout),t.stderr?.pipe(hu.stderr)},cee=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(hu.kill(-t.pid,e),Nv.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Nv.error("Error killing process:",r),!1}},_Ue=t=>cee(t,"SIGKILL"),yUe=(t,e)=>{let r=null,n=()=>{Nv.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),cee(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nv.log(`Force killing idle process ${t.pid}`),_Ue(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},SUe=t=>{aee.add(t);let e=fUe();if(e){let r=e.onTimesUp(()=>{Nv.log(`Global timer expired, killing process ${t.pid}`),cee(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nv.log(`Force killing process ${t.pid} after timeout`),_Ue(t))},5e3)});t.on("exit",()=>{aee.delete(t),r()}),t.on("error",()=>{aee.delete(t),r()})}};function mu(t,e){if(!hu.env.NETLIFY_LOCAL_MODE)try{let i=sHt.resolve(pUe.name),s=Ll.dirname(i);for(;s!==Ll.dirname(s);){let o=Ll.dirname(s);if(Ll.basename(o)==="node_modules"){let a=Ll.join(o,".bin",e);if(HU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(hu.env.NODE_PATH){let i=Ll.join(hu.env.NODE_PATH,".bin",e);if(HU.existsSync(i))return i}let r=Ll.join(t,"node_modules",".bin",e);if(HU.existsSync(r))return r;let n=Ll.join(iHt,"..","node_modules",".bin",e);if(HU.existsSync(n))return n}import Wq from"process";import{fileURLToPath as AQt}from"url";import{createRequire as IQt}from"module";import zO from"path";import{readFileSync as xQt}from"fs";var aHt="__netlify__getTracer",cHt="__netlify__shutdownTracers",Lt=(t,e)=>globalThis[aHt]?.(t,e),vUe=async()=>globalThis[cHt]?.();function Bx(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{createHash as pQt}from"crypto";import{setTimeout as hQt}from"timers/promises";Fe();import rGt from"process";Fe();var uHt=(t,e)=>{e.recordException(t),e.setStatus({code:Fn.ERROR})};var Ml=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=EUe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>bUe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=EUe(r,n,i),c=this._tracer.startSpan(e,s,o);return bUe(c,s,a)}};function EUe(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??ir.active(),{opts:n,ctx:i,fn:s}}function bUe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:uHt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Fe();var Dv=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var lee=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=kUe(e),n._asyncAttributesPending=e.filter(([i,s])=>Dv(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Dv(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=kUe(this._rawAttributes),this._schemaUrl=lHt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,Dv(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ge.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Dv(n)){ge.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=dHt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function dee(t,e){return lee.FromAttributeList(Object.entries(t),e)}function kUe(t){return t.map(([e,r])=>Dv(r)?[e,r.catch(n=>{ge.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function lHt(t){if(typeof t=="string"||t===void 0)return t;ge.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function dHt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ge.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Fe();var Vx=class{emit(e){}enabled(){return!1}},NUe=new Vx;var Hx=Symbol.for("io.opentelemetry.js.api.logs"),Lv=globalThis;function $Ue(t,e,r){return n=>n===t?e:r}var fee=1;var pee=class{getLogger(e,r,n){return new Vx}},KU=new pee;var YU=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):NUe}};var Gx=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new YU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:KU}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var JU=class t{constructor(){this._proxyLoggerProvider=new Gx}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Lv[Hx]?this.getLoggerProvider():(Lv[Hx]=$Ue(fee,e,KU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Lv[Hx])===null||e===void 0?void 0:e.call(Lv,fee))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Lv[Hx],this._proxyLoggerProvider=new Gx}};var DUe=JU.getInstance();function LUe(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function MUe(t){t.forEach(e=>e.disable())}function hee(t){let e=t.tracerProvider||jt.getTracerProvider(),r=t.meterProvider||VA.getMeterProvider(),n=t.loggerProvider||DUe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return LUe(i,e,r,n),()=>{MUe(i)}}Fe();var fHt=Un("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function UUe(t){return t.getValue(fHt)===!0}var Mv;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Mv||(Mv={}));Fe();var mee="[_0-9a-z-*/]",pHt=`[a-z]${mee}{0,255}`,hHt=`[a-z0-9]${mee}{0,240}@[a-z]${mee}{0,13}`,mHt=new RegExp(`^(?:${pHt}|${hHt})$`),gHt=/^[ -~]{0,255}[!-~]$/,_Ht=/,|=/;function gee(t){return mHt.test(t)}function _ee(t){return gHt.test(t)&&!_Ht.test(t)}var yHt=32,FUe=512,jUe=",",zUe="=",ZU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!gee(e)||!_ee(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>FUe)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=jUe+e),e=`${n[0]}${zUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(jUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(zUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!gee(a)||!_ee(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>FUe)&&(r.set(a,c),n=u,r.size>=yHt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var XU="traceparent",QU="tracestate",SHt="00",vHt="(?!ff)[\\da-f]{2}",EHt="(?![0]{32})[\\da-f]{32}",bHt="(?![0]{16})[\\da-f]{16}",wHt="[\\da-f]{2}",THt=new RegExp(`^\\s?(${vHt})-(${EHt})-(${bHt})-(${wHt})(-.*)?\\s?$`);function qUe(t){let e=THt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var zf=class{inject(e,r,n){let i=jt.getSpanContext(e);if(!i||UUe(e)||!Rs(i))return;let s=`${SHt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Cr.NONE).toString(16)}`;n.set(r,XU,s),i.traceState&&n.set(r,QU,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,XU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=qUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,QU);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new ZU(typeof c=="string"?c:void 0)}return jt.setSpanContext(e,o)}fields(){return[XU,QU]}};var eF=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var Wx=class{_isCalled=!1;_deferred=new eF;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var WF=bn(ste(),1);Fe();var jze=t=>{throw TypeError(t)},ute=(t,e,r)=>e.has(t)||jze("Cannot "+r),GF=(t,e,r)=>(ute(t,e,"read from private field"),r?r.call(t):e.get(t)),ote=(t,e,r)=>e.has(t)?jze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Mze=(t,e,r,n)=>(ute(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),tGt=(t,e,r)=>(ute(t,e,"access private method"),r),Uze="__netlify__getTracer",nGt="__netlify__shutdownTracers",iGt="__nfOTLPTrace",f0,p0,cte,zze,sGt=class{constructor(){ote(this,cte),ote(this,f0),ote(this,p0),Mze(this,f0,new Wx(tGt(this,cte,zze),this)),Mze(this,p0,ge.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(GF(this,p0).debug(`export ${t.length.toString()} spans`),GF(this,f0).isCalled){e({code:Mv.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(iGt,JSON.stringify(oGt(t))),e({code:Mv.SUCCESS})}shutdown(){return GF(this,f0).call()}};f0=new WeakMap;p0=new WeakMap;cte=new WeakSet;zze=function(){return GF(this,p0).debug("Shutting down"),Promise.resolve()};function oGt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:HF(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||Ka.SERVER,startTimeUnixNano:ate(e.startTime),endTimeUnixNano:ate(e.endTime),attributes:HF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:ate(n.time),attributes:HF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:HF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function HF(t){return Object.keys(t).map(e=>qze(e,t[e]))}function qze(t,e){return{key:t,value:Bze(e)}}function Bze(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(Bze)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>qze(r,n))}}:{}}function ate(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var Fze={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},Vze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Uze))return;let e=rGt.version.slice(1),r=dee({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[aGt()],i=new WF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new zf});let s=t.instrumentations??[];hee({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,Uze,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Ml(jt.getTracer(a,c)):new Ml(jt.getTracer(Fze.name,Fze.version))}}),Object.defineProperty(globalThis,nGt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},aGt=()=>new WF.SimpleSpanProcessor(new sGt);Fe();var Yv=bn(ste(),1);Fe();import*as KF from"diagnostics_channel";var Hze=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Fn.ERROR:Fn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Ml?t:new Ml(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){KF.subscribe(t,e);let r=()=>KF.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:Ka.CLIENT},ir.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Fn.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var NWe=bn(OWe(),1);Fe();ioe();var PWe=0;var dQt=3*1024*1024,fQt=t=>LO.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Hq=class{constructor(e,r=dQt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=fQt(c);i.length&&s+u>this.maxBytes&&(n.push(i),i=[],s=0),i.push(c),s+=u}i.length&&n.push(i);let o,a=c=>{if(c===n.length){r(o??{code:PWe});return}this.inner.export(n[c],u=>{u.code!==PWe&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var YE=he("tracing"),CWe=8e3,mQt=5e3,kWe=t=>t.length>CWe?`${t.slice(0,CWe)}\u2026`:t,JE={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},gQt=Math.ceil(JE.maxQueueSize/JE.maxExportBatchSize)+1,$We=0,aoe=()=>$We,_Qt=t=>{let e=0,r=new Hq(new NWe.OTLPTraceExporter({url:t,concurrencyLimit:gQt})),n=new Yv.BatchSpanProcessor({export:(i,s)=>{e=Math.max(0,e-i.length),r.export(i,s)},shutdown:()=>r.shutdown(),forceFlush:()=>r.forceFlush()},JE);return{onStart:(i,s)=>n.onStart(i,s),onEnd:i=>{i.spanContext().traceFlags&Cr.SAMPLED&&(e>=JE.maxQueueSize?$We+=1:e+=1),n.onEnd(i)},forceFlush:()=>n.forceFlush(),shutdown:()=>n.shutdown()}},Tg=async(t=mQt)=>{try{let e=Symbol("timed out");await Promise.race([vUe(),hQt(t,e)])===e&&YE.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){YE.warn("Failed to flush tracers on shutdown",e)}},DWe=async(t,e,r)=>{if(!Lt()){let n=[new Yv.SimpleSpanProcessor(new ooe),_Qt(r.exporterUrl)];await Vze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new Hze({skipHeaders:!0})]})}return r.traceparent?(Zi.setGlobalPropagator(new zf),Zi.extract(ir.active(),{traceparent:r.traceparent,isRemote:!0})):ir.active()};function gr(t,e,r){return YE.log(`\u23F3 TRACE: ${e} starting...`),Bx(t,e,r)}var ooe=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";YE.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&YE.log(` \u274C Error: ${e.status.message}`)}};function coe(){return He().captureLlmContentEnabled}function LWe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function Gq(t,e,r){let n={role:t,parts:[{type:"text",content:vi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var yQt=new Set([X.Task,X.RunCommand,X.Explore,X.FileRead,X.FileWrite,X.Notebook,X.Web,X.Todo,X.Skill,X.Tool,X.Memorize,X.Deployment,X.SiteGeneration]),SQt=new Set(["claude","codex"]),vQt=(t,e)=>JSON.stringify([t,e.operation,e.path??null]),EQt=t=>pQt("sha256").update(t.map(e=>Buffer.from(e)).sort(Buffer.compare).join(`
|
|
606
606
|
`)).digest("hex"),MWe=(t,e,r)=>({"spark.trace.file_operations_recorded":SQt.has(t)&&!e.fileOperationsIncomplete,...r?{"spark.file_operations.count":r.count,"spark.file_operations.digest":r.digest}:{}});function UWe(t,e,r,n){let i=[],s=()=>({count:i.length,digest:EQt(i)});if(!t.length)return s();let o=Lt();if(!o)return s();let a=t.reduce((l,d)=>l+1+(d.fileOperations?.length??0),0);a>JE.maxQueueSize&&YE.warn(`${a} step spans exceed the span queue of ${JE.maxQueueSize}; spans may be dropped`);let c=coe(),u=Math.max(1,(n-r)/t.length);return t.forEach((l,d)=>{let f=l.timingSource?to(l.startedAtMs,l.endedAtMs,l.timingSource):{},p=f.startedAtMs??Math.min(n,r+d*u),h=f.endedAtMs??Math.min(n,p+u),m=f.timingSource??"even-split",g=l.type==="tool_use"||l.type==="tool_result"||l.category!=null&&yQt.has(l.category)||l.category===X.AgentMessage&&l.toolCallId!==void 0,y=g?"execute_tool":"chat",v=kWe(l.title||l.type||`step-${l.id??d}`),S=l.category||"unknown",_=g?`${y} ${S}`:y,w=l.message?kWe(l.message):void 0,b=o.startSpan(_,{startTime:p,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":vi(v),"gen_ai.operation.name":y,...g?{"gen_ai.tool.name":S}:{},"spark.step.id":l.id??-1,"spark.step.timing":m,"spark.file_operations.count":l.fileOperations?.length??0,...l.type?{"spark.step.type":l.type}:{},...l.category?{"spark.step.category":l.category}:{},...l.groupId?{"spark.step.group_id":l.groupId}:{},...l.parentGroupId?{"spark.step.parent_group_id":l.parentGroupId}:{},...l.skillId?{"spark.skill.id":l.skillId}:{},...c&&w?g?{"gen_ai.tool.call.result":vi(w)}:{"gen_ai.output.messages":Gq("assistant",w)}:{}}});g&&(l.toolCallId!==void 0&&b.setAttribute("gen_ai.tool.call.id",l.toolCallId),l.toolStatus!==void 0&&b.setAttribute("spark.step.tool_status",l.toolStatus),l.exitCode!==void 0&&b.setAttribute("spark.step.exit_code",l.exitCode),l.toolStatus==="error"&&(b.setAttribute("error.type","tool_error"),b.setStatus({code:Fn.ERROR})));let R=l.fileOperations?.length?jt.setSpan(ir.active(),b):void 0;for(let T of l.fileOperations??[])i.push(vQt(l.id??-1,T)),o.startSpan("file_operation",{startTime:p,attributes:{"gen_ai.capability.name":e,"spark.step.id":l.id??-1,"spark.file.operation":T.operation,...T.path!==void 0?{"spark.file.path":T.path}:T.unresolved?{"spark.file.path_unresolved":!0}:{"spark.file.outside_repo":!0},...l.toolCallId!==void 0?{"gen_ai.tool.call.id":l.toolCallId}:{}}},R).end(h);b.end(h)}),s()}import{readdir as bQt,rm as wQt}from"fs/promises";import{join as TQt}from"path";async function FWe(t,e=[]){let n=(await bQt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>wQt(TQt(t,i),{recursive:!0,force:!0})))}var RQt=300,FO=t=>He().budgetCreditThresholds[t.mode]?.[t.runner]??RQt,jO=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var uoe=t=>{let e=FO(t);if(!jO(t,e))return"default";let r=He();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},jWe=t=>{let e=uoe(t),r=FO(t);return{budget_eligible:jO(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var OQt=zO.dirname(AQt(import.meta.url)),zWe=IQt(import.meta.url),PQt=zO.resolve(OQt,"scripts/scaffold.js"),CQt="scripts/scaffold.js",kQt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,loe=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},NQt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),$Qt=t=>{let e=loe(t);return e==="node"||e.endsWith("/node")},ho=t=>{if(typeof t!="string")return!1;let e=t.match(kQt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&NQt(loe(e[r]));)r+=1;if(r>=e.length||!$Qt(e[r]))return!1;let n=e[r+1];return n?loe(n).includes(CQt):!1},Rg=he("create_stage"),doe="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",DQt=`${doe}
|
|
607
607
|
|
|
608
608
|
Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,LQt=`${doe}
|
package/dist/index.js
CHANGED
|
@@ -395,7 +395,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
395
395
|
`,LF:`
|
|
396
396
|
`,concatBytes:i8},ngt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},igt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:ngt};import{Buffer as ogt}from"buffer";var Lxe=(t,e)=>t?void 0:sgt.bind(void 0,e),sgt=function*(t,e){if(typeof e!="string"&&!Hr(e)&&!ogt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Uxe=(t,e)=>t?agt.bind(void 0,e):cgt.bind(void 0,e),agt=function*(t,e){Fxe(t,e),yield e},cgt=function*(t,e){if(Fxe(t,e),typeof e!="string"&&!Hr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Fxe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
397
397
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
398
|
-
if (condition) { yield value; }`)};import{Buffer as ugt}from"buffer";import{StringDecoder as lgt}from"string_decoder";var WM=(t,e,r)=>{if(r)return;if(t)return{transform:dgt.bind(void 0,new TextEncoder)};let n=new lgt(e);return{transform:fgt.bind(void 0,n),final:pgt.bind(void 0,n)}},dgt=function*(t,e){ugt.isBuffer(e)?yield wu(e):typeof e=="string"?yield t.encode(e):yield e},fgt=function*(t,e){yield Hr(e)?t.write(e):e},pgt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as zxe}from"util";var s8=zxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),KM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=hgt}=e[r];for await(let i of n(t))yield*KM(i,e,r+1)},jxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*mgt(r,Number(e),t)},mgt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*KM(n,r,e+1)},qxe=zxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),hgt=function*(t){yield t};var a8=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Bxe=(t,e)=>[...e.flatMap(r=>[...rm(r,t,0)]),...SR(t)],rm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_gt}=e[r];for(let i of n(t))yield*rm(i,e,r+1)},SR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ggt(r,Number(e),t)},ggt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*rm(n,r,e+1)},_gt=function*(t){yield t};var c8=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Gxe(t,s,o),u=tm(e),l=tm(r),d=u?s8.bind(void 0,KM,a):a8.bind(void 0,rm),f=u||l?s8.bind(void 0,jxe,a):a8.bind(void 0,SR),p=u||l?qxe.bind(void 0,a):void 0;return{stream:new ygt({writableObjectMode:n,writableHighWaterMark:Vxe(n),readableObjectMode:i,readableHighWaterMark:Vxe(i),transform(h,_,y){d([h,c,0],this,y)},flush(h){f([c],this,h)},destroy:p})}},YM=(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=Gxe(s,r,a);t=Bxe(c,t)}return t},Gxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Lxe(n,a)},WM(r,s,n),HM(r,o,n,c),{transform:t,final:e},{transform:Uxe(i,a)},Mxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Hxe=(t,e)=>{for(let r of Sgt(t))vgt(t,r,e)},Sgt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),vgt=(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 ${md[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>bgt(a,n));r.input=uR(s)},bgt=(t,e)=>{let r=YM(t,e,"utf8",!0);return Egt(r),uR(r)},Egt=t=>{let e=t.find(r=>typeof r!="string"&&!Hr(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 Rgt,appendFileSync as xgt}from"fs";var ZM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ry(r,n)&&!_o.has(e)&&wgt(n)&&(t.some(({type:i,value:o})=>i==="native"&&Tgt.has(o))||t.every(({type:i})=>ts.has(i))),wgt=t=>t===1||t===2,Tgt=new Set(["pipe","overlapped"]),Wxe=async(t,e,r,n)=>{for await(let i of t)Agt(e)||Yxe(i,r,n)},Kxe=(t,e,r)=>{for(let n of t)Yxe(n,e,r)},Agt=t=>t._readableState.pipes.length>0,Yxe=(t,e,r)=>{let n=lM(t);dc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Zxe=({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,u)=>Igt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Igt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=XRe(t,o,d),p=wu(f),{stdioItems:m,objectMode:h}=e[r],_=Ogt([p],m,c,n),{serializedResult:y,finalResult:v=y}=Pgt({chunks:_,objectMode:h,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Cgt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:m,objectMode:h});let T=a[r]?v:void 0;try{return n.error===void 0&&kgt(y,m,i),T}catch(b){return n.error=b,T}},Ogt=(t,e,r,n)=>{try{return YM(t,e,r,!1)}catch(i){return n.error=i,t}},Pgt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:uR(t)};let s=dTe(t,r);return n[o]?{serializedResult:s,finalResult:o8(s,!i[o],e)}:{serializedResult:s}},Cgt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!ZM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=o8(t,!1,s);try{Kxe(a,e,n)}catch(c){r.error??=c}},kgt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>VM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?xgt(n,t):(r.add(o),Rgt(n,t))}};var Xxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ru(e,r,"all")]:Array.isArray(e)?[Ru(t,r,"all"),...e]:Hr(t)&&Hr(e)?m5([t,e]):`${t}${e}`};import{once as u8}from"events";var Jxe=async(t,e)=>{let[r,n]=await Ngt(t);return e.isForcefullyTerminated??=!1,[r,n]},Ngt=async t=>{let[e,r]=await Promise.allSettled([u8(t,"spawn"),u8(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Qxe(t):r.value},Qxe=async t=>{try{return await u8(t,"exit")}catch{return Qxe(t)}},eIe=async t=>{let[e,r]=await t;if(!$gt(e,r)&&l8(e,r))throw new pa;return[e,r]},$gt=(t,e)=>t===void 0&&e===void 0,l8=(t,e)=>t!==0||e!==null;var tIe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=Dgt(t,e,r),s=o?.code==="ETIMEDOUT",a=ZRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},Dgt=(t,e,r)=>t!==void 0?t:l8(e,r)?new pa:void 0;var rIe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Lgt(t,e,r),d=zgt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return My(d,c,u)},Lgt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=fM(t,e,r),a=Ugt(r),{file:c,commandArguments:u,options:l}=kM(t,e,a);Fgt(l);let d=kxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Ugt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Fgt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&XM("ipcInput"),t&&XM("ipc: true"),r&&XM("detached: true"),n&&XM("cancelSignal")},XM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},zgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=jgt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=tIe(c,r),{output:m,error:h=u}=Zxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=m.map((v,T)=>Ru(v,r,T)),y=Ru(Xxe(m,r),r,"all");return Bgt({error:h,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},jgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Hxe(o,r);let a=qgt(r);return Mgt(...NM(t,e,a))}catch(a){return Dy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},qgt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:zM(e)}),Bgt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?jM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):yR({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as Pyt}from"events";import{spawn as Cyt}from"child_process";import aIe from"process";import{once as d8,on as Vgt}from"events";var nIe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Oy({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:RM(t)}),Ggt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Ggt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{EM(e,i);let o=pd(t,e,r),s=new AbortController;try{return await Promise.race([Hgt(o,n,s),Wgt(o,r,s),Kgt(o,r,s)])}catch(a){throw Py(t),a}finally{s.abort(),wM(e,i)}},Hgt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await d8(t,"message",{signal:r});return n}for await(let[n]of Vgt(t,"message",{signal:r}))if(e(n))return n},Wgt=async(t,e,{signal:r})=>{await d8(t,"disconnect",{signal:r}),BAe(e)},Kgt=async(t,e,{signal:r})=>{let[n]=await d8(t,"strict:error",{signal:r});throw SM(n,e)};import{once as oIe,on as Ygt}from"events";var sIe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>f8({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),f8=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Oy({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:RM(t)}),EM(e,o);let s=pd(t,e,r),a=new AbortController,c={};return Zgt(t,s,a),Xgt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Jgt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Zgt=async(t,e,r)=>{try{await oIe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Xgt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await oIe(t,"strict:error",{signal:r.signal});n.error=SM(i,e),r.abort()}catch{}},Jgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Ygt(r,"message",{signal:o.signal}))iIe(s),yield c}catch{iIe(s)}finally{o.abort(),wM(e,a),n||Py(t),i&&await t}},iIe=({error:t})=>{if(t)throw t};var cIe=(t,{ipc:e})=>{Object.assign(t,lIe(t,!1,e))},uIe=()=>{let t=aIe,e=!0,r=aIe.channel!==void 0;return{...lIe(t,e,r),getCancelSignal:gRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},lIe=(t,e,r)=>({sendMessage:PM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:nIe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:sIe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Qgt}from"child_process";import{PassThrough as e_t,Readable as t_t,Writable as r_t,Duplex as n_t}from"stream";var dIe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{r8(n);let a=new Qgt;i_t(a,n),Object.assign(a,{readable:o_t,writable:s_t,duplex:a_t});let c=Dy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=c_t(c,s,i);return{subprocess:a,promise:u}},i_t=(t,e)=>{let r=vR(),n=vR(),i=vR(),o=Array.from({length:e.length-3},vR),s=vR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},vR=()=>{let t=new e_t;return t.end(),t},o_t=()=>new t_t({read(){}}),s_t=()=>new r_t({write(){}}),a_t=()=>new n_t({read(){},write(){}}),c_t=async(t,e,r)=>My(t,e,r);import{createReadStream as fIe,createWriteStream as pIe}from"fs";import{Buffer as u_t}from"buffer";import{Readable as bR,Writable as l_t,Duplex as d_t}from"stream";var hIe=(t,e)=>GM(f_t,t,e,!1),ER=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${md[t]}.`)},mIe={fileNumber:ER,generator:c8,asyncGenerator:c8,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:d_t.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},f_t={input:{...mIe,fileUrl:({value:t})=>({stream:fIe(t)}),filePath:({value:{file:t}})=>({stream:fIe(t)}),webStream:({value:t})=>({stream:bR.fromWeb(t)}),iterable:({value:t})=>({stream:bR.from(t)}),asyncIterable:({value:t})=>({stream:bR.from(t)}),string:({value:t})=>({stream:bR.from(t)}),uint8Array:({value:t})=>({stream:bR.from(u_t.from(t))})},output:{...mIe,fileUrl:({value:t})=>({stream:pIe(t)}),filePath:({value:{file:t,append:e}})=>({stream:pIe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:l_t.fromWeb(t)}),iterable:ER,asyncIterable:ER,string:ER,uint8Array:ER}};import{on as p_t,once as gIe}from"events";import{PassThrough as m_t,getDefaultHighWaterMark as h_t}from"stream";import{finished as SIe}from"stream/promises";function nm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)m8(i);let e=t.some(({readableObjectMode:i})=>i),r=g_t(t,e),n=new p8({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var g_t=(t,e)=>{if(t.length===0)return h_t(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},p8=class extends m_t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(m8(e),this.#e.has(e))return;this.#e.add(e),this.#n??=__t(this,this.#e,this.#o);let r=v_t({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(m8(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)}},__t=async(t,e,r)=>{JM(t,_Ie);let n=new AbortController;try{await Promise.race([y_t(t,n),S_t(t,e,r,n)])}finally{n.abort(),JM(t,-_Ie)}},y_t=async(t,{signal:e})=>{try{await SIe(t,{signal:e,cleanup:!0})}catch(r){throw vIe(t,r),r}},S_t=async(t,e,r,{signal:n})=>{for await(let[i]of p_t(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},m8=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},v_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{JM(t,yIe);let a=new AbortController;try{await Promise.race([b_t(o,e,a),E_t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),w_t({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),JM(t,-yIe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?h8(t):T_t(t))},b_t=async(t,e,{signal:r})=>{try{await t,r.aborted||h8(e)}catch(n){r.aborted||vIe(e,n)}},E_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await SIe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;bIe(s)?i.add(e):EIe(t,s)}},w_t=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await gIe(t,i,{signal:o}),!t.readable)return gIe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},T_t=t=>{t.writable&&t.end()},vIe=(t,e)=>{bIe(e)?h8(t):EIe(t,e)},bIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",h8=t=>{(t.readable||t.writable)&&t.destroy()},EIe=(t,e)=>{t.destroyed||(t.once("error",A_t),t.destroy(e))},A_t=()=>{},JM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},_Ie=2,yIe=1;import{finished as wIe}from"stream/promises";var Uy=(t,e)=>{t.pipe(e),R_t(t,e),x_t(t,e)},R_t=async(t,e)=>{if(!(fa(t)||fa(e))){try{await wIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}g8(e)}},g8=t=>{t.writable&&t.end()},x_t=async(t,e)=>{if(!(fa(t)||fa(e))){try{await wIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}_8(t)}},_8=t=>{t.readable&&t.destroy()};var TIe=(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})=>ts.has(c)))I_t(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ts.has(c)))P_t({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]:nm(o);Uy(s,i)}},I_t=(t,e,r,n)=>{r==="output"?Uy(t.stdio[n],e):Uy(e,t.stdio[n]);let i=O_t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},O_t=["stdin","stdout","stderr"],P_t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;C_t(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},C_t=(t,{signal:e})=>{fa(t)&&Qp(t,k_t,e)},k_t=2;import{addAbortListener as D_t}from"events";var im=[];im.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&im.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&im.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var QM=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",y8=Symbol.for("signal-exit emitter"),S8=globalThis,N_t=Object.defineProperty.bind(Object),v8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(S8[y8])return S8[y8];N_t(S8,y8,{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}},eL=class{},$_t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),b8=class extends eL{onExit(){return()=>{}}load(){}unload(){}},E8=class extends eL{#e=w8.platform==="win32"?"SIGINT":"SIGHUP";#r=new v8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of im)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(!QM(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 im)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,im.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 QM(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"&&QM(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)}},w8=globalThis.process,{onExit:AIe,load:Imr,unload:Omr}=$_t(QM(w8)?new E8(w8):new b8);var RIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=AIe(()=>{t.kill()});D_t(n,()=>{i()})};var IIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=dM(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=M_t(r,n,i),{sourceStream:d,sourceError:f}=U_t(t,u),{options:p,fileDescriptors:m}=pc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:m,startTime:o}},M_t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=L_t(t,e,...r),a=bM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},L_t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(xIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||f5(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]=tM(r,...n);return{destination:e(xIe)(i,o,s),pipeOptions:s}}if(pc.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}`)},xIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),U_t=(t,e)=>{try{return{sourceStream:Cy(t,e)}}catch(r){return{sourceError:r}}};var PIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=F_t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw T8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},F_t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return _8(t),n;if(e!==void 0)return g8(r),e},T8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Dy({error:t,command:OIe,escapedCommand:OIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),OIe="source.pipe(destination)";var CIe=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 z_t}from"stream/promises";var kIe=(t,e,r)=>{let n=tL.has(e)?q_t(t,e):j_t(t,e);return Qp(t,V_t,r.signal),Qp(e,G_t,r.signal),B_t(e),n},j_t=(t,e)=>{let r=nm([t]);return Uy(r,e),tL.set(e,r),r},q_t=(t,e)=>{let r=tL.get(e);return r.add(t),r},B_t=async t=>{try{await z_t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}tL.delete(t)},tL=new WeakMap,V_t=2,G_t=1;import{aborted as H_t}from"util";var NIe=(t,e)=>t===void 0?[]:[W_t(t,e)],W_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await H_t(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw T8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var rL=(t,...e)=>{if(Rr(e[0]))return rL.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=IIe(t,...e),i=K_t({...n,destination:r});return i.pipe=rL.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},K_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Y_t(t,i);PIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=kIe(e,o,d);return await Promise.race([CIe(l),...NIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Y_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as ryt}from"timers/promises";import{on as Z_t}from"events";import{getDefaultHighWaterMark as X_t}from"stream";var nL=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return J_t(e,s),DIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},J_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},A8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;Q_t(e,s,t);let a=t.readableObjectMode&&!o;return DIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Q_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},DIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Z_t(t,"data",{signal:e.signal,highWaterMark:$Ie,highWatermark:$Ie});return eyt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},R8=X_t(!0),$Ie=R8,eyt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=tyt({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*rm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*SR(a)}},tyt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[WM(t,r,!e),HM(t,i,!n,{})].filter(Boolean);var MIe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=nyt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([iyt(t),d]);return}let f=n8(c,r),p=A8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[m]=await Promise.all([oyt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return m},nyt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!ZM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=A8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Wxe(a,t,r,o)},iyt=async t=>{await ryt(),t.readableFlowing===null&&t.resume()},oyt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await LM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await UM(r,{maxBuffer:o})):await $y(r,{maxBuffer:o})}catch(a){return LIe(WRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},x8=async t=>{try{return await t}catch(e){return LIe(e)}},LIe=({bufferedData:t})=>uTe(t)?new Uint8Array(t):t;import{finished as syt}from"stream/promises";var wR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=ayt(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],syt(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||lyt(a,e,r,n)}finally{s.abort()}},ayt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&cyt(t,r,n),n},cyt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{uyt(e,r),n.call(t,...i)}},uyt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},lyt=(t,e,r,n)=>{if(!dyt(t,e,r,n))throw t},dyt=(t,e,r,n=!0)=>r.propagating?UIe(t)||iL(t):(r.propagating=!0,I8(r,e)===n?UIe(t):iL(t)),I8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",iL=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",UIe=t=>t?.code==="EPIPE";var FIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>O8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),O8=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=wR(t,e,u);if(I8(u,e)){await l;return}let[d]=await Promise.all([MIe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var zIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?nm([t,e].filter(Boolean)):void 0,jIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>O8({...fyt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:pyt(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),fyt=({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}},pyt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as myt}from"events";var qIe=t=>Ry(t,"ipc"),BIe=(t,e)=>{let r=lM(t);dc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var VIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=qIe(o),a=Tu(e,"ipc"),c=Tu(r,"ipc");for await(let u of f8({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(KRe(t,i,c),i.push(u)),s&&BIe(u,o);return i},GIe=async(t,e)=>(await Promise.allSettled([t]),e);var HIe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:m,originalStreams:h,onInternalError:_,controller:y})=>{let v=Jxe(t,f),T={originalStreams:h,fileDescriptors:m,subprocess:t,exitPromise:v,propagating:!1},b=FIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),E=jIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),S=[],I=VIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:S,verboseInfo:p}),P=hyt(h,t,T),O=gyt(m,T);try{return await Promise.race([Promise.all([{},eIe(v),Promise.all(b),E,I,RRe(t,d),...P,...O]),_,_yt(t,y),...bRe(t,o,f,y),...qAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...SRe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},v,Promise.all(b.map(A=>x8(A))),x8(E),GIe(I,S),Promise.allSettled(P),Promise.allSettled(O)])}},hyt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:wR(n,i,r)),gyt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>ha(o,{checkOpen:!1})&&!fa(o)).map(({type:i,value:o,stream:s=o})=>wR(s,n,e,{isSameDirection:ts.has(i),stopOnExit:i==="native"}))),_yt=async(t,{signal:e})=>{let[r]=await myt(t,"error",{signal:e});throw r};var WIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),TR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=fc();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Fy=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 yyt}from"stream";import{callbackify as Syt}from"util";import{finished as KIe}from"stream/promises";var P8=async t=>{if(t!==void 0)try{await C8(t)}catch{}},YIe=async t=>{if(t!==void 0)try{await k8(t)}catch{}},C8=async t=>{await KIe(t,{cleanup:!0,readable:!1,writable:!0})},k8=async t=>{await KIe(t,{cleanup:!0,readable:!0,writable:!1})},oL=async(t,e)=>{if(await t,e)throw e},sL=(t,e,r)=>{r&&!iL(r)?t.destroy(r):e&&t.destroy()};var ZIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_o.has(r),{subprocessStdout:a,waitReadableDestroy:c}=N8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=$8(a,s),{read:f,onStdoutDataDone:p}=D8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),m=new yyt({read:f,destroy:Syt(L8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return M8({subprocessStdout:a,onStdoutDataDone:p,readable:m,subprocess:t}),m},N8=(t,e,r)=>{let n=Cy(t,e),i=TR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},$8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:R8},D8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=fc(),s=nL({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){vyt(this,s,o)},onStdoutDataDone:o}},vyt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},M8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await k8(t),await n,await P8(i),await e,r.readable&&r.push(null)}catch(o){await P8(i),XIe(r,o)}},L8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Fy(r,e)&&(XIe(t,n),await oL(e,n))},XIe=(t,e)=>{sL(t,t.readable,e)};import{Writable as byt}from"stream";import{callbackify as JIe}from"util";var QIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=U8(t,r,e),s=new byt({...F8(n,t,i),destroy:JIe(j8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return z8(n,s),s},U8=(t,e,r)=>{let n=bM(t,e),i=TR(r,n,"writableFinal"),o=TR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},F8=(t,e,r)=>({write:Eyt.bind(void 0,t),final:JIe(wyt.bind(void 0,t,e,r))}),Eyt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},wyt=async(t,e,r)=>{await Fy(r,e)&&(t.writable&&t.end(),await e)},z8=async(t,e,r)=>{try{await C8(t),e.writable&&e.end()}catch(n){await YIe(r),eOe(e,n)}},j8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Fy(r,e),await Fy(n,e)&&(eOe(t,i),await oL(e,i))},eOe=(t,e)=>{sL(t,t.writable,e)};import{Duplex as Tyt}from"stream";import{callbackify as Ayt}from"util";var tOe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_o.has(r),{subprocessStdout:c,waitReadableDestroy:u}=N8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=U8(t,i,e),{readableEncoding:p,readableObjectMode:m,readableHighWaterMark:h}=$8(c,a),{read:_,onStdoutDataDone:y}=D8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new Tyt({read:_,...F8(l,t,d),destroy:Ayt(Ryt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:h,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:m,writableObjectMode:l.writableObjectMode,encoding:p});return M8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),z8(l,v,c),v},Ryt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([L8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),j8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var q8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_o.has(e),s=Cy(t,r),a=nL({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return xyt(a,s,t)},xyt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var rOe=(t,{encoding:e})=>{let r=WIe();t.readable=ZIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=QIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=tOe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=q8.bind(void 0,t,e),t[Symbol.asyncIterator]=q8.bind(void 0,t,e,{})};var nOe=(t,e)=>{for(let[r,n]of Oyt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Iyt=(async()=>{})().constructor.prototype,Oyt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Iyt,t)]);var iOe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=kyt(t,e,r),{subprocess:f,promise:p}=$yt({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=rL.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),nOe(f,p),pc.set(f,{options:l,fileDescriptors:d}),f},kyt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=fM(t,e,r),{file:a,commandArguments:c,options:u}=kM(t,e,r),l=Nyt(u),d=hIe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Nyt=({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}},$yt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=Cyt(...NM(t,e,r))}catch(m){return dIe({error:m,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;Pyt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];TIe(c,a,u),RIe(c,r,u);let d={},f=fc();c.kill=zAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=zIe(c,r),rOe(c,r),cIe(c,r);let p=Dyt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},Dyt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],m,h,_]=await HIe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=m.map((b,E)=>Ru(b,e,E)),v=Ru(h,e,"all"),T=Myt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return My(T,n,e)},Myt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?yR({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof mc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):jM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var aL=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Lyt(n,t[n],i)]));return{...t,...r}},Lyt=(t,e,r)=>Uyt.has(t)&&Rr(e)&&Rr(r)?{...e,...r}:r,Uyt=new Set(["env",...y5]);var hd=(t,e,r,n)=>{let i=(s,a,c)=>hd(s,a,r,c),o=(...s)=>Fyt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},Fyt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Rr(o))return i(t,aL(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=zyt({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?rIe(a,c,u):iOe(a,c,u,i)},zyt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=hTe(e)?gTe(e,r):[e,...r],[s,a,c]=tM(...o),u=aL(aL(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var oOe=({file:t,commandArguments:e})=>aOe(t,e),sOe=({file:t,commandArguments:e})=>({...aOe(t,e),isSync:!0}),aOe=(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]=jyt(t);return{file:r,commandArguments:n}},jyt=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(qyt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},qyt=/ +/g;var cOe=(t,e,r)=>{t.sync=e(Byt,r),t.s=t.sync},uOe=({options:t})=>lOe(t),Byt=({options:t})=>({...lOe(t),isSync:!0}),lOe=t=>({options:{...Vyt(t),...t}}),Vyt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},dOe={preferLocal:!0};var fOe=hd(()=>({})),y_r=hd(()=>({isSync:!0})),pOe=hd(oOe),S_r=hd(sOe),v_r=hd(wRe),b_r=hd(uOe,{},dOe,cOe),{sendMessage:E_r,getOneMessage:w_r,getEachMessage:T_r,getCancelSignal:A_r}=uIe();var mOe=!1,hOe,Gyt=t=>{hOe??=t},gOe=t=>{mOe=!0,Gyt(t)},Gn=()=>mOe,xu=()=>hOe,_Oe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var AR=null,yOe=t=>(AR&&AR.destroy(),AR=new rs({totalAllowedTime:t}),AR),SOe=()=>AR;var rs=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&&Gn())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((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await Sk({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{Y.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),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 vOe={name:"@netlify/agent-runner-cli",type:"module",version:"2.18.0-smtp-3.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","build:bundle":"tsup --no-dts",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build:bundle 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:antigravity":"vitest run test/integration/antigravity.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",prompts:"LOG=0 vitest run --config vitest.prompts.config.js","site:build":"npm run prompts && node site/build.mjs","site:dev":"npm run site:build && netlify dev --dir site/dist",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.7","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.8.0","@opentelemetry/sdk-trace-base":"2.9.0","@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.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.3","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var Yyt=Wyt(import.meta.url),Zyt=Iu.dirname(Yyt),Xyt=Kyt(import.meta.url),zy=ce("shell"),B8=new Set,bOe={preferLocal:!0},Et=(t,e,r)=>{let[n,i]=Jyt(e,r),o={...bOe,...i},s=fOe(t,n,o);wOe(s,o),ROe(s);let a=r?.idleTimeout;return a&&a>0&&AOe(s,a),s},EOe=(t,e)=>{let r={...bOe,...e},n=pOe(t,r);return wOe(n,r),ROe(n),e?.idleTimeout&&e.idleTimeout>0&&AOe(n,e.idleTimeout),n},Jyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},wOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||gc.env.NETLIFY_LOCAL_QUIET==="true")return;if(gc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Yw).pipe(gc.stdout),t.stderr?.pipe(new Yw).pipe(gc.stderr);return}t.stdout?.pipe(gc.stdout),t.stderr?.pipe(gc.stderr)},V8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(gc.kill(-t.pid,e),zy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return zy.error("Error killing process:",r),!1}},TOe=t=>V8(t,"SIGKILL"),AOe=(t,e)=>{let r=null,n=()=>{zy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),V8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(zy.log(`Force killing idle process ${t.pid}`),TOe(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)},ROe=t=>{B8.add(t);let e=SOe();if(e){let r=e.onTimesUp(()=>{zy.log(`Global timer expired, killing process ${t.pid}`),V8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(zy.log(`Force killing process ${t.pid} after timeout`),TOe(t))},5e3)});t.on("exit",()=>{B8.delete(t),r()}),t.on("error",()=>{B8.delete(t),r()})}};function _c(t,e){if(!gc.env.NETLIFY_LOCAL_MODE)try{let i=Xyt.resolve(vOe.name),o=Iu.dirname(i);for(;o!==Iu.dirname(o);){let s=Iu.dirname(o);if(Iu.basename(s)==="node_modules"){let a=Iu.join(s,".bin",e);if(cL.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(gc.env.NODE_PATH){let i=Iu.join(gc.env.NODE_PATH,".bin",e);if(cL.existsSync(i))return i}let r=Iu.join(t,"node_modules",".bin",e);if(cL.existsSync(r))return r;let n=Iu.join(Zyt,"..","node_modules",".bin",e);if(cL.existsSync(n))return n}var jy=ce("repo"),$Oe="runner-diffs-",G8=t=>`${$Oe}${t}-`,DOe=async t=>{let e=lL.tmpdir(),r;try{r=await Hn.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith($Oe)&&!n.startsWith(G8(t))).map(n=>Hn.rm(yo.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},xOe=async t=>{let e=Qyt("sha256");for await(let r of eSt(t))e.update(r);return e.digest("hex")},IOe=async(t,e)=>t.size===e.size&&await xOe(t.path)===await xOe(e.path),MOe=/.. (.+)?\.log$/,tSt=[MOe],rSt=1,OOe=/^<<<<<<<( |$)/m,POe=t=>{let e=t.split(`
|
|
398
|
+
if (condition) { yield value; }`)};import{Buffer as ugt}from"buffer";import{StringDecoder as lgt}from"string_decoder";var WM=(t,e,r)=>{if(r)return;if(t)return{transform:dgt.bind(void 0,new TextEncoder)};let n=new lgt(e);return{transform:fgt.bind(void 0,n),final:pgt.bind(void 0,n)}},dgt=function*(t,e){ugt.isBuffer(e)?yield wu(e):typeof e=="string"?yield t.encode(e):yield e},fgt=function*(t,e){yield Hr(e)?t.write(e):e},pgt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as zxe}from"util";var s8=zxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),KM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=hgt}=e[r];for await(let i of n(t))yield*KM(i,e,r+1)},jxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*mgt(r,Number(e),t)},mgt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*KM(n,r,e+1)},qxe=zxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),hgt=function*(t){yield t};var a8=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Bxe=(t,e)=>[...e.flatMap(r=>[...rm(r,t,0)]),...SR(t)],rm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_gt}=e[r];for(let i of n(t))yield*rm(i,e,r+1)},SR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ggt(r,Number(e),t)},ggt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*rm(n,r,e+1)},_gt=function*(t){yield t};var c8=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Gxe(t,s,o),u=tm(e),l=tm(r),d=u?s8.bind(void 0,KM,a):a8.bind(void 0,rm),f=u||l?s8.bind(void 0,jxe,a):a8.bind(void 0,SR),p=u||l?qxe.bind(void 0,a):void 0;return{stream:new ygt({writableObjectMode:n,writableHighWaterMark:Vxe(n),readableObjectMode:i,readableHighWaterMark:Vxe(i),transform(h,_,y){d([h,c,0],this,y)},flush(h){f([c],this,h)},destroy:p})}},YM=(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=Gxe(s,r,a);t=Bxe(c,t)}return t},Gxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Lxe(n,a)},WM(r,s,n),HM(r,o,n,c),{transform:t,final:e},{transform:Uxe(i,a)},Mxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Hxe=(t,e)=>{for(let r of Sgt(t))vgt(t,r,e)},Sgt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),vgt=(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 ${md[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>bgt(a,n));r.input=uR(s)},bgt=(t,e)=>{let r=YM(t,e,"utf8",!0);return Egt(r),uR(r)},Egt=t=>{let e=t.find(r=>typeof r!="string"&&!Hr(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 Rgt,appendFileSync as xgt}from"fs";var ZM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ry(r,n)&&!_o.has(e)&&wgt(n)&&(t.some(({type:i,value:o})=>i==="native"&&Tgt.has(o))||t.every(({type:i})=>ts.has(i))),wgt=t=>t===1||t===2,Tgt=new Set(["pipe","overlapped"]),Wxe=async(t,e,r,n)=>{for await(let i of t)Agt(e)||Yxe(i,r,n)},Kxe=(t,e,r)=>{for(let n of t)Yxe(n,e,r)},Agt=t=>t._readableState.pipes.length>0,Yxe=(t,e,r)=>{let n=lM(t);dc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Zxe=({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,u)=>Igt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Igt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=XRe(t,o,d),p=wu(f),{stdioItems:m,objectMode:h}=e[r],_=Ogt([p],m,c,n),{serializedResult:y,finalResult:v=y}=Pgt({chunks:_,objectMode:h,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Cgt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:m,objectMode:h});let T=a[r]?v:void 0;try{return n.error===void 0&&kgt(y,m,i),T}catch(b){return n.error=b,T}},Ogt=(t,e,r,n)=>{try{return YM(t,e,r,!1)}catch(i){return n.error=i,t}},Pgt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:uR(t)};let s=dTe(t,r);return n[o]?{serializedResult:s,finalResult:o8(s,!i[o],e)}:{serializedResult:s}},Cgt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!ZM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=o8(t,!1,s);try{Kxe(a,e,n)}catch(c){r.error??=c}},kgt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>VM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?xgt(n,t):(r.add(o),Rgt(n,t))}};var Xxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ru(e,r,"all")]:Array.isArray(e)?[Ru(t,r,"all"),...e]:Hr(t)&&Hr(e)?m5([t,e]):`${t}${e}`};import{once as u8}from"events";var Jxe=async(t,e)=>{let[r,n]=await Ngt(t);return e.isForcefullyTerminated??=!1,[r,n]},Ngt=async t=>{let[e,r]=await Promise.allSettled([u8(t,"spawn"),u8(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Qxe(t):r.value},Qxe=async t=>{try{return await u8(t,"exit")}catch{return Qxe(t)}},eIe=async t=>{let[e,r]=await t;if(!$gt(e,r)&&l8(e,r))throw new pa;return[e,r]},$gt=(t,e)=>t===void 0&&e===void 0,l8=(t,e)=>t!==0||e!==null;var tIe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=Dgt(t,e,r),s=o?.code==="ETIMEDOUT",a=ZRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},Dgt=(t,e,r)=>t!==void 0?t:l8(e,r)?new pa:void 0;var rIe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Lgt(t,e,r),d=zgt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return My(d,c,u)},Lgt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=fM(t,e,r),a=Ugt(r),{file:c,commandArguments:u,options:l}=kM(t,e,a);Fgt(l);let d=kxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Ugt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Fgt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&XM("ipcInput"),t&&XM("ipc: true"),r&&XM("detached: true"),n&&XM("cancelSignal")},XM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},zgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=jgt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=tIe(c,r),{output:m,error:h=u}=Zxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=m.map((v,T)=>Ru(v,r,T)),y=Ru(Xxe(m,r),r,"all");return Bgt({error:h,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},jgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Hxe(o,r);let a=qgt(r);return Mgt(...NM(t,e,a))}catch(a){return Dy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},qgt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:zM(e)}),Bgt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?jM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):yR({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as Pyt}from"events";import{spawn as Cyt}from"child_process";import aIe from"process";import{once as d8,on as Vgt}from"events";var nIe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Oy({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:RM(t)}),Ggt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Ggt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{EM(e,i);let o=pd(t,e,r),s=new AbortController;try{return await Promise.race([Hgt(o,n,s),Wgt(o,r,s),Kgt(o,r,s)])}catch(a){throw Py(t),a}finally{s.abort(),wM(e,i)}},Hgt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await d8(t,"message",{signal:r});return n}for await(let[n]of Vgt(t,"message",{signal:r}))if(e(n))return n},Wgt=async(t,e,{signal:r})=>{await d8(t,"disconnect",{signal:r}),BAe(e)},Kgt=async(t,e,{signal:r})=>{let[n]=await d8(t,"strict:error",{signal:r});throw SM(n,e)};import{once as oIe,on as Ygt}from"events";var sIe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>f8({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),f8=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Oy({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:RM(t)}),EM(e,o);let s=pd(t,e,r),a=new AbortController,c={};return Zgt(t,s,a),Xgt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Jgt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Zgt=async(t,e,r)=>{try{await oIe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Xgt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await oIe(t,"strict:error",{signal:r.signal});n.error=SM(i,e),r.abort()}catch{}},Jgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Ygt(r,"message",{signal:o.signal}))iIe(s),yield c}catch{iIe(s)}finally{o.abort(),wM(e,a),n||Py(t),i&&await t}},iIe=({error:t})=>{if(t)throw t};var cIe=(t,{ipc:e})=>{Object.assign(t,lIe(t,!1,e))},uIe=()=>{let t=aIe,e=!0,r=aIe.channel!==void 0;return{...lIe(t,e,r),getCancelSignal:gRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},lIe=(t,e,r)=>({sendMessage:PM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:nIe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:sIe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Qgt}from"child_process";import{PassThrough as e_t,Readable as t_t,Writable as r_t,Duplex as n_t}from"stream";var dIe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{r8(n);let a=new Qgt;i_t(a,n),Object.assign(a,{readable:o_t,writable:s_t,duplex:a_t});let c=Dy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=c_t(c,s,i);return{subprocess:a,promise:u}},i_t=(t,e)=>{let r=vR(),n=vR(),i=vR(),o=Array.from({length:e.length-3},vR),s=vR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},vR=()=>{let t=new e_t;return t.end(),t},o_t=()=>new t_t({read(){}}),s_t=()=>new r_t({write(){}}),a_t=()=>new n_t({read(){},write(){}}),c_t=async(t,e,r)=>My(t,e,r);import{createReadStream as fIe,createWriteStream as pIe}from"fs";import{Buffer as u_t}from"buffer";import{Readable as bR,Writable as l_t,Duplex as d_t}from"stream";var hIe=(t,e)=>GM(f_t,t,e,!1),ER=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${md[t]}.`)},mIe={fileNumber:ER,generator:c8,asyncGenerator:c8,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:d_t.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},f_t={input:{...mIe,fileUrl:({value:t})=>({stream:fIe(t)}),filePath:({value:{file:t}})=>({stream:fIe(t)}),webStream:({value:t})=>({stream:bR.fromWeb(t)}),iterable:({value:t})=>({stream:bR.from(t)}),asyncIterable:({value:t})=>({stream:bR.from(t)}),string:({value:t})=>({stream:bR.from(t)}),uint8Array:({value:t})=>({stream:bR.from(u_t.from(t))})},output:{...mIe,fileUrl:({value:t})=>({stream:pIe(t)}),filePath:({value:{file:t,append:e}})=>({stream:pIe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:l_t.fromWeb(t)}),iterable:ER,asyncIterable:ER,string:ER,uint8Array:ER}};import{on as p_t,once as gIe}from"events";import{PassThrough as m_t,getDefaultHighWaterMark as h_t}from"stream";import{finished as SIe}from"stream/promises";function nm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)m8(i);let e=t.some(({readableObjectMode:i})=>i),r=g_t(t,e),n=new p8({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var g_t=(t,e)=>{if(t.length===0)return h_t(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},p8=class extends m_t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(m8(e),this.#e.has(e))return;this.#e.add(e),this.#n??=__t(this,this.#e,this.#o);let r=v_t({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(m8(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)}},__t=async(t,e,r)=>{JM(t,_Ie);let n=new AbortController;try{await Promise.race([y_t(t,n),S_t(t,e,r,n)])}finally{n.abort(),JM(t,-_Ie)}},y_t=async(t,{signal:e})=>{try{await SIe(t,{signal:e,cleanup:!0})}catch(r){throw vIe(t,r),r}},S_t=async(t,e,r,{signal:n})=>{for await(let[i]of p_t(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},m8=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},v_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{JM(t,yIe);let a=new AbortController;try{await Promise.race([b_t(o,e,a),E_t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),w_t({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),JM(t,-yIe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?h8(t):T_t(t))},b_t=async(t,e,{signal:r})=>{try{await t,r.aborted||h8(e)}catch(n){r.aborted||vIe(e,n)}},E_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await SIe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;bIe(s)?i.add(e):EIe(t,s)}},w_t=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await gIe(t,i,{signal:o}),!t.readable)return gIe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},T_t=t=>{t.writable&&t.end()},vIe=(t,e)=>{bIe(e)?h8(t):EIe(t,e)},bIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",h8=t=>{(t.readable||t.writable)&&t.destroy()},EIe=(t,e)=>{t.destroyed||(t.once("error",A_t),t.destroy(e))},A_t=()=>{},JM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},_Ie=2,yIe=1;import{finished as wIe}from"stream/promises";var Uy=(t,e)=>{t.pipe(e),R_t(t,e),x_t(t,e)},R_t=async(t,e)=>{if(!(fa(t)||fa(e))){try{await wIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}g8(e)}},g8=t=>{t.writable&&t.end()},x_t=async(t,e)=>{if(!(fa(t)||fa(e))){try{await wIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}_8(t)}},_8=t=>{t.readable&&t.destroy()};var TIe=(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})=>ts.has(c)))I_t(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ts.has(c)))P_t({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]:nm(o);Uy(s,i)}},I_t=(t,e,r,n)=>{r==="output"?Uy(t.stdio[n],e):Uy(e,t.stdio[n]);let i=O_t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},O_t=["stdin","stdout","stderr"],P_t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;C_t(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},C_t=(t,{signal:e})=>{fa(t)&&Qp(t,k_t,e)},k_t=2;import{addAbortListener as D_t}from"events";var im=[];im.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&im.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&im.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var QM=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",y8=Symbol.for("signal-exit emitter"),S8=globalThis,N_t=Object.defineProperty.bind(Object),v8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(S8[y8])return S8[y8];N_t(S8,y8,{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}},eL=class{},$_t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),b8=class extends eL{onExit(){return()=>{}}load(){}unload(){}},E8=class extends eL{#e=w8.platform==="win32"?"SIGINT":"SIGHUP";#r=new v8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of im)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(!QM(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 im)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,im.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 QM(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"&&QM(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)}},w8=globalThis.process,{onExit:AIe,load:Imr,unload:Omr}=$_t(QM(w8)?new E8(w8):new b8);var RIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=AIe(()=>{t.kill()});D_t(n,()=>{i()})};var IIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=dM(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=M_t(r,n,i),{sourceStream:d,sourceError:f}=U_t(t,u),{options:p,fileDescriptors:m}=pc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:m,startTime:o}},M_t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=L_t(t,e,...r),a=bM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},L_t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(xIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||f5(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]=tM(r,...n);return{destination:e(xIe)(i,o,s),pipeOptions:s}}if(pc.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}`)},xIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),U_t=(t,e)=>{try{return{sourceStream:Cy(t,e)}}catch(r){return{sourceError:r}}};var PIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=F_t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw T8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},F_t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return _8(t),n;if(e!==void 0)return g8(r),e},T8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Dy({error:t,command:OIe,escapedCommand:OIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),OIe="source.pipe(destination)";var CIe=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 z_t}from"stream/promises";var kIe=(t,e,r)=>{let n=tL.has(e)?q_t(t,e):j_t(t,e);return Qp(t,V_t,r.signal),Qp(e,G_t,r.signal),B_t(e),n},j_t=(t,e)=>{let r=nm([t]);return Uy(r,e),tL.set(e,r),r},q_t=(t,e)=>{let r=tL.get(e);return r.add(t),r},B_t=async t=>{try{await z_t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}tL.delete(t)},tL=new WeakMap,V_t=2,G_t=1;import{aborted as H_t}from"util";var NIe=(t,e)=>t===void 0?[]:[W_t(t,e)],W_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await H_t(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw T8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var rL=(t,...e)=>{if(Rr(e[0]))return rL.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=IIe(t,...e),i=K_t({...n,destination:r});return i.pipe=rL.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},K_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Y_t(t,i);PIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=kIe(e,o,d);return await Promise.race([CIe(l),...NIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Y_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as ryt}from"timers/promises";import{on as Z_t}from"events";import{getDefaultHighWaterMark as X_t}from"stream";var nL=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return J_t(e,s),DIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},J_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},A8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;Q_t(e,s,t);let a=t.readableObjectMode&&!o;return DIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Q_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},DIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Z_t(t,"data",{signal:e.signal,highWaterMark:$Ie,highWatermark:$Ie});return eyt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},R8=X_t(!0),$Ie=R8,eyt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=tyt({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*rm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*SR(a)}},tyt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[WM(t,r,!e),HM(t,i,!n,{})].filter(Boolean);var MIe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=nyt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([iyt(t),d]);return}let f=n8(c,r),p=A8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[m]=await Promise.all([oyt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return m},nyt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!ZM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=A8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Wxe(a,t,r,o)},iyt=async t=>{await ryt(),t.readableFlowing===null&&t.resume()},oyt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await LM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await UM(r,{maxBuffer:o})):await $y(r,{maxBuffer:o})}catch(a){return LIe(WRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},x8=async t=>{try{return await t}catch(e){return LIe(e)}},LIe=({bufferedData:t})=>uTe(t)?new Uint8Array(t):t;import{finished as syt}from"stream/promises";var wR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=ayt(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],syt(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||lyt(a,e,r,n)}finally{s.abort()}},ayt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&cyt(t,r,n),n},cyt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{uyt(e,r),n.call(t,...i)}},uyt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},lyt=(t,e,r,n)=>{if(!dyt(t,e,r,n))throw t},dyt=(t,e,r,n=!0)=>r.propagating?UIe(t)||iL(t):(r.propagating=!0,I8(r,e)===n?UIe(t):iL(t)),I8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",iL=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",UIe=t=>t?.code==="EPIPE";var FIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>O8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),O8=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=wR(t,e,u);if(I8(u,e)){await l;return}let[d]=await Promise.all([MIe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var zIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?nm([t,e].filter(Boolean)):void 0,jIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>O8({...fyt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:pyt(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),fyt=({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}},pyt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as myt}from"events";var qIe=t=>Ry(t,"ipc"),BIe=(t,e)=>{let r=lM(t);dc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var VIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=qIe(o),a=Tu(e,"ipc"),c=Tu(r,"ipc");for await(let u of f8({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(KRe(t,i,c),i.push(u)),s&&BIe(u,o);return i},GIe=async(t,e)=>(await Promise.allSettled([t]),e);var HIe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:m,originalStreams:h,onInternalError:_,controller:y})=>{let v=Jxe(t,f),T={originalStreams:h,fileDescriptors:m,subprocess:t,exitPromise:v,propagating:!1},b=FIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),E=jIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),S=[],I=VIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:S,verboseInfo:p}),P=hyt(h,t,T),O=gyt(m,T);try{return await Promise.race([Promise.all([{},eIe(v),Promise.all(b),E,I,RRe(t,d),...P,...O]),_,_yt(t,y),...bRe(t,o,f,y),...qAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...SRe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},v,Promise.all(b.map(A=>x8(A))),x8(E),GIe(I,S),Promise.allSettled(P),Promise.allSettled(O)])}},hyt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:wR(n,i,r)),gyt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>ha(o,{checkOpen:!1})&&!fa(o)).map(({type:i,value:o,stream:s=o})=>wR(s,n,e,{isSameDirection:ts.has(i),stopOnExit:i==="native"}))),_yt=async(t,{signal:e})=>{let[r]=await myt(t,"error",{signal:e});throw r};var WIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),TR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=fc();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Fy=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 yyt}from"stream";import{callbackify as Syt}from"util";import{finished as KIe}from"stream/promises";var P8=async t=>{if(t!==void 0)try{await C8(t)}catch{}},YIe=async t=>{if(t!==void 0)try{await k8(t)}catch{}},C8=async t=>{await KIe(t,{cleanup:!0,readable:!1,writable:!0})},k8=async t=>{await KIe(t,{cleanup:!0,readable:!0,writable:!1})},oL=async(t,e)=>{if(await t,e)throw e},sL=(t,e,r)=>{r&&!iL(r)?t.destroy(r):e&&t.destroy()};var ZIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_o.has(r),{subprocessStdout:a,waitReadableDestroy:c}=N8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=$8(a,s),{read:f,onStdoutDataDone:p}=D8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),m=new yyt({read:f,destroy:Syt(L8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return M8({subprocessStdout:a,onStdoutDataDone:p,readable:m,subprocess:t}),m},N8=(t,e,r)=>{let n=Cy(t,e),i=TR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},$8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:R8},D8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=fc(),s=nL({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){vyt(this,s,o)},onStdoutDataDone:o}},vyt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},M8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await k8(t),await n,await P8(i),await e,r.readable&&r.push(null)}catch(o){await P8(i),XIe(r,o)}},L8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Fy(r,e)&&(XIe(t,n),await oL(e,n))},XIe=(t,e)=>{sL(t,t.readable,e)};import{Writable as byt}from"stream";import{callbackify as JIe}from"util";var QIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=U8(t,r,e),s=new byt({...F8(n,t,i),destroy:JIe(j8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return z8(n,s),s},U8=(t,e,r)=>{let n=bM(t,e),i=TR(r,n,"writableFinal"),o=TR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},F8=(t,e,r)=>({write:Eyt.bind(void 0,t),final:JIe(wyt.bind(void 0,t,e,r))}),Eyt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},wyt=async(t,e,r)=>{await Fy(r,e)&&(t.writable&&t.end(),await e)},z8=async(t,e,r)=>{try{await C8(t),e.writable&&e.end()}catch(n){await YIe(r),eOe(e,n)}},j8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Fy(r,e),await Fy(n,e)&&(eOe(t,i),await oL(e,i))},eOe=(t,e)=>{sL(t,t.writable,e)};import{Duplex as Tyt}from"stream";import{callbackify as Ayt}from"util";var tOe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_o.has(r),{subprocessStdout:c,waitReadableDestroy:u}=N8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=U8(t,i,e),{readableEncoding:p,readableObjectMode:m,readableHighWaterMark:h}=$8(c,a),{read:_,onStdoutDataDone:y}=D8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new Tyt({read:_,...F8(l,t,d),destroy:Ayt(Ryt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:h,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:m,writableObjectMode:l.writableObjectMode,encoding:p});return M8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),z8(l,v,c),v},Ryt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([L8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),j8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var q8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_o.has(e),s=Cy(t,r),a=nL({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return xyt(a,s,t)},xyt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var rOe=(t,{encoding:e})=>{let r=WIe();t.readable=ZIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=QIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=tOe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=q8.bind(void 0,t,e),t[Symbol.asyncIterator]=q8.bind(void 0,t,e,{})};var nOe=(t,e)=>{for(let[r,n]of Oyt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Iyt=(async()=>{})().constructor.prototype,Oyt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Iyt,t)]);var iOe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=kyt(t,e,r),{subprocess:f,promise:p}=$yt({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=rL.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),nOe(f,p),pc.set(f,{options:l,fileDescriptors:d}),f},kyt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=fM(t,e,r),{file:a,commandArguments:c,options:u}=kM(t,e,r),l=Nyt(u),d=hIe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Nyt=({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}},$yt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=Cyt(...NM(t,e,r))}catch(m){return dIe({error:m,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;Pyt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];TIe(c,a,u),RIe(c,r,u);let d={},f=fc();c.kill=zAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=zIe(c,r),rOe(c,r),cIe(c,r);let p=Dyt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},Dyt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],m,h,_]=await HIe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=m.map((b,E)=>Ru(b,e,E)),v=Ru(h,e,"all"),T=Myt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return My(T,n,e)},Myt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?yR({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof mc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):jM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var aL=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Lyt(n,t[n],i)]));return{...t,...r}},Lyt=(t,e,r)=>Uyt.has(t)&&Rr(e)&&Rr(r)?{...e,...r}:r,Uyt=new Set(["env",...y5]);var hd=(t,e,r,n)=>{let i=(s,a,c)=>hd(s,a,r,c),o=(...s)=>Fyt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},Fyt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Rr(o))return i(t,aL(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=zyt({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?rIe(a,c,u):iOe(a,c,u,i)},zyt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=hTe(e)?gTe(e,r):[e,...r],[s,a,c]=tM(...o),u=aL(aL(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var oOe=({file:t,commandArguments:e})=>aOe(t,e),sOe=({file:t,commandArguments:e})=>({...aOe(t,e),isSync:!0}),aOe=(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]=jyt(t);return{file:r,commandArguments:n}},jyt=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(qyt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},qyt=/ +/g;var cOe=(t,e,r)=>{t.sync=e(Byt,r),t.s=t.sync},uOe=({options:t})=>lOe(t),Byt=({options:t})=>({...lOe(t),isSync:!0}),lOe=t=>({options:{...Vyt(t),...t}}),Vyt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},dOe={preferLocal:!0};var fOe=hd(()=>({})),y_r=hd(()=>({isSync:!0})),pOe=hd(oOe),S_r=hd(sOe),v_r=hd(wRe),b_r=hd(uOe,{},dOe,cOe),{sendMessage:E_r,getOneMessage:w_r,getEachMessage:T_r,getCancelSignal:A_r}=uIe();var mOe=!1,hOe,Gyt=t=>{hOe??=t},gOe=t=>{mOe=!0,Gyt(t)},Gn=()=>mOe,xu=()=>hOe,_Oe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var AR=null,yOe=t=>(AR&&AR.destroy(),AR=new rs({totalAllowedTime:t}),AR),SOe=()=>AR;var rs=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&&Gn())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((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await Sk({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{Y.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),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 vOe={name:"@netlify/agent-runner-cli",type:"module",version:"2.18.0-smtp.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup","build:bundle":"tsup --no-dts",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build:bundle 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:antigravity":"vitest run test/integration/antigravity.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",prompts:"LOG=0 vitest run --config vitest.prompts.config.js","site:build":"npm run prompts && node site/build.mjs","site:dev":"npm run site:build && netlify dev --dir site/dist",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.7","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.8.0","@opentelemetry/sdk-trace-base":"2.9.0","@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.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.3","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var Yyt=Wyt(import.meta.url),Zyt=Iu.dirname(Yyt),Xyt=Kyt(import.meta.url),zy=ce("shell"),B8=new Set,bOe={preferLocal:!0},Et=(t,e,r)=>{let[n,i]=Jyt(e,r),o={...bOe,...i},s=fOe(t,n,o);wOe(s,o),ROe(s);let a=r?.idleTimeout;return a&&a>0&&AOe(s,a),s},EOe=(t,e)=>{let r={...bOe,...e},n=pOe(t,r);return wOe(n,r),ROe(n),e?.idleTimeout&&e.idleTimeout>0&&AOe(n,e.idleTimeout),n},Jyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},wOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||gc.env.NETLIFY_LOCAL_QUIET==="true")return;if(gc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Yw).pipe(gc.stdout),t.stderr?.pipe(new Yw).pipe(gc.stderr);return}t.stdout?.pipe(gc.stdout),t.stderr?.pipe(gc.stderr)},V8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(gc.kill(-t.pid,e),zy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return zy.error("Error killing process:",r),!1}},TOe=t=>V8(t,"SIGKILL"),AOe=(t,e)=>{let r=null,n=()=>{zy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),V8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(zy.log(`Force killing idle process ${t.pid}`),TOe(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)},ROe=t=>{B8.add(t);let e=SOe();if(e){let r=e.onTimesUp(()=>{zy.log(`Global timer expired, killing process ${t.pid}`),V8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(zy.log(`Force killing process ${t.pid} after timeout`),TOe(t))},5e3)});t.on("exit",()=>{B8.delete(t),r()}),t.on("error",()=>{B8.delete(t),r()})}};function _c(t,e){if(!gc.env.NETLIFY_LOCAL_MODE)try{let i=Xyt.resolve(vOe.name),o=Iu.dirname(i);for(;o!==Iu.dirname(o);){let s=Iu.dirname(o);if(Iu.basename(s)==="node_modules"){let a=Iu.join(s,".bin",e);if(cL.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(gc.env.NODE_PATH){let i=Iu.join(gc.env.NODE_PATH,".bin",e);if(cL.existsSync(i))return i}let r=Iu.join(t,"node_modules",".bin",e);if(cL.existsSync(r))return r;let n=Iu.join(Zyt,"..","node_modules",".bin",e);if(cL.existsSync(n))return n}var jy=ce("repo"),$Oe="runner-diffs-",G8=t=>`${$Oe}${t}-`,DOe=async t=>{let e=lL.tmpdir(),r;try{r=await Hn.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith($Oe)&&!n.startsWith(G8(t))).map(n=>Hn.rm(yo.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},xOe=async t=>{let e=Qyt("sha256");for await(let r of eSt(t))e.update(r);return e.digest("hex")},IOe=async(t,e)=>t.size===e.size&&await xOe(t.path)===await xOe(e.path),MOe=/.. (.+)?\.log$/,tSt=[MOe],rSt=1,OOe=/^<<<<<<<( |$)/m,POe=t=>{let e=t.split(`
|
|
399
399
|
`).reduce((r,n)=>{if(!n)return r;let[i,o,,...s]=n,a=s.join(""),c=i.trim(),u=o.trim();return r[a]?r[a].change=u:r[a]={filePath:a,stage:c,change:u},r},{});return Object.values(e)},nSt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),COe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return On(r?`${e}: ${r}`:e)},iSt=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),kOe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),oSt=(t,e)=>{try{let r=new URL(t),n=new URL(e);return["https:","http:"].includes(n.protocol)&&n.protocol===r.protocol&&n.host===r.host&&kOe(n)===kOe(r)&&n.password!==""}catch{return!1}},NOe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},uL=500,RR=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},Bi=class{constructor(e=process.cwd()){this.cwd=e}getRoot(){return this.root??=this.run(["rev-parse","--show-toplevel"],{stdout:"pipe"}).then(({stdout:e})=>String(e).trim()),this.root}async restorePausedWork(e){let r="restore";try{let n=await this.restorePausedFiles(e);r="stage",await this.stageBuildSetup();let i=await this.getRoot(),o=new Set(n.changedFiles),s=(await this.listIndexEntries(n.deletedFiles,{cwd:i})).filter(({filePath:a})=>!o.has(a));return await this.unstageFiles(n.changedFiles,{cwd:i}),s.length>0&&await Hn.writeFile(await this.getSetupMetadataPath(),JSON.stringify(s)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new RR(r,n)}}run(e,r={}){return Et("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){jy.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!r){let u=POe(o);await this.discardSetupOnlyChanges(u)}jy.info("Changes after processing"),await this.getStatus();let s=await this.getIgnoredPathspecs(o);if(await this.stageFiles(s),await this.excludeUnchangedSetupDescendants(),i=await this.hasStagedChanges(),!i)return{hasChanges:!1,ignored:s};await this.run(["commit","-m","Agent runner [skip ci]"]);let a=await Hn.mkdtemp(yo.join(lL.tmpdir(),G8(e.sessionId))),c=await this.writeDiffFiles({config:e,diffDir:a,target:{commit:"HEAD"},ignored:s});return await this.rollbackIfLocal(),c.hasChanges&&Y.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c}async getStatus(){let e=await this.run(["-c","status.relativePaths=true","status","-s"]);return String(e.stdout??"")}async hasAgentChanges(){let e=await this.getStatus();return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
400
400
|
`).filter(i=>tSt.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}}async getCurrentCommitSha(){let{stdout:e}=await this.run(["rev-parse","HEAD"]);return String(e??"").trim()}async reset(){await this.run(["reset","--hard","HEAD"]),await Hn.rm(await this.getSetupMetadataPath(),{force:!0})}async discardSetupOnlyChanges(e){let r=e.filter(n=>n.stage&&!n.change).map(n=>n.filePath);r.length!==0&&await this.run(["restore","--staged","--worktree","--pathspec-from-file=-"],{input:r.join(`
|
|
401
401
|
`)})}async stageBuildSetup(){await Hn.rm(await this.getSetupMetadataPath(),{force:!0});let e=await this.getIgnoredPathspecs();await this.stageFiles(e)}async unstageSetupResolvedConflicts(e){let r=await this.getRoot(),{stdout:n}=await this.run(["diff","--no-relative","--name-only","-z","--text",`-G${OOe.source}`,e,"HEAD"],{cwd:r,stdout:"pipe"}),i=String(n??"").split("\0").filter(Boolean),o=[];for(let s of i){let a=await Hn.readFile(yo.join(r,s),"utf8").catch(()=>{});a!==void 0&&!OOe.test(a)&&o.push(s)}return await this.unstageFiles(o,{cwd:r}),o}getSetupMetadataPath(){return this.setupMetadataPath??=this.getRoot().then(async e=>{let{stdout:r}=await this.run(["rev-parse","--git-path","netlify-agent-runner-setup.json"],{cwd:e,stdout:"pipe"});return yo.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=uL){let o=e.slice(i,i+uL).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...NOe,...r});for(let a of String(s??"").split("\0").filter(Boolean))n.push({filePath:a.slice(a.indexOf(" ")+1),entry:a})}return n}async excludeUnchangedSetupDescendants(e){let r;try{r=JSON.parse(await Hn.readFile(await this.getSetupMetadataPath(),"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}let i={cwd:await this.getRoot(),env:e},o=new Map((await this.listIndexEntries(r.map(({filePath:a})=>a),i)).map(({filePath:a,entry:c})=>[a,c])),s=r.filter(({filePath:a,entry:c})=>o.get(a)===c);s.length!==0&&await this.run(["update-index","--force-remove","-z","--stdin"],{...i,input:s.map(({filePath:a})=>a).join("\0")})}async getIgnoredPathspecs(e){e||=await this.getStatus();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 e.split(`
|
package/package.json
CHANGED