@netlify/agent-runner-cli 1.168.0 → 1.168.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 CHANGED
@@ -140,7 +140,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
140
140
  `,LF:`
141
141
  `,concatBytes:ez},JVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},XVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:JVe};import{Buffer as QVe}from"buffer";var Bce=(t,e)=>t?void 0:eGe.bind(void 0,e),eGe=function*(t,e){if(typeof e!="string"&&!gr(e)&&!QVe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},qce=(t,e)=>t?tGe.bind(void 0,e):rGe.bind(void 0,e),tGe=function*(t,e){Vce(t,e),yield e},rGe=function*(t,e){if(Vce(t,e),typeof e!="string"&&!gr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Vce=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
142
142
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
143
- if (condition) { yield value; }`)};import{Buffer as nGe}from"buffer";import{StringDecoder as iGe}from"string_decoder";var U0=(t,e,r)=>{if(r)return;if(t)return{transform:oGe.bind(void 0,new TextEncoder)};let n=new iGe(e);return{transform:sGe.bind(void 0,n),final:aGe.bind(void 0,n)}},oGe=function*(t,e){nGe.isBuffer(e)?yield Ca(e):typeof e=="string"?yield t.encode(e):yield e},sGe=function*(t,e){yield gr(e)?t.write(e):e},aGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Gce}from"util";var rz=Gce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),F0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=lGe}=e[r];for await(let i of n(t))yield*F0(i,e,r+1)},Hce=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*cGe(r,Number(e),t)},cGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*F0(n,r,e+1)},Wce=Gce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),lGe=function*(t){yield t};var nz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Yce=(t,e)=>[...e.flatMap(r=>[...ad(r,t,0)]),...VS(t)],ad=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=dGe}=e[r];for(let i of n(t))yield*ad(i,e,r+1)},VS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*uGe(r,Number(e),t)},uGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*ad(n,r,e+1)},dGe=function*(t){yield t};var iz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Zce(t,s,o),l=sd(e),u=sd(r),d=l?rz.bind(void 0,F0,a):nz.bind(void 0,ad),f=l||u?rz.bind(void 0,Hce,a):nz.bind(void 0,VS),p=l||u?Wce.bind(void 0,a):void 0;return{stream:new fGe({writableObjectMode:n,writableHighWaterMark:Kce(n),readableObjectMode:i,readableHighWaterMark:Kce(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},z0=(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=Zce(s,r,a);t=Yce(c,t)}return t},Zce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Bce(n,a)},U0(r,s,n),L0(r,o,n,c),{transform:t,final:e},{transform:qce(i,a)},jce({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Jce=(t,e)=>{for(let r of pGe(t))hGe(t,r,e)},pGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),hGe=(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 ${Qc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>mGe(a,n));r.input=MS(s)},mGe=(t,e)=>{let r=z0(t,e,"utf8",!0);return gGe(r),MS(r)},gGe=t=>{let e=t.find(r=>typeof r!="string"&&!gr(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 EGe,appendFileSync as vGe}from"fs";var j0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Jp(r,n)&&!hi.has(e)&&_Ge(n)&&(t.some(({type:i,value:o})=>i==="native"&&yGe.has(o))||t.every(({type:i})=>Vi.has(i))),_Ge=t=>t===1||t===2,yGe=new Set(["pipe","overlapped"]),Xce=async(t,e,r,n)=>{for await(let i of t)SGe(e)||ele(i,r,n)},Qce=(t,e,r)=>{for(let n of t)ele(n,e,r)},SGe=t=>t._readableState.pipes.length>0,ele=(t,e,r)=>{let n=t0(t);Ss({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var tle=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>bGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},bGe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=rce(t,o,d),p=Ca(f),{stdioItems:h,objectMode:m}=e[r],g=TGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=wGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});xGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?b:void 0;try{return n.error===void 0&&AGe(_,h,i),T}catch(S){return n.error=S,T}},TGe=(t,e,r,n)=>{try{return z0(t,e,r,!1)}catch(i){return n.error=i,t}},wGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:MS(t)};let s=goe(t,r);return n[o]?{serializedResult:s,finalResult:tz(s,!i[o],e)}:{serializedResult:s}},xGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!j0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=tz(t,!1,s);try{Qce(a,e,n)}catch(c){r.error??=c}},AGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>$0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?vGe(n,t):(r.add(o),EGe(n,t))}};var rle=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Oa(e,r,"all")]:Array.isArray(e)?[Oa(t,r,"all"),...e]:gr(t)&&gr(e)?uF([t,e]):`${t}${e}`};import{once as oz}from"events";var nle=async(t,e)=>{let[r,n]=await RGe(t);return e.isForcefullyTerminated??=!1,[r,n]},RGe=async t=>{let[e,r]=await Promise.allSettled([oz(t,"spawn"),oz(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?ile(t):r.value},ile=async t=>{try{return await oz(t,"exit")}catch{return ile(t)}},ole=async t=>{let[e,r]=await t;if(!CGe(e,r)&&sz(e,r))throw new Io;return[e,r]},CGe=(t,e)=>t===void 0&&e===void 0,sz=(t,e)=>t!==0||e!==null;var sle=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=IGe(t,e,r),s=o?.code==="ETIMEDOUT",a=tce(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},IGe=(t,e,r)=>t!==void 0?t:sz(e,r)?new Io:void 0;var ale=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=OGe(t,e,r),d=MGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return ah(d,c,l)},OGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=n0(t,e,r),a=NGe(r),{file:c,commandArguments:l,options:u}=T0(t,e,a);kGe(u);let d=Lce(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},NGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,kGe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&B0("ipcInput"),t&&B0("ipc: true"),r&&B0("detached: true"),n&&B0("cancelSignal")},B0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},MGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=$Ge({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=sle(c,r),{output:h,error:m=l}=tle({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>Oa(b,r,T)),_=Oa(rle(h,r),r,"all");return LGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},$Ge=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Jce(o,r);let a=DGe(r);return PGe(...w0(t,e,a))}catch(a){return sh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},DGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:O0(e)}),LGe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?N0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):qS({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as w6e}from"events";import{spawn as x6e}from"child_process";import fle from"process";import{once as az,on as UGe}from"events";var cle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(eh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:_0(t)}),FGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),FGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{p0(e,i);let o=Xc(t,e,r),s=new AbortController;try{return await Promise.race([zGe(o,n,s),jGe(o,r,s),BGe(o,r,s)])}catch(a){throw th(t),a}finally{s.abort(),h0(e,i)}},zGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await az(t,"message",{signal:r});return n}for await(let[n]of UGe(t,"message",{signal:r}))if(e(n))return n},jGe=async(t,e,{signal:r})=>{await az(t,"disconnect",{signal:r}),Yse(e)},BGe=async(t,e,{signal:r})=>{let[n]=await az(t,"strict:error",{signal:r});throw u0(n,e)};import{once as ule,on as qGe}from"events";var dle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>cz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),cz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{eh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:_0(t)}),p0(e,o);let s=Xc(t,e,r),a=new AbortController,c={};return VGe(t,s,a),GGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),HGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},VGe=async(t,e,r)=>{try{await ule(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},GGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ule(t,"strict:error",{signal:r.signal});n.error=u0(i,e),r.abort()}catch{}},HGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of qGe(r,"message",{signal:o.signal}))lle(s),yield c}catch{lle(s)}finally{o.abort(),h0(e,a),n||th(t),i&&await t}},lle=({error:t})=>{if(t)throw t};var ple=(t,{ipc:e})=>{Object.assign(t,mle(t,!1,e))},hle=()=>{let t=fle,e=!0,r=fle.channel!==void 0;return{...mle(t,e,r),getCancelSignal:vae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},mle=(t,e,r)=>({sendMessage:v0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:cle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:dle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as WGe}from"child_process";import{PassThrough as YGe,Readable as KGe,Writable as ZGe,Duplex as JGe}from"stream";var gle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{XF(n);let a=new WGe;XGe(a,n),Object.assign(a,{readable:QGe,writable:eHe,duplex:tHe});let c=sh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=rHe(c,s,i);return{subprocess:a,promise:l}},XGe=(t,e)=>{let r=GS(),n=GS(),i=GS(),o=Array.from({length:e.length-3},GS),s=GS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},GS=()=>{let t=new YGe;return t.end(),t},QGe=()=>new KGe({read(){}}),eHe=()=>new ZGe({write(){}}),tHe=()=>new JGe({read(){},write(){}}),rHe=async(t,e,r)=>ah(t,e,r);import{createReadStream as _le,createWriteStream as yle}from"fs";import{Buffer as nHe}from"buffer";import{Readable as HS,Writable as iHe,Duplex as oHe}from"stream";var Ele=(t,e)=>D0(sHe,t,e,!1),WS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Qc[t]}.`)},Sle={fileNumber:WS,generator:iz,asyncGenerator:iz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:oHe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},sHe={input:{...Sle,fileUrl:({value:t})=>({stream:_le(t)}),filePath:({value:{file:t}})=>({stream:_le(t)}),webStream:({value:t})=>({stream:HS.fromWeb(t)}),iterable:({value:t})=>({stream:HS.from(t)}),asyncIterable:({value:t})=>({stream:HS.from(t)}),string:({value:t})=>({stream:HS.from(t)}),uint8Array:({value:t})=>({stream:HS.from(nHe.from(t))})},output:{...Sle,fileUrl:({value:t})=>({stream:yle(t)}),filePath:({value:{file:t,append:e}})=>({stream:yle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:iHe.fromWeb(t)}),iterable:WS,asyncIterable:WS,string:WS,uint8Array:WS}};import{on as aHe,once as vle}from"events";import{PassThrough as cHe,getDefaultHighWaterMark as lHe}from"stream";import{finished as wle}from"stream/promises";function cd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)uz(i);let e=t.some(({readableObjectMode:i})=>i),r=uHe(t,e),n=new lz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var uHe=(t,e)=>{if(t.length===0)return lHe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},lz=class extends cHe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(uz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=dHe(this,this.#e,this.#o);let r=hHe({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(uz(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)}},dHe=async(t,e,r)=>{q0(t,ble);let n=new AbortController;try{await Promise.race([fHe(t,n),pHe(t,e,r,n)])}finally{n.abort(),q0(t,-ble)}},fHe=async(t,{signal:e})=>{try{await wle(t,{signal:e,cleanup:!0})}catch(r){throw xle(t,r),r}},pHe=async(t,e,r,{signal:n})=>{for await(let[i]of aHe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},uz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},hHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{q0(t,Tle);let a=new AbortController;try{await Promise.race([mHe(o,e,a),gHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),_He({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),q0(t,-Tle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?dz(t):yHe(t))},mHe=async(t,e,{signal:r})=>{try{await t,r.aborted||dz(e)}catch(n){r.aborted||xle(e,n)}},gHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await wle(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Ale(s)?i.add(e):Rle(t,s)}},_He=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await vle(t,i,{signal:o}),!t.readable)return vle(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},yHe=t=>{t.writable&&t.end()},xle=(t,e)=>{Ale(e)?dz(t):Rle(t,e)},Ale=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",dz=t=>{(t.readable||t.writable)&&t.destroy()},Rle=(t,e)=>{t.destroyed||(t.once("error",SHe),t.destroy(e))},SHe=()=>{},q0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ble=2,Tle=1;import{finished as Cle}from"stream/promises";var lh=(t,e)=>{t.pipe(e),EHe(t,e),vHe(t,e)},EHe=async(t,e)=>{if(!(Co(t)||Co(e))){try{await Cle(t,{cleanup:!0,readable:!0,writable:!1})}catch{}fz(e)}},fz=t=>{t.writable&&t.end()},vHe=async(t,e)=>{if(!(Co(t)||Co(e))){try{await Cle(e,{cleanup:!0,readable:!1,writable:!0})}catch{}pz(t)}},pz=t=>{t.readable&&t.destroy()};var Ile=(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})=>Vi.has(c)))bHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Vi.has(c)))wHe({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]:cd(o);lh(s,i)}},bHe=(t,e,r,n)=>{r==="output"?lh(t.stdio[n],e):lh(e,t.stdio[n]);let i=THe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},THe=["stdin","stdout","stderr"],wHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;xHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},xHe=(t,{signal:e})=>{Co(t)&&id(t,AHe,e)},AHe=2;import{addAbortListener as IHe}from"events";var ld=[];ld.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ld.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ld.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var V0=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",hz=Symbol.for("signal-exit emitter"),mz=globalThis,RHe=Object.defineProperty.bind(Object),gz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(mz[hz])return mz[hz];RHe(mz,hz,{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}},G0=class{},CHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),_z=class extends G0{onExit(){return()=>{}}load(){}unload(){}},yz=class extends G0{#e=Sz.platform==="win32"?"SIGINT":"SIGHUP";#r=new gz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ld)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(!V0(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 ld)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,ld.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 V0(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"&&V0(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)}},Sz=globalThis.process,{onExit:Ple,load:fUt,unload:pUt}=CHe(V0(Sz)?new yz(Sz):new _z);var Ole=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Ple(()=>{t.kill()});IHe(n,()=>{i()})};var kle=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=r0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=PHe(r,n,i),{sourceStream:d,sourceError:f}=NHe(t,l),{options:p,fileDescriptors:h}=vs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},PHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=OHe(t,e,...r),a=f0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},OHe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Nle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||cF(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]=HR(r,...n);return{destination:e(Nle)(i,o,s),pipeOptions:s}}if(vs.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}`)},Nle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),NHe=(t,e)=>{try{return{sourceStream:rh(t,e)}}catch(r){return{sourceError:r}}};var $le=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=kHe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw Ez({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},kHe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return pz(t),n;if(e!==void 0)return fz(r),e},Ez=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>sh({error:t,command:Mle,escapedCommand:Mle,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Mle="source.pipe(destination)";var Dle=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 MHe}from"stream/promises";var Lle=(t,e,r)=>{let n=H0.has(e)?DHe(t,e):$He(t,e);return id(t,UHe,r.signal),id(e,FHe,r.signal),LHe(e),n},$He=(t,e)=>{let r=cd([t]);return lh(r,e),H0.set(e,r),r},DHe=(t,e)=>{let r=H0.get(e);return r.add(t),r},LHe=async t=>{try{await MHe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}H0.delete(t)},H0=new WeakMap,UHe=2,FHe=1;import{aborted as zHe}from"util";var Ule=(t,e)=>t===void 0?[]:[jHe(t,e)],jHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await zHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw Ez({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var W0=(t,...e)=>{if(ir(e[0]))return W0.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=kle(t,...e),i=BHe({...n,destination:r});return i.pipe=W0.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},BHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=qHe(t,i);$le({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Lle(e,o,d);return await Promise.race([Dle(u),...Ule(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},qHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as ZHe}from"timers/promises";import{on as VHe}from"events";import{getDefaultHighWaterMark as GHe}from"stream";var Y0=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return HHe(e,s),zle({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},HHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},vz=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;WHe(e,s,t);let a=t.readableObjectMode&&!o;return zle({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},WHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},zle=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=VHe(t,"data",{signal:e.signal,highWaterMark:Fle,highWatermark:Fle});return YHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},bz=GHe(!0),Fle=bz,YHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=KHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*ad(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*VS(a)}},KHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[U0(t,r,!e),L0(t,i,!n,{})].filter(Boolean);var jle=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=JHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([XHe(t),d]);return}let f=QF(c,r),p=vz({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([QHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},JHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!j0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=vz({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Xce(a,t,r,o)},XHe=async t=>{await ZHe(),t.readableFlowing===null&&t.resume()},QHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await C0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await I0(r,{maxBuffer:o})):await oh(r,{maxBuffer:o})}catch(a){return Ble(Xae({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},Tz=async t=>{try{return await t}catch(e){return Ble(e)}},Ble=({bufferedData:t})=>hoe(t)?new Uint8Array(t):t;import{finished as e6e}from"stream/promises";var YS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=t6e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],e6e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||i6e(a,e,r,n)}finally{s.abort()}},t6e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&r6e(t,r,n),n},r6e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{n6e(e,r),n.call(t,...i)}},n6e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},i6e=(t,e,r,n)=>{if(!o6e(t,e,r,n))throw t},o6e=(t,e,r,n=!0)=>r.propagating?qle(t)||K0(t):(r.propagating=!0,wz(r,e)===n?qle(t):K0(t)),wz=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",K0=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",qle=t=>t?.code==="EPIPE";var Vle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>xz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),xz=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=YS(t,e,l);if(wz(l,e)){await u;return}let[d]=await Promise.all([jle({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Gle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?cd([t,e].filter(Boolean)):void 0,Hle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>xz({...s6e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:a6e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),s6e=({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}},a6e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as c6e}from"events";var Wle=t=>Jp(t,"ipc"),Yle=(t,e)=>{let r=t0(t);Ss({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Kle=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Wle(o),a=Ia(e,"ipc"),c=Ia(r,"ipc");for await(let l of cz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Qae(t,i,c),i.push(l)),s&&Yle(l,o);return i},Zle=async(t,e)=>(await Promise.allSettled([t]),e);var Jle=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let b=nle(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=Vle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=Hle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),P=[],C=Kle({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),N=l6e(m,t,T),k=u6e(h,T);try{return await Promise.race([Promise.all([{},ole(b),Promise.all(S),w,C,Oae(t,d),...N,...k]),g,d6e(t,_),...Aae(t,o,f,_),...Wse({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...wae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(U){return f.terminationReason??="other",Promise.all([{error:U},b,Promise.all(S.map(v=>Tz(v))),Tz(w),Zle(C,P),Promise.allSettled(N),Promise.allSettled(k)])}},l6e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:YS(n,i,r)),u6e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Oo(o,{checkOpen:!1})&&!Co(o)).map(({type:i,value:o,stream:s=o})=>YS(s,n,e,{isSameDirection:Vi.has(i),stopOnExit:i==="native"}))),d6e=async(t,{signal:e})=>{let[r]=await c6e(t,"error",{signal:e});throw r};var Xle=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),KS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Es();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},uh=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 f6e}from"stream";import{callbackify as p6e}from"util";import{finished as Qle}from"stream/promises";var Az=async t=>{if(t!==void 0)try{await Rz(t)}catch{}},eue=async t=>{if(t!==void 0)try{await Cz(t)}catch{}},Rz=async t=>{await Qle(t,{cleanup:!0,readable:!1,writable:!0})},Cz=async t=>{await Qle(t,{cleanup:!0,readable:!0,writable:!1})},Z0=async(t,e)=>{if(await t,e)throw e},J0=(t,e,r)=>{r&&!K0(r)?t.destroy(r):e&&t.destroy()};var tue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||hi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Iz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Pz(a,s),{read:f,onStdoutDataDone:p}=Oz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new f6e({read:f,destroy:p6e(kz.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Nz({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Iz=(t,e,r)=>{let n=rh(t,e),i=KS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Pz=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:bz},Oz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Es(),s=Y0({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){h6e(this,s,o)},onStdoutDataDone:o}},h6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Nz=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Cz(t),await n,await Az(i),await e,r.readable&&r.push(null)}catch(o){await Az(i),rue(r,o)}},kz=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await uh(r,e)&&(rue(t,n),await Z0(e,n))},rue=(t,e)=>{J0(t,t.readable,e)};import{Writable as m6e}from"stream";import{callbackify as nue}from"util";var iue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Mz(t,r,e),s=new m6e({...$z(n,t,i),destroy:nue(Lz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Dz(n,s),s},Mz=(t,e,r)=>{let n=f0(t,e),i=KS(r,n,"writableFinal"),o=KS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},$z=(t,e,r)=>({write:g6e.bind(void 0,t),final:nue(_6e.bind(void 0,t,e,r))}),g6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},_6e=async(t,e,r)=>{await uh(r,e)&&(t.writable&&t.end(),await e)},Dz=async(t,e,r)=>{try{await Rz(t),e.writable&&e.end()}catch(n){await eue(r),oue(e,n)}},Lz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await uh(r,e),await uh(n,e)&&(oue(t,i),await Z0(e,i))},oue=(t,e)=>{J0(t,t.writable,e)};import{Duplex as y6e}from"stream";import{callbackify as S6e}from"util";var sue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||hi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Iz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Mz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Pz(c,a),{read:g,onStdoutDataDone:_}=Oz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new y6e({read:g,...$z(u,t,d),destroy:S6e(E6e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return Nz({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),Dz(u,b,c),b},E6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([kz({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Lz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Uz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||hi.has(e),s=rh(t,r),a=Y0({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return v6e(a,s,t)},v6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var aue=(t,{encoding:e})=>{let r=Xle();t.readable=tue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=iue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=sue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Uz.bind(void 0,t,e),t[Symbol.asyncIterator]=Uz.bind(void 0,t,e,{})};var cue=(t,e)=>{for(let[r,n]of T6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},b6e=(async()=>{})().constructor.prototype,T6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(b6e,t)]);var lue=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=A6e(t,e,r),{subprocess:f,promise:p}=C6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=W0.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),cue(f,p),vs.set(f,{options:u,fileDescriptors:d}),f},A6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=n0(t,e,r),{file:a,commandArguments:c,options:l}=T0(t,e,r),u=R6e(l),d=Ele(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},R6e=({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}},C6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=x6e(...w0(t,e,r))}catch(h){return gle({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;w6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ile(c,a,l),Ole(c,r,l);let d={},f=Es();c.kill=Gse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Gle(c,r),aue(c,r),ple(c,r);let p=I6e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},I6e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Jle({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((S,w)=>Oa(S,e,w)),b=Oa(m,e,"all"),T=P6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return ah(T,n,e)},P6e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?qS({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof bs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):N0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var X0=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,O6e(n,t[n],i)]));return{...t,...r}},O6e=(t,e,r)=>N6e.has(t)&&ir(e)&&ir(r)?{...e,...r}:r,N6e=new Set(["env",...hF]);var el=(t,e,r,n)=>{let i=(s,a,c)=>el(s,a,r,c),o=(...s)=>k6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},k6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(ir(o))return i(t,X0(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=M6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?ale(a,c,l):lue(a,c,l,i)},M6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Eoe(e)?voe(e,r):[e,...r],[s,a,c]=HR(...o),l=X0(X0(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var uue=({file:t,commandArguments:e})=>fue(t,e),due=({file:t,commandArguments:e})=>({...fue(t,e),isSync:!0}),fue=(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]=$6e(t);return{file:r,commandArguments:n}},$6e=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(D6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},D6e=/ +/g;var pue=(t,e,r)=>{t.sync=e(L6e,r),t.s=t.sync},hue=({options:t})=>mue(t),L6e=({options:t})=>({...mue(t),isSync:!0}),mue=t=>({options:{...U6e(t),...t}}),U6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},gue={preferLocal:!0};var _ue=el(()=>({})),rjt=el(()=>({isSync:!0})),yue=el(uue),njt=el(due),ijt=el(Cae),ojt=el(hue,{},gue,pue),{sendMessage:sjt,getOneMessage:ajt,getEachMessage:cjt,getCancelSignal:ljt}=hle();var Sue=!1,Eue=()=>{Sue=!0},ws=()=>Sue;var ZS=null,vue=t=>(ZS&&ZS.destroy(),ZS=new No({totalAllowedTime:t}),ZS),bue=()=>ZS;var No=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&&ws())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await LR({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{re.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Tue={name:"@netlify/agent-runner-cli",type:"module",version:"1.168.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var B6e=z6e(import.meta.url),q6e=Na.dirname(B6e),V6e=j6e(import.meta.url),dh=ce("shell"),Fz=new Set,wue={preferLocal:!0},_r=(t,e,r)=>{let[n,i]=G6e(e,r),o={...wue,...i},s=_ue(t,n,o);Aue(s,o),Iue(s);let a=r?.idleTimeout;return a&&a>0&&Cue(s,a),s},xue=(t,e)=>{let r={...wue,...e},n=yue(t,r);return Aue(n,r),Iue(n),e?.idleTimeout&&e.idleTimeout>0&&Cue(n,e.idleTimeout),n},G6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Aue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||xs.env.NETLIFY_LOCAL_QUIET==="true")return;if(xs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new xS).pipe(xs.stdout),t.stderr?.pipe(new xS).pipe(xs.stderr);return}t.stdout?.pipe(xs.stdout),t.stderr?.pipe(xs.stderr)},zz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(xs.kill(-t.pid,e),dh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return dh.error("Error killing process:",r),!1}},Rue=t=>zz(t,"SIGKILL"),Cue=(t,e)=>{let r=null,n=()=>{dh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),zz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dh.log(`Force killing idle process ${t.pid}`),Rue(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)},Iue=t=>{Fz.add(t);let e=bue();if(e){let r=e.onTimesUp(()=>{dh.log(`Global timer expired, killing process ${t.pid}`),zz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dh.log(`Force killing process ${t.pid} after timeout`),Rue(t))},5e3)});t.on("exit",()=>{Fz.delete(t),r()}),t.on("error",()=>{Fz.delete(t),r()})}};function eC(t,e){return!!ko(t,e)}function ko(t,e){if(!xs.env.NETLIFY_LOCAL_MODE)try{let i=V6e.resolve(Tue.name),o=Na.dirname(i);for(;o!==Na.dirname(o);){let s=Na.dirname(o);if(Na.basename(s)==="node_modules"){let a=Na.join(s,".bin",e);if(Q0.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(xs.env.NODE_PATH){let i=Na.join(xs.env.NODE_PATH,".bin",e);if(Q0.existsSync(i))return i}let r=Na.join(t,"node_modules",".bin",e);if(Q0.existsSync(r))return r;let n=Na.join(q6e,"..","node_modules",".bin",e);if(Q0.existsSync(n))return n}var H6e=ce("utils"),W6e=t=>new Promise(e=>{setTimeout(e,t)});var jz=t=>{try{return new URL(t).hostname||null}catch{return null}},tC=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await W6e(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},tl=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Pue=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):H6e.error("Could not parse JSON",n))}},Y6e=t=>t.charAt(0).toUpperCase()+t.slice(1),As=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():Y6e(e)).join(" ");function ka(t,e){e&&t.log(`Skill invoked: ${e}`)}var rC=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Oue=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var Bz=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},K6e=1e4,qz=(t,e=K6e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{createHash as Z6e}from"crypto";import{createReadStream as J6e}from"fs";import nC from"fs/promises";import Due from"os";import iC from"path";var Nue=ce("repo"),Lue="runner-diffs-",Uue=t=>`${Lue}${t}-`,Fue=async t=>{let e=Due.tmpdir(),r;try{r=await nC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Lue)&&!n.startsWith(Uue(t))).map(n=>nC.rm(iC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Hn=(t,e={})=>_r("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),oC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Nue.info("Getting runner diffs");let n=await Q6e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=t3e(o);await r3e(h,r)}Nue.info("Changes after processing"),await Gz(r);let s=await Hz(o,r);if(await Vz(s,r),i=await e3e(r),!i)return{hasChanges:!1,ignored:s};await Hn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await nC.mkdtemp(iC.join(Due.tmpdir(),Uue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=iC.join(a,g);await Hn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await nC.stat(b);return{path:b,size:S}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await $ue(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await Mue(d,h)||(f=h)}await $ue(r),re.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Mue(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},kue=async t=>{let e=Z6e("sha256");for await(let r of J6e(t))e.update(r);return e.digest("hex")},Mue=async(t,e)=>t.size===e.size&&await kue(t.path)===await kue(e.path),$ue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Hn(["reset","--soft","HEAD~1"],{cwd:t})},Vz=async(t=[],e=process.cwd())=>{await Hn(["add",".",...t],{cwd:e})},Gz=async(t=process.cwd())=>{let e=await Hn(["status","-s"],{cwd:t});return String(e.stdout??"")},zue=/.. (.+)?\.log$/,X6e=[zue],Q6e=async(t=process.cwd())=>{let e=await Gz(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
143
+ if (condition) { yield value; }`)};import{Buffer as nGe}from"buffer";import{StringDecoder as iGe}from"string_decoder";var U0=(t,e,r)=>{if(r)return;if(t)return{transform:oGe.bind(void 0,new TextEncoder)};let n=new iGe(e);return{transform:sGe.bind(void 0,n),final:aGe.bind(void 0,n)}},oGe=function*(t,e){nGe.isBuffer(e)?yield Ca(e):typeof e=="string"?yield t.encode(e):yield e},sGe=function*(t,e){yield gr(e)?t.write(e):e},aGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Gce}from"util";var rz=Gce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),F0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=lGe}=e[r];for await(let i of n(t))yield*F0(i,e,r+1)},Hce=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*cGe(r,Number(e),t)},cGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*F0(n,r,e+1)},Wce=Gce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),lGe=function*(t){yield t};var nz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Yce=(t,e)=>[...e.flatMap(r=>[...ad(r,t,0)]),...VS(t)],ad=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=dGe}=e[r];for(let i of n(t))yield*ad(i,e,r+1)},VS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*uGe(r,Number(e),t)},uGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*ad(n,r,e+1)},dGe=function*(t){yield t};var iz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Zce(t,s,o),l=sd(e),u=sd(r),d=l?rz.bind(void 0,F0,a):nz.bind(void 0,ad),f=l||u?rz.bind(void 0,Hce,a):nz.bind(void 0,VS),p=l||u?Wce.bind(void 0,a):void 0;return{stream:new fGe({writableObjectMode:n,writableHighWaterMark:Kce(n),readableObjectMode:i,readableHighWaterMark:Kce(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},z0=(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=Zce(s,r,a);t=Yce(c,t)}return t},Zce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Bce(n,a)},U0(r,s,n),L0(r,o,n,c),{transform:t,final:e},{transform:qce(i,a)},jce({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Jce=(t,e)=>{for(let r of pGe(t))hGe(t,r,e)},pGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),hGe=(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 ${Qc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>mGe(a,n));r.input=MS(s)},mGe=(t,e)=>{let r=z0(t,e,"utf8",!0);return gGe(r),MS(r)},gGe=t=>{let e=t.find(r=>typeof r!="string"&&!gr(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 EGe,appendFileSync as vGe}from"fs";var j0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Jp(r,n)&&!hi.has(e)&&_Ge(n)&&(t.some(({type:i,value:o})=>i==="native"&&yGe.has(o))||t.every(({type:i})=>Vi.has(i))),_Ge=t=>t===1||t===2,yGe=new Set(["pipe","overlapped"]),Xce=async(t,e,r,n)=>{for await(let i of t)SGe(e)||ele(i,r,n)},Qce=(t,e,r)=>{for(let n of t)ele(n,e,r)},SGe=t=>t._readableState.pipes.length>0,ele=(t,e,r)=>{let n=t0(t);Ss({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var tle=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>bGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},bGe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=rce(t,o,d),p=Ca(f),{stdioItems:h,objectMode:m}=e[r],g=TGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=wGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});xGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?b:void 0;try{return n.error===void 0&&AGe(_,h,i),T}catch(S){return n.error=S,T}},TGe=(t,e,r,n)=>{try{return z0(t,e,r,!1)}catch(i){return n.error=i,t}},wGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:MS(t)};let s=goe(t,r);return n[o]?{serializedResult:s,finalResult:tz(s,!i[o],e)}:{serializedResult:s}},xGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!j0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=tz(t,!1,s);try{Qce(a,e,n)}catch(c){r.error??=c}},AGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>$0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?vGe(n,t):(r.add(o),EGe(n,t))}};var rle=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Oa(e,r,"all")]:Array.isArray(e)?[Oa(t,r,"all"),...e]:gr(t)&&gr(e)?uF([t,e]):`${t}${e}`};import{once as oz}from"events";var nle=async(t,e)=>{let[r,n]=await RGe(t);return e.isForcefullyTerminated??=!1,[r,n]},RGe=async t=>{let[e,r]=await Promise.allSettled([oz(t,"spawn"),oz(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?ile(t):r.value},ile=async t=>{try{return await oz(t,"exit")}catch{return ile(t)}},ole=async t=>{let[e,r]=await t;if(!CGe(e,r)&&sz(e,r))throw new Io;return[e,r]},CGe=(t,e)=>t===void 0&&e===void 0,sz=(t,e)=>t!==0||e!==null;var sle=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=IGe(t,e,r),s=o?.code==="ETIMEDOUT",a=tce(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},IGe=(t,e,r)=>t!==void 0?t:sz(e,r)?new Io:void 0;var ale=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=OGe(t,e,r),d=MGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return ah(d,c,l)},OGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=n0(t,e,r),a=NGe(r),{file:c,commandArguments:l,options:u}=T0(t,e,a);kGe(u);let d=Lce(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},NGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,kGe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&B0("ipcInput"),t&&B0("ipc: true"),r&&B0("detached: true"),n&&B0("cancelSignal")},B0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},MGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=$Ge({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=sle(c,r),{output:h,error:m=l}=tle({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>Oa(b,r,T)),_=Oa(rle(h,r),r,"all");return LGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},$Ge=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Jce(o,r);let a=DGe(r);return PGe(...w0(t,e,a))}catch(a){return sh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},DGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:O0(e)}),LGe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?N0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):qS({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as w6e}from"events";import{spawn as x6e}from"child_process";import fle from"process";import{once as az,on as UGe}from"events";var cle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(eh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:_0(t)}),FGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),FGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{p0(e,i);let o=Xc(t,e,r),s=new AbortController;try{return await Promise.race([zGe(o,n,s),jGe(o,r,s),BGe(o,r,s)])}catch(a){throw th(t),a}finally{s.abort(),h0(e,i)}},zGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await az(t,"message",{signal:r});return n}for await(let[n]of UGe(t,"message",{signal:r}))if(e(n))return n},jGe=async(t,e,{signal:r})=>{await az(t,"disconnect",{signal:r}),Yse(e)},BGe=async(t,e,{signal:r})=>{let[n]=await az(t,"strict:error",{signal:r});throw u0(n,e)};import{once as ule,on as qGe}from"events";var dle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>cz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),cz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{eh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:_0(t)}),p0(e,o);let s=Xc(t,e,r),a=new AbortController,c={};return VGe(t,s,a),GGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),HGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},VGe=async(t,e,r)=>{try{await ule(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},GGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ule(t,"strict:error",{signal:r.signal});n.error=u0(i,e),r.abort()}catch{}},HGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of qGe(r,"message",{signal:o.signal}))lle(s),yield c}catch{lle(s)}finally{o.abort(),h0(e,a),n||th(t),i&&await t}},lle=({error:t})=>{if(t)throw t};var ple=(t,{ipc:e})=>{Object.assign(t,mle(t,!1,e))},hle=()=>{let t=fle,e=!0,r=fle.channel!==void 0;return{...mle(t,e,r),getCancelSignal:vae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},mle=(t,e,r)=>({sendMessage:v0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:cle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:dle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as WGe}from"child_process";import{PassThrough as YGe,Readable as KGe,Writable as ZGe,Duplex as JGe}from"stream";var gle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{XF(n);let a=new WGe;XGe(a,n),Object.assign(a,{readable:QGe,writable:eHe,duplex:tHe});let c=sh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=rHe(c,s,i);return{subprocess:a,promise:l}},XGe=(t,e)=>{let r=GS(),n=GS(),i=GS(),o=Array.from({length:e.length-3},GS),s=GS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},GS=()=>{let t=new YGe;return t.end(),t},QGe=()=>new KGe({read(){}}),eHe=()=>new ZGe({write(){}}),tHe=()=>new JGe({read(){},write(){}}),rHe=async(t,e,r)=>ah(t,e,r);import{createReadStream as _le,createWriteStream as yle}from"fs";import{Buffer as nHe}from"buffer";import{Readable as HS,Writable as iHe,Duplex as oHe}from"stream";var Ele=(t,e)=>D0(sHe,t,e,!1),WS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Qc[t]}.`)},Sle={fileNumber:WS,generator:iz,asyncGenerator:iz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:oHe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},sHe={input:{...Sle,fileUrl:({value:t})=>({stream:_le(t)}),filePath:({value:{file:t}})=>({stream:_le(t)}),webStream:({value:t})=>({stream:HS.fromWeb(t)}),iterable:({value:t})=>({stream:HS.from(t)}),asyncIterable:({value:t})=>({stream:HS.from(t)}),string:({value:t})=>({stream:HS.from(t)}),uint8Array:({value:t})=>({stream:HS.from(nHe.from(t))})},output:{...Sle,fileUrl:({value:t})=>({stream:yle(t)}),filePath:({value:{file:t,append:e}})=>({stream:yle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:iHe.fromWeb(t)}),iterable:WS,asyncIterable:WS,string:WS,uint8Array:WS}};import{on as aHe,once as vle}from"events";import{PassThrough as cHe,getDefaultHighWaterMark as lHe}from"stream";import{finished as wle}from"stream/promises";function cd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)uz(i);let e=t.some(({readableObjectMode:i})=>i),r=uHe(t,e),n=new lz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var uHe=(t,e)=>{if(t.length===0)return lHe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},lz=class extends cHe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(uz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=dHe(this,this.#e,this.#o);let r=hHe({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(uz(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)}},dHe=async(t,e,r)=>{q0(t,ble);let n=new AbortController;try{await Promise.race([fHe(t,n),pHe(t,e,r,n)])}finally{n.abort(),q0(t,-ble)}},fHe=async(t,{signal:e})=>{try{await wle(t,{signal:e,cleanup:!0})}catch(r){throw xle(t,r),r}},pHe=async(t,e,r,{signal:n})=>{for await(let[i]of aHe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},uz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},hHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{q0(t,Tle);let a=new AbortController;try{await Promise.race([mHe(o,e,a),gHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),_He({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),q0(t,-Tle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?dz(t):yHe(t))},mHe=async(t,e,{signal:r})=>{try{await t,r.aborted||dz(e)}catch(n){r.aborted||xle(e,n)}},gHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await wle(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Ale(s)?i.add(e):Rle(t,s)}},_He=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await vle(t,i,{signal:o}),!t.readable)return vle(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},yHe=t=>{t.writable&&t.end()},xle=(t,e)=>{Ale(e)?dz(t):Rle(t,e)},Ale=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",dz=t=>{(t.readable||t.writable)&&t.destroy()},Rle=(t,e)=>{t.destroyed||(t.once("error",SHe),t.destroy(e))},SHe=()=>{},q0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ble=2,Tle=1;import{finished as Cle}from"stream/promises";var lh=(t,e)=>{t.pipe(e),EHe(t,e),vHe(t,e)},EHe=async(t,e)=>{if(!(Co(t)||Co(e))){try{await Cle(t,{cleanup:!0,readable:!0,writable:!1})}catch{}fz(e)}},fz=t=>{t.writable&&t.end()},vHe=async(t,e)=>{if(!(Co(t)||Co(e))){try{await Cle(e,{cleanup:!0,readable:!1,writable:!0})}catch{}pz(t)}},pz=t=>{t.readable&&t.destroy()};var Ile=(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})=>Vi.has(c)))bHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Vi.has(c)))wHe({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]:cd(o);lh(s,i)}},bHe=(t,e,r,n)=>{r==="output"?lh(t.stdio[n],e):lh(e,t.stdio[n]);let i=THe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},THe=["stdin","stdout","stderr"],wHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;xHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},xHe=(t,{signal:e})=>{Co(t)&&id(t,AHe,e)},AHe=2;import{addAbortListener as IHe}from"events";var ld=[];ld.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ld.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ld.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var V0=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",hz=Symbol.for("signal-exit emitter"),mz=globalThis,RHe=Object.defineProperty.bind(Object),gz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(mz[hz])return mz[hz];RHe(mz,hz,{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}},G0=class{},CHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),_z=class extends G0{onExit(){return()=>{}}load(){}unload(){}},yz=class extends G0{#e=Sz.platform==="win32"?"SIGINT":"SIGHUP";#r=new gz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ld)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(!V0(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 ld)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,ld.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 V0(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"&&V0(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)}},Sz=globalThis.process,{onExit:Ple,load:fUt,unload:pUt}=CHe(V0(Sz)?new yz(Sz):new _z);var Ole=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Ple(()=>{t.kill()});IHe(n,()=>{i()})};var kle=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=r0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=PHe(r,n,i),{sourceStream:d,sourceError:f}=NHe(t,l),{options:p,fileDescriptors:h}=vs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},PHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=OHe(t,e,...r),a=f0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},OHe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Nle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||cF(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]=HR(r,...n);return{destination:e(Nle)(i,o,s),pipeOptions:s}}if(vs.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}`)},Nle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),NHe=(t,e)=>{try{return{sourceStream:rh(t,e)}}catch(r){return{sourceError:r}}};var $le=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=kHe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw Ez({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},kHe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return pz(t),n;if(e!==void 0)return fz(r),e},Ez=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>sh({error:t,command:Mle,escapedCommand:Mle,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Mle="source.pipe(destination)";var Dle=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 MHe}from"stream/promises";var Lle=(t,e,r)=>{let n=H0.has(e)?DHe(t,e):$He(t,e);return id(t,UHe,r.signal),id(e,FHe,r.signal),LHe(e),n},$He=(t,e)=>{let r=cd([t]);return lh(r,e),H0.set(e,r),r},DHe=(t,e)=>{let r=H0.get(e);return r.add(t),r},LHe=async t=>{try{await MHe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}H0.delete(t)},H0=new WeakMap,UHe=2,FHe=1;import{aborted as zHe}from"util";var Ule=(t,e)=>t===void 0?[]:[jHe(t,e)],jHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await zHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw Ez({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var W0=(t,...e)=>{if(ir(e[0]))return W0.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=kle(t,...e),i=BHe({...n,destination:r});return i.pipe=W0.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},BHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=qHe(t,i);$le({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Lle(e,o,d);return await Promise.race([Dle(u),...Ule(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},qHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as ZHe}from"timers/promises";import{on as VHe}from"events";import{getDefaultHighWaterMark as GHe}from"stream";var Y0=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return HHe(e,s),zle({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},HHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},vz=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;WHe(e,s,t);let a=t.readableObjectMode&&!o;return zle({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},WHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},zle=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=VHe(t,"data",{signal:e.signal,highWaterMark:Fle,highWatermark:Fle});return YHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},bz=GHe(!0),Fle=bz,YHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=KHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*ad(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*VS(a)}},KHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[U0(t,r,!e),L0(t,i,!n,{})].filter(Boolean);var jle=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=JHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([XHe(t),d]);return}let f=QF(c,r),p=vz({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([QHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},JHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!j0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=vz({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Xce(a,t,r,o)},XHe=async t=>{await ZHe(),t.readableFlowing===null&&t.resume()},QHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await C0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await I0(r,{maxBuffer:o})):await oh(r,{maxBuffer:o})}catch(a){return Ble(Xae({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},Tz=async t=>{try{return await t}catch(e){return Ble(e)}},Ble=({bufferedData:t})=>hoe(t)?new Uint8Array(t):t;import{finished as e6e}from"stream/promises";var YS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=t6e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],e6e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||i6e(a,e,r,n)}finally{s.abort()}},t6e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&r6e(t,r,n),n},r6e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{n6e(e,r),n.call(t,...i)}},n6e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},i6e=(t,e,r,n)=>{if(!o6e(t,e,r,n))throw t},o6e=(t,e,r,n=!0)=>r.propagating?qle(t)||K0(t):(r.propagating=!0,wz(r,e)===n?qle(t):K0(t)),wz=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",K0=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",qle=t=>t?.code==="EPIPE";var Vle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>xz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),xz=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=YS(t,e,l);if(wz(l,e)){await u;return}let[d]=await Promise.all([jle({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Gle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?cd([t,e].filter(Boolean)):void 0,Hle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>xz({...s6e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:a6e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),s6e=({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}},a6e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as c6e}from"events";var Wle=t=>Jp(t,"ipc"),Yle=(t,e)=>{let r=t0(t);Ss({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Kle=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Wle(o),a=Ia(e,"ipc"),c=Ia(r,"ipc");for await(let l of cz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Qae(t,i,c),i.push(l)),s&&Yle(l,o);return i},Zle=async(t,e)=>(await Promise.allSettled([t]),e);var Jle=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let b=nle(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=Vle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=Hle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),P=[],C=Kle({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),N=l6e(m,t,T),k=u6e(h,T);try{return await Promise.race([Promise.all([{},ole(b),Promise.all(S),w,C,Oae(t,d),...N,...k]),g,d6e(t,_),...Aae(t,o,f,_),...Wse({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...wae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(U){return f.terminationReason??="other",Promise.all([{error:U},b,Promise.all(S.map(v=>Tz(v))),Tz(w),Zle(C,P),Promise.allSettled(N),Promise.allSettled(k)])}},l6e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:YS(n,i,r)),u6e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Oo(o,{checkOpen:!1})&&!Co(o)).map(({type:i,value:o,stream:s=o})=>YS(s,n,e,{isSameDirection:Vi.has(i),stopOnExit:i==="native"}))),d6e=async(t,{signal:e})=>{let[r]=await c6e(t,"error",{signal:e});throw r};var Xle=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),KS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Es();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},uh=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 f6e}from"stream";import{callbackify as p6e}from"util";import{finished as Qle}from"stream/promises";var Az=async t=>{if(t!==void 0)try{await Rz(t)}catch{}},eue=async t=>{if(t!==void 0)try{await Cz(t)}catch{}},Rz=async t=>{await Qle(t,{cleanup:!0,readable:!1,writable:!0})},Cz=async t=>{await Qle(t,{cleanup:!0,readable:!0,writable:!1})},Z0=async(t,e)=>{if(await t,e)throw e},J0=(t,e,r)=>{r&&!K0(r)?t.destroy(r):e&&t.destroy()};var tue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||hi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Iz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Pz(a,s),{read:f,onStdoutDataDone:p}=Oz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new f6e({read:f,destroy:p6e(kz.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Nz({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Iz=(t,e,r)=>{let n=rh(t,e),i=KS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Pz=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:bz},Oz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Es(),s=Y0({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){h6e(this,s,o)},onStdoutDataDone:o}},h6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Nz=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Cz(t),await n,await Az(i),await e,r.readable&&r.push(null)}catch(o){await Az(i),rue(r,o)}},kz=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await uh(r,e)&&(rue(t,n),await Z0(e,n))},rue=(t,e)=>{J0(t,t.readable,e)};import{Writable as m6e}from"stream";import{callbackify as nue}from"util";var iue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Mz(t,r,e),s=new m6e({...$z(n,t,i),destroy:nue(Lz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Dz(n,s),s},Mz=(t,e,r)=>{let n=f0(t,e),i=KS(r,n,"writableFinal"),o=KS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},$z=(t,e,r)=>({write:g6e.bind(void 0,t),final:nue(_6e.bind(void 0,t,e,r))}),g6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},_6e=async(t,e,r)=>{await uh(r,e)&&(t.writable&&t.end(),await e)},Dz=async(t,e,r)=>{try{await Rz(t),e.writable&&e.end()}catch(n){await eue(r),oue(e,n)}},Lz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await uh(r,e),await uh(n,e)&&(oue(t,i),await Z0(e,i))},oue=(t,e)=>{J0(t,t.writable,e)};import{Duplex as y6e}from"stream";import{callbackify as S6e}from"util";var sue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||hi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Iz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Mz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Pz(c,a),{read:g,onStdoutDataDone:_}=Oz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new y6e({read:g,...$z(u,t,d),destroy:S6e(E6e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return Nz({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),Dz(u,b,c),b},E6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([kz({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Lz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Uz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||hi.has(e),s=rh(t,r),a=Y0({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return v6e(a,s,t)},v6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var aue=(t,{encoding:e})=>{let r=Xle();t.readable=tue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=iue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=sue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Uz.bind(void 0,t,e),t[Symbol.asyncIterator]=Uz.bind(void 0,t,e,{})};var cue=(t,e)=>{for(let[r,n]of T6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},b6e=(async()=>{})().constructor.prototype,T6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(b6e,t)]);var lue=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=A6e(t,e,r),{subprocess:f,promise:p}=C6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=W0.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),cue(f,p),vs.set(f,{options:u,fileDescriptors:d}),f},A6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=n0(t,e,r),{file:a,commandArguments:c,options:l}=T0(t,e,r),u=R6e(l),d=Ele(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},R6e=({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}},C6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=x6e(...w0(t,e,r))}catch(h){return gle({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;w6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ile(c,a,l),Ole(c,r,l);let d={},f=Es();c.kill=Gse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Gle(c,r),aue(c,r),ple(c,r);let p=I6e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},I6e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Jle({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((S,w)=>Oa(S,e,w)),b=Oa(m,e,"all"),T=P6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return ah(T,n,e)},P6e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?qS({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof bs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):N0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var X0=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,O6e(n,t[n],i)]));return{...t,...r}},O6e=(t,e,r)=>N6e.has(t)&&ir(e)&&ir(r)?{...e,...r}:r,N6e=new Set(["env",...hF]);var el=(t,e,r,n)=>{let i=(s,a,c)=>el(s,a,r,c),o=(...s)=>k6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},k6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(ir(o))return i(t,X0(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=M6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?ale(a,c,l):lue(a,c,l,i)},M6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Eoe(e)?voe(e,r):[e,...r],[s,a,c]=HR(...o),l=X0(X0(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var uue=({file:t,commandArguments:e})=>fue(t,e),due=({file:t,commandArguments:e})=>({...fue(t,e),isSync:!0}),fue=(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]=$6e(t);return{file:r,commandArguments:n}},$6e=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(D6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},D6e=/ +/g;var pue=(t,e,r)=>{t.sync=e(L6e,r),t.s=t.sync},hue=({options:t})=>mue(t),L6e=({options:t})=>({...mue(t),isSync:!0}),mue=t=>({options:{...U6e(t),...t}}),U6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},gue={preferLocal:!0};var _ue=el(()=>({})),rjt=el(()=>({isSync:!0})),yue=el(uue),njt=el(due),ijt=el(Cae),ojt=el(hue,{},gue,pue),{sendMessage:sjt,getOneMessage:ajt,getEachMessage:cjt,getCancelSignal:ljt}=hle();var Sue=!1,Eue=()=>{Sue=!0},ws=()=>Sue;var ZS=null,vue=t=>(ZS&&ZS.destroy(),ZS=new No({totalAllowedTime:t}),ZS),bue=()=>ZS;var No=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&&ws())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await LR({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{re.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Tue={name:"@netlify/agent-runner-cli",type:"module",version:"1.168.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",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var B6e=z6e(import.meta.url),q6e=Na.dirname(B6e),V6e=j6e(import.meta.url),dh=ce("shell"),Fz=new Set,wue={preferLocal:!0},_r=(t,e,r)=>{let[n,i]=G6e(e,r),o={...wue,...i},s=_ue(t,n,o);Aue(s,o),Iue(s);let a=r?.idleTimeout;return a&&a>0&&Cue(s,a),s},xue=(t,e)=>{let r={...wue,...e},n=yue(t,r);return Aue(n,r),Iue(n),e?.idleTimeout&&e.idleTimeout>0&&Cue(n,e.idleTimeout),n},G6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Aue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||xs.env.NETLIFY_LOCAL_QUIET==="true")return;if(xs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new xS).pipe(xs.stdout),t.stderr?.pipe(new xS).pipe(xs.stderr);return}t.stdout?.pipe(xs.stdout),t.stderr?.pipe(xs.stderr)},zz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(xs.kill(-t.pid,e),dh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return dh.error("Error killing process:",r),!1}},Rue=t=>zz(t,"SIGKILL"),Cue=(t,e)=>{let r=null,n=()=>{dh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),zz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dh.log(`Force killing idle process ${t.pid}`),Rue(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)},Iue=t=>{Fz.add(t);let e=bue();if(e){let r=e.onTimesUp(()=>{dh.log(`Global timer expired, killing process ${t.pid}`),zz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dh.log(`Force killing process ${t.pid} after timeout`),Rue(t))},5e3)});t.on("exit",()=>{Fz.delete(t),r()}),t.on("error",()=>{Fz.delete(t),r()})}};function eC(t,e){return!!ko(t,e)}function ko(t,e){if(!xs.env.NETLIFY_LOCAL_MODE)try{let i=V6e.resolve(Tue.name),o=Na.dirname(i);for(;o!==Na.dirname(o);){let s=Na.dirname(o);if(Na.basename(s)==="node_modules"){let a=Na.join(s,".bin",e);if(Q0.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(xs.env.NODE_PATH){let i=Na.join(xs.env.NODE_PATH,".bin",e);if(Q0.existsSync(i))return i}let r=Na.join(t,"node_modules",".bin",e);if(Q0.existsSync(r))return r;let n=Na.join(q6e,"..","node_modules",".bin",e);if(Q0.existsSync(n))return n}var H6e=ce("utils"),W6e=t=>new Promise(e=>{setTimeout(e,t)});var jz=t=>{try{return new URL(t).hostname||null}catch{return null}},tC=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await W6e(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},tl=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Pue=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):H6e.error("Could not parse JSON",n))}},Y6e=t=>t.charAt(0).toUpperCase()+t.slice(1),As=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():Y6e(e)).join(" ");function ka(t,e){e&&t.log(`Skill invoked: ${e}`)}var rC=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Oue=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var Bz=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},K6e=1e4,qz=(t,e=K6e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{createHash as Z6e}from"crypto";import{createReadStream as J6e}from"fs";import nC from"fs/promises";import Due from"os";import iC from"path";var Nue=ce("repo"),Lue="runner-diffs-",Uue=t=>`${Lue}${t}-`,Fue=async t=>{let e=Due.tmpdir(),r;try{r=await nC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Lue)&&!n.startsWith(Uue(t))).map(n=>nC.rm(iC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Hn=(t,e={})=>_r("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),oC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Nue.info("Getting runner diffs");let n=await Q6e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=t3e(o);await r3e(h,r)}Nue.info("Changes after processing"),await Gz(r);let s=await Hz(o,r);if(await Vz(s,r),i=await e3e(r),!i)return{hasChanges:!1,ignored:s};await Hn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await nC.mkdtemp(iC.join(Due.tmpdir(),Uue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=iC.join(a,g);await Hn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await nC.stat(b);return{path:b,size:S}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await $ue(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await Mue(d,h)||(f=h)}await $ue(r),re.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Mue(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},kue=async t=>{let e=Z6e("sha256");for await(let r of J6e(t))e.update(r);return e.digest("hex")},Mue=async(t,e)=>t.size===e.size&&await kue(t.path)===await kue(e.path),$ue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Hn(["reset","--soft","HEAD~1"],{cwd:t})},Vz=async(t=[],e=process.cwd())=>{await Hn(["add",".",...t],{cwd:e})},Gz=async(t=process.cwd())=>{let e=await Hn(["status","-s"],{cwd:t});return String(e.stdout??"")},zue=/.. (.+)?\.log$/,X6e=[zue],Q6e=async(t=process.cwd())=>{let e=await Gz(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
144
144
  `).filter(i=>X6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},e3e=async(t=process.cwd())=>{try{return await Hn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},JS=async(t=process.cwd())=>{let{stdout:e}=await Hn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},jue=async(t=process.cwd())=>{let{stdout:e}=await Hn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},Hz=async(t,e=process.cwd())=>{t||=await Gz(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
145
145
  `).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${iC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(zue)?.[1];o&&n.push(`:!${o}.log`)}),n},Bue=async(t=process.cwd())=>{await Hn(["reset","--hard","HEAD"],{cwd:t})},que=async(t=process.cwd())=>{let e=await Hn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
146
146
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},t3e=t=>{let e=t.split(`
package/dist/bin.js CHANGED
@@ -621,7 +621,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
621
621
  `,LF:`
622
622
  `,concatBytes:oY},FTt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},jTt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:FTt};import{Buffer as zTt}from"buffer";var GRe=(t,e)=>t?void 0:qTt.bind(void 0,e),qTt=function*(t,e){if(typeof e!="string"&&!Yr(e)&&!zTt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},WRe=(t,e)=>t?BTt.bind(void 0,e):HTt.bind(void 0,e),BTt=function*(t,e){YRe(t,e),yield e},HTt=function*(t,e){if(YRe(t,e),typeof e!="string"&&!Yr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},YRe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
623
623
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
624
- if (condition) { yield value; }`)};import{Buffer as VTt}from"buffer";import{StringDecoder as GTt}from"string_decoder";var XN=(t,e,r)=>{if(r)return;if(t)return{transform:WTt.bind(void 0,new TextEncoder)};let n=new GTt(e);return{transform:YTt.bind(void 0,n),final:KTt.bind(void 0,n)}},WTt=function*(t,e){VTt.isBuffer(e)?yield Jc(e):typeof e=="string"?yield t.encode(e):yield e},YTt=function*(t,e){yield Yr(e)?t.write(e):e},KTt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as KRe}from"util";var cY=KRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),QN=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=ZTt}=e[r];for await(let i of n(t))yield*QN(i,e,r+1)},JRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*JTt(r,Number(e),t)},JTt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*QN(n,r,e+1)},ZRe=KRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),ZTt=function*(t){yield t};var lY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},XRe=(t,e)=>[...e.flatMap(r=>[...Sp(r,t,0)]),...qT(t)],Sp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QTt}=e[r];for(let i of n(t))yield*Sp(i,e,r+1)},qT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XTt(r,Number(e),t)},XTt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Sp(n,r,e+1)},QTt=function*(t){yield t};var uY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=e0e(t,o,s),l=yp(e),u=yp(r),d=l?cY.bind(void 0,QN,a):lY.bind(void 0,Sp),f=l||u?cY.bind(void 0,JRe,a):lY.bind(void 0,qT),p=l||u?ZRe.bind(void 0,a):void 0;return{stream:new ewt({writableObjectMode:n,writableHighWaterMark:QRe(n),readableObjectMode:i,readableHighWaterMark:QRe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},ek=(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=e0e(o,r,a);t=XRe(c,t)}return t},e0e=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:GRe(n,a)},XN(r,o,n),ZN(r,s,n,c),{transform:t,final:e},{transform:WRe(i,a)},VRe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var t0e=(t,e)=>{for(let r of twt(t))rwt(t,r,e)},twt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),rwt=(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 ${td[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>nwt(a,n));r.input=NT(o)},nwt=(t,e)=>{let r=ek(t,e,"utf8",!0);return iwt(r),NT(r)},iwt=t=>{let e=t.find(r=>typeof r!="string"&&!Yr(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 cwt,appendFileSync as lwt}from"fs";var tk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&E_(r,n)&&!os.has(e)&&swt(n)&&(t.some(({type:i,value:s})=>i==="native"&&owt.has(s))||t.every(({type:i})=>Bs.has(i))),swt=t=>t===1||t===2,owt=new Set(["pipe","overlapped"]),r0e=async(t,e,r,n)=>{for await(let i of t)awt(e)||i0e(i,r,n)},n0e=(t,e,r)=>{for(let n of t)i0e(n,e,r)},awt=t=>t._readableState.pipes.length>0,i0e=(t,e,r)=>{let n=mN(t);Pa({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var s0e=({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,l)=>uwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},uwt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=oRe(t,s,d),p=Jc(f),{stdioItems:h,objectMode:m}=e[r],_=dwt([p],h,c,n),{serializedResult:y,finalResult:v=y}=fwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});pwt({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&&hwt(y,h,i),S}catch(g){return n.error=g,S}},dwt=(t,e,r,n)=>{try{return ek(t,e,r,!1)}catch(i){return n.error=i,t}},fwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:NT(t)};let o=Ebe(t,r);return n[s]?{serializedResult:o,finalResult:aY(o,!i[s],e)}:{serializedResult:o}},pwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!tk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=aY(t,!1,o);try{n0e(a,e,n)}catch(c){r.error??=c}},hwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>KN.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?lwt(n,t):(r.add(s),cwt(n,t))}};var o0e=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Qc(e,r,"all")]:Array.isArray(e)?[Qc(t,r,"all"),...e]:Yr(t)&&Yr(e)?gW([t,e]):`${t}${e}`};import{once as dY}from"events";var a0e=async(t,e)=>{let[r,n]=await mwt(t);return e.isForcefullyTerminated??=!1,[r,n]},mwt=async t=>{let[e,r]=await Promise.allSettled([dY(t,"spawn"),dY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?c0e(t):r.value},c0e=async t=>{try{return await dY(t,"exit")}catch{return c0e(t)}},l0e=async t=>{let[e,r]=await t;if(!gwt(e,r)&&fY(e,r))throw new Ro;return[e,r]},gwt=(t,e)=>t===void 0&&e===void 0,fY=(t,e)=>t!==0||e!==null;var u0e=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=_wt(t,e,r),o=s?.code==="ETIMEDOUT",a=sRe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},_wt=(t,e,r)=>t!==void 0?t:fY(e,r)?new Ro:void 0;var d0e=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Swt(t,e,r),d=bwt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return I_(d,c,l)},Swt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),a=Ewt(r),{file:c,commandArguments:l,options:u}=MN(t,e,a);vwt(u);let d=zRe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Ewt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vwt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&rk("ipcInput"),t&&rk("ipc: true"),r&&rk("detached: true"),n&&rk("cancelSignal")},rk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},bwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Twt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=u0e(c,r),{output:h,error:m=l}=s0e({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>Qc(v,r,S)),y=Qc(o0e(h,r),r,"all");return Rwt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Twt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{t0e(s,r);let a=wwt(r);return ywt(...UN(t,e,a))}catch(a){return C_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},wwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:VN(e)}),Rwt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?GN({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):zT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as f0t}from"events";import{spawn as p0t}from"child_process";import g0e from"process";import{once as pY,on as Awt}from"events";var f0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(T_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),xwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),xwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{xN(e,i);let s=ed(t,e,r),o=new AbortController;try{return await Promise.race([Pwt(s,n,o),Cwt(s,r,o),Iwt(s,r,o)])}catch(a){throw w_(t),a}finally{o.abort(),PN(e,i)}},Pwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await pY(t,"message",{signal:r});return n}for await(let[n]of Awt(t,"message",{signal:r}))if(e(n))return n},Cwt=async(t,e,{signal:r})=>{await pY(t,"disconnect",{signal:r}),XTe(e)},Iwt=async(t,e,{signal:r})=>{let[n]=await pY(t,"strict:error",{signal:r});throw wN(n,e)};import{once as h0e,on as Owt}from"events";var m0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>hY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),hY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{T_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),xN(e,s);let o=ed(t,e,r),a=new AbortController,c={};return Nwt(t,o,a),kwt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),$wt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Nwt=async(t,e,r)=>{try{await h0e(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kwt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await h0e(t,"strict:error",{signal:r.signal});n.error=wN(i,e),r.abort()}catch{}},$wt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Owt(r,"message",{signal:s.signal}))p0e(o),yield c}catch{p0e(o)}finally{s.abort(),PN(e,a),n||w_(t),i&&await t}},p0e=({error:t})=>{if(t)throw t};var _0e=(t,{ipc:e})=>{Object.assign(t,S0e(t,!1,e))},y0e=()=>{let t=g0e,e=!0,r=g0e.channel!==void 0;return{...S0e(t,e,r),getCancelSignal:Rwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},S0e=(t,e,r)=>({sendMessage:LN.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:f0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:m0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Lwt}from"child_process";import{PassThrough as Dwt,Readable as Mwt,Writable as Uwt,Duplex as Fwt}from"stream";var E0e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{iY(n);let a=new Lwt;jwt(a,n),Object.assign(a,{readable:zwt,writable:qwt,duplex:Bwt});let c=C_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Hwt(c,o,i);return{subprocess:a,promise:l}},jwt=(t,e)=>{let r=BT(),n=BT(),i=BT(),s=Array.from({length:e.length-3},BT),o=BT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},BT=()=>{let t=new Dwt;return t.end(),t},zwt=()=>new Mwt({read(){}}),qwt=()=>new Uwt({write(){}}),Bwt=()=>new Fwt({read(){},write(){}}),Hwt=async(t,e,r)=>I_(t,e,r);import{createReadStream as v0e,createWriteStream as b0e}from"fs";import{Buffer as Vwt}from"buffer";import{Readable as HT,Writable as Gwt,Duplex as Wwt}from"stream";var w0e=(t,e)=>JN(Ywt,t,e,!1),VT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${td[t]}.`)},T0e={fileNumber:VT,generator:uY,asyncGenerator:uY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Wwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Ywt={input:{...T0e,fileUrl:({value:t})=>({stream:v0e(t)}),filePath:({value:{file:t}})=>({stream:v0e(t)}),webStream:({value:t})=>({stream:HT.fromWeb(t)}),iterable:({value:t})=>({stream:HT.from(t)}),asyncIterable:({value:t})=>({stream:HT.from(t)}),string:({value:t})=>({stream:HT.from(t)}),uint8Array:({value:t})=>({stream:HT.from(Vwt.from(t))})},output:{...T0e,fileUrl:({value:t})=>({stream:b0e(t)}),filePath:({value:{file:t,append:e}})=>({stream:b0e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Gwt.fromWeb(t)}),iterable:VT,asyncIterable:VT,string:VT,uint8Array:VT}};import{on as Kwt,once as R0e}from"events";import{PassThrough as Jwt,getDefaultHighWaterMark as Zwt}from"stream";import{finished as P0e}from"stream/promises";function Ep(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)gY(i);let e=t.some(({readableObjectMode:i})=>i),r=Xwt(t,e),n=new mY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Xwt=(t,e)=>{if(t.length===0)return Zwt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},mY=class extends Jwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(gY(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Qwt(this,this.#e,this.#s);let r=rRt({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(gY(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)}},Qwt=async(t,e,r)=>{nk(t,A0e);let n=new AbortController;try{await Promise.race([eRt(t,n),tRt(t,e,r,n)])}finally{n.abort(),nk(t,-A0e)}},eRt=async(t,{signal:e})=>{try{await P0e(t,{signal:e,cleanup:!0})}catch(r){throw C0e(t,r),r}},tRt=async(t,e,r,{signal:n})=>{for await(let[i]of Kwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},gY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},rRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{nk(t,x0e);let a=new AbortController;try{await Promise.race([nRt(s,e,a),iRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),sRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),nk(t,-x0e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?_Y(t):oRt(t))},nRt=async(t,e,{signal:r})=>{try{await t,r.aborted||_Y(e)}catch(n){r.aborted||C0e(e,n)}},iRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await P0e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;I0e(o)?i.add(e):O0e(t,o)}},sRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await R0e(t,i,{signal:s}),!t.readable)return R0e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},oRt=t=>{t.writable&&t.end()},C0e=(t,e)=>{I0e(e)?_Y(t):O0e(t,e)},I0e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_Y=t=>{(t.readable||t.writable)&&t.destroy()},O0e=(t,e)=>{t.destroyed||(t.once("error",aRt),t.destroy(e))},aRt=()=>{},nk=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},A0e=2,x0e=1;import{finished as N0e}from"stream/promises";var N_=(t,e)=>{t.pipe(e),cRt(t,e),lRt(t,e)},cRt=async(t,e)=>{if(!(wo(t)||wo(e))){try{await N0e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}yY(e)}},yY=t=>{t.writable&&t.end()},lRt=async(t,e)=>{if(!(wo(t)||wo(e))){try{await N0e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}SY(t)}},SY=t=>{t.readable&&t.destroy()};var k0e=(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})=>Bs.has(c)))uRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Bs.has(c)))fRt({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]:Ep(s);N_(o,i)}},uRt=(t,e,r,n)=>{r==="output"?N_(t.stdio[n],e):N_(e,t.stdio[n]);let i=dRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},dRt=["stdin","stdout","stderr"],fRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;pRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},pRt=(t,{signal:e})=>{wo(t)&&gp(t,hRt,e)},hRt=2;import{addAbortListener as _Rt}from"events";var vp=[];vp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&vp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&vp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ik=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",EY=Symbol.for("signal-exit emitter"),vY=globalThis,mRt=Object.defineProperty.bind(Object),bY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vY[EY])return vY[EY];mRt(vY,EY,{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}},sk=class{},gRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),TY=class extends sk{onExit(){return()=>{}}load(){}unload(){}},wY=class extends sk{#e=RY.platform==="win32"?"SIGINT":"SIGHUP";#r=new bY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of vp)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(!ik(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 vp)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,vp.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 ik(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"&&ik(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)}},RY=globalThis.process,{onExit:$0e,load:Kgr,unload:Jgr}=gRt(ik(RY)?new wY(RY):new TY);var L0e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=$0e(()=>{t.kill()});_Rt(n,()=>{i()})};var M0e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=gN(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=yRt(r,n,i),{sourceStream:d,sourceError:f}=ERt(t,l),{options:p,fileDescriptors:h}=Ia.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},yRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=SRt(t,e,...r),a=AN(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},SRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(D0e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||hW(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]=oN(r,...n);return{destination:e(D0e)(i,s,o),pipeOptions:o}}if(Ia.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}`)},D0e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),ERt=(t,e)=>{try{return{sourceStream:R_(t,e)}}catch(r){return{sourceError:r}}};var F0e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=vRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw AY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},vRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return SY(t),n;if(e!==void 0)return yY(r),e},AY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>C_({error:t,command:U0e,escapedCommand:U0e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),U0e="source.pipe(destination)";var j0e=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 bRt}from"stream/promises";var z0e=(t,e,r)=>{let n=ok.has(e)?wRt(t,e):TRt(t,e);return gp(t,ARt,r.signal),gp(e,xRt,r.signal),RRt(e),n},TRt=(t,e)=>{let r=Ep([t]);return N_(r,e),ok.set(e,r),r},wRt=(t,e)=>{let r=ok.get(e);return r.add(t),r},RRt=async t=>{try{await bRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ok.delete(t)},ok=new WeakMap,ARt=2,xRt=1;import{aborted as PRt}from"util";var q0e=(t,e)=>t===void 0?[]:[CRt(t,e)],CRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await PRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw AY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ak=(t,...e)=>{if(kr(e[0]))return ak.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=M0e(t,...e),i=IRt({...n,destination:r});return i.pipe=ak.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},IRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=ORt(t,i);F0e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=z0e(e,s,d);return await Promise.race([j0e(u),...q0e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},ORt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as URt}from"timers/promises";import{on as NRt}from"events";import{getDefaultHighWaterMark as kRt}from"stream";var ck=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return $Rt(e,o),H0e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},$Rt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},xY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;LRt(e,o,t);let a=t.readableObjectMode&&!s;return H0e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},LRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},H0e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=NRt(t,"data",{signal:e.signal,highWaterMark:B0e,highWatermark:B0e});return DRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},PY=kRt(!0),B0e=PY,DRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=MRt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Sp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*qT(a)}},MRt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[XN(t,r,!e),ZN(t,i,!n,{})].filter(Boolean);var V0e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=FRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([jRt(t),d]);return}let f=sY(c,r),p=xY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},FRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!tk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=xY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await r0e(a,t,r,s)},jRt=async t=>{await URt(),t.readableFlowing===null&&t.resume()},zRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qN(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await BN(r,{maxBuffer:s})):await P_(r,{maxBuffer:s})}catch(a){return G0e(rRe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},CY=async t=>{try{return await t}catch(e){return G0e(e)}},G0e=({bufferedData:t})=>ybe(t)?new Uint8Array(t):t;import{finished as qRt}from"stream/promises";var GT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=BRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],qRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||GRt(a,e,r,n)}finally{o.abort()}},BRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&HRt(t,r,n),n},HRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{VRt(e,r),n.call(t,...i)}},VRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},GRt=(t,e,r,n)=>{if(!WRt(t,e,r,n))throw t},WRt=(t,e,r,n=!0)=>r.propagating?W0e(t)||lk(t):(r.propagating=!0,IY(r,e)===n?W0e(t):lk(t)),IY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",lk=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",W0e=t=>t?.code==="EPIPE";var Y0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>OY({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),OY=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=GT(t,e,l);if(IY(l,e)){await u;return}let[d]=await Promise.all([V0e({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var K0e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ep([t,e].filter(Boolean)):void 0,J0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>OY({...YRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:KRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),YRt=({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}},KRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as JRt}from"events";var Z0e=t=>E_(t,"ipc"),X0e=(t,e)=>{let r=mN(t);Pa({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Q0e=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Z0e(s),a=Zc(e,"ipc"),c=Zc(r,"ipc");for await(let l of hY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(nRe(t,i,c),i.push(l)),o&&X0e(l,s);return i},eAe=async(t,e)=>(await Promise.allSettled([t]),e);var tAe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=a0e(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Y0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=J0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),x=[],R=Q0e({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),b=ZRt(m,t,S),P=XRt(h,S);try{return await Promise.race([Promise.all([{},l0e(v),Promise.all(g),w,R,Lwe(t,d),...b,...P]),_,QRt(t,y),...Iwe(t,s,f,y),...ZTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Pwe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(O){return f.terminationReason??="other",Promise.all([{error:O},v,Promise.all(g.map(A=>CY(A))),CY(w),eAe(R,x),Promise.allSettled(b),Promise.allSettled(P)])}},ZRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:GT(n,i,r)),XRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>xo(s,{checkOpen:!1})&&!wo(s)).map(({type:i,value:s,stream:o=s})=>GT(o,n,e,{isSameDirection:Bs.has(i),stopOnExit:i==="native"}))),QRt=async(t,{signal:e})=>{let[r]=await JRt(t,"error",{signal:e});throw r};var rAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),WT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Ca();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},k_=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 e0t}from"stream";import{callbackify as t0t}from"util";import{finished as nAe}from"stream/promises";var NY=async t=>{if(t!==void 0)try{await kY(t)}catch{}},iAe=async t=>{if(t!==void 0)try{await $Y(t)}catch{}},kY=async t=>{await nAe(t,{cleanup:!0,readable:!1,writable:!0})},$Y=async t=>{await nAe(t,{cleanup:!0,readable:!0,writable:!1})},uk=async(t,e)=>{if(await t,e)throw e},dk=(t,e,r)=>{r&&!lk(r)?t.destroy(r):e&&t.destroy()};var sAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||os.has(r),{subprocessStdout:a,waitReadableDestroy:c}=LY(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=DY(a,o),{read:f,onStdoutDataDone:p}=MY({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new e0t({read:f,destroy:t0t(FY.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return UY({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},LY=(t,e,r)=>{let n=R_(t,e),i=WT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},DY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:PY},MY=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Ca(),o=ck({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){r0t(this,o,s)},onStdoutDataDone:s}},r0t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},UY=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await $Y(t),await n,await NY(i),await e,r.readable&&r.push(null)}catch(s){await NY(i),oAe(r,s)}},FY=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await k_(r,e)&&(oAe(t,n),await uk(e,n))},oAe=(t,e)=>{dk(t,t.readable,e)};import{Writable as n0t}from"stream";import{callbackify as aAe}from"util";var cAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=jY(t,r,e),o=new n0t({...zY(n,t,i),destroy:aAe(BY.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return qY(n,o),o},jY=(t,e,r)=>{let n=AN(t,e),i=WT(r,n,"writableFinal"),s=WT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},zY=(t,e,r)=>({write:i0t.bind(void 0,t),final:aAe(s0t.bind(void 0,t,e,r))}),i0t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},s0t=async(t,e,r)=>{await k_(r,e)&&(t.writable&&t.end(),await e)},qY=async(t,e,r)=>{try{await kY(t),e.writable&&e.end()}catch(n){await iAe(r),lAe(e,n)}},BY=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await k_(r,e),await k_(n,e)&&(lAe(t,i),await uk(e,i))},lAe=(t,e)=>{dk(t,t.writable,e)};import{Duplex as o0t}from"stream";import{callbackify as a0t}from"util";var uAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||os.has(r),{subprocessStdout:c,waitReadableDestroy:l}=LY(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=jY(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=DY(c,a),{read:_,onStdoutDataDone:y}=MY({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new o0t({read:_,...zY(u,t,d),destroy:a0t(c0t.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return UY({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),qY(u,v,c),v},c0t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([FY({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),BY({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var HY=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||os.has(e),o=R_(t,r),a=ck({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return l0t(a,o,t)},l0t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var dAe=(t,{encoding:e})=>{let r=rAe();t.readable=sAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=cAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=uAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=HY.bind(void 0,t,e),t[Symbol.asyncIterator]=HY.bind(void 0,t,e,{})};var fAe=(t,e)=>{for(let[r,n]of d0t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},u0t=(async()=>{})().constructor.prototype,d0t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(u0t,t)]);var pAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=h0t(t,e,r),{subprocess:f,promise:p}=g0t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ak.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),fAe(f,p),Ia.set(f,{options:u,fileDescriptors:d}),f},h0t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),{file:a,commandArguments:c,options:l}=MN(t,e,r),u=m0t(l),d=w0e(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},m0t=({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}},g0t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=p0t(...UN(t,e,r))}catch(h){return E0e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;f0t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];k0e(c,a,l),L0e(c,r,l);let d={},f=Ca();c.kill=KTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=K0e(c,r),dAe(c,r),_0e(c,r);let p=_0t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},_0t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await tAe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,w)=>Qc(g,e,w)),v=Qc(m,e,"all"),S=y0t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return I_(S,n,e)},y0t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?zT({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Oa,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):GN({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var fk=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,S0t(n,t[n],i)]));return{...t,...r}},S0t=(t,e,r)=>E0t.has(t)&&kr(e)&&kr(r)?{...e,...r}:r,E0t=new Set(["env",...EW]);var rd=(t,e,r,n)=>{let i=(o,a,c)=>rd(o,a,r,c),s=(...o)=>v0t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},v0t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(kr(s))return i(t,fk(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=b0t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?d0e(a,c,l):pAe(a,c,l,i)},b0t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=wbe(e)?Rbe(e,r):[e,...r],[o,a,c]=oN(...s),l=fk(fk(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var hAe=({file:t,commandArguments:e})=>gAe(t,e),mAe=({file:t,commandArguments:e})=>({...gAe(t,e),isSync:!0}),gAe=(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]=T0t(t);return{file:r,commandArguments:n}},T0t=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(w0t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},w0t=/ +/g;var _Ae=(t,e,r)=>{t.sync=e(R0t,r),t.s=t.sync},yAe=({options:t})=>SAe(t),R0t=({options:t})=>({...SAe(t),isSync:!0}),SAe=t=>({options:{...A0t(t),...t}}),A0t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},EAe={preferLocal:!0};var vAe=rd(()=>({})),FSr=rd(()=>({isSync:!0})),bAe=rd(hAe),jSr=rd(mAe),zSr=rd(Nwe),qSr=rd(yAe,{},EAe,_Ae),{sendMessage:BSr,getOneMessage:HSr,getEachMessage:VSr,getCancelSignal:GSr}=y0e();import{Transform as x0t}from"stream";var P0t=["NETLIFY_AI_GATEWAY_KEY"];function C0t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...P0t])]}function I0t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function O0t(){let e=C0t().map(r=>process.env[r]).filter(r=>!(!r||I0t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Hs(t){if(typeof t!="string")return t;let e=O0t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(N0t(n),"g");r=r.replace(i,"******")}),r}function N0t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var YT=class extends x0t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Hs(i);n(null,s)}},pk=Symbol("maskedWrite");function TAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[pk]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Hs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stdout.write=r}if(!process.stderr.write[pk]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Hs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stderr.write=r}}}var wAe=!1,RAe=()=>{wAe=!0},zi=()=>wAe;var KT=null,AAe=t=>(KT&&KT.destroy(),KT=new Po({totalAllowedTime:t}),KT),xAe=()=>KT;var Po=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&zi())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((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await tN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{fe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),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 PAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.168.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var D0t=$0t(import.meta.url),M0t=el.dirname(D0t),U0t=L0t(import.meta.url),$_=me("shell"),VY=new Set,CAe={preferLocal:!0},On=(t,e,r)=>{let[n,i]=F0t(e,r),s={...CAe,...i},o=vAe(t,n,s);OAe(o,s),$Ae(o);let a=r?.idleTimeout;return a&&a>0&&kAe(o,a),o},IAe=(t,e)=>{let r={...CAe,...e},n=bAe(t,r);return OAe(n,r),$Ae(n),e?.idleTimeout&&e.idleTimeout>0&&kAe(n,e.idleTimeout),n},F0t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},OAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ka.env.NETLIFY_LOCAL_QUIET==="true")return;if(ka.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new YT).pipe(ka.stdout),t.stderr?.pipe(new YT).pipe(ka.stderr);return}t.stdout?.pipe(ka.stdout),t.stderr?.pipe(ka.stderr)},GY=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ka.kill(-t.pid,e),$_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return $_.error("Error killing process:",r),!1}},NAe=t=>GY(t,"SIGKILL"),kAe=(t,e)=>{let r=null,n=()=>{$_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),GY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&($_.log(`Force killing idle process ${t.pid}`),NAe(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)},$Ae=t=>{VY.add(t);let e=xAe();if(e){let r=e.onTimesUp(()=>{$_.log(`Global timer expired, killing process ${t.pid}`),GY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&($_.log(`Force killing process ${t.pid} after timeout`),NAe(t))},5e3)});t.on("exit",()=>{VY.delete(t),r()}),t.on("error",()=>{VY.delete(t),r()})}};function $a(t,e){if(!ka.env.NETLIFY_LOCAL_MODE)try{let i=U0t.resolve(PAe.name),s=el.dirname(i);for(;s!==el.dirname(s);){let o=el.dirname(s);if(el.basename(o)==="node_modules"){let a=el.join(o,".bin",e);if(hk.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(ka.env.NODE_PATH){let i=el.join(ka.env.NODE_PATH,".bin",e);if(hk.existsSync(i))return i}let r=el.join(t,"node_modules",".bin",e);if(hk.existsSync(r))return r;let n=el.join(M0t,"..","node_modules",".bin",e);if(hk.existsSync(n))return n}import MM from"process";import{fileURLToPath as pFt}from"url";import{createRequire as hFt}from"module";import WR from"path";import{readFileSync as mFt}from"fs";var j0t="__netlify__getTracer",z0t="__netlify__shutdownTracers",xt=(t,e)=>globalThis[j0t]?.(t,e),LAe=async()=>globalThis[z0t]?.();function JT(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{setTimeout as aFt}from"timers/promises";ke();import qxt from"process";ke();var dAt=(t,e)=>{e.recordException(t),e.setStatus({code:ei.ERROR})};var nl=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}=Pxe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>Cxe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Pxe(r,n,i),c=this._tracer.startSpan(e,s,o);return Cxe(c,s,a)}};function Pxe(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??Xt.active(),{opts:n,ctx:i,fn:s}}function Cxe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:dAt,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)}}ke();var z_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var AK=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=Fxe(e),n._asyncAttributesPending=e.filter(([i,s])=>z_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(z_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=Fxe(this._rawAttributes),this._schemaUrl=fAt(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,z_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ae.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(z_(n)){ae.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=pAt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function xK(t,e){return AK.FromAttributeList(Object.entries(t),e)}function Fxe(t){return t.map(([e,r])=>z_(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function fAt(t){if(typeof t=="string"||t===void 0)return t;ae.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function pAt(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;ae.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}ke();var cw=class{emit(e){}enabled(){return!1}},jxe=new cw;var lw=Symbol.for("io.opentelemetry.js.api.logs"),q_=globalThis;function zxe(t,e,r){return n=>n===t?e:r}var PK=1;var CK=class{getLogger(e,r,n){return new cw}},Mk=new CK;var Uk=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):jxe}};var uw=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new Uk(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Mk}_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 Fk=class t{constructor(){this._proxyLoggerProvider=new uw}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return q_[lw]?this.getLoggerProvider():(q_[lw]=zxe(PK,e,Mk),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=q_[lw])===null||e===void 0?void 0:e.call(q_,PK))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete q_[lw],this._proxyLoggerProvider=new uw}};var qxe=Fk.getInstance();function Bxe(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 Hxe(t){t.forEach(e=>e.disable())}function IK(t){let e=t.tracerProvider||Mt.getTracerProvider(),r=t.meterProvider||aw.getMeterProvider(),n=t.loggerProvider||qxe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Bxe(i,e,r,n),()=>{Hxe(i)}}ke();var hAt=on("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Vxe(t){return t.getValue(hAt)===!0}var B_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(B_||(B_={}));ke();var OK="[_0-9a-z-*/]",mAt=`[a-z]${OK}{0,255}`,gAt=`[a-z0-9]${OK}{0,240}@[a-z]${OK}{0,13}`,_At=new RegExp(`^(?:${mAt}|${gAt})$`),yAt=/^[ -~]{0,255}[!-~]$/,SAt=/,|=/;function NK(t){return _At.test(t)}function kK(t){return yAt.test(t)&&!SAt.test(t)}var EAt=32,Gxe=512,Wxe=",",Yxe="=",jk=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!NK(e)||!kK(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>Gxe)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=Wxe+e),e=`${n[0]}${Yxe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(Wxe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Yxe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!NK(a)||!kK(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>Gxe)&&(r.set(a,c),n=l,r.size>=EAt))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 zk="traceparent",qk="tracestate",vAt="00",bAt="(?!ff)[\\da-f]{2}",TAt="(?![0]{32})[\\da-f]{32}",wAt="(?![0]{16})[\\da-f]{16}",RAt="[\\da-f]{2}",AAt=new RegExp(`^\\s?(${bAt})-(${TAt})-(${wAt})-(${RAt})(-.*)?\\s?$`);function Kxe(t){let e=AAt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var sd=class{inject(e,r,n){let i=Mt.getSpanContext(e);if(!i||Vxe(e)||!qi(i))return;let s=`${vAt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Ar.NONE).toString(16)}`;n.set(r,zk,s),i.traceState&&n.set(r,qk,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,zk);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=Kxe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,qk);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new jk(typeof c=="string"?c:void 0)}return Mt.setSpanContext(e,o)}fields(){return[zk,qk]}};var Bk=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 dw=class{_isCalled=!1;_deferred=new Bk;_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 $$=Vn(y5(),1);ke();var OIe=t=>{throw TypeError(t)},b5=(t,e,r)=>e.has(t)||OIe("Cannot "+r),k$=(t,e,r)=>(b5(t,e,"read from private field"),r?r.call(t):e.get(t)),S5=(t,e,r)=>e.has(t)?OIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),PIe=(t,e,r,n)=>(b5(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),zxt=(t,e,r)=>(b5(t,e,"access private method"),r),CIe="__netlify__getTracer",Bxt="__netlify__shutdownTracers",Hxt="__nfOTLPTrace",Aw,xw,v5,NIe,Vxt=class{constructor(){S5(this,v5),S5(this,Aw),S5(this,xw),PIe(this,Aw,new dw(zxt(this,v5,NIe),this)),PIe(this,xw,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(k$(this,xw).debug(`export ${t.length.toString()} spans`),k$(this,Aw).isCalled){e({code:B_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Hxt,JSON.stringify(Gxt(t))),e({code:B_.SUCCESS})}shutdown(){return k$(this,Aw).call()}};Aw=new WeakMap;xw=new WeakMap;v5=new WeakSet;NIe=function(){return k$(this,xw).debug("Shutting down"),Promise.resolve()};function Gxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:N$(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||Co.SERVER,startTimeUnixNano:E5(e.startTime),endTimeUnixNano:E5(e.endTime),attributes:N$(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:E5(n.time),attributes:N$(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:N$(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function N$(t){return Object.keys(t).map(e=>kIe(e,t[e]))}function kIe(t,e){return{key:t,value:$Ie(e)}}function $Ie(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($Ie)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>kIe(r,n))}}:{}}function E5(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var IIe={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"}},LIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,CIe))return;let e=qxt.version.slice(1),r=xK({"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??[Wxt()],i=new $$.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new sd});let s=t.instrumentations??[];IK({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,CIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new nl(Mt.getTracer(a,c)):new nl(Mt.getTracer(IIe.name,IIe.version))}}),Object.defineProperty(globalThis,Bxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Wxt=()=>new $$.SimpleSpanProcessor(new Vxt);ke();var Pw=Vn(y5(),1);ke();import*as L$ from"diagnostics_channel";var DIe=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?ei.ERROR:ei.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],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.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 nl?t:new nl(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){L$.subscribe(t,e);let r=()=>L$.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:Co.CLIENT},Xt.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:ei.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 oUe=Vn(iUe(),1);var LM=me("tracing"),sUe=8e3,cFt=5e3,GR=async(t=cFt)=>{try{await Promise.race([LAe(),aFt(t)])}catch(e){LM.warn("Failed to flush tracers on shutdown",e)}},aUe=async(t,e,r)=>{if(!xt()){let n=[new Pw.SimpleSpanProcessor(new TX),new Pw.SimpleSpanProcessor(new oUe.OTLPTraceExporter({url:r.exporterUrl}))];await LIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new DIe({skipHeaders:!0})]})}return r.traceparent?(Si.setGlobalPropagator(new sd),Si.extract(Xt.active(),{traceparent:r.traceparent,isRemote:!0})):Xt.active()};function tr(t,e,r){return LM.log(`\u23F3 TRACE: ${e} starting...`),JT(t,e,r)}var TX=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(", ")}]`:"";LM.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&LM.log(` \u274C Error: ${e.status.message}`)}};function wX(){return Ke().captureLlmContentEnabled}function cUe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function DM(t,e,r){let n={role:t,parts:[{type:"text",content:Hs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var lFt=new Set([te.Task,te.RunCommand,te.Explore,te.FileRead,te.FileWrite,te.Notebook,te.Web,te.Todo,te.Skill,te.Tool,te.Memorize,te.Deployment,te.SiteGeneration]);function lUe(t,e,r,n){if(!t.length)return;let i=xt();if(!i)return;let s=wX(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&lFt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>sUe?`${a.message.slice(0,sUe)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Hs(_)}:{"gen_ai.output.messages":DM("assistant",_)}:{}}}).end(u)})}import{readdir as uFt,rm as dFt}from"fs/promises";import{join as fFt}from"path";async function uUe(t,e=[]){let n=(await uFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>dFt(fFt(t,i),{recursive:!0,force:!0})))}var ah=({mode:t,sessionCreditLimit:e})=>t==="create"&&e!=null&&e<=300;var RX=t=>{if(!ah(t))return"default";let e=Ke();return e.createAskFirstEnabled&&e.questionsEnabled?"ask_first":e.creditWrapUpEnabled?"budget_constrained":"default"},dUe=t=>{let e=RX(t);return{budget_eligible:ah(t),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var gFt=WR.dirname(pFt(import.meta.url)),fUe=hFt(import.meta.url),_Ft=WR.resolve(gFt,"scripts/scaffold.js"),yFt="scripts/scaffold.js",SFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,AX=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},EFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),vFt=t=>{let e=AX(t);return e==="node"||e.endsWith("/node")},xl=t=>{if(typeof t!="string")return!1;let e=t.match(SFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&EFt(AX(e[r]));)r+=1;if(r>=e.length||!vFt(e[r]))return!1;let n=e[r+1];return n?AX(n).includes(yFt):!1},ch=me("create_stage"),xX="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.",bFt=`${xX}
624
+ if (condition) { yield value; }`)};import{Buffer as VTt}from"buffer";import{StringDecoder as GTt}from"string_decoder";var XN=(t,e,r)=>{if(r)return;if(t)return{transform:WTt.bind(void 0,new TextEncoder)};let n=new GTt(e);return{transform:YTt.bind(void 0,n),final:KTt.bind(void 0,n)}},WTt=function*(t,e){VTt.isBuffer(e)?yield Jc(e):typeof e=="string"?yield t.encode(e):yield e},YTt=function*(t,e){yield Yr(e)?t.write(e):e},KTt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as KRe}from"util";var cY=KRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),QN=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=ZTt}=e[r];for await(let i of n(t))yield*QN(i,e,r+1)},JRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*JTt(r,Number(e),t)},JTt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*QN(n,r,e+1)},ZRe=KRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),ZTt=function*(t){yield t};var lY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},XRe=(t,e)=>[...e.flatMap(r=>[...Sp(r,t,0)]),...qT(t)],Sp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QTt}=e[r];for(let i of n(t))yield*Sp(i,e,r+1)},qT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XTt(r,Number(e),t)},XTt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Sp(n,r,e+1)},QTt=function*(t){yield t};var uY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=e0e(t,o,s),l=yp(e),u=yp(r),d=l?cY.bind(void 0,QN,a):lY.bind(void 0,Sp),f=l||u?cY.bind(void 0,JRe,a):lY.bind(void 0,qT),p=l||u?ZRe.bind(void 0,a):void 0;return{stream:new ewt({writableObjectMode:n,writableHighWaterMark:QRe(n),readableObjectMode:i,readableHighWaterMark:QRe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},ek=(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=e0e(o,r,a);t=XRe(c,t)}return t},e0e=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:GRe(n,a)},XN(r,o,n),ZN(r,s,n,c),{transform:t,final:e},{transform:WRe(i,a)},VRe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var t0e=(t,e)=>{for(let r of twt(t))rwt(t,r,e)},twt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),rwt=(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 ${td[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>nwt(a,n));r.input=NT(o)},nwt=(t,e)=>{let r=ek(t,e,"utf8",!0);return iwt(r),NT(r)},iwt=t=>{let e=t.find(r=>typeof r!="string"&&!Yr(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 cwt,appendFileSync as lwt}from"fs";var tk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&E_(r,n)&&!os.has(e)&&swt(n)&&(t.some(({type:i,value:s})=>i==="native"&&owt.has(s))||t.every(({type:i})=>Bs.has(i))),swt=t=>t===1||t===2,owt=new Set(["pipe","overlapped"]),r0e=async(t,e,r,n)=>{for await(let i of t)awt(e)||i0e(i,r,n)},n0e=(t,e,r)=>{for(let n of t)i0e(n,e,r)},awt=t=>t._readableState.pipes.length>0,i0e=(t,e,r)=>{let n=mN(t);Pa({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var s0e=({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,l)=>uwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},uwt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=oRe(t,s,d),p=Jc(f),{stdioItems:h,objectMode:m}=e[r],_=dwt([p],h,c,n),{serializedResult:y,finalResult:v=y}=fwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});pwt({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&&hwt(y,h,i),S}catch(g){return n.error=g,S}},dwt=(t,e,r,n)=>{try{return ek(t,e,r,!1)}catch(i){return n.error=i,t}},fwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:NT(t)};let o=Ebe(t,r);return n[s]?{serializedResult:o,finalResult:aY(o,!i[s],e)}:{serializedResult:o}},pwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!tk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=aY(t,!1,o);try{n0e(a,e,n)}catch(c){r.error??=c}},hwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>KN.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?lwt(n,t):(r.add(s),cwt(n,t))}};var o0e=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Qc(e,r,"all")]:Array.isArray(e)?[Qc(t,r,"all"),...e]:Yr(t)&&Yr(e)?gW([t,e]):`${t}${e}`};import{once as dY}from"events";var a0e=async(t,e)=>{let[r,n]=await mwt(t);return e.isForcefullyTerminated??=!1,[r,n]},mwt=async t=>{let[e,r]=await Promise.allSettled([dY(t,"spawn"),dY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?c0e(t):r.value},c0e=async t=>{try{return await dY(t,"exit")}catch{return c0e(t)}},l0e=async t=>{let[e,r]=await t;if(!gwt(e,r)&&fY(e,r))throw new Ro;return[e,r]},gwt=(t,e)=>t===void 0&&e===void 0,fY=(t,e)=>t!==0||e!==null;var u0e=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=_wt(t,e,r),o=s?.code==="ETIMEDOUT",a=sRe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},_wt=(t,e,r)=>t!==void 0?t:fY(e,r)?new Ro:void 0;var d0e=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Swt(t,e,r),d=bwt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return I_(d,c,l)},Swt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),a=Ewt(r),{file:c,commandArguments:l,options:u}=MN(t,e,a);vwt(u);let d=zRe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Ewt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vwt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&rk("ipcInput"),t&&rk("ipc: true"),r&&rk("detached: true"),n&&rk("cancelSignal")},rk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},bwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Twt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=u0e(c,r),{output:h,error:m=l}=s0e({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>Qc(v,r,S)),y=Qc(o0e(h,r),r,"all");return Rwt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Twt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{t0e(s,r);let a=wwt(r);return ywt(...UN(t,e,a))}catch(a){return C_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},wwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:VN(e)}),Rwt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?GN({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):zT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as f0t}from"events";import{spawn as p0t}from"child_process";import g0e from"process";import{once as pY,on as Awt}from"events";var f0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(T_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),xwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),xwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{xN(e,i);let s=ed(t,e,r),o=new AbortController;try{return await Promise.race([Pwt(s,n,o),Cwt(s,r,o),Iwt(s,r,o)])}catch(a){throw w_(t),a}finally{o.abort(),PN(e,i)}},Pwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await pY(t,"message",{signal:r});return n}for await(let[n]of Awt(t,"message",{signal:r}))if(e(n))return n},Cwt=async(t,e,{signal:r})=>{await pY(t,"disconnect",{signal:r}),XTe(e)},Iwt=async(t,e,{signal:r})=>{let[n]=await pY(t,"strict:error",{signal:r});throw wN(n,e)};import{once as h0e,on as Owt}from"events";var m0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>hY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),hY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{T_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),xN(e,s);let o=ed(t,e,r),a=new AbortController,c={};return Nwt(t,o,a),kwt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),$wt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Nwt=async(t,e,r)=>{try{await h0e(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kwt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await h0e(t,"strict:error",{signal:r.signal});n.error=wN(i,e),r.abort()}catch{}},$wt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Owt(r,"message",{signal:s.signal}))p0e(o),yield c}catch{p0e(o)}finally{s.abort(),PN(e,a),n||w_(t),i&&await t}},p0e=({error:t})=>{if(t)throw t};var _0e=(t,{ipc:e})=>{Object.assign(t,S0e(t,!1,e))},y0e=()=>{let t=g0e,e=!0,r=g0e.channel!==void 0;return{...S0e(t,e,r),getCancelSignal:Rwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},S0e=(t,e,r)=>({sendMessage:LN.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:f0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:m0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Lwt}from"child_process";import{PassThrough as Dwt,Readable as Mwt,Writable as Uwt,Duplex as Fwt}from"stream";var E0e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{iY(n);let a=new Lwt;jwt(a,n),Object.assign(a,{readable:zwt,writable:qwt,duplex:Bwt});let c=C_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Hwt(c,o,i);return{subprocess:a,promise:l}},jwt=(t,e)=>{let r=BT(),n=BT(),i=BT(),s=Array.from({length:e.length-3},BT),o=BT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},BT=()=>{let t=new Dwt;return t.end(),t},zwt=()=>new Mwt({read(){}}),qwt=()=>new Uwt({write(){}}),Bwt=()=>new Fwt({read(){},write(){}}),Hwt=async(t,e,r)=>I_(t,e,r);import{createReadStream as v0e,createWriteStream as b0e}from"fs";import{Buffer as Vwt}from"buffer";import{Readable as HT,Writable as Gwt,Duplex as Wwt}from"stream";var w0e=(t,e)=>JN(Ywt,t,e,!1),VT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${td[t]}.`)},T0e={fileNumber:VT,generator:uY,asyncGenerator:uY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Wwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Ywt={input:{...T0e,fileUrl:({value:t})=>({stream:v0e(t)}),filePath:({value:{file:t}})=>({stream:v0e(t)}),webStream:({value:t})=>({stream:HT.fromWeb(t)}),iterable:({value:t})=>({stream:HT.from(t)}),asyncIterable:({value:t})=>({stream:HT.from(t)}),string:({value:t})=>({stream:HT.from(t)}),uint8Array:({value:t})=>({stream:HT.from(Vwt.from(t))})},output:{...T0e,fileUrl:({value:t})=>({stream:b0e(t)}),filePath:({value:{file:t,append:e}})=>({stream:b0e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Gwt.fromWeb(t)}),iterable:VT,asyncIterable:VT,string:VT,uint8Array:VT}};import{on as Kwt,once as R0e}from"events";import{PassThrough as Jwt,getDefaultHighWaterMark as Zwt}from"stream";import{finished as P0e}from"stream/promises";function Ep(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)gY(i);let e=t.some(({readableObjectMode:i})=>i),r=Xwt(t,e),n=new mY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Xwt=(t,e)=>{if(t.length===0)return Zwt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},mY=class extends Jwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(gY(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Qwt(this,this.#e,this.#s);let r=rRt({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(gY(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)}},Qwt=async(t,e,r)=>{nk(t,A0e);let n=new AbortController;try{await Promise.race([eRt(t,n),tRt(t,e,r,n)])}finally{n.abort(),nk(t,-A0e)}},eRt=async(t,{signal:e})=>{try{await P0e(t,{signal:e,cleanup:!0})}catch(r){throw C0e(t,r),r}},tRt=async(t,e,r,{signal:n})=>{for await(let[i]of Kwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},gY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},rRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{nk(t,x0e);let a=new AbortController;try{await Promise.race([nRt(s,e,a),iRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),sRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),nk(t,-x0e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?_Y(t):oRt(t))},nRt=async(t,e,{signal:r})=>{try{await t,r.aborted||_Y(e)}catch(n){r.aborted||C0e(e,n)}},iRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await P0e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;I0e(o)?i.add(e):O0e(t,o)}},sRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await R0e(t,i,{signal:s}),!t.readable)return R0e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},oRt=t=>{t.writable&&t.end()},C0e=(t,e)=>{I0e(e)?_Y(t):O0e(t,e)},I0e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_Y=t=>{(t.readable||t.writable)&&t.destroy()},O0e=(t,e)=>{t.destroyed||(t.once("error",aRt),t.destroy(e))},aRt=()=>{},nk=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},A0e=2,x0e=1;import{finished as N0e}from"stream/promises";var N_=(t,e)=>{t.pipe(e),cRt(t,e),lRt(t,e)},cRt=async(t,e)=>{if(!(wo(t)||wo(e))){try{await N0e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}yY(e)}},yY=t=>{t.writable&&t.end()},lRt=async(t,e)=>{if(!(wo(t)||wo(e))){try{await N0e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}SY(t)}},SY=t=>{t.readable&&t.destroy()};var k0e=(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})=>Bs.has(c)))uRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Bs.has(c)))fRt({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]:Ep(s);N_(o,i)}},uRt=(t,e,r,n)=>{r==="output"?N_(t.stdio[n],e):N_(e,t.stdio[n]);let i=dRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},dRt=["stdin","stdout","stderr"],fRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;pRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},pRt=(t,{signal:e})=>{wo(t)&&gp(t,hRt,e)},hRt=2;import{addAbortListener as _Rt}from"events";var vp=[];vp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&vp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&vp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ik=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",EY=Symbol.for("signal-exit emitter"),vY=globalThis,mRt=Object.defineProperty.bind(Object),bY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vY[EY])return vY[EY];mRt(vY,EY,{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}},sk=class{},gRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),TY=class extends sk{onExit(){return()=>{}}load(){}unload(){}},wY=class extends sk{#e=RY.platform==="win32"?"SIGINT":"SIGHUP";#r=new bY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of vp)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(!ik(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 vp)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,vp.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 ik(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"&&ik(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)}},RY=globalThis.process,{onExit:$0e,load:Kgr,unload:Jgr}=gRt(ik(RY)?new wY(RY):new TY);var L0e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=$0e(()=>{t.kill()});_Rt(n,()=>{i()})};var M0e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=gN(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=yRt(r,n,i),{sourceStream:d,sourceError:f}=ERt(t,l),{options:p,fileDescriptors:h}=Ia.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},yRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=SRt(t,e,...r),a=AN(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},SRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(D0e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||hW(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]=oN(r,...n);return{destination:e(D0e)(i,s,o),pipeOptions:o}}if(Ia.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}`)},D0e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),ERt=(t,e)=>{try{return{sourceStream:R_(t,e)}}catch(r){return{sourceError:r}}};var F0e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=vRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw AY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},vRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return SY(t),n;if(e!==void 0)return yY(r),e},AY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>C_({error:t,command:U0e,escapedCommand:U0e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),U0e="source.pipe(destination)";var j0e=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 bRt}from"stream/promises";var z0e=(t,e,r)=>{let n=ok.has(e)?wRt(t,e):TRt(t,e);return gp(t,ARt,r.signal),gp(e,xRt,r.signal),RRt(e),n},TRt=(t,e)=>{let r=Ep([t]);return N_(r,e),ok.set(e,r),r},wRt=(t,e)=>{let r=ok.get(e);return r.add(t),r},RRt=async t=>{try{await bRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ok.delete(t)},ok=new WeakMap,ARt=2,xRt=1;import{aborted as PRt}from"util";var q0e=(t,e)=>t===void 0?[]:[CRt(t,e)],CRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await PRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw AY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ak=(t,...e)=>{if(kr(e[0]))return ak.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=M0e(t,...e),i=IRt({...n,destination:r});return i.pipe=ak.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},IRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=ORt(t,i);F0e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=z0e(e,s,d);return await Promise.race([j0e(u),...q0e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},ORt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as URt}from"timers/promises";import{on as NRt}from"events";import{getDefaultHighWaterMark as kRt}from"stream";var ck=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return $Rt(e,o),H0e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},$Rt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},xY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;LRt(e,o,t);let a=t.readableObjectMode&&!s;return H0e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},LRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},H0e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=NRt(t,"data",{signal:e.signal,highWaterMark:B0e,highWatermark:B0e});return DRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},PY=kRt(!0),B0e=PY,DRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=MRt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Sp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*qT(a)}},MRt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[XN(t,r,!e),ZN(t,i,!n,{})].filter(Boolean);var V0e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=FRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([jRt(t),d]);return}let f=sY(c,r),p=xY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},FRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!tk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=xY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await r0e(a,t,r,s)},jRt=async t=>{await URt(),t.readableFlowing===null&&t.resume()},zRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qN(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await BN(r,{maxBuffer:s})):await P_(r,{maxBuffer:s})}catch(a){return G0e(rRe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},CY=async t=>{try{return await t}catch(e){return G0e(e)}},G0e=({bufferedData:t})=>ybe(t)?new Uint8Array(t):t;import{finished as qRt}from"stream/promises";var GT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=BRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],qRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||GRt(a,e,r,n)}finally{o.abort()}},BRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&HRt(t,r,n),n},HRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{VRt(e,r),n.call(t,...i)}},VRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},GRt=(t,e,r,n)=>{if(!WRt(t,e,r,n))throw t},WRt=(t,e,r,n=!0)=>r.propagating?W0e(t)||lk(t):(r.propagating=!0,IY(r,e)===n?W0e(t):lk(t)),IY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",lk=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",W0e=t=>t?.code==="EPIPE";var Y0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>OY({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),OY=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=GT(t,e,l);if(IY(l,e)){await u;return}let[d]=await Promise.all([V0e({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var K0e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ep([t,e].filter(Boolean)):void 0,J0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>OY({...YRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:KRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),YRt=({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}},KRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as JRt}from"events";var Z0e=t=>E_(t,"ipc"),X0e=(t,e)=>{let r=mN(t);Pa({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Q0e=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Z0e(s),a=Zc(e,"ipc"),c=Zc(r,"ipc");for await(let l of hY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(nRe(t,i,c),i.push(l)),o&&X0e(l,s);return i},eAe=async(t,e)=>(await Promise.allSettled([t]),e);var tAe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=a0e(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Y0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=J0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),x=[],R=Q0e({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),b=ZRt(m,t,S),P=XRt(h,S);try{return await Promise.race([Promise.all([{},l0e(v),Promise.all(g),w,R,Lwe(t,d),...b,...P]),_,QRt(t,y),...Iwe(t,s,f,y),...ZTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Pwe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(O){return f.terminationReason??="other",Promise.all([{error:O},v,Promise.all(g.map(A=>CY(A))),CY(w),eAe(R,x),Promise.allSettled(b),Promise.allSettled(P)])}},ZRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:GT(n,i,r)),XRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>xo(s,{checkOpen:!1})&&!wo(s)).map(({type:i,value:s,stream:o=s})=>GT(o,n,e,{isSameDirection:Bs.has(i),stopOnExit:i==="native"}))),QRt=async(t,{signal:e})=>{let[r]=await JRt(t,"error",{signal:e});throw r};var rAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),WT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Ca();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},k_=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 e0t}from"stream";import{callbackify as t0t}from"util";import{finished as nAe}from"stream/promises";var NY=async t=>{if(t!==void 0)try{await kY(t)}catch{}},iAe=async t=>{if(t!==void 0)try{await $Y(t)}catch{}},kY=async t=>{await nAe(t,{cleanup:!0,readable:!1,writable:!0})},$Y=async t=>{await nAe(t,{cleanup:!0,readable:!0,writable:!1})},uk=async(t,e)=>{if(await t,e)throw e},dk=(t,e,r)=>{r&&!lk(r)?t.destroy(r):e&&t.destroy()};var sAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||os.has(r),{subprocessStdout:a,waitReadableDestroy:c}=LY(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=DY(a,o),{read:f,onStdoutDataDone:p}=MY({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new e0t({read:f,destroy:t0t(FY.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return UY({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},LY=(t,e,r)=>{let n=R_(t,e),i=WT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},DY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:PY},MY=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Ca(),o=ck({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){r0t(this,o,s)},onStdoutDataDone:s}},r0t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},UY=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await $Y(t),await n,await NY(i),await e,r.readable&&r.push(null)}catch(s){await NY(i),oAe(r,s)}},FY=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await k_(r,e)&&(oAe(t,n),await uk(e,n))},oAe=(t,e)=>{dk(t,t.readable,e)};import{Writable as n0t}from"stream";import{callbackify as aAe}from"util";var cAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=jY(t,r,e),o=new n0t({...zY(n,t,i),destroy:aAe(BY.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return qY(n,o),o},jY=(t,e,r)=>{let n=AN(t,e),i=WT(r,n,"writableFinal"),s=WT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},zY=(t,e,r)=>({write:i0t.bind(void 0,t),final:aAe(s0t.bind(void 0,t,e,r))}),i0t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},s0t=async(t,e,r)=>{await k_(r,e)&&(t.writable&&t.end(),await e)},qY=async(t,e,r)=>{try{await kY(t),e.writable&&e.end()}catch(n){await iAe(r),lAe(e,n)}},BY=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await k_(r,e),await k_(n,e)&&(lAe(t,i),await uk(e,i))},lAe=(t,e)=>{dk(t,t.writable,e)};import{Duplex as o0t}from"stream";import{callbackify as a0t}from"util";var uAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||os.has(r),{subprocessStdout:c,waitReadableDestroy:l}=LY(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=jY(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=DY(c,a),{read:_,onStdoutDataDone:y}=MY({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new o0t({read:_,...zY(u,t,d),destroy:a0t(c0t.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return UY({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),qY(u,v,c),v},c0t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([FY({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),BY({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var HY=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||os.has(e),o=R_(t,r),a=ck({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return l0t(a,o,t)},l0t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var dAe=(t,{encoding:e})=>{let r=rAe();t.readable=sAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=cAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=uAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=HY.bind(void 0,t,e),t[Symbol.asyncIterator]=HY.bind(void 0,t,e,{})};var fAe=(t,e)=>{for(let[r,n]of d0t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},u0t=(async()=>{})().constructor.prototype,d0t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(u0t,t)]);var pAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=h0t(t,e,r),{subprocess:f,promise:p}=g0t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ak.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),fAe(f,p),Ia.set(f,{options:u,fileDescriptors:d}),f},h0t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),{file:a,commandArguments:c,options:l}=MN(t,e,r),u=m0t(l),d=w0e(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},m0t=({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}},g0t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=p0t(...UN(t,e,r))}catch(h){return E0e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;f0t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];k0e(c,a,l),L0e(c,r,l);let d={},f=Ca();c.kill=KTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=K0e(c,r),dAe(c,r),_0e(c,r);let p=_0t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},_0t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await tAe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,w)=>Qc(g,e,w)),v=Qc(m,e,"all"),S=y0t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return I_(S,n,e)},y0t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?zT({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Oa,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):GN({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var fk=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,S0t(n,t[n],i)]));return{...t,...r}},S0t=(t,e,r)=>E0t.has(t)&&kr(e)&&kr(r)?{...e,...r}:r,E0t=new Set(["env",...EW]);var rd=(t,e,r,n)=>{let i=(o,a,c)=>rd(o,a,r,c),s=(...o)=>v0t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},v0t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(kr(s))return i(t,fk(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=b0t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?d0e(a,c,l):pAe(a,c,l,i)},b0t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=wbe(e)?Rbe(e,r):[e,...r],[o,a,c]=oN(...s),l=fk(fk(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var hAe=({file:t,commandArguments:e})=>gAe(t,e),mAe=({file:t,commandArguments:e})=>({...gAe(t,e),isSync:!0}),gAe=(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]=T0t(t);return{file:r,commandArguments:n}},T0t=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(w0t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},w0t=/ +/g;var _Ae=(t,e,r)=>{t.sync=e(R0t,r),t.s=t.sync},yAe=({options:t})=>SAe(t),R0t=({options:t})=>({...SAe(t),isSync:!0}),SAe=t=>({options:{...A0t(t),...t}}),A0t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},EAe={preferLocal:!0};var vAe=rd(()=>({})),FSr=rd(()=>({isSync:!0})),bAe=rd(hAe),jSr=rd(mAe),zSr=rd(Nwe),qSr=rd(yAe,{},EAe,_Ae),{sendMessage:BSr,getOneMessage:HSr,getEachMessage:VSr,getCancelSignal:GSr}=y0e();import{Transform as x0t}from"stream";var P0t=["NETLIFY_AI_GATEWAY_KEY"];function C0t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...P0t])]}function I0t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function O0t(){let e=C0t().map(r=>process.env[r]).filter(r=>!(!r||I0t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Hs(t){if(typeof t!="string")return t;let e=O0t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(N0t(n),"g");r=r.replace(i,"******")}),r}function N0t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var YT=class extends x0t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Hs(i);n(null,s)}},pk=Symbol("maskedWrite");function TAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[pk]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Hs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stdout.write=r}if(!process.stderr.write[pk]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Hs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stderr.write=r}}}var wAe=!1,RAe=()=>{wAe=!0},zi=()=>wAe;var KT=null,AAe=t=>(KT&&KT.destroy(),KT=new Po({totalAllowedTime:t}),KT),xAe=()=>KT;var Po=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&zi())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((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await tN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{fe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),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 PAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.168.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",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var D0t=$0t(import.meta.url),M0t=el.dirname(D0t),U0t=L0t(import.meta.url),$_=me("shell"),VY=new Set,CAe={preferLocal:!0},On=(t,e,r)=>{let[n,i]=F0t(e,r),s={...CAe,...i},o=vAe(t,n,s);OAe(o,s),$Ae(o);let a=r?.idleTimeout;return a&&a>0&&kAe(o,a),o},IAe=(t,e)=>{let r={...CAe,...e},n=bAe(t,r);return OAe(n,r),$Ae(n),e?.idleTimeout&&e.idleTimeout>0&&kAe(n,e.idleTimeout),n},F0t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},OAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ka.env.NETLIFY_LOCAL_QUIET==="true")return;if(ka.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new YT).pipe(ka.stdout),t.stderr?.pipe(new YT).pipe(ka.stderr);return}t.stdout?.pipe(ka.stdout),t.stderr?.pipe(ka.stderr)},GY=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ka.kill(-t.pid,e),$_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return $_.error("Error killing process:",r),!1}},NAe=t=>GY(t,"SIGKILL"),kAe=(t,e)=>{let r=null,n=()=>{$_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),GY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&($_.log(`Force killing idle process ${t.pid}`),NAe(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)},$Ae=t=>{VY.add(t);let e=xAe();if(e){let r=e.onTimesUp(()=>{$_.log(`Global timer expired, killing process ${t.pid}`),GY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&($_.log(`Force killing process ${t.pid} after timeout`),NAe(t))},5e3)});t.on("exit",()=>{VY.delete(t),r()}),t.on("error",()=>{VY.delete(t),r()})}};function $a(t,e){if(!ka.env.NETLIFY_LOCAL_MODE)try{let i=U0t.resolve(PAe.name),s=el.dirname(i);for(;s!==el.dirname(s);){let o=el.dirname(s);if(el.basename(o)==="node_modules"){let a=el.join(o,".bin",e);if(hk.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(ka.env.NODE_PATH){let i=el.join(ka.env.NODE_PATH,".bin",e);if(hk.existsSync(i))return i}let r=el.join(t,"node_modules",".bin",e);if(hk.existsSync(r))return r;let n=el.join(M0t,"..","node_modules",".bin",e);if(hk.existsSync(n))return n}import MM from"process";import{fileURLToPath as pFt}from"url";import{createRequire as hFt}from"module";import WR from"path";import{readFileSync as mFt}from"fs";var j0t="__netlify__getTracer",z0t="__netlify__shutdownTracers",xt=(t,e)=>globalThis[j0t]?.(t,e),LAe=async()=>globalThis[z0t]?.();function JT(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{setTimeout as aFt}from"timers/promises";ke();import qxt from"process";ke();var dAt=(t,e)=>{e.recordException(t),e.setStatus({code:ei.ERROR})};var nl=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}=Pxe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>Cxe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Pxe(r,n,i),c=this._tracer.startSpan(e,s,o);return Cxe(c,s,a)}};function Pxe(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??Xt.active(),{opts:n,ctx:i,fn:s}}function Cxe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:dAt,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)}}ke();var z_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var AK=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=Fxe(e),n._asyncAttributesPending=e.filter(([i,s])=>z_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(z_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=Fxe(this._rawAttributes),this._schemaUrl=fAt(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,z_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ae.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(z_(n)){ae.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=pAt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function xK(t,e){return AK.FromAttributeList(Object.entries(t),e)}function Fxe(t){return t.map(([e,r])=>z_(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function fAt(t){if(typeof t=="string"||t===void 0)return t;ae.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function pAt(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;ae.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}ke();var cw=class{emit(e){}enabled(){return!1}},jxe=new cw;var lw=Symbol.for("io.opentelemetry.js.api.logs"),q_=globalThis;function zxe(t,e,r){return n=>n===t?e:r}var PK=1;var CK=class{getLogger(e,r,n){return new cw}},Mk=new CK;var Uk=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):jxe}};var uw=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new Uk(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Mk}_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 Fk=class t{constructor(){this._proxyLoggerProvider=new uw}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return q_[lw]?this.getLoggerProvider():(q_[lw]=zxe(PK,e,Mk),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=q_[lw])===null||e===void 0?void 0:e.call(q_,PK))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete q_[lw],this._proxyLoggerProvider=new uw}};var qxe=Fk.getInstance();function Bxe(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 Hxe(t){t.forEach(e=>e.disable())}function IK(t){let e=t.tracerProvider||Mt.getTracerProvider(),r=t.meterProvider||aw.getMeterProvider(),n=t.loggerProvider||qxe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Bxe(i,e,r,n),()=>{Hxe(i)}}ke();var hAt=on("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Vxe(t){return t.getValue(hAt)===!0}var B_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(B_||(B_={}));ke();var OK="[_0-9a-z-*/]",mAt=`[a-z]${OK}{0,255}`,gAt=`[a-z0-9]${OK}{0,240}@[a-z]${OK}{0,13}`,_At=new RegExp(`^(?:${mAt}|${gAt})$`),yAt=/^[ -~]{0,255}[!-~]$/,SAt=/,|=/;function NK(t){return _At.test(t)}function kK(t){return yAt.test(t)&&!SAt.test(t)}var EAt=32,Gxe=512,Wxe=",",Yxe="=",jk=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!NK(e)||!kK(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>Gxe)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=Wxe+e),e=`${n[0]}${Yxe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(Wxe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Yxe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!NK(a)||!kK(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>Gxe)&&(r.set(a,c),n=l,r.size>=EAt))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 zk="traceparent",qk="tracestate",vAt="00",bAt="(?!ff)[\\da-f]{2}",TAt="(?![0]{32})[\\da-f]{32}",wAt="(?![0]{16})[\\da-f]{16}",RAt="[\\da-f]{2}",AAt=new RegExp(`^\\s?(${bAt})-(${TAt})-(${wAt})-(${RAt})(-.*)?\\s?$`);function Kxe(t){let e=AAt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var sd=class{inject(e,r,n){let i=Mt.getSpanContext(e);if(!i||Vxe(e)||!qi(i))return;let s=`${vAt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Ar.NONE).toString(16)}`;n.set(r,zk,s),i.traceState&&n.set(r,qk,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,zk);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=Kxe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,qk);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new jk(typeof c=="string"?c:void 0)}return Mt.setSpanContext(e,o)}fields(){return[zk,qk]}};var Bk=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 dw=class{_isCalled=!1;_deferred=new Bk;_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 $$=Vn(y5(),1);ke();var OIe=t=>{throw TypeError(t)},b5=(t,e,r)=>e.has(t)||OIe("Cannot "+r),k$=(t,e,r)=>(b5(t,e,"read from private field"),r?r.call(t):e.get(t)),S5=(t,e,r)=>e.has(t)?OIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),PIe=(t,e,r,n)=>(b5(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),zxt=(t,e,r)=>(b5(t,e,"access private method"),r),CIe="__netlify__getTracer",Bxt="__netlify__shutdownTracers",Hxt="__nfOTLPTrace",Aw,xw,v5,NIe,Vxt=class{constructor(){S5(this,v5),S5(this,Aw),S5(this,xw),PIe(this,Aw,new dw(zxt(this,v5,NIe),this)),PIe(this,xw,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(k$(this,xw).debug(`export ${t.length.toString()} spans`),k$(this,Aw).isCalled){e({code:B_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Hxt,JSON.stringify(Gxt(t))),e({code:B_.SUCCESS})}shutdown(){return k$(this,Aw).call()}};Aw=new WeakMap;xw=new WeakMap;v5=new WeakSet;NIe=function(){return k$(this,xw).debug("Shutting down"),Promise.resolve()};function Gxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:N$(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||Co.SERVER,startTimeUnixNano:E5(e.startTime),endTimeUnixNano:E5(e.endTime),attributes:N$(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:E5(n.time),attributes:N$(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:N$(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function N$(t){return Object.keys(t).map(e=>kIe(e,t[e]))}function kIe(t,e){return{key:t,value:$Ie(e)}}function $Ie(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($Ie)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>kIe(r,n))}}:{}}function E5(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var IIe={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"}},LIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,CIe))return;let e=qxt.version.slice(1),r=xK({"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??[Wxt()],i=new $$.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new sd});let s=t.instrumentations??[];IK({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,CIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new nl(Mt.getTracer(a,c)):new nl(Mt.getTracer(IIe.name,IIe.version))}}),Object.defineProperty(globalThis,Bxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Wxt=()=>new $$.SimpleSpanProcessor(new Vxt);ke();var Pw=Vn(y5(),1);ke();import*as L$ from"diagnostics_channel";var DIe=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?ei.ERROR:ei.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],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.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 nl?t:new nl(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){L$.subscribe(t,e);let r=()=>L$.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:Co.CLIENT},Xt.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:ei.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 oUe=Vn(iUe(),1);var LM=me("tracing"),sUe=8e3,cFt=5e3,GR=async(t=cFt)=>{try{await Promise.race([LAe(),aFt(t)])}catch(e){LM.warn("Failed to flush tracers on shutdown",e)}},aUe=async(t,e,r)=>{if(!xt()){let n=[new Pw.SimpleSpanProcessor(new TX),new Pw.SimpleSpanProcessor(new oUe.OTLPTraceExporter({url:r.exporterUrl}))];await LIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new DIe({skipHeaders:!0})]})}return r.traceparent?(Si.setGlobalPropagator(new sd),Si.extract(Xt.active(),{traceparent:r.traceparent,isRemote:!0})):Xt.active()};function tr(t,e,r){return LM.log(`\u23F3 TRACE: ${e} starting...`),JT(t,e,r)}var TX=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(", ")}]`:"";LM.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&LM.log(` \u274C Error: ${e.status.message}`)}};function wX(){return Ke().captureLlmContentEnabled}function cUe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function DM(t,e,r){let n={role:t,parts:[{type:"text",content:Hs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var lFt=new Set([te.Task,te.RunCommand,te.Explore,te.FileRead,te.FileWrite,te.Notebook,te.Web,te.Todo,te.Skill,te.Tool,te.Memorize,te.Deployment,te.SiteGeneration]);function lUe(t,e,r,n){if(!t.length)return;let i=xt();if(!i)return;let s=wX(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&lFt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>sUe?`${a.message.slice(0,sUe)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Hs(_)}:{"gen_ai.output.messages":DM("assistant",_)}:{}}}).end(u)})}import{readdir as uFt,rm as dFt}from"fs/promises";import{join as fFt}from"path";async function uUe(t,e=[]){let n=(await uFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>dFt(fFt(t,i),{recursive:!0,force:!0})))}var ah=({mode:t,sessionCreditLimit:e})=>t==="create"&&e!=null&&e<=300;var RX=t=>{if(!ah(t))return"default";let e=Ke();return e.createAskFirstEnabled&&e.questionsEnabled?"ask_first":e.creditWrapUpEnabled?"budget_constrained":"default"},dUe=t=>{let e=RX(t);return{budget_eligible:ah(t),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var gFt=WR.dirname(pFt(import.meta.url)),fUe=hFt(import.meta.url),_Ft=WR.resolve(gFt,"scripts/scaffold.js"),yFt="scripts/scaffold.js",SFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,AX=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},EFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),vFt=t=>{let e=AX(t);return e==="node"||e.endsWith("/node")},xl=t=>{if(typeof t!="string")return!1;let e=t.match(SFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&EFt(AX(e[r]));)r+=1;if(r>=e.length||!vFt(e[r]))return!1;let n=e[r+1];return n?AX(n).includes(yFt):!1},ch=me("create_stage"),xX="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.",bFt=`${xX}
625
625
 
626
626
  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.`,TFt=`${xX}
627
627
 
@@ -85,5 +85,5 @@ ${Ce}`,d++}else Fx($,I,de)?p=$.slice($.charCodeAt(I+6)===Tr?I+7:I+6,A)||void 0:S
85
85
  `,I),fe=-1;if(A!==-1&&de!==-1?fe=A<de?A:de:A!==-1?A===$.length-1?fe=-1:fe=A:de!==-1&&(fe=de),fe===-1)break;S($,I,fe),I=fe+1,$.charCodeAt(I-1)===fN&&$.charCodeAt(I)===Mx&&I++}return $.slice(I)}function S($,I,A){if(I===A){T();return}let de=$.charCodeAt(I);if(Lx($,I,de)){let Ot=$.charCodeAt(I+5)===Tr?I+6:I+5,sg=$.slice(Ot,A);l=d===0?sg:`${l}
86
86
  ${sg}`,d++;return}if(Fx($,I,de)){p=$.slice($.charCodeAt(I+6)===Tr?I+7:I+6,A)||void 0;return}if(de===105&&$.charCodeAt(I+1)===100&&$.charCodeAt(I+2)===58){let Ot=$.slice($.charCodeAt(I+3)===Tr?I+4:I+3,A);u=Ot.includes("\0")?void 0:Ot;return}if(de===58){if(r){let Ot=$.slice(I,A);r(Ot.slice($.charCodeAt(I+1)===Tr?2:1))}return}let fe=$.slice(I,A),Ce=fe.indexOf(":");if(Ce===-1){j(fe,"",fe);return}let Cn=fe.slice(0,Ce),Oi=fe.charCodeAt(Ce+1)===Tr?2:1,ji=fe.slice(Ce+Oi);j(Cn,ji,fe)}function j($,I,A){switch($){case"event":p=I||void 0;break;case"data":l=d===0?I:`${l}
87
87
  ${I}`,d++;break;case"id":u=I.includes("\0")?void 0:I;break;case"retry":/^\d+$/.test(I)?o(parseInt(I,10)):n(new Ti(`Invalid \`retry\` value: "${I}"`,{type:"invalid-retry",value:I,line:A}));break;default:n(new Ti(`Unknown field "${$.length>20?`${$.slice(0,20)}\u2026`:$}"`,{type:"unknown-field",field:$,value:I,line:A}));break}}function T(){d>0&&t({id:u,event:p,data:l}),u=void 0,l="",d=0,p=void 0}function N($={}){if($.consume&&a.length>0){let I=a.join("");S(I,0,I.length)}c=!0,u=void 0,l="",d=0,p=void 0,a.length=0,s=0,f=!1}return{feed:g,reset:N}}function Lx(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function Fx(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var $c=class extends TransformStream{constructor({onError:t,onRetry:n,onComment:o,maxBufferSize:r}={}){let i;super({start(a){i=Vx({onEvent:s=>{a.enqueue(s)},onError(s){typeof t=="function"&&t(s),(t==="terminate"||s.type==="max-buffer-size-exceeded")&&a.error(s)},onRetry:n,onComment:o,maxBufferSize:r})},transform(a){i.feed(a)}})}};var mN={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},nr=class extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}},bc=class{constructor(t,n){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=zx(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=n?.reconnectionOptions??mN}async _authThenStart(){if(!this._authProvider)throw new Et("No auth provider");let t;try{t=await Pi(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new Et;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let t={};if(this._authProvider){let o=await this._authProvider.tokens();o&&(t.Authorization=`Bearer ${o.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let n=yc(this._requestInit?.headers);return new Headers({...t,...n})}async _startOrAuthSse(t){let{resumptionToken:n}=t;try{let o=await this._commonHeaders();o.set("Accept","text/event-stream"),n&&o.set("last-event-id",n);let r=await(this._fetch??fetch)(this._url,{method:"GET",headers:o,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new nr(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,t,!0)}catch(o){throw this.onerror?.(o),o}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let n=this._reconnectionOptions.initialReconnectionDelay,o=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(o,t),r)}_scheduleReconnection(t,n=0){let o=this._reconnectionOptions.maxRetries;if(n>=o){this.onerror?.(new Error(`Maximum reconnection attempts (${o}) exceeded.`));return}let r=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(i=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${i instanceof Error?i.message:String(i)}`)),this._scheduleReconnection(t,n+1)})},r)}_handleSseStream(t,n,o){if(!t)return;let{onresumptiontoken:r,replayMessageId:i}=n,a,s=!1,c=!1;(async()=>{try{let l=t.pipeThrough(new TextDecoderStream).pipeThrough(new $c({onRetry:f=>{this._serverRetryMs=f}})).getReader();for(;;){let{value:f,done:g}=await l.read();if(g)break;if(f.id&&(a=f.id,s=!0,r?.(f.id)),!!f.data&&(!f.event||f.event==="message"))try{let _=pn.parse(JSON.parse(f.data));pr(_)&&(c=!0,i!==void 0&&(_.id=i)),this.onmessage?.(_)}catch(_){this.onerror?.(_)}}(o||s)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(o||s)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(f){this.onerror?.(new Error(`Failed to reconnect: ${f instanceof Error?f.message:String(f)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new Et("No auth provider");if(await Pi(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Et("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,n){try{let{resumptionToken:o,onresumptiontoken:r}=n||{};if(o){this._startOrAuthSse({resumptionToken:o,replayMessageId:ko(t)?t.id:void 0}).catch(p=>this.onerror?.(p));return}let i=await this._commonHeaders();i.set("content-type","application/json"),i.set("accept","application/json, text/event-stream");let a={...this._requestInit,method:"POST",headers:i,body:JSON.stringify(t),signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._url,a),c=s.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!s.ok){let p=await s.text().catch(()=>null);if(s.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new nr(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:f,scope:g}=eg(s);if(this._resourceMetadataUrl=f,this._scope=g,await Pi(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Et;return this._hasCompletedAuthFlow=!0,this.send(t)}if(s.status===403&&this._authProvider){let{resourceMetadataUrl:f,scope:g,error:_}=eg(s);if(_==="insufficient_scope"){let y=s.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===y)throw new nr(403,"Server returned 403 after trying upscoping");if(g&&(this._scope=g),f&&(this._resourceMetadataUrl=f),this._lastUpscopingHeader=y??void 0,await Pi(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Et;return this.send(t)}}throw new nr(s.status,`Error POSTing to endpoint: ${p}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,s.status===202){await s.body?.cancel(),gy(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(p=>this.onerror?.(p));return}let l=(Array.isArray(t)?t:[t]).filter(p=>"method"in p&&"id"in p&&p.id!==void 0).length>0,d=s.headers.get("content-type");if(l)if(d?.includes("text/event-stream"))this._handleSseStream(s.body,{onresumptiontoken:r},!1);else if(d?.includes("application/json")){let p=await s.json(),f=Array.isArray(p)?p.map(g=>pn.parse(g)):[pn.parse(p)];for(let g of f)this.onmessage?.(g)}else throw await s.body?.cancel(),new nr(-1,`Unexpected content type: ${d}`);else await s.body?.cancel()}catch(o){throw this.onerror?.(o),o}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let t=await this._commonHeaders(),n={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,n);if(await o.body?.cancel(),!o.ok&&o.status!==405)throw new nr(o.status,`Failed to terminate session: ${o.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}};var hN="NETLIFY_AGENT_CONNECTIONS_LOCAL",Er=(e,t)=>{Jx.stderr.write(`[connections-mcp] ${e}${t?` ${JSON.stringify(t)}`:""}
88
- `)},Hx=()=>{let e=Jx.env[hN];if(e){Er("using local connections from env (development only)");try{return JSON.parse(e)}catch{return Er("local connections env var is not valid JSON; continuing with none"),[]}}},Kx=async e=>(await Promise.all(e.map(async n=>{try{let o=new _c({name:"netlify-connections",version:"1.0.0"});await o.connect(new bc(new URL(n.mcp_server_url),{requestInit:{headers:{Authorization:`Bearer ${n.token}`}}}));let{tools:r}=await o.listTools();return{service:n.service,scope:n.scope??"project",client:o,tools:r}}catch(o){return Er("upstream unavailable; dropping this service",{service:n.service,scope:n.scope??"project",error:o?.message}),null}}))).filter(n=>n!==null),Gx=e=>{let t=new Map,n=[],o=[...e].sort((r,i)=>Jh(r.scope)-Jh(i.scope));for(let r of o)for(let i of r.tools)t.has(i.name)||(t.set(i.name,r),n.push(i));return{owner:t,tools:n}};import{renameSync as gN,writeFileSync as vN}from"fs";import xc from"process";var Wx=(e,t)=>{let n=`${e}.partial`;vN(n,JSON.stringify(t)),gN(n,e)},Bx=()=>new Promise(()=>{}),Xx=()=>{let e=()=>xc.exit(0);xc.stdin.on("close",e),xc.stdin.on("end",e)},wc=(e,t=xc.argv)=>{let n=t.indexOf(e);return n===-1?void 0:t[n+1]};var ng="netlify_interactions";var Ei="netlify_connections",Dn="request_service_authorization",Yx="--runner-id",Qx="--session-id",ew="--request-file",tw=(e,t)=>`mcp__${e}__${t}`,rw=(e,t)=>`mcp_${e}_${t}`,nw=(e,t)=>`${e}_${t}`,XZ=tw(ng,"ask"),YZ=rw(ng,"ask"),QZ=nw(ng,"ask"),eq=tw(Ei,Dn),tq=rw(Ei,Dn),rq=nw(Ei,Dn);var ow=wc(Yx),iw=wc(Qx),aw=wc(ew);xx({constants:{NETLIFY_API_HOST:og.env.NETLIFY_API_HOST,NETLIFY_API_TOKEN:og.env.NETLIFY_AUTH_TOKEN||og.env.NETLIFY_API_TOKEN}});var _N=async()=>{let e=Hx();if(e)return e;if(!ow||!iw)return[];try{let{connections:t}=await wx(ow,iw);return t??[]}catch(t){return Er("could not fetch connections; continuing with none",{error:t?.message}),[]}},sw=await Kx(await _N()),{owner:yN,tools:cw}=Gx(sw);Er("ready",{services:sw.map(e=>e.service),toolCount:cw.length});var $N={type:"object",properties:{}},ag=new fc({name:Ei,version:"1.0.0"},{capabilities:{tools:{}}}),bN={name:Dn,description:Sx,inputSchema:bt.toJSONSchema(Hh)};ag.setRequestHandler(Zf,()=>({tools:[...cw.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema??$N})),bN]}));var ig=e=>({content:[{type:"text",text:e}],isError:!0});ag.setRequestHandler(Oo,async e=>{let{name:t,arguments:n}=e.params;if(t===Dn){let r=Hh.safeParse(n);return r.success?(aw&&Wx(aw,r.data),Bx()):ig(bt.prettifyError(r.error))}let o=yN.get(t);if(!o)return ig(`Tool ${t} not found`);try{return await o.client.callTool({name:t,arguments:n??{}})}catch(r){return Er("upstream tool call failed",{service:o.service,tool:t,error:r?.message}),ig(r?.message??"Upstream tool call failed")}});Xx();await ag.connect(new hc);
88
+ `)},Hx=()=>{let e=Jx.env[hN];if(e){Er("using local connections from env (development only)");try{return JSON.parse(e)}catch{return Er("local connections env var is not valid JSON; continuing with none"),[]}}},Kx=async e=>(await Promise.all(e.map(async n=>{try{let o=new _c({name:"netlify-connections",version:"1.0.0"});await o.connect(new bc(new URL(n.mcp_server_url),{requestInit:{headers:{Authorization:`Bearer ${n.token}`}}}));let{tools:r}=await o.listTools();return{service:n.service,scope:n.scope??"project",client:o,tools:r}}catch(o){return Er("upstream unavailable; dropping this service",{service:n.service,scope:n.scope??"project",error:o?.message}),null}}))).filter(n=>n!==null),Gx=e=>{let t=new Map,n=[],o=[...e].sort((r,i)=>Jh(r.scope)-Jh(i.scope));for(let r of o)for(let i of r.tools)t.has(i.name)||(t.set(i.name,r),n.push(i));return{owner:t,tools:n}};import{renameSync as gN,writeFileSync as vN}from"fs";import xc from"process";var Wx=(e,t)=>{let n=`${e}.partial`;vN(n,JSON.stringify(t)),gN(n,e)},Bx=()=>new Promise(()=>{}),Xx=()=>{let e=()=>xc.exit(0);xc.stdin.on("close",e),xc.stdin.on("end",e)},wc=(e,t=xc.argv)=>{let n=t.indexOf(e);return n===-1?void 0:t[n+1]};var ng="netlify_interactions";var Ei="netlify_connections",Dn="request_service_authorization",Yx="--runner-id",Qx="--session-id",ew="--request-file",tw=(e,t)=>`mcp__${e}__${t}`,rw=(e,t)=>`mcp_${e}_${t}`,nw=(e,t)=>`${e}_${t}`,XZ=tw(ng,"ask"),YZ=rw(ng,"ask"),QZ=nw(ng,"ask"),eq=tw(Ei,Dn),tq=rw(Ei,Dn),rq=nw(Ei,Dn);var ow=wc(Yx),iw=wc(Qx),aw=wc(ew);xx({constants:{NETLIFY_API_HOST:og.env.NETLIFY_API_HOST||"api.netlify.com",NETLIFY_API_TOKEN:og.env.NETLIFY_AUTH_TOKEN||og.env.NETLIFY_API_TOKEN}});var _N=async()=>{let e=Hx();if(e)return e;if(!ow||!iw)return[];try{let{connections:t}=await wx(ow,iw);return t??[]}catch(t){return Er("could not fetch connections; continuing with none",{error:t?.message}),[]}},sw=await Kx(await _N()),{owner:yN,tools:cw}=Gx(sw);Er("ready",{services:sw.map(e=>e.service),toolCount:cw.length});var $N={type:"object",properties:{}},ag=new fc({name:Ei,version:"1.0.0"},{capabilities:{tools:{}}}),bN={name:Dn,description:Sx,inputSchema:bt.toJSONSchema(Hh)};ag.setRequestHandler(Zf,()=>({tools:[...cw.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema??$N})),bN]}));var ig=e=>({content:[{type:"text",text:e}],isError:!0});ag.setRequestHandler(Oo,async e=>{let{name:t,arguments:n}=e.params;if(t===Dn){let r=Hh.safeParse(n);return r.success?(aw&&Wx(aw,r.data),Bx()):ig(bt.prettifyError(r.error))}let o=yN.get(t);if(!o)return ig(`Tool ${t} not found`);try{return await o.client.callTool({name:t,arguments:n??{}})}catch(r){return Er("upstream tool call failed",{service:o.service,tool:t,error:r?.message}),ig(r?.message??"Upstream tool call failed")}});Xx();await ag.connect(new hc);
89
89
  //# sourceMappingURL=connections-mcp-server.js.map
package/dist/index.js CHANGED
@@ -139,7 +139,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
139
139
  `,LF:`
140
140
  `,concatBytes:YF},$Ve=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},DVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:$Ve};import{Buffer as LVe}from"buffer";var Oce=(t,e)=>t?void 0:UVe.bind(void 0,e),UVe=function*(t,e){if(typeof e!="string"&&!gr(e)&&!LVe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Nce=(t,e)=>t?FVe.bind(void 0,e):zVe.bind(void 0,e),FVe=function*(t,e){kce(t,e),yield e},zVe=function*(t,e){if(kce(t,e),typeof e!="string"&&!gr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},kce=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
141
141
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
142
- if (condition) { yield value; }`)};import{Buffer as jVe}from"buffer";import{StringDecoder as BVe}from"string_decoder";var k0=(t,e,r)=>{if(r)return;if(t)return{transform:qVe.bind(void 0,new TextEncoder)};let n=new BVe(e);return{transform:VVe.bind(void 0,n),final:GVe.bind(void 0,n)}},qVe=function*(t,e){jVe.isBuffer(e)?yield xa(e):typeof e=="string"?yield t.encode(e):yield e},VVe=function*(t,e){yield gr(e)?t.write(e):e},GVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Mce}from"util";var ZF=Mce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),M0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=WVe}=e[r];for await(let i of n(t))yield*M0(i,e,r+1)},$ce=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*HVe(r,Number(e),t)},HVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*M0(n,r,e+1)},Dce=Mce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),WVe=function*(t){yield t};var JF=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Lce=(t,e)=>[...e.flatMap(r=>[...id(r,t,0)]),...jS(t)],id=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=KVe}=e[r];for(let i of n(t))yield*id(i,e,r+1)},jS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*YVe(r,Number(e),t)},YVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*id(n,r,e+1)},KVe=function*(t){yield t};var XF=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Fce(t,s,o),l=nd(e),u=nd(r),d=l?ZF.bind(void 0,M0,a):JF.bind(void 0,id),f=l||u?ZF.bind(void 0,$ce,a):JF.bind(void 0,jS),p=l||u?Dce.bind(void 0,a):void 0;return{stream:new ZVe({writableObjectMode:n,writableHighWaterMark:Uce(n),readableObjectMode:i,readableHighWaterMark:Uce(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},$0=(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=Fce(s,r,a);t=Lce(c,t)}return t},Fce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Oce(n,a)},k0(r,s,n),N0(r,o,n,c),{transform:t,final:e},{transform:Nce(i,a)},Ice({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var zce=(t,e)=>{for(let r of JVe(t))XVe(t,r,e)},JVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),XVe=(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 ${Zc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>QVe(a,n));r.input=OS(s)},QVe=(t,e)=>{let r=$0(t,e,"utf8",!0);return eGe(r),OS(r)},eGe=t=>{let e=t.find(r=>typeof r!="string"&&!gr(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 iGe,appendFileSync as oGe}from"fs";var D0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Yp(r,n)&&!di.has(e)&&tGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&rGe.has(o))||t.every(({type:i})=>ji.has(i))),tGe=t=>t===1||t===2,rGe=new Set(["pipe","overlapped"]),jce=async(t,e,r,n)=>{for await(let i of t)nGe(e)||qce(i,r,n)},Bce=(t,e,r)=>{for(let n of t)qce(n,e,r)},nGe=t=>t._readableState.pipes.length>0,qce=(t,e,r)=>{let n=ZR(t);ms({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Vce=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>sGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},sGe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Gae(t,o,d),p=xa(f),{stdioItems:h,objectMode:m}=e[r],g=aGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=cGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});lGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?b:void 0;try{return n.error===void 0&&uGe(_,h,i),T}catch(v){return n.error=v,T}},aGe=(t,e,r,n)=>{try{return $0(t,e,r,!1)}catch(i){return n.error=i,t}},cGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:OS(t)};let s=ooe(t,r);return n[o]?{serializedResult:s,finalResult:KF(s,!i[o],e)}:{serializedResult:s}},lGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!D0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=KF(t,!1,s);try{Bce(a,e,n)}catch(c){r.error??=c}},uGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>I0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?oGe(n,t):(r.add(o),iGe(n,t))}};var Gce=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ca(e,r,"all")]:Array.isArray(e)?[Ca(t,r,"all"),...e]:gr(t)&&gr(e)?iF([t,e]):`${t}${e}`};import{once as QF}from"events";var Hce=async(t,e)=>{let[r,n]=await dGe(t);return e.isForcefullyTerminated??=!1,[r,n]},dGe=async t=>{let[e,r]=await Promise.allSettled([QF(t,"spawn"),QF(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Wce(t):r.value},Wce=async t=>{try{return await QF(t,"exit")}catch{return Wce(t)}},Yce=async t=>{let[e,r]=await t;if(!fGe(e,r)&&ez(e,r))throw new Ao;return[e,r]},fGe=(t,e)=>t===void 0&&e===void 0,ez=(t,e)=>t!==0||e!==null;var Kce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=pGe(t,e,r),s=o?.code==="ETIMEDOUT",a=Vae(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},pGe=(t,e,r)=>t!==void 0?t:ez(e,r)?new Ao:void 0;var Zce=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=mGe(t,e,r),d=yGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return ih(d,c,l)},mGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=XR(t,e,r),a=gGe(r),{file:c,commandArguments:l,options:u}=y0(t,e,a);_Ge(u);let d=Ace(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},gGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,_Ge=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&L0("ipcInput"),t&&L0("ipc: true"),r&&L0("detached: true"),n&&L0("cancelSignal")},L0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},yGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=SGe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Kce(c,r),{output:h,error:m=l}=Vce({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>Ca(b,r,T)),_=Ca(Gce(h,r),r,"all");return vGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},SGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{zce(o,r);let a=EGe(r);return hGe(...S0(t,e,a))}catch(a){return nh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},EGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:A0(e)}),vGe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?R0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):zS({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as c6e}from"events";import{spawn as l6e}from"child_process";import tle from"process";import{once as tz,on as bGe}from"events";var Jce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Jp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:f0(t)}),TGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),TGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{c0(e,i);let o=Kc(t,e,r),s=new AbortController;try{return await Promise.race([wGe(o,n,s),xGe(o,r,s),AGe(o,r,s)])}catch(a){throw Xp(t),a}finally{s.abort(),l0(e,i)}},wGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await tz(t,"message",{signal:r});return n}for await(let[n]of bGe(t,"message",{signal:r}))if(e(n))return n},xGe=async(t,e,{signal:r})=>{await tz(t,"disconnect",{signal:r}),Lse(e)},AGe=async(t,e,{signal:r})=>{let[n]=await tz(t,"strict:error",{signal:r});throw o0(n,e)};import{once as Qce,on as RGe}from"events";var ele=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>rz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),rz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Jp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:f0(t)}),c0(e,o);let s=Kc(t,e,r),a=new AbortController,c={};return CGe(t,s,a),PGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),IGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},CGe=async(t,e,r)=>{try{await Qce(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},PGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Qce(t,"strict:error",{signal:r.signal});n.error=o0(i,e),r.abort()}catch{}},IGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of RGe(r,"message",{signal:o.signal}))Xce(s),yield c}catch{Xce(s)}finally{o.abort(),l0(e,a),n||Xp(t),i&&await t}},Xce=({error:t})=>{if(t)throw t};var rle=(t,{ipc:e})=>{Object.assign(t,ile(t,!1,e))},nle=()=>{let t=tle,e=!0,r=tle.channel!==void 0;return{...ile(t,e,r),getCancelSignal:uae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ile=(t,e,r)=>({sendMessage:g0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Jce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ele.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as OGe}from"child_process";import{PassThrough as NGe,Readable as kGe,Writable as MGe,Duplex as $Ge}from"stream";var ole=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{HF(n);let a=new OGe;DGe(a,n),Object.assign(a,{readable:LGe,writable:UGe,duplex:FGe});let c=nh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=zGe(c,s,i);return{subprocess:a,promise:l}},DGe=(t,e)=>{let r=BS(),n=BS(),i=BS(),o=Array.from({length:e.length-3},BS),s=BS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},BS=()=>{let t=new NGe;return t.end(),t},LGe=()=>new kGe({read(){}}),UGe=()=>new MGe({write(){}}),FGe=()=>new $Ge({read(){},write(){}}),zGe=async(t,e,r)=>ih(t,e,r);import{createReadStream as sle,createWriteStream as ale}from"fs";import{Buffer as jGe}from"buffer";import{Readable as qS,Writable as BGe,Duplex as qGe}from"stream";var lle=(t,e)=>O0(VGe,t,e,!1),VS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Zc[t]}.`)},cle={fileNumber:VS,generator:XF,asyncGenerator:XF,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:qGe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},VGe={input:{...cle,fileUrl:({value:t})=>({stream:sle(t)}),filePath:({value:{file:t}})=>({stream:sle(t)}),webStream:({value:t})=>({stream:qS.fromWeb(t)}),iterable:({value:t})=>({stream:qS.from(t)}),asyncIterable:({value:t})=>({stream:qS.from(t)}),string:({value:t})=>({stream:qS.from(t)}),uint8Array:({value:t})=>({stream:qS.from(jGe.from(t))})},output:{...cle,fileUrl:({value:t})=>({stream:ale(t)}),filePath:({value:{file:t,append:e}})=>({stream:ale(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:BGe.fromWeb(t)}),iterable:VS,asyncIterable:VS,string:VS,uint8Array:VS}};import{on as GGe,once as ule}from"events";import{PassThrough as HGe,getDefaultHighWaterMark as WGe}from"stream";import{finished as ple}from"stream/promises";function od(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)iz(i);let e=t.some(({readableObjectMode:i})=>i),r=YGe(t,e),n=new nz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var YGe=(t,e)=>{if(t.length===0)return WGe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},nz=class extends HGe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(iz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=KGe(this,this.#e,this.#o);let r=XGe({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(iz(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)}},KGe=async(t,e,r)=>{U0(t,dle);let n=new AbortController;try{await Promise.race([ZGe(t,n),JGe(t,e,r,n)])}finally{n.abort(),U0(t,-dle)}},ZGe=async(t,{signal:e})=>{try{await ple(t,{signal:e,cleanup:!0})}catch(r){throw hle(t,r),r}},JGe=async(t,e,r,{signal:n})=>{for await(let[i]of GGe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},iz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},XGe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{U0(t,fle);let a=new AbortController;try{await Promise.race([QGe(o,e,a),eHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),tHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),U0(t,-fle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?oz(t):rHe(t))},QGe=async(t,e,{signal:r})=>{try{await t,r.aborted||oz(e)}catch(n){r.aborted||hle(e,n)}},eHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await ple(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;mle(s)?i.add(e):gle(t,s)}},tHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await ule(t,i,{signal:o}),!t.readable)return ule(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},rHe=t=>{t.writable&&t.end()},hle=(t,e)=>{mle(e)?oz(t):gle(t,e)},mle=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oz=t=>{(t.readable||t.writable)&&t.destroy()},gle=(t,e)=>{t.destroyed||(t.once("error",nHe),t.destroy(e))},nHe=()=>{},U0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},dle=2,fle=1;import{finished as _le}from"stream/promises";var sh=(t,e)=>{t.pipe(e),iHe(t,e),oHe(t,e)},iHe=async(t,e)=>{if(!(xo(t)||xo(e))){try{await _le(t,{cleanup:!0,readable:!0,writable:!1})}catch{}sz(e)}},sz=t=>{t.writable&&t.end()},oHe=async(t,e)=>{if(!(xo(t)||xo(e))){try{await _le(e,{cleanup:!0,readable:!1,writable:!0})}catch{}az(t)}},az=t=>{t.readable&&t.destroy()};var yle=(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})=>ji.has(c)))sHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ji.has(c)))cHe({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]:od(o);sh(s,i)}},sHe=(t,e,r,n)=>{r==="output"?sh(t.stdio[n],e):sh(e,t.stdio[n]);let i=aHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},aHe=["stdin","stdout","stderr"],cHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;lHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},lHe=(t,{signal:e})=>{xo(t)&&td(t,uHe,e)},uHe=2;import{addAbortListener as pHe}from"events";var sd=[];sd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&sd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&sd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var F0=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",cz=Symbol.for("signal-exit emitter"),lz=globalThis,dHe=Object.defineProperty.bind(Object),uz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(lz[cz])return lz[cz];dHe(lz,cz,{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}},z0=class{},fHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),dz=class extends z0{onExit(){return()=>{}}load(){}unload(){}},fz=class extends z0{#e=pz.platform==="win32"?"SIGINT":"SIGHUP";#r=new uz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of sd)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(!F0(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 sd)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,sd.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 F0(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"&&F0(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)}},pz=globalThis.process,{onExit:Sle,load:K1t,unload:Z1t}=fHe(F0(pz)?new fz(pz):new dz);var Ele=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Sle(()=>{t.kill()});pHe(n,()=>{i()})};var ble=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=JR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=hHe(r,n,i),{sourceStream:d,sourceError:f}=gHe(t,l),{options:p,fileDescriptors:h}=_s.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},hHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=mHe(t,e,...r),a=a0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},mHe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(vle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||rF(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]=jR(r,...n);return{destination:e(vle)(i,o,s),pipeOptions:s}}if(_s.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}`)},vle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),gHe=(t,e)=>{try{return{sourceStream:Qp(t,e)}}catch(r){return{sourceError:r}}};var wle=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=_He({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw hz({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},_He=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return az(t),n;if(e!==void 0)return sz(r),e},hz=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>nh({error:t,command:Tle,escapedCommand:Tle,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Tle="source.pipe(destination)";var xle=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 yHe}from"stream/promises";var Ale=(t,e,r)=>{let n=j0.has(e)?EHe(t,e):SHe(t,e);return td(t,bHe,r.signal),td(e,THe,r.signal),vHe(e),n},SHe=(t,e)=>{let r=od([t]);return sh(r,e),j0.set(e,r),r},EHe=(t,e)=>{let r=j0.get(e);return r.add(t),r},vHe=async t=>{try{await yHe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}j0.delete(t)},j0=new WeakMap,bHe=2,THe=1;import{aborted as wHe}from"util";var Rle=(t,e)=>t===void 0?[]:[xHe(t,e)],xHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await wHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw hz({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var B0=(t,...e)=>{if(ir(e[0]))return B0.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ble(t,...e),i=AHe({...n,destination:r});return i.pipe=B0.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},AHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=RHe(t,i);wle({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Ale(e,o,d);return await Promise.race([xle(u),...Rle(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},RHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as MHe}from"timers/promises";import{on as CHe}from"events";import{getDefaultHighWaterMark as PHe}from"stream";var q0=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return IHe(e,s),Ple({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},IHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},mz=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;OHe(e,s,t);let a=t.readableObjectMode&&!o;return Ple({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},OHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Ple=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=CHe(t,"data",{signal:e.signal,highWaterMark:Cle,highWatermark:Cle});return NHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},gz=PHe(!0),Cle=gz,NHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=kHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*id(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*jS(a)}},kHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[k0(t,r,!e),N0(t,i,!n,{})].filter(Boolean);var Ile=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=$He({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([DHe(t),d]);return}let f=WF(c,r),p=mz({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([LHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},$He=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!D0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=mz({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await jce(a,t,r,o)},DHe=async t=>{await MHe(),t.readableFlowing===null&&t.resume()},LHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await T0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await w0(r,{maxBuffer:o})):await rh(r,{maxBuffer:o})}catch(a){return Ole(jae({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},_z=async t=>{try{return await t}catch(e){return Ole(e)}},Ole=({bufferedData:t})=>noe(t)?new Uint8Array(t):t;import{finished as UHe}from"stream/promises";var GS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=FHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],UHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||BHe(a,e,r,n)}finally{s.abort()}},FHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&zHe(t,r,n),n},zHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{jHe(e,r),n.call(t,...i)}},jHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},BHe=(t,e,r,n)=>{if(!qHe(t,e,r,n))throw t},qHe=(t,e,r,n=!0)=>r.propagating?Nle(t)||V0(t):(r.propagating=!0,yz(r,e)===n?Nle(t):V0(t)),yz=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",V0=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Nle=t=>t?.code==="EPIPE";var kle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>Sz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Sz=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=GS(t,e,l);if(yz(l,e)){await u;return}let[d]=await Promise.all([Ile({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Mle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?od([t,e].filter(Boolean)):void 0,$le=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Sz({...VHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:GHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),VHe=({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}},GHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as HHe}from"events";var Dle=t=>Yp(t,"ipc"),Lle=(t,e)=>{let r=ZR(t);ms({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Ule=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Dle(o),a=Aa(e,"ipc"),c=Aa(r,"ipc");for await(let l of rz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Bae(t,i,c),i.push(l)),s&&Lle(l,o);return i},Fle=async(t,e)=>(await Promise.allSettled([t]),e);var zle=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let b=Hce(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=kle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=$le({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),I=[],N=Ule({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),O=WHe(m,t,T),$=YHe(h,T);try{return await Promise.race([Promise.all([{},Yce(b),Promise.all(v),x,N,Eae(t,d),...O,...$]),g,KHe(t,_),...mae(t,o,f,_),...Dse({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...pae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(z){return f.terminationReason??="other",Promise.all([{error:z},b,Promise.all(v.map(E=>_z(E))),_z(x),Fle(N,I),Promise.allSettled(O),Promise.allSettled($)])}},WHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:GS(n,i,r)),YHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Co(o,{checkOpen:!1})&&!xo(o)).map(({type:i,value:o,stream:s=o})=>GS(s,n,e,{isSameDirection:ji.has(i),stopOnExit:i==="native"}))),KHe=async(t,{signal:e})=>{let[r]=await HHe(t,"error",{signal:e});throw r};var jle=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),HS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=gs();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},ah=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 ZHe}from"stream";import{callbackify as JHe}from"util";import{finished as Ble}from"stream/promises";var Ez=async t=>{if(t!==void 0)try{await vz(t)}catch{}},qle=async t=>{if(t!==void 0)try{await bz(t)}catch{}},vz=async t=>{await Ble(t,{cleanup:!0,readable:!1,writable:!0})},bz=async t=>{await Ble(t,{cleanup:!0,readable:!0,writable:!1})},G0=async(t,e)=>{if(await t,e)throw e},H0=(t,e,r)=>{r&&!V0(r)?t.destroy(r):e&&t.destroy()};var Vle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||di.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Tz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=wz(a,s),{read:f,onStdoutDataDone:p}=xz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new ZHe({read:f,destroy:JHe(Rz.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Az({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Tz=(t,e,r)=>{let n=Qp(t,e),i=HS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},wz=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:gz},xz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=gs(),s=q0({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){XHe(this,s,o)},onStdoutDataDone:o}},XHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Az=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await bz(t),await n,await Ez(i),await e,r.readable&&r.push(null)}catch(o){await Ez(i),Gle(r,o)}},Rz=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ah(r,e)&&(Gle(t,n),await G0(e,n))},Gle=(t,e)=>{H0(t,t.readable,e)};import{Writable as QHe}from"stream";import{callbackify as Hle}from"util";var Wle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Cz(t,r,e),s=new QHe({...Pz(n,t,i),destroy:Hle(Oz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Iz(n,s),s},Cz=(t,e,r)=>{let n=a0(t,e),i=HS(r,n,"writableFinal"),o=HS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Pz=(t,e,r)=>({write:e6e.bind(void 0,t),final:Hle(t6e.bind(void 0,t,e,r))}),e6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},t6e=async(t,e,r)=>{await ah(r,e)&&(t.writable&&t.end(),await e)},Iz=async(t,e,r)=>{try{await vz(t),e.writable&&e.end()}catch(n){await qle(r),Yle(e,n)}},Oz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ah(r,e),await ah(n,e)&&(Yle(t,i),await G0(e,i))},Yle=(t,e)=>{H0(t,t.writable,e)};import{Duplex as r6e}from"stream";import{callbackify as n6e}from"util";var Kle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||di.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Tz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Cz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=wz(c,a),{read:g,onStdoutDataDone:_}=xz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new r6e({read:g,...Pz(u,t,d),destroy:n6e(i6e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return Az({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),Iz(u,b,c),b},i6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([Rz({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Oz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Nz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||di.has(e),s=Qp(t,r),a=q0({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return o6e(a,s,t)},o6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Zle=(t,{encoding:e})=>{let r=jle();t.readable=Vle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Wle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Kle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Nz.bind(void 0,t,e),t[Symbol.asyncIterator]=Nz.bind(void 0,t,e,{})};var Jle=(t,e)=>{for(let[r,n]of a6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},s6e=(async()=>{})().constructor.prototype,a6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(s6e,t)]);var Xle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=u6e(t,e,r),{subprocess:f,promise:p}=f6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=B0.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Jle(f,p),_s.set(f,{options:u,fileDescriptors:d}),f},u6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=XR(t,e,r),{file:a,commandArguments:c,options:l}=y0(t,e,r),u=d6e(l),d=lle(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},d6e=({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}},f6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=l6e(...S0(t,e,r))}catch(h){return ole({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;c6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];yle(c,a,l),Ele(c,r,l);let d={},f=gs();c.kill=Mse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Mle(c,r),Zle(c,r),rle(c,r);let p=p6e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},p6e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await zle({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((v,x)=>Ca(v,e,x)),b=Ca(m,e,"all"),T=h6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return ih(T,n,e)},h6e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?zS({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ys,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):R0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var W0=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,m6e(n,t[n],i)]));return{...t,...r}},m6e=(t,e,r)=>g6e.has(t)&&ir(e)&&ir(r)?{...e,...r}:r,g6e=new Set(["env",...cF]);var Jc=(t,e,r,n)=>{let i=(s,a,c)=>Jc(s,a,r,c),o=(...s)=>_6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},_6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(ir(o))return i(t,W0(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=y6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Zce(a,c,l):Xle(a,c,l,i)},y6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=loe(e)?uoe(e,r):[e,...r],[s,a,c]=jR(...o),l=W0(W0(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var Qle=({file:t,commandArguments:e})=>tue(t,e),eue=({file:t,commandArguments:e})=>({...tue(t,e),isSync:!0}),tue=(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]=S6e(t);return{file:r,commandArguments:n}},S6e=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(E6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},E6e=/ +/g;var rue=(t,e,r)=>{t.sync=e(v6e,r),t.s=t.sync},nue=({options:t})=>iue(t),v6e=({options:t})=>({...iue(t),isSync:!0}),iue=t=>({options:{...b6e(t),...t}}),b6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},oue={preferLocal:!0};var sue=Jc(()=>({})),Fzt=Jc(()=>({isSync:!0})),aue=Jc(Qle),zzt=Jc(eue),jzt=Jc(_ae),Bzt=Jc(nue,{},oue,rue),{sendMessage:qzt,getOneMessage:Vzt,getEachMessage:Gzt,getCancelSignal:Hzt}=nle();var cue=!1,lue=()=>{cue=!0},Es=()=>cue;var WS=null,uue=t=>(WS&&WS.destroy(),WS=new Po({totalAllowedTime:t}),WS),due=()=>WS;var Po=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Es())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await NR({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{re.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var fue={name:"@netlify/agent-runner-cli",type:"module",version:"1.168.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var A6e=w6e(import.meta.url),R6e=Pa.dirname(A6e),C6e=x6e(import.meta.url),ch=ce("shell"),kz=new Set,pue={preferLocal:!0},Vr=(t,e,r)=>{let[n,i]=P6e(e,r),o={...pue,...i},s=sue(t,n,o);mue(s,o),yue(s);let a=r?.idleTimeout;return a&&a>0&&_ue(s,a),s},hue=(t,e)=>{let r={...pue,...e},n=aue(t,r);return mue(n,r),yue(n),e?.idleTimeout&&e.idleTimeout>0&&_ue(n,e.idleTimeout),n},P6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},mue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||vs.env.NETLIFY_LOCAL_QUIET==="true")return;if(vs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new bS).pipe(vs.stdout),t.stderr?.pipe(new bS).pipe(vs.stderr);return}t.stdout?.pipe(vs.stdout),t.stderr?.pipe(vs.stderr)},Mz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vs.kill(-t.pid,e),ch.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return ch.error("Error killing process:",r),!1}},gue=t=>Mz(t,"SIGKILL"),_ue=(t,e)=>{let r=null,n=()=>{ch.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Mz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ch.log(`Force killing idle process ${t.pid}`),gue(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)},yue=t=>{kz.add(t);let e=due();if(e){let r=e.onTimesUp(()=>{ch.log(`Global timer expired, killing process ${t.pid}`),Mz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ch.log(`Force killing process ${t.pid} after timeout`),gue(t))},5e3)});t.on("exit",()=>{kz.delete(t),r()}),t.on("error",()=>{kz.delete(t),r()})}};function bs(t,e){if(!vs.env.NETLIFY_LOCAL_MODE)try{let i=C6e.resolve(fue.name),o=Pa.dirname(i);for(;o!==Pa.dirname(o);){let s=Pa.dirname(o);if(Pa.basename(s)==="node_modules"){let a=Pa.join(s,".bin",e);if(Y0.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(vs.env.NODE_PATH){let i=Pa.join(vs.env.NODE_PATH,".bin",e);if(Y0.existsSync(i))return i}let r=Pa.join(t,"node_modules",".bin",e);if(Y0.existsSync(r))return r;let n=Pa.join(R6e,"..","node_modules",".bin",e);if(Y0.existsSync(n))return n}var I6e=ce("utils"),O6e=t=>new Promise(e=>{setTimeout(e,t)});var $z=t=>{try{return new URL(t).hostname||null}catch{return null}},K0=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await O6e(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Xc=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Sue=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):I6e.error("Could not parse JSON",n))}},N6e=t=>t.charAt(0).toUpperCase()+t.slice(1),Ts=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():N6e(e)).join(" ");function Ia(t,e){e&&t.log(`Skill invoked: ${e}`)}var Z0=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Eue=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var Dz=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},k6e=1e4,Lz=(t,e=k6e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{createHash as M6e}from"crypto";import{createReadStream as $6e}from"fs";import J0 from"fs/promises";import xue from"os";import X0 from"path";var vue=ce("repo"),Aue="runner-diffs-",Rue=t=>`${Aue}${t}-`,Cue=async t=>{let e=xue.tmpdir(),r;try{r=await J0.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Aue)&&!n.startsWith(Rue(t))).map(n=>J0.rm(X0.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Vn=(t,e={})=>Vr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Q0=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{vue.info("Getting runner diffs");let n=await L6e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=F6e(o);await z6e(h,r)}vue.info("Changes after processing"),await Fz(r);let s=await jz(o,r);if(await Uz(s,r),i=await U6e(r),!i)return{hasChanges:!1,ignored:s};await Vn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await J0.mkdtemp(X0.join(xue.tmpdir(),Rue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=X0.join(a,g);await Vn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:v}=await J0.stat(b);return{path:b,size:v}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await wue(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await Tue(d,h)||(f=h)}await wue(r),re.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Tue(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},bue=async t=>{let e=M6e("sha256");for await(let r of $6e(t))e.update(r);return e.digest("hex")},Tue=async(t,e)=>t.size===e.size&&await bue(t.path)===await bue(e.path),wue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Vn(["reset","--soft","HEAD~1"],{cwd:t})},Uz=async(t=[],e=process.cwd())=>{await Vn(["add",".",...t],{cwd:e})},Fz=async(t=process.cwd())=>{let e=await Vn(["status","-s"],{cwd:t});return String(e.stdout??"")},Pue=/.. (.+)?\.log$/,D6e=[Pue],L6e=async(t=process.cwd())=>{let e=await Fz(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
142
+ if (condition) { yield value; }`)};import{Buffer as jVe}from"buffer";import{StringDecoder as BVe}from"string_decoder";var k0=(t,e,r)=>{if(r)return;if(t)return{transform:qVe.bind(void 0,new TextEncoder)};let n=new BVe(e);return{transform:VVe.bind(void 0,n),final:GVe.bind(void 0,n)}},qVe=function*(t,e){jVe.isBuffer(e)?yield xa(e):typeof e=="string"?yield t.encode(e):yield e},VVe=function*(t,e){yield gr(e)?t.write(e):e},GVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Mce}from"util";var ZF=Mce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),M0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=WVe}=e[r];for await(let i of n(t))yield*M0(i,e,r+1)},$ce=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*HVe(r,Number(e),t)},HVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*M0(n,r,e+1)},Dce=Mce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),WVe=function*(t){yield t};var JF=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Lce=(t,e)=>[...e.flatMap(r=>[...id(r,t,0)]),...jS(t)],id=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=KVe}=e[r];for(let i of n(t))yield*id(i,e,r+1)},jS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*YVe(r,Number(e),t)},YVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*id(n,r,e+1)},KVe=function*(t){yield t};var XF=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Fce(t,s,o),l=nd(e),u=nd(r),d=l?ZF.bind(void 0,M0,a):JF.bind(void 0,id),f=l||u?ZF.bind(void 0,$ce,a):JF.bind(void 0,jS),p=l||u?Dce.bind(void 0,a):void 0;return{stream:new ZVe({writableObjectMode:n,writableHighWaterMark:Uce(n),readableObjectMode:i,readableHighWaterMark:Uce(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},$0=(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=Fce(s,r,a);t=Lce(c,t)}return t},Fce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Oce(n,a)},k0(r,s,n),N0(r,o,n,c),{transform:t,final:e},{transform:Nce(i,a)},Ice({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var zce=(t,e)=>{for(let r of JVe(t))XVe(t,r,e)},JVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),XVe=(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 ${Zc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>QVe(a,n));r.input=OS(s)},QVe=(t,e)=>{let r=$0(t,e,"utf8",!0);return eGe(r),OS(r)},eGe=t=>{let e=t.find(r=>typeof r!="string"&&!gr(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 iGe,appendFileSync as oGe}from"fs";var D0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Yp(r,n)&&!di.has(e)&&tGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&rGe.has(o))||t.every(({type:i})=>ji.has(i))),tGe=t=>t===1||t===2,rGe=new Set(["pipe","overlapped"]),jce=async(t,e,r,n)=>{for await(let i of t)nGe(e)||qce(i,r,n)},Bce=(t,e,r)=>{for(let n of t)qce(n,e,r)},nGe=t=>t._readableState.pipes.length>0,qce=(t,e,r)=>{let n=ZR(t);ms({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Vce=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>sGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},sGe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Gae(t,o,d),p=xa(f),{stdioItems:h,objectMode:m}=e[r],g=aGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=cGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});lGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?b:void 0;try{return n.error===void 0&&uGe(_,h,i),T}catch(v){return n.error=v,T}},aGe=(t,e,r,n)=>{try{return $0(t,e,r,!1)}catch(i){return n.error=i,t}},cGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:OS(t)};let s=ooe(t,r);return n[o]?{serializedResult:s,finalResult:KF(s,!i[o],e)}:{serializedResult:s}},lGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!D0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=KF(t,!1,s);try{Bce(a,e,n)}catch(c){r.error??=c}},uGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>I0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?oGe(n,t):(r.add(o),iGe(n,t))}};var Gce=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ca(e,r,"all")]:Array.isArray(e)?[Ca(t,r,"all"),...e]:gr(t)&&gr(e)?iF([t,e]):`${t}${e}`};import{once as QF}from"events";var Hce=async(t,e)=>{let[r,n]=await dGe(t);return e.isForcefullyTerminated??=!1,[r,n]},dGe=async t=>{let[e,r]=await Promise.allSettled([QF(t,"spawn"),QF(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Wce(t):r.value},Wce=async t=>{try{return await QF(t,"exit")}catch{return Wce(t)}},Yce=async t=>{let[e,r]=await t;if(!fGe(e,r)&&ez(e,r))throw new Ao;return[e,r]},fGe=(t,e)=>t===void 0&&e===void 0,ez=(t,e)=>t!==0||e!==null;var Kce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=pGe(t,e,r),s=o?.code==="ETIMEDOUT",a=Vae(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},pGe=(t,e,r)=>t!==void 0?t:ez(e,r)?new Ao:void 0;var Zce=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=mGe(t,e,r),d=yGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return ih(d,c,l)},mGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=XR(t,e,r),a=gGe(r),{file:c,commandArguments:l,options:u}=y0(t,e,a);_Ge(u);let d=Ace(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},gGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,_Ge=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&L0("ipcInput"),t&&L0("ipc: true"),r&&L0("detached: true"),n&&L0("cancelSignal")},L0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},yGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=SGe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Kce(c,r),{output:h,error:m=l}=Vce({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>Ca(b,r,T)),_=Ca(Gce(h,r),r,"all");return vGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},SGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{zce(o,r);let a=EGe(r);return hGe(...S0(t,e,a))}catch(a){return nh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},EGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:A0(e)}),vGe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?R0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):zS({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as c6e}from"events";import{spawn as l6e}from"child_process";import tle from"process";import{once as tz,on as bGe}from"events";var Jce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Jp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:f0(t)}),TGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),TGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{c0(e,i);let o=Kc(t,e,r),s=new AbortController;try{return await Promise.race([wGe(o,n,s),xGe(o,r,s),AGe(o,r,s)])}catch(a){throw Xp(t),a}finally{s.abort(),l0(e,i)}},wGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await tz(t,"message",{signal:r});return n}for await(let[n]of bGe(t,"message",{signal:r}))if(e(n))return n},xGe=async(t,e,{signal:r})=>{await tz(t,"disconnect",{signal:r}),Lse(e)},AGe=async(t,e,{signal:r})=>{let[n]=await tz(t,"strict:error",{signal:r});throw o0(n,e)};import{once as Qce,on as RGe}from"events";var ele=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>rz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),rz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Jp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:f0(t)}),c0(e,o);let s=Kc(t,e,r),a=new AbortController,c={};return CGe(t,s,a),PGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),IGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},CGe=async(t,e,r)=>{try{await Qce(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},PGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Qce(t,"strict:error",{signal:r.signal});n.error=o0(i,e),r.abort()}catch{}},IGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of RGe(r,"message",{signal:o.signal}))Xce(s),yield c}catch{Xce(s)}finally{o.abort(),l0(e,a),n||Xp(t),i&&await t}},Xce=({error:t})=>{if(t)throw t};var rle=(t,{ipc:e})=>{Object.assign(t,ile(t,!1,e))},nle=()=>{let t=tle,e=!0,r=tle.channel!==void 0;return{...ile(t,e,r),getCancelSignal:uae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ile=(t,e,r)=>({sendMessage:g0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Jce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ele.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as OGe}from"child_process";import{PassThrough as NGe,Readable as kGe,Writable as MGe,Duplex as $Ge}from"stream";var ole=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{HF(n);let a=new OGe;DGe(a,n),Object.assign(a,{readable:LGe,writable:UGe,duplex:FGe});let c=nh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=zGe(c,s,i);return{subprocess:a,promise:l}},DGe=(t,e)=>{let r=BS(),n=BS(),i=BS(),o=Array.from({length:e.length-3},BS),s=BS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},BS=()=>{let t=new NGe;return t.end(),t},LGe=()=>new kGe({read(){}}),UGe=()=>new MGe({write(){}}),FGe=()=>new $Ge({read(){},write(){}}),zGe=async(t,e,r)=>ih(t,e,r);import{createReadStream as sle,createWriteStream as ale}from"fs";import{Buffer as jGe}from"buffer";import{Readable as qS,Writable as BGe,Duplex as qGe}from"stream";var lle=(t,e)=>O0(VGe,t,e,!1),VS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Zc[t]}.`)},cle={fileNumber:VS,generator:XF,asyncGenerator:XF,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:qGe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},VGe={input:{...cle,fileUrl:({value:t})=>({stream:sle(t)}),filePath:({value:{file:t}})=>({stream:sle(t)}),webStream:({value:t})=>({stream:qS.fromWeb(t)}),iterable:({value:t})=>({stream:qS.from(t)}),asyncIterable:({value:t})=>({stream:qS.from(t)}),string:({value:t})=>({stream:qS.from(t)}),uint8Array:({value:t})=>({stream:qS.from(jGe.from(t))})},output:{...cle,fileUrl:({value:t})=>({stream:ale(t)}),filePath:({value:{file:t,append:e}})=>({stream:ale(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:BGe.fromWeb(t)}),iterable:VS,asyncIterable:VS,string:VS,uint8Array:VS}};import{on as GGe,once as ule}from"events";import{PassThrough as HGe,getDefaultHighWaterMark as WGe}from"stream";import{finished as ple}from"stream/promises";function od(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)iz(i);let e=t.some(({readableObjectMode:i})=>i),r=YGe(t,e),n=new nz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var YGe=(t,e)=>{if(t.length===0)return WGe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},nz=class extends HGe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(iz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=KGe(this,this.#e,this.#o);let r=XGe({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(iz(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)}},KGe=async(t,e,r)=>{U0(t,dle);let n=new AbortController;try{await Promise.race([ZGe(t,n),JGe(t,e,r,n)])}finally{n.abort(),U0(t,-dle)}},ZGe=async(t,{signal:e})=>{try{await ple(t,{signal:e,cleanup:!0})}catch(r){throw hle(t,r),r}},JGe=async(t,e,r,{signal:n})=>{for await(let[i]of GGe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},iz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},XGe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{U0(t,fle);let a=new AbortController;try{await Promise.race([QGe(o,e,a),eHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),tHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),U0(t,-fle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?oz(t):rHe(t))},QGe=async(t,e,{signal:r})=>{try{await t,r.aborted||oz(e)}catch(n){r.aborted||hle(e,n)}},eHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await ple(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;mle(s)?i.add(e):gle(t,s)}},tHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await ule(t,i,{signal:o}),!t.readable)return ule(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},rHe=t=>{t.writable&&t.end()},hle=(t,e)=>{mle(e)?oz(t):gle(t,e)},mle=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oz=t=>{(t.readable||t.writable)&&t.destroy()},gle=(t,e)=>{t.destroyed||(t.once("error",nHe),t.destroy(e))},nHe=()=>{},U0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},dle=2,fle=1;import{finished as _le}from"stream/promises";var sh=(t,e)=>{t.pipe(e),iHe(t,e),oHe(t,e)},iHe=async(t,e)=>{if(!(xo(t)||xo(e))){try{await _le(t,{cleanup:!0,readable:!0,writable:!1})}catch{}sz(e)}},sz=t=>{t.writable&&t.end()},oHe=async(t,e)=>{if(!(xo(t)||xo(e))){try{await _le(e,{cleanup:!0,readable:!1,writable:!0})}catch{}az(t)}},az=t=>{t.readable&&t.destroy()};var yle=(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})=>ji.has(c)))sHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ji.has(c)))cHe({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]:od(o);sh(s,i)}},sHe=(t,e,r,n)=>{r==="output"?sh(t.stdio[n],e):sh(e,t.stdio[n]);let i=aHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},aHe=["stdin","stdout","stderr"],cHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;lHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},lHe=(t,{signal:e})=>{xo(t)&&td(t,uHe,e)},uHe=2;import{addAbortListener as pHe}from"events";var sd=[];sd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&sd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&sd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var F0=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",cz=Symbol.for("signal-exit emitter"),lz=globalThis,dHe=Object.defineProperty.bind(Object),uz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(lz[cz])return lz[cz];dHe(lz,cz,{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}},z0=class{},fHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),dz=class extends z0{onExit(){return()=>{}}load(){}unload(){}},fz=class extends z0{#e=pz.platform==="win32"?"SIGINT":"SIGHUP";#r=new uz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of sd)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(!F0(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 sd)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,sd.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 F0(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"&&F0(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)}},pz=globalThis.process,{onExit:Sle,load:K1t,unload:Z1t}=fHe(F0(pz)?new fz(pz):new dz);var Ele=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Sle(()=>{t.kill()});pHe(n,()=>{i()})};var ble=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=JR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=hHe(r,n,i),{sourceStream:d,sourceError:f}=gHe(t,l),{options:p,fileDescriptors:h}=_s.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},hHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=mHe(t,e,...r),a=a0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},mHe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(vle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||rF(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]=jR(r,...n);return{destination:e(vle)(i,o,s),pipeOptions:s}}if(_s.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}`)},vle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),gHe=(t,e)=>{try{return{sourceStream:Qp(t,e)}}catch(r){return{sourceError:r}}};var wle=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=_He({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw hz({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},_He=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return az(t),n;if(e!==void 0)return sz(r),e},hz=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>nh({error:t,command:Tle,escapedCommand:Tle,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Tle="source.pipe(destination)";var xle=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 yHe}from"stream/promises";var Ale=(t,e,r)=>{let n=j0.has(e)?EHe(t,e):SHe(t,e);return td(t,bHe,r.signal),td(e,THe,r.signal),vHe(e),n},SHe=(t,e)=>{let r=od([t]);return sh(r,e),j0.set(e,r),r},EHe=(t,e)=>{let r=j0.get(e);return r.add(t),r},vHe=async t=>{try{await yHe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}j0.delete(t)},j0=new WeakMap,bHe=2,THe=1;import{aborted as wHe}from"util";var Rle=(t,e)=>t===void 0?[]:[xHe(t,e)],xHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await wHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw hz({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var B0=(t,...e)=>{if(ir(e[0]))return B0.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ble(t,...e),i=AHe({...n,destination:r});return i.pipe=B0.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},AHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=RHe(t,i);wle({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Ale(e,o,d);return await Promise.race([xle(u),...Rle(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},RHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as MHe}from"timers/promises";import{on as CHe}from"events";import{getDefaultHighWaterMark as PHe}from"stream";var q0=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return IHe(e,s),Ple({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},IHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},mz=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;OHe(e,s,t);let a=t.readableObjectMode&&!o;return Ple({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},OHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Ple=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=CHe(t,"data",{signal:e.signal,highWaterMark:Cle,highWatermark:Cle});return NHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},gz=PHe(!0),Cle=gz,NHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=kHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*id(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*jS(a)}},kHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[k0(t,r,!e),N0(t,i,!n,{})].filter(Boolean);var Ile=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=$He({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([DHe(t),d]);return}let f=WF(c,r),p=mz({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([LHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},$He=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!D0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=mz({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await jce(a,t,r,o)},DHe=async t=>{await MHe(),t.readableFlowing===null&&t.resume()},LHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await T0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await w0(r,{maxBuffer:o})):await rh(r,{maxBuffer:o})}catch(a){return Ole(jae({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},_z=async t=>{try{return await t}catch(e){return Ole(e)}},Ole=({bufferedData:t})=>noe(t)?new Uint8Array(t):t;import{finished as UHe}from"stream/promises";var GS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=FHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],UHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||BHe(a,e,r,n)}finally{s.abort()}},FHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&zHe(t,r,n),n},zHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{jHe(e,r),n.call(t,...i)}},jHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},BHe=(t,e,r,n)=>{if(!qHe(t,e,r,n))throw t},qHe=(t,e,r,n=!0)=>r.propagating?Nle(t)||V0(t):(r.propagating=!0,yz(r,e)===n?Nle(t):V0(t)),yz=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",V0=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Nle=t=>t?.code==="EPIPE";var kle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>Sz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Sz=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=GS(t,e,l);if(yz(l,e)){await u;return}let[d]=await Promise.all([Ile({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Mle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?od([t,e].filter(Boolean)):void 0,$le=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Sz({...VHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:GHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),VHe=({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}},GHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as HHe}from"events";var Dle=t=>Yp(t,"ipc"),Lle=(t,e)=>{let r=ZR(t);ms({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Ule=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Dle(o),a=Aa(e,"ipc"),c=Aa(r,"ipc");for await(let l of rz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Bae(t,i,c),i.push(l)),s&&Lle(l,o);return i},Fle=async(t,e)=>(await Promise.allSettled([t]),e);var zle=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let b=Hce(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=kle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=$le({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),I=[],N=Ule({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),O=WHe(m,t,T),$=YHe(h,T);try{return await Promise.race([Promise.all([{},Yce(b),Promise.all(v),x,N,Eae(t,d),...O,...$]),g,KHe(t,_),...mae(t,o,f,_),...Dse({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...pae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(z){return f.terminationReason??="other",Promise.all([{error:z},b,Promise.all(v.map(E=>_z(E))),_z(x),Fle(N,I),Promise.allSettled(O),Promise.allSettled($)])}},WHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:GS(n,i,r)),YHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Co(o,{checkOpen:!1})&&!xo(o)).map(({type:i,value:o,stream:s=o})=>GS(s,n,e,{isSameDirection:ji.has(i),stopOnExit:i==="native"}))),KHe=async(t,{signal:e})=>{let[r]=await HHe(t,"error",{signal:e});throw r};var jle=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),HS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=gs();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},ah=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 ZHe}from"stream";import{callbackify as JHe}from"util";import{finished as Ble}from"stream/promises";var Ez=async t=>{if(t!==void 0)try{await vz(t)}catch{}},qle=async t=>{if(t!==void 0)try{await bz(t)}catch{}},vz=async t=>{await Ble(t,{cleanup:!0,readable:!1,writable:!0})},bz=async t=>{await Ble(t,{cleanup:!0,readable:!0,writable:!1})},G0=async(t,e)=>{if(await t,e)throw e},H0=(t,e,r)=>{r&&!V0(r)?t.destroy(r):e&&t.destroy()};var Vle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||di.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Tz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=wz(a,s),{read:f,onStdoutDataDone:p}=xz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new ZHe({read:f,destroy:JHe(Rz.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Az({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Tz=(t,e,r)=>{let n=Qp(t,e),i=HS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},wz=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:gz},xz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=gs(),s=q0({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){XHe(this,s,o)},onStdoutDataDone:o}},XHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Az=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await bz(t),await n,await Ez(i),await e,r.readable&&r.push(null)}catch(o){await Ez(i),Gle(r,o)}},Rz=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ah(r,e)&&(Gle(t,n),await G0(e,n))},Gle=(t,e)=>{H0(t,t.readable,e)};import{Writable as QHe}from"stream";import{callbackify as Hle}from"util";var Wle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Cz(t,r,e),s=new QHe({...Pz(n,t,i),destroy:Hle(Oz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Iz(n,s),s},Cz=(t,e,r)=>{let n=a0(t,e),i=HS(r,n,"writableFinal"),o=HS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Pz=(t,e,r)=>({write:e6e.bind(void 0,t),final:Hle(t6e.bind(void 0,t,e,r))}),e6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},t6e=async(t,e,r)=>{await ah(r,e)&&(t.writable&&t.end(),await e)},Iz=async(t,e,r)=>{try{await vz(t),e.writable&&e.end()}catch(n){await qle(r),Yle(e,n)}},Oz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ah(r,e),await ah(n,e)&&(Yle(t,i),await G0(e,i))},Yle=(t,e)=>{H0(t,t.writable,e)};import{Duplex as r6e}from"stream";import{callbackify as n6e}from"util";var Kle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||di.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Tz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Cz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=wz(c,a),{read:g,onStdoutDataDone:_}=xz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new r6e({read:g,...Pz(u,t,d),destroy:n6e(i6e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return Az({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),Iz(u,b,c),b},i6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([Rz({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Oz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Nz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||di.has(e),s=Qp(t,r),a=q0({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return o6e(a,s,t)},o6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Zle=(t,{encoding:e})=>{let r=jle();t.readable=Vle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Wle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Kle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Nz.bind(void 0,t,e),t[Symbol.asyncIterator]=Nz.bind(void 0,t,e,{})};var Jle=(t,e)=>{for(let[r,n]of a6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},s6e=(async()=>{})().constructor.prototype,a6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(s6e,t)]);var Xle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=u6e(t,e,r),{subprocess:f,promise:p}=f6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=B0.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Jle(f,p),_s.set(f,{options:u,fileDescriptors:d}),f},u6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=XR(t,e,r),{file:a,commandArguments:c,options:l}=y0(t,e,r),u=d6e(l),d=lle(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},d6e=({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}},f6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=l6e(...S0(t,e,r))}catch(h){return ole({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;c6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];yle(c,a,l),Ele(c,r,l);let d={},f=gs();c.kill=Mse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Mle(c,r),Zle(c,r),rle(c,r);let p=p6e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},p6e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await zle({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((v,x)=>Ca(v,e,x)),b=Ca(m,e,"all"),T=h6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return ih(T,n,e)},h6e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?zS({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ys,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):R0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var W0=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,m6e(n,t[n],i)]));return{...t,...r}},m6e=(t,e,r)=>g6e.has(t)&&ir(e)&&ir(r)?{...e,...r}:r,g6e=new Set(["env",...cF]);var Jc=(t,e,r,n)=>{let i=(s,a,c)=>Jc(s,a,r,c),o=(...s)=>_6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},_6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(ir(o))return i(t,W0(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=y6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Zce(a,c,l):Xle(a,c,l,i)},y6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=loe(e)?uoe(e,r):[e,...r],[s,a,c]=jR(...o),l=W0(W0(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var Qle=({file:t,commandArguments:e})=>tue(t,e),eue=({file:t,commandArguments:e})=>({...tue(t,e),isSync:!0}),tue=(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]=S6e(t);return{file:r,commandArguments:n}},S6e=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(E6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},E6e=/ +/g;var rue=(t,e,r)=>{t.sync=e(v6e,r),t.s=t.sync},nue=({options:t})=>iue(t),v6e=({options:t})=>({...iue(t),isSync:!0}),iue=t=>({options:{...b6e(t),...t}}),b6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},oue={preferLocal:!0};var sue=Jc(()=>({})),Fzt=Jc(()=>({isSync:!0})),aue=Jc(Qle),zzt=Jc(eue),jzt=Jc(_ae),Bzt=Jc(nue,{},oue,rue),{sendMessage:qzt,getOneMessage:Vzt,getEachMessage:Gzt,getCancelSignal:Hzt}=nle();var cue=!1,lue=()=>{cue=!0},Es=()=>cue;var WS=null,uue=t=>(WS&&WS.destroy(),WS=new Po({totalAllowedTime:t}),WS),due=()=>WS;var Po=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Es())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await NR({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{re.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var fue={name:"@netlify/agent-runner-cli",type:"module",version:"1.168.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",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var A6e=w6e(import.meta.url),R6e=Pa.dirname(A6e),C6e=x6e(import.meta.url),ch=ce("shell"),kz=new Set,pue={preferLocal:!0},Vr=(t,e,r)=>{let[n,i]=P6e(e,r),o={...pue,...i},s=sue(t,n,o);mue(s,o),yue(s);let a=r?.idleTimeout;return a&&a>0&&_ue(s,a),s},hue=(t,e)=>{let r={...pue,...e},n=aue(t,r);return mue(n,r),yue(n),e?.idleTimeout&&e.idleTimeout>0&&_ue(n,e.idleTimeout),n},P6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},mue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||vs.env.NETLIFY_LOCAL_QUIET==="true")return;if(vs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new bS).pipe(vs.stdout),t.stderr?.pipe(new bS).pipe(vs.stderr);return}t.stdout?.pipe(vs.stdout),t.stderr?.pipe(vs.stderr)},Mz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vs.kill(-t.pid,e),ch.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return ch.error("Error killing process:",r),!1}},gue=t=>Mz(t,"SIGKILL"),_ue=(t,e)=>{let r=null,n=()=>{ch.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Mz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ch.log(`Force killing idle process ${t.pid}`),gue(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)},yue=t=>{kz.add(t);let e=due();if(e){let r=e.onTimesUp(()=>{ch.log(`Global timer expired, killing process ${t.pid}`),Mz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ch.log(`Force killing process ${t.pid} after timeout`),gue(t))},5e3)});t.on("exit",()=>{kz.delete(t),r()}),t.on("error",()=>{kz.delete(t),r()})}};function bs(t,e){if(!vs.env.NETLIFY_LOCAL_MODE)try{let i=C6e.resolve(fue.name),o=Pa.dirname(i);for(;o!==Pa.dirname(o);){let s=Pa.dirname(o);if(Pa.basename(s)==="node_modules"){let a=Pa.join(s,".bin",e);if(Y0.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(vs.env.NODE_PATH){let i=Pa.join(vs.env.NODE_PATH,".bin",e);if(Y0.existsSync(i))return i}let r=Pa.join(t,"node_modules",".bin",e);if(Y0.existsSync(r))return r;let n=Pa.join(R6e,"..","node_modules",".bin",e);if(Y0.existsSync(n))return n}var I6e=ce("utils"),O6e=t=>new Promise(e=>{setTimeout(e,t)});var $z=t=>{try{return new URL(t).hostname||null}catch{return null}},K0=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await O6e(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Xc=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Sue=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):I6e.error("Could not parse JSON",n))}},N6e=t=>t.charAt(0).toUpperCase()+t.slice(1),Ts=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():N6e(e)).join(" ");function Ia(t,e){e&&t.log(`Skill invoked: ${e}`)}var Z0=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Eue=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var Dz=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},k6e=1e4,Lz=(t,e=k6e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{createHash as M6e}from"crypto";import{createReadStream as $6e}from"fs";import J0 from"fs/promises";import xue from"os";import X0 from"path";var vue=ce("repo"),Aue="runner-diffs-",Rue=t=>`${Aue}${t}-`,Cue=async t=>{let e=xue.tmpdir(),r;try{r=await J0.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Aue)&&!n.startsWith(Rue(t))).map(n=>J0.rm(X0.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Vn=(t,e={})=>Vr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Q0=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{vue.info("Getting runner diffs");let n=await L6e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=F6e(o);await z6e(h,r)}vue.info("Changes after processing"),await Fz(r);let s=await jz(o,r);if(await Uz(s,r),i=await U6e(r),!i)return{hasChanges:!1,ignored:s};await Vn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await J0.mkdtemp(X0.join(xue.tmpdir(),Rue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=X0.join(a,g);await Vn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:v}=await J0.stat(b);return{path:b,size:v}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await wue(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await Tue(d,h)||(f=h)}await wue(r),re.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Tue(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},bue=async t=>{let e=M6e("sha256");for await(let r of $6e(t))e.update(r);return e.digest("hex")},Tue=async(t,e)=>t.size===e.size&&await bue(t.path)===await bue(e.path),wue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Vn(["reset","--soft","HEAD~1"],{cwd:t})},Uz=async(t=[],e=process.cwd())=>{await Vn(["add",".",...t],{cwd:e})},Fz=async(t=process.cwd())=>{let e=await Vn(["status","-s"],{cwd:t});return String(e.stdout??"")},Pue=/.. (.+)?\.log$/,D6e=[Pue],L6e=async(t=process.cwd())=>{let e=await Fz(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
143
143
  `).filter(i=>D6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},U6e=async(t=process.cwd())=>{try{return await Vn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},zz=async(t=process.cwd())=>{let{stdout:e}=await Vn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Iue=async(t=process.cwd())=>{let{stdout:e}=await Vn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},jz=async(t,e=process.cwd())=>{t||=await Fz(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
144
144
  `).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${X0.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Pue)?.[1];o&&n.push(`:!${o}.log`)}),n},Oue=async(t=process.cwd())=>{await Vn(["reset","--hard","HEAD"],{cwd:t})},Nue=async(t=process.cwd())=>{let e=await Vn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
145
145
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},F6e=t=>{let e=t.split(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/agent-runner-cli",
3
3
  "type": "module",
4
- "version": "1.168.0",
4
+ "version": "1.168.1",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",