@netlify/agent-runner-cli 1.149.0-git.0 → 1.149.0-git.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +1 -1
- package/dist/bin.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -99,7 +99,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
99
99
|
`,LF:`
|
|
100
100
|
`,concatBytes:mL},zDe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},GDe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:zDe};import{Buffer as VDe}from"buffer";var Rte=(t,e)=>t?void 0:qDe.bind(void 0,e),qDe=function*(t,e){if(typeof e!="string"&&!jt(e)&&!VDe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Ite=(t,e)=>t?HDe.bind(void 0,e):WDe.bind(void 0,e),HDe=function*(t,e){Cte(t,e),yield e},WDe=function*(t,e){if(Cte(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Cte=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
101
101
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
102
|
-
if (condition) { yield value; }`)};import{Buffer as YDe}from"buffer";import{StringDecoder as KDe}from"string_decoder";var rx=(t,e,r)=>{if(r)return;if(t)return{transform:ZDe.bind(void 0,new TextEncoder)};let n=new KDe(e);return{transform:JDe.bind(void 0,n),final:XDe.bind(void 0,n)}},ZDe=function*(t,e){YDe.isBuffer(e)?yield hs(e):typeof e=="string"?yield t.encode(e):yield e},JDe=function*(t,e){yield jt(e)?t.write(e):e},XDe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Pte}from"util";var _L=Pte(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),nx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=eLe}=e[r];for await(let i of n(t))yield*nx(i,e,r+1)},Ote=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*QDe(r,Number(e),t)},QDe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*nx(n,r,e+1)},Nte=Pte(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),eLe=function*(t){yield t};var yL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},kte=(t,e)=>[...e.flatMap(r=>[...wl(r,t,0)]),...T_(t)],wl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=rLe}=e[r];for(let i of n(t))yield*wl(i,e,r+1)},T_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*tLe(r,Number(e),t)},tLe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*wl(n,r,e+1)},rLe=function*(t){yield t};var SL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Dte(t,s,o),l=xl(e),u=xl(r),d=l?_L.bind(void 0,nx,a):yL.bind(void 0,wl),f=l||u?_L.bind(void 0,Ote,a):yL.bind(void 0,T_),p=l||u?Nte.bind(void 0,a):void 0;return{stream:new nLe({writableObjectMode:n,writableHighWaterMark:Mte(n),readableObjectMode:i,readableHighWaterMark:Mte(i),transform(m,v,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},ix=(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=Dte(s,r,a);t=kte(c,t)}return t},Dte=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Rte(n,a)},rx(r,s,n),tx(r,o,n,c),{transform:t,final:e},{transform:Ite(i,a)},wte({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Lte=(t,e)=>{for(let r of iLe(t))oLe(t,r,e)},iLe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),oLe=(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 ${Oa[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>sLe(a,n));r.input=f_(s)},sLe=(t,e)=>{let r=ix(t,e,"utf8",!0);return aLe(r),f_(r)},aLe=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 dLe,appendFileSync as fLe}from"fs";var ox=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&ef(r,n)&&!gn.has(e)&&cLe(n)&&(t.some(({type:i,value:o})=>i==="native"&&lLe.has(o))||t.every(({type:i})=>Yn.has(i))),cLe=t=>t===1||t===2,lLe=new Set(["pipe","overlapped"]),$te=async(t,e,r,n)=>{for await(let i of t)uLe(e)||Fte(i,r,n)},Ute=(t,e,r)=>{for(let n of t)Fte(n,e,r)},uLe=t=>t._readableState.pipes.length>0,Fte=(t,e,r)=>{let n=SA(t);fo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Bte=({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)=>pLe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},pLe=({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=jee(t,o,d),p=hs(f),{stdioItems:h,objectMode:m}=e[r],v=hLe([p],h,c,n),{serializedResult:S,finalResult:A=S}=mLe({chunks:v,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});gLe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let b=a[r]?A:void 0;try{return n.error===void 0&&_Le(S,h,i),b}catch(_){return n.error=_,b}},hLe=(t,e,r,n)=>{try{return ix(t,e,r,!1)}catch(i){return n.error=i,t}},mLe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:f_(t)};let s=tQ(t,r);return n[o]?{serializedResult:s,finalResult:gL(s,!i[o],e)}:{serializedResult:s}},gLe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!ox({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=gL(t,!1,s);try{Ute(a,e,n)}catch(c){r.error??=c}},_Le=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>QA.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?fLe(n,t):(r.add(o),dLe(n,t))}};var jte=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,_s(e,r,"all")]:Array.isArray(e)?[_s(t,r,"all"),...e]:jt(t)&&jt(e)?xD([t,e]):`${t}${e}`};import{once as EL}from"events";var zte=async(t,e)=>{let[r,n]=await yLe(t);return e.isForcefullyTerminated??=!1,[r,n]},yLe=async t=>{let[e,r]=await Promise.allSettled([EL(t,"spawn"),EL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Gte(t):r.value},Gte=async t=>{try{return await EL(t,"exit")}catch{return Gte(t)}},Vte=async t=>{let[e,r]=await t;if(!SLe(e,r)&&vL(e,r))throw new Ri;return[e,r]},SLe=(t,e)=>t===void 0&&e===void 0,vL=(t,e)=>t!==0||e!==null;var qte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=ELe(t,e,r),s=o?.code==="ETIMEDOUT",a=Bee(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},ELe=(t,e,r)=>t!==void 0?t:vL(e,r)?new Ri:void 0;var Hte=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=TLe(t,e,r),d=xLe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return df(d,c,l)},TLe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=vA(t,e,r),a=bLe(r),{file:c,commandArguments:l,options:u}=jA(t,e,a);ALe(u);let d=Tte(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},bLe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ALe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&sx("ipcInput"),t&&sx("ipc: true"),r&&sx("detached: true"),n&&sx("cancelSignal")},sx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},xLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=wLe({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}=qte(c,r),{output:h,error:m=l}=Bte({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),v=h.map((A,b)=>_s(A,r,b)),S=_s(jte(h,r),r,"all");return ILe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:v,all:S,options:r,command:n,escapedCommand:i,startTime:a})},wLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Lte(o,r);let a=RLe(r);return vLe(...zA(t,e,a))}catch(a){return uf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},RLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:KA(e)}),ILe=({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?ZA({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):v_({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 m1e}from"events";import{spawn as g1e}from"child_process";import Jte from"process";import{once as TL,on as CLe}from"events";var Wte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(nf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:DA(t)}),PLe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),PLe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{OA(e,i);let o=Pa(t,e,r),s=new AbortController;try{return await Promise.race([OLe(o,n,s),NLe(o,r,s),kLe(o,r,s)])}catch(a){throw of(t),a}finally{s.abort(),NA(e,i)}},OLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await TL(t,"message",{signal:r});return n}for await(let[n]of CLe(t,"message",{signal:r}))if(e(n))return n},NLe=async(t,e,{signal:r})=>{await TL(t,"disconnect",{signal:r}),k7(e)},kLe=async(t,e,{signal:r})=>{let[n]=await TL(t,"strict:error",{signal:r});throw IA(n,e)};import{once as Kte,on as MLe}from"events";var Zte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>bL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),bL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{nf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:DA(t)}),OA(e,o);let s=Pa(t,e,r),a=new AbortController,c={};return DLe(t,s,a),LLe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),$Le({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},DLe=async(t,e,r)=>{try{await Kte(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},LLe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Kte(t,"strict:error",{signal:r.signal});n.error=IA(i,e),r.abort()}catch{}},$Le=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of MLe(r,"message",{signal:o.signal}))Yte(s),yield c}catch{Yte(s)}finally{o.abort(),NA(e,a),n||of(t),i&&await t}},Yte=({error:t})=>{if(t)throw t};var Xte=(t,{ipc:e})=>{Object.assign(t,ere(t,!1,e))},Qte=()=>{let t=Jte,e=!0,r=Jte.channel!==void 0;return{...ere(t,e,r),getCancelSignal:see.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ere=(t,e,r)=>({sendMessage:FA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Wte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Zte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as ULe}from"child_process";import{PassThrough as FLe,Readable as BLe,Writable as jLe,Duplex as zLe}from"stream";var tre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{pL(n);let a=new ULe;GLe(a,n),Object.assign(a,{readable:VLe,writable:qLe,duplex:HLe});let c=uf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=WLe(c,s,i);return{subprocess:a,promise:l}},GLe=(t,e)=>{let r=b_(),n=b_(),i=b_(),o=Array.from({length:e.length-3},b_),s=b_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},b_=()=>{let t=new FLe;return t.end(),t},VLe=()=>new BLe({read(){}}),qLe=()=>new jLe({write(){}}),HLe=()=>new zLe({read(){},write(){}}),WLe=async(t,e,r)=>df(t,e,r);import{createReadStream as rre,createWriteStream as nre}from"fs";import{Buffer as YLe}from"buffer";import{Readable as A_,Writable as KLe,Duplex as ZLe}from"stream";var ore=(t,e)=>ex(JLe,t,e,!1),x_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Oa[t]}.`)},ire={fileNumber:x_,generator:SL,asyncGenerator:SL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ZLe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},JLe={input:{...ire,fileUrl:({value:t})=>({stream:rre(t)}),filePath:({value:{file:t}})=>({stream:rre(t)}),webStream:({value:t})=>({stream:A_.fromWeb(t)}),iterable:({value:t})=>({stream:A_.from(t)}),asyncIterable:({value:t})=>({stream:A_.from(t)}),string:({value:t})=>({stream:A_.from(t)}),uint8Array:({value:t})=>({stream:A_.from(YLe.from(t))})},output:{...ire,fileUrl:({value:t})=>({stream:nre(t)}),filePath:({value:{file:t,append:e}})=>({stream:nre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:KLe.fromWeb(t)}),iterable:x_,asyncIterable:x_,string:x_,uint8Array:x_}};import{on as XLe,once as sre}from"events";import{PassThrough as QLe,getDefaultHighWaterMark as e$e}from"stream";import{finished as lre}from"stream/promises";function Rl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)xL(i);let e=t.some(({readableObjectMode:i})=>i),r=t$e(t,e),n=new AL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var t$e=(t,e)=>{if(t.length===0)return e$e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AL=class extends QLe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(xL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=r$e(this,this.#e,this.#o);let r=o$e({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(xL(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)}},r$e=async(t,e,r)=>{ax(t,are);let n=new AbortController;try{await Promise.race([n$e(t,n),i$e(t,e,r,n)])}finally{n.abort(),ax(t,-are)}},n$e=async(t,{signal:e})=>{try{await lre(t,{signal:e,cleanup:!0})}catch(r){throw ure(t,r),r}},i$e=async(t,e,r,{signal:n})=>{for await(let[i]of XLe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},xL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},o$e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{ax(t,cre);let a=new AbortController;try{await Promise.race([s$e(o,e,a),a$e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),c$e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),ax(t,-cre)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?wL(t):l$e(t))},s$e=async(t,e,{signal:r})=>{try{await t,r.aborted||wL(e)}catch(n){r.aborted||ure(e,n)}},a$e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await lre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;dre(s)?i.add(e):fre(t,s)}},c$e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await sre(t,i,{signal:o}),!t.readable)return sre(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},l$e=t=>{t.writable&&t.end()},ure=(t,e)=>{dre(e)?wL(t):fre(t,e)},dre=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",wL=t=>{(t.readable||t.writable)&&t.destroy()},fre=(t,e)=>{t.destroyed||(t.once("error",u$e),t.destroy(e))},u$e=()=>{},ax=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},are=2,cre=1;import{finished as pre}from"stream/promises";var pf=(t,e)=>{t.pipe(e),d$e(t,e),f$e(t,e)},d$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await pre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}RL(e)}},RL=t=>{t.writable&&t.end()},f$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await pre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}IL(t)}},IL=t=>{t.readable&&t.destroy()};var hre=(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})=>Yn.has(c)))p$e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))m$e({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]:Rl(o);pf(s,i)}},p$e=(t,e,r,n)=>{r==="output"?pf(t.stdio[n],e):pf(e,t.stdio[n]);let i=h$e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},h$e=["stdin","stdout","stderr"],m$e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;g$e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},g$e=(t,{signal:e})=>{wi(t)&&bl(t,_$e,e)},_$e=2;import{addAbortListener as E$e}from"events";var Il=[];Il.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Il.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Il.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var cx=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",CL=Symbol.for("signal-exit emitter"),PL=globalThis,y$e=Object.defineProperty.bind(Object),OL=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(PL[CL])return PL[CL];y$e(PL,CL,{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}},lx=class{},S$e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),NL=class extends lx{onExit(){return()=>{}}load(){}unload(){}},kL=class extends lx{#e=ML.platform==="win32"?"SIGINT":"SIGHUP";#r=new OL;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Il)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(!cx(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 Il)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,Il.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 cx(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"&&cx(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)}},ML=globalThis.process,{onExit:mre,load:xyt,unload:wyt}=S$e(cx(ML)?new kL(ML):new NL);var gre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=mre(()=>{t.kill()});E$e(n,()=>{i()})};var yre=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=EA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=v$e(r,n,i),{sourceStream:d,sourceError:f}=b$e(t,l),{options:p,fileDescriptors:h}=ho.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},v$e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=T$e(t,e,...r),a=PA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},T$e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(_re,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||bD(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]=uA(r,...n);return{destination:e(_re)(i,o,s),pipeOptions:s}}if(ho.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}`)},_re=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),b$e=(t,e)=>{try{return{sourceStream:sf(t,e)}}catch(r){return{sourceError:r}}};var Ere=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=A$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw DL({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},A$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return IL(t),n;if(e!==void 0)return RL(r),e},DL=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>uf({error:t,command:Sre,escapedCommand:Sre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Sre="source.pipe(destination)";var vre=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 x$e}from"stream/promises";var Tre=(t,e,r)=>{let n=ux.has(e)?R$e(t,e):w$e(t,e);return bl(t,C$e,r.signal),bl(e,P$e,r.signal),I$e(e),n},w$e=(t,e)=>{let r=Rl([t]);return pf(r,e),ux.set(e,r),r},R$e=(t,e)=>{let r=ux.get(e);return r.add(t),r},I$e=async t=>{try{await x$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ux.delete(t)},ux=new WeakMap,C$e=2,P$e=1;import{aborted as O$e}from"util";var bre=(t,e)=>t===void 0?[]:[N$e(t,e)],N$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await O$e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw DL({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var dx=(t,...e)=>{if(Pt(e[0]))return dx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=yre(t,...e),i=k$e({...n,destination:r});return i.pipe=dx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},k$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=M$e(t,i);Ere({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Tre(e,o,d);return await Promise.race([vre(u),...bre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},M$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as j$e}from"timers/promises";import{on as D$e}from"events";import{getDefaultHighWaterMark as L$e}from"stream";var fx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return $$e(e,s),xre({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},$$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},LL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;U$e(e,s,t);let a=t.readableObjectMode&&!o;return xre({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},U$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},xre=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=D$e(t,"data",{signal:e.signal,highWaterMark:Are,highWatermark:Are});return F$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},$L=L$e(!0),Are=$L,F$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=B$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*wl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*T_(a)}},B$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[rx(t,r,!e),tx(t,i,!n,{})].filter(Boolean);var wre=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=z$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([G$e(t),d]);return}let f=hL(c,r),p=LL({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([V$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},z$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!ox({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=LL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await $te(a,t,r,o)},G$e=async t=>{await j$e(),t.readableFlowing===null&&t.resume()},V$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await HA(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await WA(r,{maxBuffer:o})):await lf(r,{maxBuffer:o})}catch(a){return Rre($ee({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},UL=async t=>{try{return await t}catch(e){return Rre(e)}},Rre=({bufferedData:t})=>QX(t)?new Uint8Array(t):t;import{finished as q$e}from"stream/promises";var w_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=H$e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],q$e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||K$e(a,e,r,n)}finally{s.abort()}},H$e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&W$e(t,r,n),n},W$e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Y$e(e,r),n.call(t,...i)}},Y$e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},K$e=(t,e,r,n)=>{if(!Z$e(t,e,r,n))throw t},Z$e=(t,e,r,n=!0)=>r.propagating?Ire(t)||px(t):(r.propagating=!0,FL(r,e)===n?Ire(t):px(t)),FL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",px=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ire=t=>t?.code==="EPIPE";var Cre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>BL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),BL=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=w_(t,e,l);if(FL(l,e)){await u;return}let[d]=await Promise.all([wre({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 Pre=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Rl([t,e].filter(Boolean)):void 0,Ore=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>BL({...J$e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:X$e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),J$e=({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}},X$e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Q$e}from"events";var Nre=t=>ef(t,"ipc"),kre=(t,e)=>{let r=SA(t);fo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Mre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Nre(o),a=ms(e,"ipc"),c=ms(r,"ipc");for await(let l of bL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Uee(t,i,c),i.push(l)),s&&kre(l,o);return i},Dre=async(t,e)=>(await Promise.allSettled([t]),e);var Lre=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:v,controller:S})=>{let A=zte(t,f),b={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:A,propagating:!1},_=Cre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),R=Ore({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),C=[],P=Mre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:C,verboseInfo:p}),I=e1e(m,t,b),k=t1e(h,b);try{return await Promise.race([Promise.all([{},Vte(A),Promise.all(_),R,P,gee(t,d),...I,...k]),v,r1e(t,S),...dee(t,o,f,S),...N7({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...lee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},A,Promise.all(_.map(y=>UL(y))),UL(R),Dre(P,C),Promise.allSettled(I),Promise.allSettled(k)])}},e1e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:w_(n,i,r)),t1e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ci(o,{checkOpen:!1})&&!wi(o)).map(({type:i,value:o,stream:s=o})=>w_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),r1e=async(t,{signal:e})=>{let[r]=await Q$e(t,"error",{signal:e});throw r};var $re=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),R_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=po();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},hf=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 n1e}from"stream";import{callbackify as i1e}from"util";import{finished as Ure}from"stream/promises";var jL=async t=>{if(t!==void 0)try{await zL(t)}catch{}},Fre=async t=>{if(t!==void 0)try{await GL(t)}catch{}},zL=async t=>{await Ure(t,{cleanup:!0,readable:!1,writable:!0})},GL=async t=>{await Ure(t,{cleanup:!0,readable:!0,writable:!1})},hx=async(t,e)=>{if(await t,e)throw e},mx=(t,e,r)=>{r&&!px(r)?t.destroy(r):e&&t.destroy()};var Bre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||gn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=VL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=qL(a,s),{read:f,onStdoutDataDone:p}=HL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new n1e({read:f,destroy:i1e(YL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return WL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},VL=(t,e,r)=>{let n=sf(t,e),i=R_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},qL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:$L},HL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=po(),s=fx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){o1e(this,s,o)},onStdoutDataDone:o}},o1e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},WL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await GL(t),await n,await jL(i),await e,r.readable&&r.push(null)}catch(o){await jL(i),jre(r,o)}},YL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await hf(r,e)&&(jre(t,n),await hx(e,n))},jre=(t,e)=>{mx(t,t.readable,e)};import{Writable as s1e}from"stream";import{callbackify as zre}from"util";var Gre=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=KL(t,r,e),s=new s1e({...ZL(n,t,i),destroy:zre(XL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return JL(n,s),s},KL=(t,e,r)=>{let n=PA(t,e),i=R_(r,n,"writableFinal"),o=R_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},ZL=(t,e,r)=>({write:a1e.bind(void 0,t),final:zre(c1e.bind(void 0,t,e,r))}),a1e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},c1e=async(t,e,r)=>{await hf(r,e)&&(t.writable&&t.end(),await e)},JL=async(t,e,r)=>{try{await zL(t),e.writable&&e.end()}catch(n){await Fre(r),Vre(e,n)}},XL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await hf(r,e),await hf(n,e)&&(Vre(t,i),await hx(e,i))},Vre=(t,e)=>{mx(t,t.writable,e)};import{Duplex as l1e}from"stream";import{callbackify as u1e}from"util";var qre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||gn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=VL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=KL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=qL(c,a),{read:v,onStdoutDataDone:S}=HL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),A=new l1e({read:v,...ZL(u,t,d),destroy:u1e(d1e.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 WL({subprocessStdout:c,onStdoutDataDone:S,readable:A,subprocess:t,subprocessStdin:u}),JL(u,A,c),A},d1e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([YL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),XL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var QL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||gn.has(e),s=sf(t,r),a=fx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return f1e(a,s,t)},f1e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Hre=(t,{encoding:e})=>{let r=$re();t.readable=Bre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Gre.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=qre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=QL.bind(void 0,t,e),t[Symbol.asyncIterator]=QL.bind(void 0,t,e,{})};var Wre=(t,e)=>{for(let[r,n]of h1e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},p1e=(async()=>{})().constructor.prototype,h1e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(p1e,t)]);var Yre=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=_1e(t,e,r),{subprocess:f,promise:p}=S1e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=dx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Wre(f,p),ho.set(f,{options:u,fileDescriptors:d}),f},_1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=vA(t,e,r),{file:a,commandArguments:c,options:l}=jA(t,e,r),u=y1e(l),d=ore(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},y1e=({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}},S1e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=g1e(...zA(t,e,r))}catch(h){return tre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;m1e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];hre(c,a,l),gre(c,r,l);let d={},f=po();c.kill=P7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Pre(c,r),Hre(c,r),Xte(c,r);let p=E1e({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}},E1e=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,v]=await Lre({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((_,R)=>_s(_,e,R)),A=_s(m,e,"all"),b=v1e({errorInfo:d,exitCode:f,signal:p,stdio:S,all:A,ipcOutput:v,context:c,options:e,command:s,escapedCommand:a,startTime:r});return df(b,n,e)},v1e=({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?v_({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 mo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):ZA({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var gx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,T1e(n,t[n],i)]));return{...t,...r}},T1e=(t,e,r)=>b1e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,b1e=new Set(["env",...CD]);var Na=(t,e,r,n)=>{let i=(s,a,c)=>Na(s,a,r,c),o=(...s)=>A1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},A1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Pt(o))return i(t,gx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=x1e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Hte(a,c,l):Yre(a,c,l,i)},x1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=oQ(e)?sQ(e,r):[e,...r],[s,a,c]=uA(...o),l=gx(gx(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 Kre=({file:t,commandArguments:e})=>Jre(t,e),Zre=({file:t,commandArguments:e})=>({...Jre(t,e),isSync:!0}),Jre=(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]=w1e(t);return{file:r,commandArguments:n}},w1e=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(R1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},R1e=/ +/g;var Xre=(t,e,r)=>{t.sync=e(I1e,r),t.s=t.sync},Qre=({options:t})=>ene(t),I1e=({options:t})=>({...ene(t),isSync:!0}),ene=t=>({options:{...C1e(t),...t}}),C1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},tne={preferLocal:!0};var rne=Na(()=>({})),mvt=Na(()=>({isSync:!0})),nne=Na(Kre),gvt=Na(Zre),_vt=Na(pee),yvt=Na(Qre,{},tne,Xre),{sendMessage:Svt,getOneMessage:Evt,getEachMessage:vvt,getCancelSignal:Tvt}=Qte();var ine=!1,one=()=>{ine=!0},_o=()=>ine;var I_=null,sne=t=>(I_&&I_.destroy(),I_=new ys({totalAllowedTime:t}),I_),ane=()=>I_;var ys=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&&_o())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 nA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{me.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 cne={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.0-git.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@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.1.5","@netlify/otel":"^6.0.4","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var k1e=O1e(import.meta.url),M1e=Ss.dirname(k1e),D1e=N1e(import.meta.url),mf=he("shell"),e$=new Set,lne={preferLocal:!0},lr=(t,e,r)=>{let[n,i]=L1e(e,r),o={...lne,...i},s=rne(t,n,o);dne(s,o),hne(s);let a=r?.idleTimeout;return a&&a>0&&pne(s,a),s},une=(t,e)=>{let r={...lne,...e},n=nne(t,r);return dne(n,r),hne(n),e?.idleTimeout&&e.idleTimeout>0&&pne(n,e.idleTimeout),n},L1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},dne=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Es.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new r_).pipe(Es.stdout),t.stderr?.pipe(new r_).pipe(Es.stderr);return}t.stdout?.pipe(Es.stdout),t.stderr?.pipe(Es.stderr)},t$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Es.kill(-t.pid,e),mf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return mf.error("Error killing process:",r),!1}},fne=t=>t$(t,"SIGKILL"),pne=(t,e)=>{let r=null,n=()=>{mf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),t$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(mf.log(`Force killing idle process ${t.pid}`),fne(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)},hne=t=>{e$.add(t);let e=ane();if(e){let r=e.onTimesUp(()=>{mf.log(`Global timer expired, killing process ${t.pid}`),t$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(mf.log(`Force killing process ${t.pid} after timeout`),fne(t))},5e3)});t.on("exit",()=>{e$.delete(t),r()}),t.on("error",()=>{e$.delete(t),r()})}};function yx(t,e){return!!Pi(t,e)}function Pi(t,e){if(!Es.env.NETLIFY_LOCAL_MODE)try{let i=D1e.resolve(cne.name),o=Ss.dirname(i);for(;o!==Ss.dirname(o);){let s=Ss.dirname(o);if(Ss.basename(s)==="node_modules"){let a=Ss.join(s,".bin",e);if(_x.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Es.env.NODE_PATH){let i=Ss.join(Es.env.NODE_PATH,".bin",e);if(_x.existsSync(i))return i}let r=Ss.join(t,"node_modules",".bin",e);if(_x.existsSync(r))return r;let n=Ss.join(M1e,"..","node_modules",".bin",e);if(_x.existsSync(n))return n}var $1e=he("utils"),U1e=t=>new Promise(e=>{setTimeout(e,t)});var Sx=(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 U1e(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},ka=(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},mne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):$1e.error("Could not parse JSON",n))}},F1e=t=>t.charAt(0).toUpperCase()+t.slice(1),yo=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():F1e(e)).join(" ");function vs(t,e){e&&t.log(`Skill invoked: ${e}`)}var Ex=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),gne=(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 r$=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}},B1e=1e4,n$=(t,e=B1e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as _ne}from"buffer";import j1e from"path";var yne=he("repo"),ur=(t,e={})=>lr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),vx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{yne.info("Getting runner diffs");let n=await G1e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=q1e(o);await H1e(m,r)}yne.info("Changes after processing"),await o$(r);let s=await s$(o,r);if(await i$(s,r),i=await V1e(r),!i)return{hasChanges:!1,ignored:s};await ur(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await ur(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Sne(r),{hasChanges:!1,ignored:s};let u=await ur(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await ur(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let v=await ur(["diff",t.sha,"HEAD","--binary"],a),S=String(v.stdout??"");f!==S&&(p=_ne.from(S).toString("base64"))}await Sne(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=_ne.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Sne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await ur(["reset","--soft","HEAD~1"],{cwd:t})},i$=async(t=[],e=process.cwd())=>{await ur(["add",".",...t],{cwd:e})},o$=async(t=process.cwd())=>{let e=await ur(["status","-s"],{cwd:t});return String(e.stdout??"")},Ene=/.. (.+)?\.log$/,z1e=[Ene],G1e=async(t=process.cwd())=>{let e=await o$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
|
+
if (condition) { yield value; }`)};import{Buffer as YDe}from"buffer";import{StringDecoder as KDe}from"string_decoder";var rx=(t,e,r)=>{if(r)return;if(t)return{transform:ZDe.bind(void 0,new TextEncoder)};let n=new KDe(e);return{transform:JDe.bind(void 0,n),final:XDe.bind(void 0,n)}},ZDe=function*(t,e){YDe.isBuffer(e)?yield hs(e):typeof e=="string"?yield t.encode(e):yield e},JDe=function*(t,e){yield jt(e)?t.write(e):e},XDe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Pte}from"util";var _L=Pte(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),nx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=eLe}=e[r];for await(let i of n(t))yield*nx(i,e,r+1)},Ote=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*QDe(r,Number(e),t)},QDe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*nx(n,r,e+1)},Nte=Pte(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),eLe=function*(t){yield t};var yL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},kte=(t,e)=>[...e.flatMap(r=>[...wl(r,t,0)]),...T_(t)],wl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=rLe}=e[r];for(let i of n(t))yield*wl(i,e,r+1)},T_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*tLe(r,Number(e),t)},tLe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*wl(n,r,e+1)},rLe=function*(t){yield t};var SL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Dte(t,s,o),l=xl(e),u=xl(r),d=l?_L.bind(void 0,nx,a):yL.bind(void 0,wl),f=l||u?_L.bind(void 0,Ote,a):yL.bind(void 0,T_),p=l||u?Nte.bind(void 0,a):void 0;return{stream:new nLe({writableObjectMode:n,writableHighWaterMark:Mte(n),readableObjectMode:i,readableHighWaterMark:Mte(i),transform(m,v,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},ix=(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=Dte(s,r,a);t=kte(c,t)}return t},Dte=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Rte(n,a)},rx(r,s,n),tx(r,o,n,c),{transform:t,final:e},{transform:Ite(i,a)},wte({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Lte=(t,e)=>{for(let r of iLe(t))oLe(t,r,e)},iLe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),oLe=(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 ${Oa[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>sLe(a,n));r.input=f_(s)},sLe=(t,e)=>{let r=ix(t,e,"utf8",!0);return aLe(r),f_(r)},aLe=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 dLe,appendFileSync as fLe}from"fs";var ox=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&ef(r,n)&&!gn.has(e)&&cLe(n)&&(t.some(({type:i,value:o})=>i==="native"&&lLe.has(o))||t.every(({type:i})=>Yn.has(i))),cLe=t=>t===1||t===2,lLe=new Set(["pipe","overlapped"]),$te=async(t,e,r,n)=>{for await(let i of t)uLe(e)||Fte(i,r,n)},Ute=(t,e,r)=>{for(let n of t)Fte(n,e,r)},uLe=t=>t._readableState.pipes.length>0,Fte=(t,e,r)=>{let n=SA(t);fo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Bte=({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)=>pLe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},pLe=({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=jee(t,o,d),p=hs(f),{stdioItems:h,objectMode:m}=e[r],v=hLe([p],h,c,n),{serializedResult:S,finalResult:A=S}=mLe({chunks:v,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});gLe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let b=a[r]?A:void 0;try{return n.error===void 0&&_Le(S,h,i),b}catch(_){return n.error=_,b}},hLe=(t,e,r,n)=>{try{return ix(t,e,r,!1)}catch(i){return n.error=i,t}},mLe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:f_(t)};let s=tQ(t,r);return n[o]?{serializedResult:s,finalResult:gL(s,!i[o],e)}:{serializedResult:s}},gLe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!ox({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=gL(t,!1,s);try{Ute(a,e,n)}catch(c){r.error??=c}},_Le=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>QA.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?fLe(n,t):(r.add(o),dLe(n,t))}};var jte=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,_s(e,r,"all")]:Array.isArray(e)?[_s(t,r,"all"),...e]:jt(t)&&jt(e)?xD([t,e]):`${t}${e}`};import{once as EL}from"events";var zte=async(t,e)=>{let[r,n]=await yLe(t);return e.isForcefullyTerminated??=!1,[r,n]},yLe=async t=>{let[e,r]=await Promise.allSettled([EL(t,"spawn"),EL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Gte(t):r.value},Gte=async t=>{try{return await EL(t,"exit")}catch{return Gte(t)}},Vte=async t=>{let[e,r]=await t;if(!SLe(e,r)&&vL(e,r))throw new Ri;return[e,r]},SLe=(t,e)=>t===void 0&&e===void 0,vL=(t,e)=>t!==0||e!==null;var qte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=ELe(t,e,r),s=o?.code==="ETIMEDOUT",a=Bee(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},ELe=(t,e,r)=>t!==void 0?t:vL(e,r)?new Ri:void 0;var Hte=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=TLe(t,e,r),d=xLe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return df(d,c,l)},TLe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=vA(t,e,r),a=bLe(r),{file:c,commandArguments:l,options:u}=jA(t,e,a);ALe(u);let d=Tte(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},bLe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ALe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&sx("ipcInput"),t&&sx("ipc: true"),r&&sx("detached: true"),n&&sx("cancelSignal")},sx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},xLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=wLe({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}=qte(c,r),{output:h,error:m=l}=Bte({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),v=h.map((A,b)=>_s(A,r,b)),S=_s(jte(h,r),r,"all");return ILe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:v,all:S,options:r,command:n,escapedCommand:i,startTime:a})},wLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Lte(o,r);let a=RLe(r);return vLe(...zA(t,e,a))}catch(a){return uf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},RLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:KA(e)}),ILe=({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?ZA({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):v_({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 m1e}from"events";import{spawn as g1e}from"child_process";import Jte from"process";import{once as TL,on as CLe}from"events";var Wte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(nf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:DA(t)}),PLe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),PLe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{OA(e,i);let o=Pa(t,e,r),s=new AbortController;try{return await Promise.race([OLe(o,n,s),NLe(o,r,s),kLe(o,r,s)])}catch(a){throw of(t),a}finally{s.abort(),NA(e,i)}},OLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await TL(t,"message",{signal:r});return n}for await(let[n]of CLe(t,"message",{signal:r}))if(e(n))return n},NLe=async(t,e,{signal:r})=>{await TL(t,"disconnect",{signal:r}),k7(e)},kLe=async(t,e,{signal:r})=>{let[n]=await TL(t,"strict:error",{signal:r});throw IA(n,e)};import{once as Kte,on as MLe}from"events";var Zte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>bL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),bL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{nf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:DA(t)}),OA(e,o);let s=Pa(t,e,r),a=new AbortController,c={};return DLe(t,s,a),LLe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),$Le({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},DLe=async(t,e,r)=>{try{await Kte(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},LLe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Kte(t,"strict:error",{signal:r.signal});n.error=IA(i,e),r.abort()}catch{}},$Le=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of MLe(r,"message",{signal:o.signal}))Yte(s),yield c}catch{Yte(s)}finally{o.abort(),NA(e,a),n||of(t),i&&await t}},Yte=({error:t})=>{if(t)throw t};var Xte=(t,{ipc:e})=>{Object.assign(t,ere(t,!1,e))},Qte=()=>{let t=Jte,e=!0,r=Jte.channel!==void 0;return{...ere(t,e,r),getCancelSignal:see.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ere=(t,e,r)=>({sendMessage:FA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Wte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Zte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as ULe}from"child_process";import{PassThrough as FLe,Readable as BLe,Writable as jLe,Duplex as zLe}from"stream";var tre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{pL(n);let a=new ULe;GLe(a,n),Object.assign(a,{readable:VLe,writable:qLe,duplex:HLe});let c=uf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=WLe(c,s,i);return{subprocess:a,promise:l}},GLe=(t,e)=>{let r=b_(),n=b_(),i=b_(),o=Array.from({length:e.length-3},b_),s=b_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},b_=()=>{let t=new FLe;return t.end(),t},VLe=()=>new BLe({read(){}}),qLe=()=>new jLe({write(){}}),HLe=()=>new zLe({read(){},write(){}}),WLe=async(t,e,r)=>df(t,e,r);import{createReadStream as rre,createWriteStream as nre}from"fs";import{Buffer as YLe}from"buffer";import{Readable as A_,Writable as KLe,Duplex as ZLe}from"stream";var ore=(t,e)=>ex(JLe,t,e,!1),x_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Oa[t]}.`)},ire={fileNumber:x_,generator:SL,asyncGenerator:SL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ZLe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},JLe={input:{...ire,fileUrl:({value:t})=>({stream:rre(t)}),filePath:({value:{file:t}})=>({stream:rre(t)}),webStream:({value:t})=>({stream:A_.fromWeb(t)}),iterable:({value:t})=>({stream:A_.from(t)}),asyncIterable:({value:t})=>({stream:A_.from(t)}),string:({value:t})=>({stream:A_.from(t)}),uint8Array:({value:t})=>({stream:A_.from(YLe.from(t))})},output:{...ire,fileUrl:({value:t})=>({stream:nre(t)}),filePath:({value:{file:t,append:e}})=>({stream:nre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:KLe.fromWeb(t)}),iterable:x_,asyncIterable:x_,string:x_,uint8Array:x_}};import{on as XLe,once as sre}from"events";import{PassThrough as QLe,getDefaultHighWaterMark as e$e}from"stream";import{finished as lre}from"stream/promises";function Rl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)xL(i);let e=t.some(({readableObjectMode:i})=>i),r=t$e(t,e),n=new AL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var t$e=(t,e)=>{if(t.length===0)return e$e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AL=class extends QLe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(xL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=r$e(this,this.#e,this.#o);let r=o$e({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(xL(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)}},r$e=async(t,e,r)=>{ax(t,are);let n=new AbortController;try{await Promise.race([n$e(t,n),i$e(t,e,r,n)])}finally{n.abort(),ax(t,-are)}},n$e=async(t,{signal:e})=>{try{await lre(t,{signal:e,cleanup:!0})}catch(r){throw ure(t,r),r}},i$e=async(t,e,r,{signal:n})=>{for await(let[i]of XLe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},xL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},o$e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{ax(t,cre);let a=new AbortController;try{await Promise.race([s$e(o,e,a),a$e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),c$e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),ax(t,-cre)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?wL(t):l$e(t))},s$e=async(t,e,{signal:r})=>{try{await t,r.aborted||wL(e)}catch(n){r.aborted||ure(e,n)}},a$e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await lre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;dre(s)?i.add(e):fre(t,s)}},c$e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await sre(t,i,{signal:o}),!t.readable)return sre(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},l$e=t=>{t.writable&&t.end()},ure=(t,e)=>{dre(e)?wL(t):fre(t,e)},dre=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",wL=t=>{(t.readable||t.writable)&&t.destroy()},fre=(t,e)=>{t.destroyed||(t.once("error",u$e),t.destroy(e))},u$e=()=>{},ax=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},are=2,cre=1;import{finished as pre}from"stream/promises";var pf=(t,e)=>{t.pipe(e),d$e(t,e),f$e(t,e)},d$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await pre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}RL(e)}},RL=t=>{t.writable&&t.end()},f$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await pre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}IL(t)}},IL=t=>{t.readable&&t.destroy()};var hre=(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})=>Yn.has(c)))p$e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))m$e({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]:Rl(o);pf(s,i)}},p$e=(t,e,r,n)=>{r==="output"?pf(t.stdio[n],e):pf(e,t.stdio[n]);let i=h$e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},h$e=["stdin","stdout","stderr"],m$e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;g$e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},g$e=(t,{signal:e})=>{wi(t)&&bl(t,_$e,e)},_$e=2;import{addAbortListener as E$e}from"events";var Il=[];Il.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Il.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Il.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var cx=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",CL=Symbol.for("signal-exit emitter"),PL=globalThis,y$e=Object.defineProperty.bind(Object),OL=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(PL[CL])return PL[CL];y$e(PL,CL,{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}},lx=class{},S$e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),NL=class extends lx{onExit(){return()=>{}}load(){}unload(){}},kL=class extends lx{#e=ML.platform==="win32"?"SIGINT":"SIGHUP";#r=new OL;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Il)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(!cx(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 Il)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,Il.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 cx(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"&&cx(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)}},ML=globalThis.process,{onExit:mre,load:xyt,unload:wyt}=S$e(cx(ML)?new kL(ML):new NL);var gre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=mre(()=>{t.kill()});E$e(n,()=>{i()})};var yre=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=EA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=v$e(r,n,i),{sourceStream:d,sourceError:f}=b$e(t,l),{options:p,fileDescriptors:h}=ho.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},v$e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=T$e(t,e,...r),a=PA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},T$e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(_re,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||bD(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]=uA(r,...n);return{destination:e(_re)(i,o,s),pipeOptions:s}}if(ho.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}`)},_re=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),b$e=(t,e)=>{try{return{sourceStream:sf(t,e)}}catch(r){return{sourceError:r}}};var Ere=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=A$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw DL({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},A$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return IL(t),n;if(e!==void 0)return RL(r),e},DL=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>uf({error:t,command:Sre,escapedCommand:Sre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Sre="source.pipe(destination)";var vre=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 x$e}from"stream/promises";var Tre=(t,e,r)=>{let n=ux.has(e)?R$e(t,e):w$e(t,e);return bl(t,C$e,r.signal),bl(e,P$e,r.signal),I$e(e),n},w$e=(t,e)=>{let r=Rl([t]);return pf(r,e),ux.set(e,r),r},R$e=(t,e)=>{let r=ux.get(e);return r.add(t),r},I$e=async t=>{try{await x$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ux.delete(t)},ux=new WeakMap,C$e=2,P$e=1;import{aborted as O$e}from"util";var bre=(t,e)=>t===void 0?[]:[N$e(t,e)],N$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await O$e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw DL({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var dx=(t,...e)=>{if(Pt(e[0]))return dx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=yre(t,...e),i=k$e({...n,destination:r});return i.pipe=dx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},k$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=M$e(t,i);Ere({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Tre(e,o,d);return await Promise.race([vre(u),...bre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},M$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as j$e}from"timers/promises";import{on as D$e}from"events";import{getDefaultHighWaterMark as L$e}from"stream";var fx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return $$e(e,s),xre({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},$$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},LL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;U$e(e,s,t);let a=t.readableObjectMode&&!o;return xre({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},U$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},xre=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=D$e(t,"data",{signal:e.signal,highWaterMark:Are,highWatermark:Are});return F$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},$L=L$e(!0),Are=$L,F$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=B$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*wl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*T_(a)}},B$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[rx(t,r,!e),tx(t,i,!n,{})].filter(Boolean);var wre=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=z$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([G$e(t),d]);return}let f=hL(c,r),p=LL({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([V$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},z$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!ox({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=LL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await $te(a,t,r,o)},G$e=async t=>{await j$e(),t.readableFlowing===null&&t.resume()},V$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await HA(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await WA(r,{maxBuffer:o})):await lf(r,{maxBuffer:o})}catch(a){return Rre($ee({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},UL=async t=>{try{return await t}catch(e){return Rre(e)}},Rre=({bufferedData:t})=>QX(t)?new Uint8Array(t):t;import{finished as q$e}from"stream/promises";var w_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=H$e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],q$e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||K$e(a,e,r,n)}finally{s.abort()}},H$e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&W$e(t,r,n),n},W$e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Y$e(e,r),n.call(t,...i)}},Y$e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},K$e=(t,e,r,n)=>{if(!Z$e(t,e,r,n))throw t},Z$e=(t,e,r,n=!0)=>r.propagating?Ire(t)||px(t):(r.propagating=!0,FL(r,e)===n?Ire(t):px(t)),FL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",px=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ire=t=>t?.code==="EPIPE";var Cre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>BL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),BL=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=w_(t,e,l);if(FL(l,e)){await u;return}let[d]=await Promise.all([wre({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 Pre=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Rl([t,e].filter(Boolean)):void 0,Ore=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>BL({...J$e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:X$e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),J$e=({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}},X$e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Q$e}from"events";var Nre=t=>ef(t,"ipc"),kre=(t,e)=>{let r=SA(t);fo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Mre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Nre(o),a=ms(e,"ipc"),c=ms(r,"ipc");for await(let l of bL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Uee(t,i,c),i.push(l)),s&&kre(l,o);return i},Dre=async(t,e)=>(await Promise.allSettled([t]),e);var Lre=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:v,controller:S})=>{let A=zte(t,f),b={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:A,propagating:!1},_=Cre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),R=Ore({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),C=[],P=Mre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:C,verboseInfo:p}),I=e1e(m,t,b),k=t1e(h,b);try{return await Promise.race([Promise.all([{},Vte(A),Promise.all(_),R,P,gee(t,d),...I,...k]),v,r1e(t,S),...dee(t,o,f,S),...N7({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...lee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},A,Promise.all(_.map(y=>UL(y))),UL(R),Dre(P,C),Promise.allSettled(I),Promise.allSettled(k)])}},e1e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:w_(n,i,r)),t1e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ci(o,{checkOpen:!1})&&!wi(o)).map(({type:i,value:o,stream:s=o})=>w_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),r1e=async(t,{signal:e})=>{let[r]=await Q$e(t,"error",{signal:e});throw r};var $re=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),R_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=po();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},hf=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 n1e}from"stream";import{callbackify as i1e}from"util";import{finished as Ure}from"stream/promises";var jL=async t=>{if(t!==void 0)try{await zL(t)}catch{}},Fre=async t=>{if(t!==void 0)try{await GL(t)}catch{}},zL=async t=>{await Ure(t,{cleanup:!0,readable:!1,writable:!0})},GL=async t=>{await Ure(t,{cleanup:!0,readable:!0,writable:!1})},hx=async(t,e)=>{if(await t,e)throw e},mx=(t,e,r)=>{r&&!px(r)?t.destroy(r):e&&t.destroy()};var Bre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||gn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=VL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=qL(a,s),{read:f,onStdoutDataDone:p}=HL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new n1e({read:f,destroy:i1e(YL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return WL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},VL=(t,e,r)=>{let n=sf(t,e),i=R_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},qL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:$L},HL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=po(),s=fx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){o1e(this,s,o)},onStdoutDataDone:o}},o1e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},WL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await GL(t),await n,await jL(i),await e,r.readable&&r.push(null)}catch(o){await jL(i),jre(r,o)}},YL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await hf(r,e)&&(jre(t,n),await hx(e,n))},jre=(t,e)=>{mx(t,t.readable,e)};import{Writable as s1e}from"stream";import{callbackify as zre}from"util";var Gre=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=KL(t,r,e),s=new s1e({...ZL(n,t,i),destroy:zre(XL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return JL(n,s),s},KL=(t,e,r)=>{let n=PA(t,e),i=R_(r,n,"writableFinal"),o=R_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},ZL=(t,e,r)=>({write:a1e.bind(void 0,t),final:zre(c1e.bind(void 0,t,e,r))}),a1e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},c1e=async(t,e,r)=>{await hf(r,e)&&(t.writable&&t.end(),await e)},JL=async(t,e,r)=>{try{await zL(t),e.writable&&e.end()}catch(n){await Fre(r),Vre(e,n)}},XL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await hf(r,e),await hf(n,e)&&(Vre(t,i),await hx(e,i))},Vre=(t,e)=>{mx(t,t.writable,e)};import{Duplex as l1e}from"stream";import{callbackify as u1e}from"util";var qre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||gn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=VL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=KL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=qL(c,a),{read:v,onStdoutDataDone:S}=HL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),A=new l1e({read:v,...ZL(u,t,d),destroy:u1e(d1e.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 WL({subprocessStdout:c,onStdoutDataDone:S,readable:A,subprocess:t,subprocessStdin:u}),JL(u,A,c),A},d1e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([YL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),XL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var QL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||gn.has(e),s=sf(t,r),a=fx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return f1e(a,s,t)},f1e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Hre=(t,{encoding:e})=>{let r=$re();t.readable=Bre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Gre.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=qre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=QL.bind(void 0,t,e),t[Symbol.asyncIterator]=QL.bind(void 0,t,e,{})};var Wre=(t,e)=>{for(let[r,n]of h1e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},p1e=(async()=>{})().constructor.prototype,h1e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(p1e,t)]);var Yre=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=_1e(t,e,r),{subprocess:f,promise:p}=S1e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=dx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Wre(f,p),ho.set(f,{options:u,fileDescriptors:d}),f},_1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=vA(t,e,r),{file:a,commandArguments:c,options:l}=jA(t,e,r),u=y1e(l),d=ore(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},y1e=({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}},S1e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=g1e(...zA(t,e,r))}catch(h){return tre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;m1e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];hre(c,a,l),gre(c,r,l);let d={},f=po();c.kill=P7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Pre(c,r),Hre(c,r),Xte(c,r);let p=E1e({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}},E1e=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,v]=await Lre({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((_,R)=>_s(_,e,R)),A=_s(m,e,"all"),b=v1e({errorInfo:d,exitCode:f,signal:p,stdio:S,all:A,ipcOutput:v,context:c,options:e,command:s,escapedCommand:a,startTime:r});return df(b,n,e)},v1e=({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?v_({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 mo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):ZA({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var gx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,T1e(n,t[n],i)]));return{...t,...r}},T1e=(t,e,r)=>b1e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,b1e=new Set(["env",...CD]);var Na=(t,e,r,n)=>{let i=(s,a,c)=>Na(s,a,r,c),o=(...s)=>A1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},A1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Pt(o))return i(t,gx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=x1e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Hte(a,c,l):Yre(a,c,l,i)},x1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=oQ(e)?sQ(e,r):[e,...r],[s,a,c]=uA(...o),l=gx(gx(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 Kre=({file:t,commandArguments:e})=>Jre(t,e),Zre=({file:t,commandArguments:e})=>({...Jre(t,e),isSync:!0}),Jre=(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]=w1e(t);return{file:r,commandArguments:n}},w1e=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(R1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},R1e=/ +/g;var Xre=(t,e,r)=>{t.sync=e(I1e,r),t.s=t.sync},Qre=({options:t})=>ene(t),I1e=({options:t})=>({...ene(t),isSync:!0}),ene=t=>({options:{...C1e(t),...t}}),C1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},tne={preferLocal:!0};var rne=Na(()=>({})),mvt=Na(()=>({isSync:!0})),nne=Na(Kre),gvt=Na(Zre),_vt=Na(pee),yvt=Na(Qre,{},tne,Xre),{sendMessage:Svt,getOneMessage:Evt,getEachMessage:vvt,getCancelSignal:Tvt}=Qte();var ine=!1,one=()=>{ine=!0},_o=()=>ine;var I_=null,sne=t=>(I_&&I_.destroy(),I_=new ys({totalAllowedTime:t}),I_),ane=()=>I_;var ys=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&&_o())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 nA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{me.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 cne={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.0-git.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:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@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.1.5","@netlify/otel":"^6.0.4","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var k1e=O1e(import.meta.url),M1e=Ss.dirname(k1e),D1e=N1e(import.meta.url),mf=he("shell"),e$=new Set,lne={preferLocal:!0},lr=(t,e,r)=>{let[n,i]=L1e(e,r),o={...lne,...i},s=rne(t,n,o);dne(s,o),hne(s);let a=r?.idleTimeout;return a&&a>0&&pne(s,a),s},une=(t,e)=>{let r={...lne,...e},n=nne(t,r);return dne(n,r),hne(n),e?.idleTimeout&&e.idleTimeout>0&&pne(n,e.idleTimeout),n},L1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},dne=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Es.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new r_).pipe(Es.stdout),t.stderr?.pipe(new r_).pipe(Es.stderr);return}t.stdout?.pipe(Es.stdout),t.stderr?.pipe(Es.stderr)},t$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Es.kill(-t.pid,e),mf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return mf.error("Error killing process:",r),!1}},fne=t=>t$(t,"SIGKILL"),pne=(t,e)=>{let r=null,n=()=>{mf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),t$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(mf.log(`Force killing idle process ${t.pid}`),fne(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)},hne=t=>{e$.add(t);let e=ane();if(e){let r=e.onTimesUp(()=>{mf.log(`Global timer expired, killing process ${t.pid}`),t$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(mf.log(`Force killing process ${t.pid} after timeout`),fne(t))},5e3)});t.on("exit",()=>{e$.delete(t),r()}),t.on("error",()=>{e$.delete(t),r()})}};function yx(t,e){return!!Pi(t,e)}function Pi(t,e){if(!Es.env.NETLIFY_LOCAL_MODE)try{let i=D1e.resolve(cne.name),o=Ss.dirname(i);for(;o!==Ss.dirname(o);){let s=Ss.dirname(o);if(Ss.basename(s)==="node_modules"){let a=Ss.join(s,".bin",e);if(_x.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Es.env.NODE_PATH){let i=Ss.join(Es.env.NODE_PATH,".bin",e);if(_x.existsSync(i))return i}let r=Ss.join(t,"node_modules",".bin",e);if(_x.existsSync(r))return r;let n=Ss.join(M1e,"..","node_modules",".bin",e);if(_x.existsSync(n))return n}var $1e=he("utils"),U1e=t=>new Promise(e=>{setTimeout(e,t)});var Sx=(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 U1e(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},ka=(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},mne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):$1e.error("Could not parse JSON",n))}},F1e=t=>t.charAt(0).toUpperCase()+t.slice(1),yo=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():F1e(e)).join(" ");function vs(t,e){e&&t.log(`Skill invoked: ${e}`)}var Ex=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),gne=(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 r$=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}},B1e=1e4,n$=(t,e=B1e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as _ne}from"buffer";import j1e from"path";var yne=he("repo"),ur=(t,e={})=>lr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),vx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{yne.info("Getting runner diffs");let n=await G1e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=q1e(o);await H1e(m,r)}yne.info("Changes after processing"),await o$(r);let s=await s$(o,r);if(await i$(s,r),i=await V1e(r),!i)return{hasChanges:!1,ignored:s};await ur(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await ur(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Sne(r),{hasChanges:!1,ignored:s};let u=await ur(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await ur(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let v=await ur(["diff",t.sha,"HEAD","--binary"],a),S=String(v.stdout??"");f!==S&&(p=_ne.from(S).toString("base64"))}await Sne(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=_ne.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Sne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await ur(["reset","--soft","HEAD~1"],{cwd:t})},i$=async(t=[],e=process.cwd())=>{await ur(["add",".",...t],{cwd:e})},o$=async(t=process.cwd())=>{let e=await ur(["status","-s"],{cwd:t});return String(e.stdout??"")},Ene=/.. (.+)?\.log$/,z1e=[Ene],G1e=async(t=process.cwd())=>{let e=await o$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
103
103
|
`).filter(i=>z1e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},V1e=async(t=process.cwd())=>{try{return await ur(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},C_=async(t=process.cwd())=>{let{stdout:e}=await ur(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},vne=async(t=process.cwd())=>{let{stdout:e}=await ur(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},s$=async(t,e=process.cwd())=>{t||=await o$(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(`
|
|
104
104
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${j1e.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Ene)?.[1];o&&n.push(`:!${o}.log`)}),n},Tne=async(t=process.cwd())=>{await ur(["reset","--hard","HEAD"],{cwd:t})},bne=async(t=process.cwd())=>{let e=await ur(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
105
105
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},q1e=t=>{let e=t.split(`
|
package/dist/bin.js
CHANGED
|
@@ -578,7 +578,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
578
578
|
`,LF:`
|
|
579
579
|
`,concatBytes:Z6},tyt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},ryt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:tyt};import{Buffer as nyt}from"buffer";var Dbe=(t,e)=>t?void 0:iyt.bind(void 0,e),iyt=function*(t,e){if(typeof e!="string"&&!Pr(e)&&!nyt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Mbe=(t,e)=>t?syt.bind(void 0,e):oyt.bind(void 0,e),syt=function*(t,e){Ube(t,e),yield e},oyt=function*(t,e){if(Ube(t,e),typeof e!="string"&&!Pr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Ube=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
580
580
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
581
|
-
if (condition) { yield value; }`)};import{Buffer as ayt}from"buffer";import{StringDecoder as cyt}from"string_decoder";var dC=(t,e,r)=>{if(r)return;if(t)return{transform:lyt.bind(void 0,new TextEncoder)};let n=new cyt(e);return{transform:uyt.bind(void 0,n),final:dyt.bind(void 0,n)}},lyt=function*(t,e){ayt.isBuffer(e)?yield Sc(e):typeof e=="string"?yield t.encode(e):yield e},uyt=function*(t,e){yield Pr(e)?t.write(e):e},dyt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Fbe}from"util";var Q6=Fbe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),fC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=pyt}=e[r];for await(let i of n(t))yield*fC(i,e,r+1)},jbe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*fyt(r,Number(e),t)},fyt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*fC(n,r,e+1)},qbe=Fbe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),pyt=function*(t){yield t};var e3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Bbe=(t,e)=>[...e.flatMap(r=>[...Lf(r,t,0)]),...zb(t)],Lf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=myt}=e[r];for(let i of n(t))yield*Lf(i,e,r+1)},zb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*hyt(r,Number(e),t)},hyt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Lf(n,r,e+1)},myt=function*(t){yield t};var t3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Vbe(t,o,s),l=$f(e),u=$f(r),d=l?Q6.bind(void 0,fC,a):e3.bind(void 0,Lf),f=l||u?Q6.bind(void 0,jbe,a):e3.bind(void 0,zb),p=l||u?qbe.bind(void 0,a):void 0;return{stream:new gyt({writableObjectMode:n,writableHighWaterMark:zbe(n),readableObjectMode:i,readableHighWaterMark:zbe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},pC=(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=Vbe(o,r,a);t=Bbe(c,t)}return t},Vbe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Dbe(n,a)},dC(r,o,n),uC(r,s,n,c),{transform:t,final:e},{transform:Mbe(i,a)},Lbe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Hbe=(t,e)=>{for(let r of _yt(t))yyt(t,r,e)},_yt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),yyt=(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 ${Eu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Syt(a,n));r.input=kb(o)},Syt=(t,e)=>{let r=pC(t,e,"utf8",!0);return Eyt(r),kb(r)},Eyt=t=>{let e=t.find(r=>typeof r!="string"&&!Pr(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 wyt,appendFileSync as Ryt}from"fs";var hC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ig(r,n)&&!Di.has(e)&&vyt(n)&&(t.some(({type:i,value:s})=>i==="native"&&byt.has(s))||t.every(({type:i})=>Ss.has(i))),vyt=t=>t===1||t===2,byt=new Set(["pipe","overlapped"]),Gbe=async(t,e,r,n)=>{for await(let i of t)Tyt(e)||Ybe(i,r,n)},Wbe=(t,e,r)=>{for(let n of t)Ybe(n,e,r)},Tyt=t=>t._readableState.pipes.length>0,Ybe=(t,e,r)=>{let n=IP(t);ta({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Kbe=({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)=>Ayt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Ayt=({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=Jve(t,s,d),p=Sc(f),{stdioItems:h,objectMode:m}=e[r],_=xyt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Iyt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Oyt({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&&Pyt(y,h,i),S}catch(g){return n.error=g,S}},xyt=(t,e,r,n)=>{try{return pC(t,e,r,!1)}catch(i){return n.error=i,t}},Iyt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:kb(t)};let o=uSe(t,r);return n[s]?{serializedResult:o,finalResult:X6(o,!i[s],e)}:{serializedResult:o}},Oyt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!hC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=X6(t,!1,o);try{Wbe(a,e,n)}catch(c){r.error??=c}},Pyt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>cC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?Ryt(n,t):(r.add(s),wyt(n,t))}};var Jbe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,bc(e,r,"all")]:Array.isArray(e)?[bc(t,r,"all"),...e]:Pr(t)&&Pr(e)?a6([t,e]):`${t}${e}`};import{once as r3}from"events";var Zbe=async(t,e)=>{let[r,n]=await Cyt(t);return e.isForcefullyTerminated??=!1,[r,n]},Cyt=async t=>{let[e,r]=await Promise.allSettled([r3(t,"spawn"),r3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Xbe(t):r.value},Xbe=async t=>{try{return await r3(t,"exit")}catch{return Xbe(t)}},Qbe=async t=>{let[e,r]=await t;if(!Nyt(e,r)&&n3(e,r))throw new eo;return[e,r]},Nyt=(t,e)=>t===void 0&&e===void 0,n3=(t,e)=>t!==0||e!==null;var eTe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=kyt(t,e,r),o=s?.code==="ETIMEDOUT",a=Kve(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},kyt=(t,e,r)=>t!==void 0?t:n3(e,r)?new eo:void 0;var tTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Lyt(t,e,r),d=Uyt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},Lyt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=PP(t,e,r),a=Dyt(r),{file:c,commandArguments:l,options:u}=JP(t,e,a);Myt(u);let d=Cbe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Dyt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Myt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&mC("ipcInput"),t&&mC("ipc: true"),r&&mC("detached: true"),n&&mC("cancelSignal")},mC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Uyt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Fyt({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}=eTe(c,r),{output:h,error:m=l}=Kbe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>bc(v,r,S)),y=bc(Jbe(h,r),r,"all");return qyt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Fyt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Hbe(s,r);let a=jyt(r);return $yt(...ZP(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},jyt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:iC(e)}),qyt=({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?sC({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Bb({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 IEt}from"events";import{spawn as OEt}from"child_process";import oTe from"process";import{once as i3,on as Byt}from"events";var rTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Cg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:VP(t)}),zyt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),zyt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{jP(e,i);let s=Su(t,e,r),o=new AbortController;try{return await Promise.race([Vyt(s,n,o),Hyt(s,r,o),Gyt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),qP(e,i)}},Vyt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await i3(t,"message",{signal:r});return n}for await(let[n]of Byt(t,"message",{signal:r}))if(e(n))return n},Hyt=async(t,e,{signal:r})=>{await i3(t,"disconnect",{signal:r}),BEe(e)},Gyt=async(t,e,{signal:r})=>{let[n]=await i3(t,"strict:error",{signal:r});throw MP(n,e)};import{once as iTe,on as Wyt}from"events";var sTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>s3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),s3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Cg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:VP(t)}),jP(e,s);let o=Su(t,e,r),a=new AbortController,c={};return Yyt(t,o,a),Kyt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Jyt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Yyt=async(t,e,r)=>{try{await iTe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Kyt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await iTe(t,"strict:error",{signal:r.signal});n.error=MP(i,e),r.abort()}catch{}},Jyt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Wyt(r,"message",{signal:s.signal}))nTe(o),yield c}catch{nTe(o)}finally{s.abort(),qP(e,a),n||Ng(t),i&&await t}},nTe=({error:t})=>{if(t)throw t};var aTe=(t,{ipc:e})=>{Object.assign(t,lTe(t,!1,e))},cTe=()=>{let t=oTe,e=!0,r=oTe.channel!==void 0;return{...lTe(t,e,r),getCancelSignal:mve.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},lTe=(t,e,r)=>({sendMessage:YP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:rTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:sTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Zyt}from"child_process";import{PassThrough as Xyt,Readable as Qyt,Writable as eSt,Duplex as tSt}from"stream";var uTe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{K6(n);let a=new Zyt;rSt(a,n),Object.assign(a,{readable:nSt,writable:iSt,duplex:sSt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=oSt(c,o,i);return{subprocess:a,promise:l}},rSt=(t,e)=>{let r=Vb(),n=Vb(),i=Vb(),s=Array.from({length:e.length-3},Vb),o=Vb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Vb=()=>{let t=new Xyt;return t.end(),t},nSt=()=>new Qyt({read(){}}),iSt=()=>new eSt({write(){}}),sSt=()=>new tSt({read(){},write(){}}),oSt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as dTe,createWriteStream as fTe}from"fs";import{Buffer as aSt}from"buffer";import{Readable as Hb,Writable as cSt,Duplex as lSt}from"stream";var hTe=(t,e)=>lC(uSt,t,e,!1),Gb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Eu[t]}.`)},pTe={fileNumber:Gb,generator:t3,asyncGenerator:t3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:lSt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},uSt={input:{...pTe,fileUrl:({value:t})=>({stream:dTe(t)}),filePath:({value:{file:t}})=>({stream:dTe(t)}),webStream:({value:t})=>({stream:Hb.fromWeb(t)}),iterable:({value:t})=>({stream:Hb.from(t)}),asyncIterable:({value:t})=>({stream:Hb.from(t)}),string:({value:t})=>({stream:Hb.from(t)}),uint8Array:({value:t})=>({stream:Hb.from(aSt.from(t))})},output:{...pTe,fileUrl:({value:t})=>({stream:fTe(t)}),filePath:({value:{file:t,append:e}})=>({stream:fTe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:cSt.fromWeb(t)}),iterable:Gb,asyncIterable:Gb,string:Gb,uint8Array:Gb}};import{on as dSt,once as mTe}from"events";import{PassThrough as fSt,getDefaultHighWaterMark as pSt}from"stream";import{finished as yTe}from"stream/promises";function Df(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)a3(i);let e=t.some(({readableObjectMode:i})=>i),r=hSt(t,e),n=new o3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var hSt=(t,e)=>{if(t.length===0)return pSt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},o3=class extends fSt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(a3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=mSt(this,this.#e,this.#s);let r=ySt({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(a3(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)}},mSt=async(t,e,r)=>{gC(t,gTe);let n=new AbortController;try{await Promise.race([gSt(t,n),_St(t,e,r,n)])}finally{n.abort(),gC(t,-gTe)}},gSt=async(t,{signal:e})=>{try{await yTe(t,{signal:e,cleanup:!0})}catch(r){throw STe(t,r),r}},_St=async(t,e,r,{signal:n})=>{for await(let[i]of dSt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},a3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ySt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{gC(t,_Te);let a=new AbortController;try{await Promise.race([SSt(s,e,a),ESt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),vSt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),gC(t,-_Te)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?c3(t):bSt(t))},SSt=async(t,e,{signal:r})=>{try{await t,r.aborted||c3(e)}catch(n){r.aborted||STe(e,n)}},ESt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await yTe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;ETe(o)?i.add(e):vTe(t,o)}},vSt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await mTe(t,i,{signal:s}),!t.readable)return mTe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},bSt=t=>{t.writable&&t.end()},STe=(t,e)=>{ETe(e)?c3(t):vTe(t,e)},ETe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",c3=t=>{(t.readable||t.writable)&&t.destroy()},vTe=(t,e)=>{t.destroyed||(t.once("error",TSt),t.destroy(e))},TSt=()=>{},gC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},gTe=2,_Te=1;import{finished as bTe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),wSt(t,e),RSt(t,e)},wSt=async(t,e)=>{if(!(Qs(t)||Qs(e))){try{await bTe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}l3(e)}},l3=t=>{t.writable&&t.end()},RSt=async(t,e)=>{if(!(Qs(t)||Qs(e))){try{await bTe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}u3(t)}},u3=t=>{t.readable&&t.destroy()};var TTe=(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})=>Ss.has(c)))ASt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ss.has(c)))ISt({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]:Df(s);jg(o,i)}},ASt=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=xSt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},xSt=["stdin","stdout","stderr"],ISt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;OSt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},OSt=(t,{signal:e})=>{Qs(t)&&Nf(t,PSt,e)},PSt=2;import{addAbortListener as kSt}from"events";var Mf=[];Mf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Mf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Mf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var _C=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",d3=Symbol.for("signal-exit emitter"),f3=globalThis,CSt=Object.defineProperty.bind(Object),p3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(f3[d3])return f3[d3];CSt(f3,d3,{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}},yC=class{},NSt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),h3=class extends yC{onExit(){return()=>{}}load(){}unload(){}},m3=class extends yC{#e=g3.platform==="win32"?"SIGINT":"SIGHUP";#r=new p3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Mf)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(!_C(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 Mf)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,Mf.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 _C(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"&&_C(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)}},g3=globalThis.process,{onExit:wTe,load:Uar,unload:Far}=NSt(_C(g3)?new m3(g3):new h3);var RTe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=wTe(()=>{t.kill()});kSt(n,()=>{i()})};var xTe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=OP(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=$St(r,n,i),{sourceStream:d,sourceError:f}=DSt(t,l),{options:p,fileDescriptors:h}=na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},$St=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=LSt(t,e,...r),a=FP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},LSt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(ATe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||s6(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]=SP(r,...n);return{destination:e(ATe)(i,s,o),pipeOptions:o}}if(na.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}`)},ATe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),DSt=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var OTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=MSt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw _3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},MSt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return u3(t),n;if(e!==void 0)return l3(r),e},_3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:ITe,escapedCommand:ITe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),ITe="source.pipe(destination)";var PTe=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 USt}from"stream/promises";var CTe=(t,e,r)=>{let n=SC.has(e)?jSt(t,e):FSt(t,e);return Nf(t,BSt,r.signal),Nf(e,zSt,r.signal),qSt(e),n},FSt=(t,e)=>{let r=Df([t]);return jg(r,e),SC.set(e,r),r},jSt=(t,e)=>{let r=SC.get(e);return r.add(t),r},qSt=async t=>{try{await USt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}SC.delete(t)},SC=new WeakMap,BSt=2,zSt=1;import{aborted as VSt}from"util";var NTe=(t,e)=>t===void 0?[]:[HSt(t,e)],HSt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await VSt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw _3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var EC=(t,...e)=>{if(_r(e[0]))return EC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=xTe(t,...e),i=GSt({...n,destination:r});return i.pipe=EC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},GSt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=WSt(t,i);OTe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=CTe(e,s,d);return await Promise.race([PTe(u),...NTe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},WSt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as eEt}from"timers/promises";import{on as YSt}from"events";import{getDefaultHighWaterMark as KSt}from"stream";var vC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return JSt(e,o),$Te({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},JSt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},y3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;ZSt(e,o,t);let a=t.readableObjectMode&&!s;return $Te({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},ZSt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},$Te=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=YSt(t,"data",{signal:e.signal,highWaterMark:kTe,highWatermark:kTe});return XSt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},S3=KSt(!0),kTe=S3,XSt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=QSt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Lf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*zb(a)}},QSt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[dC(t,r,!e),uC(t,i,!n,{})].filter(Boolean);var LTe=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=tEt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([rEt(t),d]);return}let f=J6(c,r),p=y3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([nEt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},tEt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!hC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=y3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Gbe(a,t,r,s)},rEt=async t=>{await eEt(),t.readableFlowing===null&&t.resume()},nEt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await tC(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await rC(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return DTe(Gve({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},E3=async t=>{try{return await t}catch(e){return DTe(e)}},DTe=({bufferedData:t})=>cSe(t)?new Uint8Array(t):t;import{finished as iEt}from"stream/promises";var Wb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=sEt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],iEt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||cEt(a,e,r,n)}finally{o.abort()}},sEt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&oEt(t,r,n),n},oEt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{aEt(e,r),n.call(t,...i)}},aEt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},cEt=(t,e,r,n)=>{if(!lEt(t,e,r,n))throw t},lEt=(t,e,r,n=!0)=>r.propagating?MTe(t)||bC(t):(r.propagating=!0,v3(r,e)===n?MTe(t):bC(t)),v3=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",bC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",MTe=t=>t?.code==="EPIPE";var UTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>b3({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),b3=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=Wb(t,e,l);if(v3(l,e)){await u;return}let[d]=await Promise.all([LTe({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 FTe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Df([t,e].filter(Boolean)):void 0,jTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>b3({...uEt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:dEt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),uEt=({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}},dEt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as fEt}from"events";var qTe=t=>Ig(t,"ipc"),BTe=(t,e)=>{let r=IP(t);ta({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var zTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=qTe(s),a=Ec(e,"ipc"),c=Ec(r,"ipc");for await(let l of s3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Wve(t,i,c),i.push(l)),o&&BTe(l,s);return i},VTe=async(t,e)=>(await Promise.allSettled([t]),e);var HTe=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=Zbe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=UTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=jTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),O=[],x=zTe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),R=pEt(m,t,S),P=hEt(h,S);try{return await Promise.race([Promise.all([{},Qbe(v),Promise.all(g),w,x,Rve(t,d),...R,...P]),_,mEt(t,y),...Eve(t,s,f,y),...qEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...yve({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(A){return f.terminationReason??="other",Promise.all([{error:A},v,Promise.all(g.map(b=>E3(b))),E3(w),VTe(x,O),Promise.allSettled(R),Promise.allSettled(P)])}},pEt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Wb(n,i,r)),hEt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>ro(s,{checkOpen:!1})&&!Qs(s)).map(({type:i,value:s,stream:o=s})=>Wb(o,n,e,{isSameDirection:Ss.has(i),stopOnExit:i==="native"}))),mEt=async(t,{signal:e})=>{let[r]=await fEt(t,"error",{signal:e});throw r};var GTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Yb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ra();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},qg=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 gEt}from"stream";import{callbackify as _Et}from"util";import{finished as WTe}from"stream/promises";var T3=async t=>{if(t!==void 0)try{await w3(t)}catch{}},YTe=async t=>{if(t!==void 0)try{await R3(t)}catch{}},w3=async t=>{await WTe(t,{cleanup:!0,readable:!1,writable:!0})},R3=async t=>{await WTe(t,{cleanup:!0,readable:!0,writable:!1})},TC=async(t,e)=>{if(await t,e)throw e},wC=(t,e,r)=>{r&&!bC(r)?t.destroy(r):e&&t.destroy()};var KTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Di.has(r),{subprocessStdout:a,waitReadableDestroy:c}=A3(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=x3(a,o),{read:f,onStdoutDataDone:p}=I3({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new gEt({read:f,destroy:_Et(P3.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return O3({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},A3=(t,e,r)=>{let n=kg(t,e),i=Yb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},x3=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:S3},I3=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ra(),o=vC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){yEt(this,o,s)},onStdoutDataDone:s}},yEt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},O3=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await R3(t),await n,await T3(i),await e,r.readable&&r.push(null)}catch(s){await T3(i),JTe(r,s)}},P3=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await qg(r,e)&&(JTe(t,n),await TC(e,n))},JTe=(t,e)=>{wC(t,t.readable,e)};import{Writable as SEt}from"stream";import{callbackify as ZTe}from"util";var XTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=C3(t,r,e),o=new SEt({...N3(n,t,i),destroy:ZTe($3.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return k3(n,o),o},C3=(t,e,r)=>{let n=FP(t,e),i=Yb(r,n,"writableFinal"),s=Yb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},N3=(t,e,r)=>({write:EEt.bind(void 0,t),final:ZTe(vEt.bind(void 0,t,e,r))}),EEt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},vEt=async(t,e,r)=>{await qg(r,e)&&(t.writable&&t.end(),await e)},k3=async(t,e,r)=>{try{await w3(t),e.writable&&e.end()}catch(n){await YTe(r),QTe(e,n)}},$3=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await qg(r,e),await qg(n,e)&&(QTe(t,i),await TC(e,i))},QTe=(t,e)=>{wC(t,t.writable,e)};import{Duplex as bEt}from"stream";import{callbackify as TEt}from"util";var ewe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Di.has(r),{subprocessStdout:c,waitReadableDestroy:l}=A3(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=C3(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=x3(c,a),{read:_,onStdoutDataDone:y}=I3({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new bEt({read:_,...N3(u,t,d),destroy:TEt(wEt.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 O3({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),k3(u,v,c),v},wEt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([P3({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),$3({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var L3=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Di.has(e),o=kg(t,r),a=vC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return REt(a,o,t)},REt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var twe=(t,{encoding:e})=>{let r=GTe();t.readable=KTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=XTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=ewe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=L3.bind(void 0,t,e),t[Symbol.asyncIterator]=L3.bind(void 0,t,e,{})};var rwe=(t,e)=>{for(let[r,n]of xEt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},AEt=(async()=>{})().constructor.prototype,xEt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(AEt,t)]);var nwe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=PEt(t,e,r),{subprocess:f,promise:p}=NEt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=EC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),rwe(f,p),na.set(f,{options:u,fileDescriptors:d}),f},PEt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=PP(t,e,r),{file:a,commandArguments:c,options:l}=JP(t,e,r),u=CEt(l),d=hTe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},CEt=({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}},NEt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=OEt(...ZP(t,e,r))}catch(h){return uTe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;IEt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];TTe(c,a,l),RTe(c,r,l);let d={},f=ra();c.kill=FEe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=FTe(c,r),twe(c,r),aTe(c,r);let p=kEt({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}},kEt=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 HTe({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)=>bc(g,e,w)),v=bc(m,e,"all"),S=$Et({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(S,n,e)},$Et=({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?Bb({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 ia,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):sC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var RC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,LEt(n,t[n],i)]));return{...t,...r}},LEt=(t,e,r)=>DEt.has(t)&&_r(e)&&_r(r)?{...e,...r}:r,DEt=new Set(["env",...d6]);var vu=(t,e,r,n)=>{let i=(o,a,c)=>vu(o,a,r,c),s=(...o)=>MEt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},MEt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(_r(s))return i(t,RC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=UEt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?tTe(a,c,l):nwe(a,c,l,i)},UEt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=hSe(e)?mSe(e,r):[e,...r],[o,a,c]=SP(...s),l=RC(RC(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 iwe=({file:t,commandArguments:e})=>owe(t,e),swe=({file:t,commandArguments:e})=>({...owe(t,e),isSync:!0}),owe=(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]=FEt(t);return{file:r,commandArguments:n}},FEt=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(jEt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},jEt=/ +/g;var awe=(t,e,r)=>{t.sync=e(qEt,r),t.s=t.sync},cwe=({options:t})=>lwe(t),qEt=({options:t})=>({...lwe(t),isSync:!0}),lwe=t=>({options:{...BEt(t),...t}}),BEt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},uwe={preferLocal:!0};var dwe=vu(()=>({})),Iur=vu(()=>({isSync:!0})),fwe=vu(iwe),Our=vu(swe),Pur=vu(bve),Cur=vu(cwe,{},uwe,awe),{sendMessage:Nur,getOneMessage:kur,getEachMessage:$ur,getCancelSignal:Lur}=cTe();import{Transform as zEt}from"stream";var VEt=["NETLIFY_AI_GATEWAY_KEY"];function HEt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...VEt])]}function GEt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function WEt(){let e=HEt().map(r=>process.env[r]).filter(r=>!(!r||GEt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Es(t){if(typeof t!="string")return t;let e=WEt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(YEt(n),"g");r=r.replace(i,"******")}),r}function YEt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Kb=class extends zEt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Es(i);n(null,s)}},AC=Symbol("maskedWrite");function pwe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[AC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Es(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AC]=!0,process.stdout.write=r}if(!process.stderr.write[AC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Es(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AC]=!0,process.stderr.write=r}}}var hwe=!1,mwe=()=>{hwe=!0},_i=()=>hwe;var Jb=null,gwe=t=>(Jb&&Jb.destroy(),Jb=new Tc({totalAllowedTime:t}),Jb),_we=()=>Jb;var Tc=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&&_i())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 _P({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{be.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 ywe={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.0-git.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@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.1.5","@netlify/otel":"^6.0.4","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var XEt=JEt(import.meta.url),QEt=wc.dirname(XEt),evt=ZEt(import.meta.url),Bg=Ee("shell"),D3=new Set,Swe={preferLocal:!0},Gn=(t,e,r)=>{let[n,i]=tvt(e,r),s={...Swe,...i},o=dwe(t,n,s);vwe(o,s),wwe(o);let a=r?.idleTimeout;return a&&a>0&&Twe(o,a),o},Ewe=(t,e)=>{let r={...Swe,...e},n=fwe(t,r);return vwe(n,r),wwe(n),e?.idleTimeout&&e.idleTimeout>0&&Twe(n,e.idleTimeout),n},tvt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},vwe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Rc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Kb).pipe(Rc.stdout),t.stderr?.pipe(new Kb).pipe(Rc.stderr);return}t.stdout?.pipe(Rc.stdout),t.stderr?.pipe(Rc.stderr)},M3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Rc.kill(-t.pid,e),Bg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bg.error("Error killing process:",r),!1}},bwe=t=>M3(t,"SIGKILL"),Twe=(t,e)=>{let r=null,n=()=>{Bg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),M3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing idle process ${t.pid}`),bwe(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)},wwe=t=>{D3.add(t);let e=_we();if(e){let r=e.onTimesUp(()=>{Bg.log(`Global timer expired, killing process ${t.pid}`),M3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing process ${t.pid} after timeout`),bwe(t))},5e3)});t.on("exit",()=>{D3.delete(t),r()}),t.on("error",()=>{D3.delete(t),r()})}};function oa(t,e){if(!Rc.env.NETLIFY_LOCAL_MODE)try{let i=evt.resolve(ywe.name),s=wc.dirname(i);for(;s!==wc.dirname(s);){let o=wc.dirname(s);if(wc.basename(o)==="node_modules"){let a=wc.join(o,".bin",e);if(xC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Rc.env.NODE_PATH){let i=wc.join(Rc.env.NODE_PATH,".bin",e);if(xC.existsSync(i))return i}let r=wc.join(t,"node_modules",".bin",e);if(xC.existsSync(r))return r;let n=wc.join(QEt,"..","node_modules",".bin",e);if(xC.existsSync(n))return n}import VL from"process";import{fileURLToPath as g$t}from"url";import{createRequire as _$t}from"module";import HL from"path";var rvt="__netlify__getTracer",nvt="__netlify__shutdownTracers",mt=(t,e)=>globalThis[rvt]?.(t,e),Rwe=async()=>globalThis[nvt]?.();function Uf(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 u$t}from"timers/promises";ke();import RTt from"process";ke();var xvt=(t,e)=>{e.recordException(t),e.setStatus({code:In.ERROR})};var Ic=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}=y0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>S0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=y0e(r,n,i),c=this._tracer.startSpan(e,s,o);return S0e(c,s,a)}};function y0e(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??Ft.active(),{opts:n,ctx:i,fn:s}}function S0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:xvt,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 Kg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var _W=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=O0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Kg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Kg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=O0e(this._rawAttributes),this._schemaUrl=Ivt(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,Kg(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(Kg(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=Ovt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function yW(t,e){return _W.FromAttributeList(Object.entries(t),e)}function O0e(t){return t.map(([e,r])=>Kg(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function Ivt(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 Ovt(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 cT=class{emit(e){}enabled(){return!1}},P0e=new cT;var lT=Symbol.for("io.opentelemetry.js.api.logs"),Jg=globalThis;function C0e(t,e,r){return n=>n===t?e:r}var SW=1;var EW=class{getLogger(e,r,n){return new cT}},JC=new EW;var ZC=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):P0e}};var uT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new ZC(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:JC}_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 XC=class t{constructor(){this._proxyLoggerProvider=new uT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Jg[lT]?this.getLoggerProvider():(Jg[lT]=C0e(SW,e,JC),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Jg[lT])===null||e===void 0?void 0:e.call(Jg,SW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Jg[lT],this._proxyLoggerProvider=new uT}};var N0e=XC.getInstance();function k0e(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 $0e(t){t.forEach(e=>e.disable())}function vW(t){let e=t.tracerProvider||zt.getTracerProvider(),r=t.meterProvider||aT.getMeterProvider(),n=t.loggerProvider||N0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return k0e(i,e,r,n),()=>{$0e(i)}}kc();var ak=Ln(TY(),1);ke();kc();var IIe=t=>{throw TypeError(t)},xY=(t,e,r)=>e.has(t)||IIe("Cannot "+r),ok=(t,e,r)=>(xY(t,e,"read from private field"),r?r.call(t):e.get(t)),wY=(t,e,r)=>e.has(t)?IIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),RIe=(t,e,r,n)=>(xY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),wTt=(t,e,r)=>(xY(t,e,"access private method"),r),AIe="__netlify__getTracer",ATt="__netlify__shutdownTracers",xTt="__nfOTLPTrace",PT,CT,AY,OIe,ITt=class{constructor(){wY(this,AY),wY(this,PT),wY(this,CT),RIe(this,PT,new t_(wTt(this,AY,OIe),this)),RIe(this,CT,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(ok(this,CT).debug(`export ${t.length.toString()} spans`),ok(this,PT).isCalled){e({code:Yn.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(xTt,JSON.stringify(OTt(t))),e({code:Yn.SUCCESS})}shutdown(){return ok(this,PT).call()}};PT=new WeakMap;CT=new WeakMap;AY=new WeakSet;OIe=function(){return ok(this,CT).debug("Shutting down"),Promise.resolve()};function OTt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:sk(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||no.SERVER,startTimeUnixNano:RY(e.startTime),endTimeUnixNano:RY(e.endTime),attributes:sk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:RY(n.time),attributes:sk(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:sk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function sk(t){return Object.keys(t).map(e=>PIe(e,t[e]))}function PIe(t,e){return{key:t,value:CIe(e)}}function CIe(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(CIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>PIe(r,n))}}:{}}function RY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var xIe={name:"@netlify/otel",version:"6.0.4",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":"^4.4.7",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.7.1","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},NIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,AIe))return;let e=RTt.version.slice(1),r=yW({"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??[PTt()],i=new ak.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Nc});let s=t.instrumentations??[];vW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,AIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Ic(zt.getTracer(a,c)):new Ic(zt.getTracer(xIe.name,xIe.version))}}),Object.defineProperty(globalThis,ATt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},PTt=()=>new ak.SimpleSpanProcessor(new ITt);ke();kc();var NT=Ln(TY(),1);ke();import*as ck from"diagnostics_channel";var kIe=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?In.ERROR:In.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 Ic?t:new Ic(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){ck.subscribe(t,e);let r=()=>ck.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:no.CLIENT},Ft.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:In.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 HLe=Ln(zLe(),1);var BL=Ee("tracing"),VLe=8e3,d$t=5e3,Hw=async(t=d$t)=>{try{await Promise.race([Rwe(),u$t(t)])}catch(e){BL.warn("Failed to flush tracers on shutdown",e)}},GLe=async(t,e,r)=>{if(!mt()){let n=[new NT.SimpleSpanProcessor(new dJ),new NT.SimpleSpanProcessor(new HLe.OTLPTraceExporter({url:r.exporterUrl}))];await NIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new kIe({skipHeaders:!0})]})}return r.traceparent?(Wn.setGlobalPropagator(new Nc),Wn.extract(Ft.active(),{traceparent:r.traceparent,isRemote:!0})):Ft.active()};function Ht(t,e,r){return BL.log(`\u23F3 TRACE: ${e} starting...`),Uf(t,e,r)}var dJ=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(", ")}]`:"";BL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&BL.log(` \u274C Error: ${e.status.message}`)}};function fJ(){return rt().captureLlmContentEnabled}function WLe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function zL(t,e,r){let n={role:t,parts:[{type:"text",content:Es(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function YLe(t,e,r,n){if(!t.length)return;let i=mt();if(!i)return;let s=fJ(),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.title||a.type||`step-${a.id??c}`,f=a.type==="tool_use"||a.type==="tool_result",p=a.message?a.message.length>VLe?`${a.message.slice(0,VLe)}\u2026`:a.message:void 0;i.startSpan(d,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":d,"gen_ai.operation.name":f?"execute_tool":"chat",...f?{"gen_ai.tool.name":d}:{},"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&&p?f?{"gen_ai.tool.call.result":Es(p)}:{"gen_ai.output.messages":zL("assistant",p)}:{}}}).end(u)})}import{readdir as f$t,rm as p$t}from"fs/promises";import{join as h$t}from"path";async function KLe(t,e=[]){let n=(await f$t(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>p$t(h$t(t,i),{recursive:!0,force:!0})))}var m$t=700,JLe=t=>t.mode==="create"&&(t.accountType===vl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=m$t);var y$t=HL.dirname(g$t(import.meta.url)),ZLe=_$t(import.meta.url),S$t=HL.resolve(y$t,"scripts/scaffold.js"),E$t="scripts/scaffold.js",v$t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,pJ=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},b$t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),T$t=t=>{let e=pJ(t);return e==="node"||e.endsWith("/node")},el=t=>{if(typeof t!="string")return!1;let e=t.match(v$t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&b$t(pJ(e[r]));)r+=1;if(r>=e.length||!T$t(e[r]))return!1;let n=e[r+1];return n?pJ(n).includes(E$t):!1},ay=Ee("create_stage"),XLe="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.",w$t=`${XLe}
|
|
581
|
+
if (condition) { yield value; }`)};import{Buffer as ayt}from"buffer";import{StringDecoder as cyt}from"string_decoder";var dC=(t,e,r)=>{if(r)return;if(t)return{transform:lyt.bind(void 0,new TextEncoder)};let n=new cyt(e);return{transform:uyt.bind(void 0,n),final:dyt.bind(void 0,n)}},lyt=function*(t,e){ayt.isBuffer(e)?yield Sc(e):typeof e=="string"?yield t.encode(e):yield e},uyt=function*(t,e){yield Pr(e)?t.write(e):e},dyt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Fbe}from"util";var Q6=Fbe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),fC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=pyt}=e[r];for await(let i of n(t))yield*fC(i,e,r+1)},jbe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*fyt(r,Number(e),t)},fyt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*fC(n,r,e+1)},qbe=Fbe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),pyt=function*(t){yield t};var e3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Bbe=(t,e)=>[...e.flatMap(r=>[...Lf(r,t,0)]),...zb(t)],Lf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=myt}=e[r];for(let i of n(t))yield*Lf(i,e,r+1)},zb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*hyt(r,Number(e),t)},hyt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Lf(n,r,e+1)},myt=function*(t){yield t};var t3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Vbe(t,o,s),l=$f(e),u=$f(r),d=l?Q6.bind(void 0,fC,a):e3.bind(void 0,Lf),f=l||u?Q6.bind(void 0,jbe,a):e3.bind(void 0,zb),p=l||u?qbe.bind(void 0,a):void 0;return{stream:new gyt({writableObjectMode:n,writableHighWaterMark:zbe(n),readableObjectMode:i,readableHighWaterMark:zbe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},pC=(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=Vbe(o,r,a);t=Bbe(c,t)}return t},Vbe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Dbe(n,a)},dC(r,o,n),uC(r,s,n,c),{transform:t,final:e},{transform:Mbe(i,a)},Lbe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Hbe=(t,e)=>{for(let r of _yt(t))yyt(t,r,e)},_yt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),yyt=(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 ${Eu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Syt(a,n));r.input=kb(o)},Syt=(t,e)=>{let r=pC(t,e,"utf8",!0);return Eyt(r),kb(r)},Eyt=t=>{let e=t.find(r=>typeof r!="string"&&!Pr(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 wyt,appendFileSync as Ryt}from"fs";var hC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ig(r,n)&&!Di.has(e)&&vyt(n)&&(t.some(({type:i,value:s})=>i==="native"&&byt.has(s))||t.every(({type:i})=>Ss.has(i))),vyt=t=>t===1||t===2,byt=new Set(["pipe","overlapped"]),Gbe=async(t,e,r,n)=>{for await(let i of t)Tyt(e)||Ybe(i,r,n)},Wbe=(t,e,r)=>{for(let n of t)Ybe(n,e,r)},Tyt=t=>t._readableState.pipes.length>0,Ybe=(t,e,r)=>{let n=IP(t);ta({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Kbe=({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)=>Ayt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Ayt=({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=Jve(t,s,d),p=Sc(f),{stdioItems:h,objectMode:m}=e[r],_=xyt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Iyt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Oyt({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&&Pyt(y,h,i),S}catch(g){return n.error=g,S}},xyt=(t,e,r,n)=>{try{return pC(t,e,r,!1)}catch(i){return n.error=i,t}},Iyt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:kb(t)};let o=uSe(t,r);return n[s]?{serializedResult:o,finalResult:X6(o,!i[s],e)}:{serializedResult:o}},Oyt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!hC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=X6(t,!1,o);try{Wbe(a,e,n)}catch(c){r.error??=c}},Pyt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>cC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?Ryt(n,t):(r.add(s),wyt(n,t))}};var Jbe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,bc(e,r,"all")]:Array.isArray(e)?[bc(t,r,"all"),...e]:Pr(t)&&Pr(e)?a6([t,e]):`${t}${e}`};import{once as r3}from"events";var Zbe=async(t,e)=>{let[r,n]=await Cyt(t);return e.isForcefullyTerminated??=!1,[r,n]},Cyt=async t=>{let[e,r]=await Promise.allSettled([r3(t,"spawn"),r3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Xbe(t):r.value},Xbe=async t=>{try{return await r3(t,"exit")}catch{return Xbe(t)}},Qbe=async t=>{let[e,r]=await t;if(!Nyt(e,r)&&n3(e,r))throw new eo;return[e,r]},Nyt=(t,e)=>t===void 0&&e===void 0,n3=(t,e)=>t!==0||e!==null;var eTe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=kyt(t,e,r),o=s?.code==="ETIMEDOUT",a=Kve(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},kyt=(t,e,r)=>t!==void 0?t:n3(e,r)?new eo:void 0;var tTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Lyt(t,e,r),d=Uyt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},Lyt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=PP(t,e,r),a=Dyt(r),{file:c,commandArguments:l,options:u}=JP(t,e,a);Myt(u);let d=Cbe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Dyt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Myt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&mC("ipcInput"),t&&mC("ipc: true"),r&&mC("detached: true"),n&&mC("cancelSignal")},mC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Uyt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Fyt({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}=eTe(c,r),{output:h,error:m=l}=Kbe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>bc(v,r,S)),y=bc(Jbe(h,r),r,"all");return qyt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Fyt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Hbe(s,r);let a=jyt(r);return $yt(...ZP(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},jyt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:iC(e)}),qyt=({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?sC({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Bb({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 IEt}from"events";import{spawn as OEt}from"child_process";import oTe from"process";import{once as i3,on as Byt}from"events";var rTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Cg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:VP(t)}),zyt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),zyt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{jP(e,i);let s=Su(t,e,r),o=new AbortController;try{return await Promise.race([Vyt(s,n,o),Hyt(s,r,o),Gyt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),qP(e,i)}},Vyt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await i3(t,"message",{signal:r});return n}for await(let[n]of Byt(t,"message",{signal:r}))if(e(n))return n},Hyt=async(t,e,{signal:r})=>{await i3(t,"disconnect",{signal:r}),BEe(e)},Gyt=async(t,e,{signal:r})=>{let[n]=await i3(t,"strict:error",{signal:r});throw MP(n,e)};import{once as iTe,on as Wyt}from"events";var sTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>s3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),s3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Cg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:VP(t)}),jP(e,s);let o=Su(t,e,r),a=new AbortController,c={};return Yyt(t,o,a),Kyt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Jyt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Yyt=async(t,e,r)=>{try{await iTe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Kyt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await iTe(t,"strict:error",{signal:r.signal});n.error=MP(i,e),r.abort()}catch{}},Jyt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Wyt(r,"message",{signal:s.signal}))nTe(o),yield c}catch{nTe(o)}finally{s.abort(),qP(e,a),n||Ng(t),i&&await t}},nTe=({error:t})=>{if(t)throw t};var aTe=(t,{ipc:e})=>{Object.assign(t,lTe(t,!1,e))},cTe=()=>{let t=oTe,e=!0,r=oTe.channel!==void 0;return{...lTe(t,e,r),getCancelSignal:mve.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},lTe=(t,e,r)=>({sendMessage:YP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:rTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:sTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Zyt}from"child_process";import{PassThrough as Xyt,Readable as Qyt,Writable as eSt,Duplex as tSt}from"stream";var uTe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{K6(n);let a=new Zyt;rSt(a,n),Object.assign(a,{readable:nSt,writable:iSt,duplex:sSt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=oSt(c,o,i);return{subprocess:a,promise:l}},rSt=(t,e)=>{let r=Vb(),n=Vb(),i=Vb(),s=Array.from({length:e.length-3},Vb),o=Vb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Vb=()=>{let t=new Xyt;return t.end(),t},nSt=()=>new Qyt({read(){}}),iSt=()=>new eSt({write(){}}),sSt=()=>new tSt({read(){},write(){}}),oSt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as dTe,createWriteStream as fTe}from"fs";import{Buffer as aSt}from"buffer";import{Readable as Hb,Writable as cSt,Duplex as lSt}from"stream";var hTe=(t,e)=>lC(uSt,t,e,!1),Gb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Eu[t]}.`)},pTe={fileNumber:Gb,generator:t3,asyncGenerator:t3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:lSt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},uSt={input:{...pTe,fileUrl:({value:t})=>({stream:dTe(t)}),filePath:({value:{file:t}})=>({stream:dTe(t)}),webStream:({value:t})=>({stream:Hb.fromWeb(t)}),iterable:({value:t})=>({stream:Hb.from(t)}),asyncIterable:({value:t})=>({stream:Hb.from(t)}),string:({value:t})=>({stream:Hb.from(t)}),uint8Array:({value:t})=>({stream:Hb.from(aSt.from(t))})},output:{...pTe,fileUrl:({value:t})=>({stream:fTe(t)}),filePath:({value:{file:t,append:e}})=>({stream:fTe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:cSt.fromWeb(t)}),iterable:Gb,asyncIterable:Gb,string:Gb,uint8Array:Gb}};import{on as dSt,once as mTe}from"events";import{PassThrough as fSt,getDefaultHighWaterMark as pSt}from"stream";import{finished as yTe}from"stream/promises";function Df(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)a3(i);let e=t.some(({readableObjectMode:i})=>i),r=hSt(t,e),n=new o3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var hSt=(t,e)=>{if(t.length===0)return pSt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},o3=class extends fSt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(a3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=mSt(this,this.#e,this.#s);let r=ySt({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(a3(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)}},mSt=async(t,e,r)=>{gC(t,gTe);let n=new AbortController;try{await Promise.race([gSt(t,n),_St(t,e,r,n)])}finally{n.abort(),gC(t,-gTe)}},gSt=async(t,{signal:e})=>{try{await yTe(t,{signal:e,cleanup:!0})}catch(r){throw STe(t,r),r}},_St=async(t,e,r,{signal:n})=>{for await(let[i]of dSt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},a3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ySt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{gC(t,_Te);let a=new AbortController;try{await Promise.race([SSt(s,e,a),ESt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),vSt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),gC(t,-_Te)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?c3(t):bSt(t))},SSt=async(t,e,{signal:r})=>{try{await t,r.aborted||c3(e)}catch(n){r.aborted||STe(e,n)}},ESt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await yTe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;ETe(o)?i.add(e):vTe(t,o)}},vSt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await mTe(t,i,{signal:s}),!t.readable)return mTe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},bSt=t=>{t.writable&&t.end()},STe=(t,e)=>{ETe(e)?c3(t):vTe(t,e)},ETe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",c3=t=>{(t.readable||t.writable)&&t.destroy()},vTe=(t,e)=>{t.destroyed||(t.once("error",TSt),t.destroy(e))},TSt=()=>{},gC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},gTe=2,_Te=1;import{finished as bTe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),wSt(t,e),RSt(t,e)},wSt=async(t,e)=>{if(!(Qs(t)||Qs(e))){try{await bTe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}l3(e)}},l3=t=>{t.writable&&t.end()},RSt=async(t,e)=>{if(!(Qs(t)||Qs(e))){try{await bTe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}u3(t)}},u3=t=>{t.readable&&t.destroy()};var TTe=(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})=>Ss.has(c)))ASt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ss.has(c)))ISt({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]:Df(s);jg(o,i)}},ASt=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=xSt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},xSt=["stdin","stdout","stderr"],ISt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;OSt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},OSt=(t,{signal:e})=>{Qs(t)&&Nf(t,PSt,e)},PSt=2;import{addAbortListener as kSt}from"events";var Mf=[];Mf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Mf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Mf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var _C=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",d3=Symbol.for("signal-exit emitter"),f3=globalThis,CSt=Object.defineProperty.bind(Object),p3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(f3[d3])return f3[d3];CSt(f3,d3,{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}},yC=class{},NSt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),h3=class extends yC{onExit(){return()=>{}}load(){}unload(){}},m3=class extends yC{#e=g3.platform==="win32"?"SIGINT":"SIGHUP";#r=new p3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Mf)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(!_C(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 Mf)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,Mf.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 _C(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"&&_C(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)}},g3=globalThis.process,{onExit:wTe,load:Uar,unload:Far}=NSt(_C(g3)?new m3(g3):new h3);var RTe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=wTe(()=>{t.kill()});kSt(n,()=>{i()})};var xTe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=OP(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=$St(r,n,i),{sourceStream:d,sourceError:f}=DSt(t,l),{options:p,fileDescriptors:h}=na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},$St=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=LSt(t,e,...r),a=FP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},LSt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(ATe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||s6(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]=SP(r,...n);return{destination:e(ATe)(i,s,o),pipeOptions:o}}if(na.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}`)},ATe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),DSt=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var OTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=MSt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw _3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},MSt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return u3(t),n;if(e!==void 0)return l3(r),e},_3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:ITe,escapedCommand:ITe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),ITe="source.pipe(destination)";var PTe=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 USt}from"stream/promises";var CTe=(t,e,r)=>{let n=SC.has(e)?jSt(t,e):FSt(t,e);return Nf(t,BSt,r.signal),Nf(e,zSt,r.signal),qSt(e),n},FSt=(t,e)=>{let r=Df([t]);return jg(r,e),SC.set(e,r),r},jSt=(t,e)=>{let r=SC.get(e);return r.add(t),r},qSt=async t=>{try{await USt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}SC.delete(t)},SC=new WeakMap,BSt=2,zSt=1;import{aborted as VSt}from"util";var NTe=(t,e)=>t===void 0?[]:[HSt(t,e)],HSt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await VSt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw _3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var EC=(t,...e)=>{if(_r(e[0]))return EC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=xTe(t,...e),i=GSt({...n,destination:r});return i.pipe=EC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},GSt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=WSt(t,i);OTe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=CTe(e,s,d);return await Promise.race([PTe(u),...NTe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},WSt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as eEt}from"timers/promises";import{on as YSt}from"events";import{getDefaultHighWaterMark as KSt}from"stream";var vC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return JSt(e,o),$Te({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},JSt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},y3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;ZSt(e,o,t);let a=t.readableObjectMode&&!s;return $Te({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},ZSt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},$Te=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=YSt(t,"data",{signal:e.signal,highWaterMark:kTe,highWatermark:kTe});return XSt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},S3=KSt(!0),kTe=S3,XSt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=QSt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Lf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*zb(a)}},QSt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[dC(t,r,!e),uC(t,i,!n,{})].filter(Boolean);var LTe=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=tEt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([rEt(t),d]);return}let f=J6(c,r),p=y3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([nEt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},tEt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!hC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=y3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Gbe(a,t,r,s)},rEt=async t=>{await eEt(),t.readableFlowing===null&&t.resume()},nEt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await tC(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await rC(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return DTe(Gve({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},E3=async t=>{try{return await t}catch(e){return DTe(e)}},DTe=({bufferedData:t})=>cSe(t)?new Uint8Array(t):t;import{finished as iEt}from"stream/promises";var Wb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=sEt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],iEt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||cEt(a,e,r,n)}finally{o.abort()}},sEt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&oEt(t,r,n),n},oEt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{aEt(e,r),n.call(t,...i)}},aEt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},cEt=(t,e,r,n)=>{if(!lEt(t,e,r,n))throw t},lEt=(t,e,r,n=!0)=>r.propagating?MTe(t)||bC(t):(r.propagating=!0,v3(r,e)===n?MTe(t):bC(t)),v3=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",bC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",MTe=t=>t?.code==="EPIPE";var UTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>b3({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),b3=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=Wb(t,e,l);if(v3(l,e)){await u;return}let[d]=await Promise.all([LTe({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 FTe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Df([t,e].filter(Boolean)):void 0,jTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>b3({...uEt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:dEt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),uEt=({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}},dEt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as fEt}from"events";var qTe=t=>Ig(t,"ipc"),BTe=(t,e)=>{let r=IP(t);ta({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var zTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=qTe(s),a=Ec(e,"ipc"),c=Ec(r,"ipc");for await(let l of s3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Wve(t,i,c),i.push(l)),o&&BTe(l,s);return i},VTe=async(t,e)=>(await Promise.allSettled([t]),e);var HTe=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=Zbe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=UTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=jTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),O=[],x=zTe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),R=pEt(m,t,S),P=hEt(h,S);try{return await Promise.race([Promise.all([{},Qbe(v),Promise.all(g),w,x,Rve(t,d),...R,...P]),_,mEt(t,y),...Eve(t,s,f,y),...qEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...yve({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(A){return f.terminationReason??="other",Promise.all([{error:A},v,Promise.all(g.map(b=>E3(b))),E3(w),VTe(x,O),Promise.allSettled(R),Promise.allSettled(P)])}},pEt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Wb(n,i,r)),hEt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>ro(s,{checkOpen:!1})&&!Qs(s)).map(({type:i,value:s,stream:o=s})=>Wb(o,n,e,{isSameDirection:Ss.has(i),stopOnExit:i==="native"}))),mEt=async(t,{signal:e})=>{let[r]=await fEt(t,"error",{signal:e});throw r};var GTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Yb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ra();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},qg=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 gEt}from"stream";import{callbackify as _Et}from"util";import{finished as WTe}from"stream/promises";var T3=async t=>{if(t!==void 0)try{await w3(t)}catch{}},YTe=async t=>{if(t!==void 0)try{await R3(t)}catch{}},w3=async t=>{await WTe(t,{cleanup:!0,readable:!1,writable:!0})},R3=async t=>{await WTe(t,{cleanup:!0,readable:!0,writable:!1})},TC=async(t,e)=>{if(await t,e)throw e},wC=(t,e,r)=>{r&&!bC(r)?t.destroy(r):e&&t.destroy()};var KTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Di.has(r),{subprocessStdout:a,waitReadableDestroy:c}=A3(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=x3(a,o),{read:f,onStdoutDataDone:p}=I3({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new gEt({read:f,destroy:_Et(P3.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return O3({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},A3=(t,e,r)=>{let n=kg(t,e),i=Yb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},x3=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:S3},I3=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ra(),o=vC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){yEt(this,o,s)},onStdoutDataDone:s}},yEt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},O3=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await R3(t),await n,await T3(i),await e,r.readable&&r.push(null)}catch(s){await T3(i),JTe(r,s)}},P3=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await qg(r,e)&&(JTe(t,n),await TC(e,n))},JTe=(t,e)=>{wC(t,t.readable,e)};import{Writable as SEt}from"stream";import{callbackify as ZTe}from"util";var XTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=C3(t,r,e),o=new SEt({...N3(n,t,i),destroy:ZTe($3.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return k3(n,o),o},C3=(t,e,r)=>{let n=FP(t,e),i=Yb(r,n,"writableFinal"),s=Yb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},N3=(t,e,r)=>({write:EEt.bind(void 0,t),final:ZTe(vEt.bind(void 0,t,e,r))}),EEt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},vEt=async(t,e,r)=>{await qg(r,e)&&(t.writable&&t.end(),await e)},k3=async(t,e,r)=>{try{await w3(t),e.writable&&e.end()}catch(n){await YTe(r),QTe(e,n)}},$3=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await qg(r,e),await qg(n,e)&&(QTe(t,i),await TC(e,i))},QTe=(t,e)=>{wC(t,t.writable,e)};import{Duplex as bEt}from"stream";import{callbackify as TEt}from"util";var ewe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Di.has(r),{subprocessStdout:c,waitReadableDestroy:l}=A3(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=C3(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=x3(c,a),{read:_,onStdoutDataDone:y}=I3({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new bEt({read:_,...N3(u,t,d),destroy:TEt(wEt.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 O3({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),k3(u,v,c),v},wEt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([P3({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),$3({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var L3=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Di.has(e),o=kg(t,r),a=vC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return REt(a,o,t)},REt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var twe=(t,{encoding:e})=>{let r=GTe();t.readable=KTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=XTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=ewe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=L3.bind(void 0,t,e),t[Symbol.asyncIterator]=L3.bind(void 0,t,e,{})};var rwe=(t,e)=>{for(let[r,n]of xEt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},AEt=(async()=>{})().constructor.prototype,xEt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(AEt,t)]);var nwe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=PEt(t,e,r),{subprocess:f,promise:p}=NEt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=EC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),rwe(f,p),na.set(f,{options:u,fileDescriptors:d}),f},PEt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=PP(t,e,r),{file:a,commandArguments:c,options:l}=JP(t,e,r),u=CEt(l),d=hTe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},CEt=({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}},NEt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=OEt(...ZP(t,e,r))}catch(h){return uTe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;IEt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];TTe(c,a,l),RTe(c,r,l);let d={},f=ra();c.kill=FEe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=FTe(c,r),twe(c,r),aTe(c,r);let p=kEt({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}},kEt=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 HTe({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)=>bc(g,e,w)),v=bc(m,e,"all"),S=$Et({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(S,n,e)},$Et=({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?Bb({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 ia,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):sC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var RC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,LEt(n,t[n],i)]));return{...t,...r}},LEt=(t,e,r)=>DEt.has(t)&&_r(e)&&_r(r)?{...e,...r}:r,DEt=new Set(["env",...d6]);var vu=(t,e,r,n)=>{let i=(o,a,c)=>vu(o,a,r,c),s=(...o)=>MEt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},MEt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(_r(s))return i(t,RC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=UEt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?tTe(a,c,l):nwe(a,c,l,i)},UEt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=hSe(e)?mSe(e,r):[e,...r],[o,a,c]=SP(...s),l=RC(RC(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 iwe=({file:t,commandArguments:e})=>owe(t,e),swe=({file:t,commandArguments:e})=>({...owe(t,e),isSync:!0}),owe=(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]=FEt(t);return{file:r,commandArguments:n}},FEt=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(jEt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},jEt=/ +/g;var awe=(t,e,r)=>{t.sync=e(qEt,r),t.s=t.sync},cwe=({options:t})=>lwe(t),qEt=({options:t})=>({...lwe(t),isSync:!0}),lwe=t=>({options:{...BEt(t),...t}}),BEt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},uwe={preferLocal:!0};var dwe=vu(()=>({})),Iur=vu(()=>({isSync:!0})),fwe=vu(iwe),Our=vu(swe),Pur=vu(bve),Cur=vu(cwe,{},uwe,awe),{sendMessage:Nur,getOneMessage:kur,getEachMessage:$ur,getCancelSignal:Lur}=cTe();import{Transform as zEt}from"stream";var VEt=["NETLIFY_AI_GATEWAY_KEY"];function HEt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...VEt])]}function GEt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function WEt(){let e=HEt().map(r=>process.env[r]).filter(r=>!(!r||GEt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Es(t){if(typeof t!="string")return t;let e=WEt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(YEt(n),"g");r=r.replace(i,"******")}),r}function YEt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Kb=class extends zEt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Es(i);n(null,s)}},AC=Symbol("maskedWrite");function pwe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[AC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Es(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AC]=!0,process.stdout.write=r}if(!process.stderr.write[AC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Es(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AC]=!0,process.stderr.write=r}}}var hwe=!1,mwe=()=>{hwe=!0},_i=()=>hwe;var Jb=null,gwe=t=>(Jb&&Jb.destroy(),Jb=new Tc({totalAllowedTime:t}),Jb),_we=()=>Jb;var Tc=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&&_i())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 _P({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{be.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 ywe={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.0-git.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:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@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.1.5","@netlify/otel":"^6.0.4","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var XEt=JEt(import.meta.url),QEt=wc.dirname(XEt),evt=ZEt(import.meta.url),Bg=Ee("shell"),D3=new Set,Swe={preferLocal:!0},Gn=(t,e,r)=>{let[n,i]=tvt(e,r),s={...Swe,...i},o=dwe(t,n,s);vwe(o,s),wwe(o);let a=r?.idleTimeout;return a&&a>0&&Twe(o,a),o},Ewe=(t,e)=>{let r={...Swe,...e},n=fwe(t,r);return vwe(n,r),wwe(n),e?.idleTimeout&&e.idleTimeout>0&&Twe(n,e.idleTimeout),n},tvt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},vwe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Rc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Kb).pipe(Rc.stdout),t.stderr?.pipe(new Kb).pipe(Rc.stderr);return}t.stdout?.pipe(Rc.stdout),t.stderr?.pipe(Rc.stderr)},M3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Rc.kill(-t.pid,e),Bg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bg.error("Error killing process:",r),!1}},bwe=t=>M3(t,"SIGKILL"),Twe=(t,e)=>{let r=null,n=()=>{Bg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),M3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing idle process ${t.pid}`),bwe(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)},wwe=t=>{D3.add(t);let e=_we();if(e){let r=e.onTimesUp(()=>{Bg.log(`Global timer expired, killing process ${t.pid}`),M3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing process ${t.pid} after timeout`),bwe(t))},5e3)});t.on("exit",()=>{D3.delete(t),r()}),t.on("error",()=>{D3.delete(t),r()})}};function oa(t,e){if(!Rc.env.NETLIFY_LOCAL_MODE)try{let i=evt.resolve(ywe.name),s=wc.dirname(i);for(;s!==wc.dirname(s);){let o=wc.dirname(s);if(wc.basename(o)==="node_modules"){let a=wc.join(o,".bin",e);if(xC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Rc.env.NODE_PATH){let i=wc.join(Rc.env.NODE_PATH,".bin",e);if(xC.existsSync(i))return i}let r=wc.join(t,"node_modules",".bin",e);if(xC.existsSync(r))return r;let n=wc.join(QEt,"..","node_modules",".bin",e);if(xC.existsSync(n))return n}import VL from"process";import{fileURLToPath as g$t}from"url";import{createRequire as _$t}from"module";import HL from"path";var rvt="__netlify__getTracer",nvt="__netlify__shutdownTracers",mt=(t,e)=>globalThis[rvt]?.(t,e),Rwe=async()=>globalThis[nvt]?.();function Uf(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 u$t}from"timers/promises";ke();import RTt from"process";ke();var xvt=(t,e)=>{e.recordException(t),e.setStatus({code:In.ERROR})};var Ic=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}=y0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>S0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=y0e(r,n,i),c=this._tracer.startSpan(e,s,o);return S0e(c,s,a)}};function y0e(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??Ft.active(),{opts:n,ctx:i,fn:s}}function S0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:xvt,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 Kg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var _W=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=O0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Kg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Kg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=O0e(this._rawAttributes),this._schemaUrl=Ivt(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,Kg(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(Kg(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=Ovt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function yW(t,e){return _W.FromAttributeList(Object.entries(t),e)}function O0e(t){return t.map(([e,r])=>Kg(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function Ivt(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 Ovt(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 cT=class{emit(e){}enabled(){return!1}},P0e=new cT;var lT=Symbol.for("io.opentelemetry.js.api.logs"),Jg=globalThis;function C0e(t,e,r){return n=>n===t?e:r}var SW=1;var EW=class{getLogger(e,r,n){return new cT}},JC=new EW;var ZC=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):P0e}};var uT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new ZC(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:JC}_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 XC=class t{constructor(){this._proxyLoggerProvider=new uT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Jg[lT]?this.getLoggerProvider():(Jg[lT]=C0e(SW,e,JC),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Jg[lT])===null||e===void 0?void 0:e.call(Jg,SW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Jg[lT],this._proxyLoggerProvider=new uT}};var N0e=XC.getInstance();function k0e(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 $0e(t){t.forEach(e=>e.disable())}function vW(t){let e=t.tracerProvider||zt.getTracerProvider(),r=t.meterProvider||aT.getMeterProvider(),n=t.loggerProvider||N0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return k0e(i,e,r,n),()=>{$0e(i)}}kc();var ak=Ln(TY(),1);ke();kc();var IIe=t=>{throw TypeError(t)},xY=(t,e,r)=>e.has(t)||IIe("Cannot "+r),ok=(t,e,r)=>(xY(t,e,"read from private field"),r?r.call(t):e.get(t)),wY=(t,e,r)=>e.has(t)?IIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),RIe=(t,e,r,n)=>(xY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),wTt=(t,e,r)=>(xY(t,e,"access private method"),r),AIe="__netlify__getTracer",ATt="__netlify__shutdownTracers",xTt="__nfOTLPTrace",PT,CT,AY,OIe,ITt=class{constructor(){wY(this,AY),wY(this,PT),wY(this,CT),RIe(this,PT,new t_(wTt(this,AY,OIe),this)),RIe(this,CT,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(ok(this,CT).debug(`export ${t.length.toString()} spans`),ok(this,PT).isCalled){e({code:Yn.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(xTt,JSON.stringify(OTt(t))),e({code:Yn.SUCCESS})}shutdown(){return ok(this,PT).call()}};PT=new WeakMap;CT=new WeakMap;AY=new WeakSet;OIe=function(){return ok(this,CT).debug("Shutting down"),Promise.resolve()};function OTt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:sk(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||no.SERVER,startTimeUnixNano:RY(e.startTime),endTimeUnixNano:RY(e.endTime),attributes:sk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:RY(n.time),attributes:sk(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:sk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function sk(t){return Object.keys(t).map(e=>PIe(e,t[e]))}function PIe(t,e){return{key:t,value:CIe(e)}}function CIe(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(CIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>PIe(r,n))}}:{}}function RY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var xIe={name:"@netlify/otel",version:"6.0.4",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":"^4.4.7",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.7.1","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},NIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,AIe))return;let e=RTt.version.slice(1),r=yW({"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??[PTt()],i=new ak.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Nc});let s=t.instrumentations??[];vW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,AIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Ic(zt.getTracer(a,c)):new Ic(zt.getTracer(xIe.name,xIe.version))}}),Object.defineProperty(globalThis,ATt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},PTt=()=>new ak.SimpleSpanProcessor(new ITt);ke();kc();var NT=Ln(TY(),1);ke();import*as ck from"diagnostics_channel";var kIe=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?In.ERROR:In.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 Ic?t:new Ic(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){ck.subscribe(t,e);let r=()=>ck.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:no.CLIENT},Ft.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:In.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 HLe=Ln(zLe(),1);var BL=Ee("tracing"),VLe=8e3,d$t=5e3,Hw=async(t=d$t)=>{try{await Promise.race([Rwe(),u$t(t)])}catch(e){BL.warn("Failed to flush tracers on shutdown",e)}},GLe=async(t,e,r)=>{if(!mt()){let n=[new NT.SimpleSpanProcessor(new dJ),new NT.SimpleSpanProcessor(new HLe.OTLPTraceExporter({url:r.exporterUrl}))];await NIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new kIe({skipHeaders:!0})]})}return r.traceparent?(Wn.setGlobalPropagator(new Nc),Wn.extract(Ft.active(),{traceparent:r.traceparent,isRemote:!0})):Ft.active()};function Ht(t,e,r){return BL.log(`\u23F3 TRACE: ${e} starting...`),Uf(t,e,r)}var dJ=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(", ")}]`:"";BL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&BL.log(` \u274C Error: ${e.status.message}`)}};function fJ(){return rt().captureLlmContentEnabled}function WLe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function zL(t,e,r){let n={role:t,parts:[{type:"text",content:Es(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function YLe(t,e,r,n){if(!t.length)return;let i=mt();if(!i)return;let s=fJ(),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.title||a.type||`step-${a.id??c}`,f=a.type==="tool_use"||a.type==="tool_result",p=a.message?a.message.length>VLe?`${a.message.slice(0,VLe)}\u2026`:a.message:void 0;i.startSpan(d,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":d,"gen_ai.operation.name":f?"execute_tool":"chat",...f?{"gen_ai.tool.name":d}:{},"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&&p?f?{"gen_ai.tool.call.result":Es(p)}:{"gen_ai.output.messages":zL("assistant",p)}:{}}}).end(u)})}import{readdir as f$t,rm as p$t}from"fs/promises";import{join as h$t}from"path";async function KLe(t,e=[]){let n=(await f$t(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>p$t(h$t(t,i),{recursive:!0,force:!0})))}var m$t=700,JLe=t=>t.mode==="create"&&(t.accountType===vl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=m$t);var y$t=HL.dirname(g$t(import.meta.url)),ZLe=_$t(import.meta.url),S$t=HL.resolve(y$t,"scripts/scaffold.js"),E$t="scripts/scaffold.js",v$t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,pJ=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},b$t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),T$t=t=>{let e=pJ(t);return e==="node"||e.endsWith("/node")},el=t=>{if(typeof t!="string")return!1;let e=t.match(v$t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&b$t(pJ(e[r]));)r+=1;if(r>=e.length||!T$t(e[r]))return!1;let n=e[r+1];return n?pJ(n).includes(E$t):!1},ay=Ee("create_stage"),XLe="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.",w$t=`${XLe}
|
|
582
582
|
|
|
583
583
|
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.`,R$t=`${XLe}
|
|
584
584
|
|
|
@@ -712,7 +712,7 @@ ${I}`:I);break}default:T.type&&!A.has(T.type)&&(A.add(T.type),oS.log(`Unhandled
|
|
|
712
712
|
${o}
|
|
713
713
|
</extracted_error_chunk>`).join(`
|
|
714
714
|
|
|
715
|
-
`);return s.length>t.length*.8?t:s}import{promises as RMe}from"fs";import Jp from"path";var kDt=/@anthropic-ai\/sdk|['"`]openai['"`]|@google\/genai|new\s+Anthropic\b|new\s+OpenAI\b|GoogleGenAI|ANTHROPIC_API_KEY|OPENAI_API_KEY|GEMINI_API_KEY/,$Dt=/satisfies\s+NetlifyFunction\b|export\s+default\s*\{/,LDt=/export\s+default\b/,DDt=/\bexports\.handler\b|\bmodule\.exports\.handler\b|\bmodule\.exports\s*=|export\s+(async\s+)?(const\s+handler\b|function\s+handler\b)/,MDt=new Set([".js",".ts",".mjs",".mts",".cjs",".cts"]);function UDt(t){return $Dt.test(t)?"v3":LDt.test(t)?"v2":DDt.test(t)?"v1":"unknown"}async function hZ(t,e=process.env.FUNCTIONS_DIST||"netlify/functions"){let r={aiTotal:0,v1:0,v2:0,v3:0,unknown:0,v1Files:[]},n=Jp.isAbsolute(e)?e:Jp.join(t,e),i;try{i=await RMe.readdir(n,{withFileTypes:!0})}catch{return r}for(let s of i){if(!s.isFile()||!MDt.has(Jp.extname(s.name))||s.name.endsWith(".d.ts"))continue;let o;try{o=await RMe.readFile(Jp.join(n,s.name),"utf8")}catch{continue}if(!kDt.test(o))continue;r.aiTotal++;let a=UDt(o);r[a]++,a==="v1"&&r.v1Files.push(Jp.relative(t,Jp.join(n,s.name)).split(Jp.sep).join("/"))}return r}import _Mt from"fs/promises";import yMt from"path";import x0 from"process";import E0 from"process";var AD=E0.env.NETLIFY_API_URL,xD=E0.env.NETLIFY_API_TOKEN,Lr=Ee("api"),fl=()=>E0.env.NETLIFY_LOCAL_MODE==="true",ti=async(t,e={})=>{if(!AD||!xD)throw new Error("No API URL or token");let r=new URL(t,AD),n={...e,headers:{...e.headers,Authorization:`Bearer ${xD}`}};E0.env.AGENT_RUNNERS_DEBUG==="true"&&(n.headers["x-nf-debug-logging"]="true"),e.json&&(n.headers||={},n.headers["Content-Type"]="application/json",n.body=JSON.stringify(e.json));let i=await fetch(r,n),s=i.ok&&i.status<=299,o=e.expectStatuses?.includes(i.status)??!1;if(E0.env.AGENT_RUNNERS_DEBUG==="true")Lr.log(`Response headers for ${r}:`),i.headers.forEach((c,l)=>{Lr.log(` ${l}: ${c}`)});else{let c=i.headers.get("x-request-id")||i.headers.get("x-nf-request-id");Lr.log(`Request ID for ${r}: ${c||"N/A"}`)}if(!s&&!o&&(Lr.error(`Got status ${i.status} for request ${r}`),be.inc("api.request_failed",1,{status:i.status})),e.raw){if(!s)throw new Error(`API request failed: ${i.status} ${i.statusText}`);return i}let a=await(i.headers.get("content-type")?.includes("application/json")?i.json():i.text());if(!s){let c=typeof a=="string"?a:JSON.stringify(a);throw i.status===404?new js(`API request failed: 404 - ${c}`,404,"The site associated with this agent run no longer exists."):i.status===503&&e.gracefulOn503&&c.toLowerCase().includes("usage exceeded")?new js(`API request failed: 503 - ${c}`,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0):new Error(`API request failed: ${i.status} - ${c}`)}return a},AMe=t=>{Lr.log("Setting details for api",{apiUrl:t?.constants?.NETLIFY_API_HOST,token:!!t?.constants?.NETLIFY_API_TOKEN}),t?.constants?.NETLIFY_API_HOST&&(AD=`https://${t.constants.NETLIFY_API_HOST}`),t?.constants?.NETLIFY_API_TOKEN&&(xD=t.constants.NETLIFY_API_TOKEN)},xMe=()=>({apiUrl:AD,token:xD}),ID=async(t,e)=>fl()?(Lr.log("Mock API: updateRunner called",{runnerId:t,data:e}),{id:t,...e}):ti(`/api/v1/agent_runners/${t}`,{method:"PUT",json:e}),Ri=async(t,e,r)=>fl()?(Lr.log("Mock API: updateRunnerSession called",JSON.stringify({runnerId:t,sessionId:e,data:r},null,2)),{id:t,sessionId:e,...r}):ti(`/api/v1/agent_runners/${t}/sessions/${e}`,{method:"PUT",json:r});var IMe=async t=>fl()?(Lr.log("Mock API: getSite called",{siteId:t}),{id:t,published_deploy:{id:"id"}}):ti(`/api/v1/sites/${t}`),OD=async(t,e)=>fl()?(Lr.log("Mock API: getRunnerSession called",{runnerId:t,sessionId:e}),{id:e,runnerId:t,state:"running"}):ti(`/api/v1/agent_runners/${t}/sessions/${e}`),OMe=(t,e,r)=>ti(`/api/v1/accounts/${t}/ai-gateway/token`,{headers:{"X-Nf-Agent-Runner-Id":e,"X-Nf-Agent-Runner-Session-Id":r},gracefulOn503:!0}),PMe=(t,e,r)=>ti(`/api/v1/sites/${t}/ai-gateway/token`,{headers:{"X-Nf-Agent-Runner-Id":e,"X-Nf-Agent-Runner-Session-Id":r},gracefulOn503:!0}),CMe=async(t,e)=>fl()?(Lr.log("Mock API: getDiffUploadUrls called",{runnerId:t,sessionId:e}),{result:{upload_url:"https://s3.mock.com/mock-upload-url-result",s3_key:"mock-s3-key-result"},cumulative:{upload_url:"https://s3.mock.com/mock-upload-url-cumulative",s3_key:"mock-s3-key-cumulative"}}):ti(`/api/v1/agent_runners/${t}/sessions/${e}/diff/upload_urls`,{method:"POST"}),NMe=async(t,e)=>fl()?(Lr.log("Mock API: getNativeSessionUploadUrl called",{runnerId:t,sessionId:e}),{upload_url:"https://s3.mock.com/mock-upload-url-native-session",s3_key:"mock-s3-key-native-session"}):ti(`/api/v1/agent_runners/${t}/sessions/${e}/native_session/upload`,{method:"POST"}),kMe=async(t,e)=>{if(fl())return Lr.log("Mock API: getNativeSessionDownloadUrl called",{runnerId:t,sessionId:e}),{download_url:"https://s3.mock.com/mock-download-url-native-session"};try{return await ti(`/api/v1/agent_runners/${t}/sessions/${e}/native_session`)}catch(r){if(r instanceof js&&r.statusCode===404)return Lr.log("No native session available to download (404), falling back"),null;throw r}},$Me=async(t,e)=>fl()?(Lr.log("Mock API: updateSessionUsage called",{runnerId:t,sessionId:e}),{id:e,runnerId:t,usage:0}):ti(`/api/v1/agent_runners/${t}/sessions/${e}/update_usage`,{method:"POST"}),mZ="netlifydb_readonly",LMe=async t=>(await ti(`/api/v1/sites/${t}/database?role=${mZ}`,{raw:!0})).json(),DMe=async t=>{if(fl())return Lr.log("Mock API: siteHasDatabase called",{siteId:t}),!1;try{return await ti(`/api/v1/sites/${t}/database?role=${mZ}`,{raw:!0,expectStatuses:[404]}),!0}catch(e){if(e?.message?.includes("404"))return!1;Lr.warn("siteHasDatabase check inconclusive",{siteId:t,error:e?.message});return}},MMe=async(t,e)=>(await ti(`/api/v1/sites/${t}/database/branch/${encodeURIComponent(e)}?role=${mZ}`,{raw:!0})).json(),UMe=async t=>ti(`/api/v1/sites/${t}/database`,{method:"POST",json:{}}),FMe=async(t,e)=>ti(`/api/v1/sites/${t}/database/branch`,{method:"POST",json:{branch_id:e}}),FDt=1e4,jMe=async t=>{Lr.log(`Downloading from S3: ${new URL(t).host}`);let e=await fetch(t,{method:"GET",signal:AbortSignal.timeout(FDt)});if(!e.ok)throw new Error(`S3 download failed with status ${e.status}`);return Buffer.from(await e.arrayBuffer())},v0=async(t,e,{maxRetries:r=3,baseDelayMs:n=500,contentType:i="text/plain"}={})=>{Lr.log(`Uploading to S3: ${new URL(t).host}`);for(let s=1;s<=r;s++)try{let o=await fetch(t,{method:"PUT",body:e,headers:{"Content-Type":i}});if(!o.ok)throw new Error(`S3 upload failed with status ${o.status}`);return o}catch(o){if(s===r)throw o;let a=n*2**(s-1);Lr.warn(`S3 upload attempt ${s}/${r} failed: ${o.message}. Retrying in ${a}ms...`),await new Promise(c=>setTimeout(c,a))}};var Zp=Ee("ai_gateway"),gZ=null;var b0=async()=>{if(gZ)return gZ;Zp.log("Fetching available AI gateway providers");let t=await fetch(`${xMe().apiUrl}/api/v1/ai-gateway/providers`);if(!t.ok)throw new Error(`Failed to fetch AI gateway providers: ${t.statusText}`);let e=await t.json();return gZ=e,Zp.log("Cached AI gateway providers",{providerCount:Object.keys(e.providers).length}),e},jDt=async(t,e)=>{let n=(await b0()).providers[t];if(!n)return Zp.log(`Provider '${t}' not found`),!1;let i=n.models.includes(e);return Zp.log(`Model validation for ${t}/${e}`,{isAvailable:i}),i},qDt=async t=>{let e=await b0(),r=Object.values(e.providers).some(n=>n.models.includes(t));return Zp.log(`Model validation across all providers for ${t}`,{isAvailable:r}),r},qMe=async({config:t})=>{let e,r,n,i,s=!t.site?.published_deploy;if(!(s?t.accountId:t.siteId))throw new Error(`No entity id for ${s?"account":"site"}`);let a=async()=>{clearTimeout(n),Zp.log("Requesting AI gateway information");let l=await(s?OMe(t.accountId,t.id,t.sessionId):PMe(t.siteId,t.id,t.sessionId));if({token:e,url:i}=l,r=l.expires_at?l.expires_at*1e3:void 0,process.env.NETLIFY_AI_GATEWAY_KEY=e,process.env.NETLIFY_AI_GATEWAY_BASE_URL=i,Zp.log("Got AI gateway information",{token:!!e,expiresAt:r,url:i}),r){let u=r-Date.now()-6e4;u>0&&(n=setTimeout(()=>{a()},u))}};return await Promise.all([a(),b0()]),{get url(){return i},get token(){return e},isModelAvailableForProvider:jDt,isModelAvailable:qDt}};import BDt from"crypto";import{createWriteStream as zDt}from"fs";import w0 from"fs/promises";import R0 from"path";import VDt from"process";import{Readable as HDt,Transform as GDt}from"stream";import{pipeline as WDt}from"stream/promises";async function PD(t,e){let{maxRetries:r,baseDelay:n,onRetry:i,shouldRetry:s}=e,o;for(let a=1;a<=r;a++)try{return await t()}catch(c){if(o=c,a===r||s&&!s(o))throw o;i&&i(a,o),await new Promise(l=>setTimeout(l,n*a))}throw o}var T0=Ee("asset_fetch"),CD=100*1024*1024,YDt=6e4,BMe=6,KDt=3,JDt=300,ZDt=t=>{if(!bl(t))return!1;switch(t.kind){case"network":case"timeout":case"http_5xx":return!0;case"http_4xx":return t.status===404;default:return!1}},XDt=t=>BDt.createHash("sha1").update(t).digest("hex").slice(0,8),QDt=t=>typeof t=="string"&&t.length>0&&t!=="."&&t!==".."&&t===R0.basename(t),eMt=async t=>{try{return await w0.stat(t),!0}catch{return!1}},tMt=t=>decodeURIComponent(new URL(t).pathname),_Z=t=>R0.basename(t)||"attachment",rMt=(t,e)=>{let r=R0.extname(t);return`${t.slice(0,t.length-r.length)}-${XDt(e)}${r}`},nMt=t=>{let e=new Map;for(let r of t)e.set(_Z(r),(e.get(_Z(r))??0)+1);return t.map(r=>{let n=_Z(r);return(e.get(n)??0)>1?rMt(n,r):n})},zMe=t=>{let e=t?.name;return e==="TimeoutError"||e==="AbortError"?"timeout":"network"},iMt=async(t,e)=>{let r;try{r=await fetch(t,{signal:AbortSignal.timeout(YDt)})}catch(a){throw new $o(`Asset fetch failed: ${a?.message||a}`,zMe(a))}if(!r.ok)throw await r.body?.cancel(),new $o(`Asset download failed: ${r.status} ${r.statusText}`,r.status>=500?"http_5xx":"http_4xx",r.status);let n=r.headers.get("content-length");if(n&&Number(n)>CD)throw new $o(`Asset too large: ${n} bytes (max ${CD})`,"too_large");if(!r.body)throw new $o("Asset download failed: missing response body","network");let i=`${e}.part`,s=0,o=new GDt({transform(a,c,l){if(s+=a.length,s>CD){l(new $o(`Asset too large: exceeded ${CD} bytes`,"too_large"));return}l(null,a)}});try{await WDt(HDt.fromWeb(r.body),o,zDt(i))}catch(a){throw await w0.rm(i,{force:!0}),bl(a)?a:new $o(`Asset body read failed: ${a?.message||a}`,zMe(a))}try{await w0.rename(i,e)}catch(a){throw await w0.rm(i,{force:!0}),a}},sMt=async(t,e,r)=>{if(!QDt(t))return T0.warn(`Skipping attachments for unsafe session id: ${t}`),[];if(!Array.isArray(e)||e.length===0)return[];let n=R0.join(r,Qr,Fs,t);await w0.mkdir(n,{recursive:!0});let i=e.filter(o=>typeof o=="string"&&o.length>0),s=nMt(i.map(tMt));return i.map((o,a)=>({sessionId:t,url:o,dest:R0.join(n,s[a])}))},VMe=async({assetMap:t,cwd:e=VDt.cwd()})=>{let r=Object.entries(t??{});if(r.length===0)return;let n=(await Promise.all(r.map(([a,c])=>sMt(a,c,e)))).flat();if(n.length===0)return;let i={};for(let a of n)i[a.sessionId]=(i[a.sessionId]??0)+1;T0.info(`Reconciling ${n.length} attachment(s) across ${Object.keys(i).length} session(s)`);let s={},o=async a=>{if(await eMt(a.dest))return;let c=performance.now(),l=new URL(a.url).pathname;try{await PD(()=>iMt(a.url,a.dest),{maxRetries:KDt,baseDelay:JDt,shouldRetry:ZDt,onRetry:(u,d)=>{let f=bl(d)?d.kind:"unknown";be.inc("assets.fetch_retry",1,{kind:f}),T0.info(`Retrying asset download session=${a.sessionId} key=${l} kind=${f} attempt=${u}`)}})}catch(u){let d=bl(u)?u.kind:"unknown",f=bl(u)?u.status:void 0;throw T0.error(`Asset download failed session=${a.sessionId} key=${new URL(a.url).pathname} kind=${d} status=${f??"-"} elapsedMs=${Math.round(performance.now()-c)} message=${u?.message||u}`),u}s[a.sessionId]=(s[a.sessionId]??0)+1};for(let a=0;a<n.length;a+=BMe){let c=n.slice(a,a+BMe);await Promise.all(c.map(o))}for(let[a,c]of Object.entries(i)){let l=s[a]??0;T0.info(`Session ${a}: fetched ${l} attachment(s), ${c-l} already present`)}};import{Buffer as HMe}from"buffer";import oMt from"path";var GMe=Ee("repo"),gn=(t,e={})=>Gn("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),ND=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{GMe.info("Getting runner diffs");let n=await cMt(r),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!e){let m=uMt(s);await dMt(m,r)}GMe.info("Changes after processing"),await SZ(r);let o=await vZ(s,r);if(await yZ(o,r),i=await lMt(r),!i)return{hasChanges:!1,ignored:o};await gn(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await gn(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await WMe(r),{hasChanges:!1,ignored:o};let u=await gn(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await gn(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let _=await gn(["diff",t.sha,"HEAD","--binary"],a),y=String(_.stdout??"");f!==y&&(p=HMe.from(y).toString("base64"))}await WMe(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(h.diffBinary=HMe.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},WMe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await gn(["reset","--soft","HEAD~1"],{cwd:t})},yZ=async(t=[],e=process.cwd())=>{await gn(["add",".",...t],{cwd:e})},SZ=async(t=process.cwd())=>{let e=await gn(["status","-s"],{cwd:t});return String(e.stdout??"")},YMe=/.. (.+)?\.log$/,aMt=[YMe],cMt=async(t=process.cwd())=>{let e=await SZ(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
715
|
+
`);return s.length>t.length*.8?t:s}import{promises as RMe}from"fs";import Jp from"path";var kDt=/@anthropic-ai\/sdk|['"`]openai['"`]|@google\/genai|new\s+Anthropic\b|new\s+OpenAI\b|GoogleGenAI|ANTHROPIC_API_KEY|OPENAI_API_KEY|GEMINI_API_KEY/,$Dt=/satisfies\s+NetlifyFunction\b|export\s+default\s*\{/,LDt=/export\s+default\b/,DDt=/\bexports\.handler\b|\bmodule\.exports\.handler\b|\bmodule\.exports\s*=|export\s+(async\s+)?(const\s+handler\b|function\s+handler\b)/,MDt=new Set([".js",".ts",".mjs",".mts",".cjs",".cts"]);function UDt(t){return $Dt.test(t)?"v3":LDt.test(t)?"v2":DDt.test(t)?"v1":"unknown"}async function hZ(t,e=process.env.FUNCTIONS_DIST||"netlify/functions"){let r={aiTotal:0,v1:0,v2:0,v3:0,unknown:0,v1Files:[]},n=Jp.isAbsolute(e)?e:Jp.join(t,e),i;try{i=await RMe.readdir(n,{withFileTypes:!0})}catch{return r}for(let s of i){if(!s.isFile()||!MDt.has(Jp.extname(s.name))||s.name.endsWith(".d.ts"))continue;let o;try{o=await RMe.readFile(Jp.join(n,s.name),"utf8")}catch{continue}if(!kDt.test(o))continue;r.aiTotal++;let a=UDt(o);r[a]++,a==="v1"&&r.v1Files.push(Jp.relative(t,Jp.join(n,s.name)).split(Jp.sep).join("/"))}return r}import _Mt from"fs/promises";import yMt from"path";import x0 from"process";import E0 from"process";var AD=E0.env.NETLIFY_API_URL,xD=E0.env.NETLIFY_API_TOKEN,Lr=Ee("api"),fl=()=>E0.env.NETLIFY_LOCAL_MODE==="true",ti=async(t,e={})=>{if(!AD||!xD)throw new Error("No API URL or token");let r=new URL(t,AD),n={...e,headers:{...e.headers,Authorization:`Bearer ${xD}`}};E0.env.AGENT_RUNNERS_DEBUG==="true"&&(n.headers["x-nf-debug-logging"]="true"),e.json&&(n.headers||={},n.headers["Content-Type"]="application/json",n.body=JSON.stringify(e.json));let i=await fetch(r,n),s=i.ok&&i.status<=299,o=e.expectStatuses?.includes(i.status)??!1;if(E0.env.AGENT_RUNNERS_DEBUG==="true")Lr.log(`Response headers for ${r}:`),i.headers.forEach((c,l)=>{Lr.log(` ${l}: ${c}`)});else{let c=i.headers.get("x-request-id")||i.headers.get("x-nf-request-id");Lr.log(`Request ID for ${r}: ${c||"N/A"}`)}if(!s&&!o&&(Lr.error(`Got status ${i.status} for request ${r}`),be.inc("api.request_failed",1,{status:i.status})),e.raw){if(!s)throw new Error(`API request failed: ${i.status} ${i.statusText}`);return i}let a=await(i.headers.get("content-type")?.includes("application/json")?i.json():i.text());if(!s){let c=typeof a=="string"?a:JSON.stringify(a);throw i.status===404?new js(`API request failed: 404 - ${c}`,404,"The site associated with this agent run no longer exists."):i.status===503&&e.gracefulOn503&&c.toLowerCase().includes("usage exceeded")?new js(`API request failed: 503 - ${c}`,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0):new Error(`API request failed: ${i.status} - ${c}`)}return a},AMe=t=>{Lr.log("Setting details for api",{apiUrl:t?.constants?.NETLIFY_API_HOST,token:!!t?.constants?.NETLIFY_API_TOKEN}),t?.constants?.NETLIFY_API_HOST&&(AD=`https://${t.constants.NETLIFY_API_HOST}`),t?.constants?.NETLIFY_API_TOKEN&&(xD=t.constants.NETLIFY_API_TOKEN)},xMe=()=>({apiUrl:AD,token:xD}),ID=async(t,e)=>fl()?(Lr.log("Mock API: updateRunner called",{runnerId:t,data:e}),{id:t,...e}):ti(`/api/v1/agent_runners/${t}`,{method:"PUT",json:e}),Ri=async(t,e,r)=>fl()?(Lr.log("Mock API: updateRunnerSession called",JSON.stringify({runnerId:t,sessionId:e,data:r},null,2)),{id:t,sessionId:e,...r}):ti(`/api/v1/agent_runners/${t}/sessions/${e}`,{method:"PUT",json:r});var IMe=async t=>fl()?(Lr.log("Mock API: getSite called",{siteId:t}),{id:t,published_deploy:{id:"id"}}):ti(`/api/v1/sites/${t}`),OD=async(t,e)=>fl()?(Lr.log("Mock API: getRunnerSession called",{runnerId:t,sessionId:e}),{id:e,runnerId:t,state:"running"}):ti(`/api/v1/agent_runners/${t}/sessions/${e}`),OMe=(t,e,r)=>ti(`/api/v1/accounts/${t}/ai-gateway/token`,{headers:{"X-Nf-Agent-Runner-Id":e,"X-Nf-Agent-Runner-Session-Id":r},gracefulOn503:!0}),PMe=(t,e,r)=>ti(`/api/v1/sites/${t}/ai-gateway/token`,{headers:{"X-Nf-Agent-Runner-Id":e,"X-Nf-Agent-Runner-Session-Id":r},gracefulOn503:!0}),CMe=async(t,e)=>fl()?(Lr.log("Mock API: getDiffUploadUrls called",{runnerId:t,sessionId:e}),{result:{upload_url:"https://s3.mock.com/mock-upload-url-result",s3_key:"mock-s3-key-result"},cumulative:{upload_url:"https://s3.mock.com/mock-upload-url-cumulative",s3_key:"mock-s3-key-cumulative"}}):ti(`/api/v1/agent_runners/${t}/sessions/${e}/diff/upload_urls`,{method:"POST"}),NMe=async(t,e)=>fl()?(Lr.log("Mock API: getNativeSessionUploadUrl called",{runnerId:t,sessionId:e}),{upload_url:"https://s3.mock.com/mock-upload-url-native-session",s3_key:"mock-s3-key-native-session"}):ti(`/api/v1/agent_runners/${t}/sessions/${e}/native_session/upload`,{method:"POST"}),kMe=async(t,e)=>{if(fl())return Lr.log("Mock API: getNativeSessionDownloadUrl called",{runnerId:t,sessionId:e}),{download_url:"https://s3.mock.com/mock-download-url-native-session"};try{return await ti(`/api/v1/agent_runners/${t}/sessions/${e}/native_session`)}catch(r){if(r instanceof js&&r.statusCode===404)return Lr.log("No native session available to download (404), falling back"),null;throw r}},$Me=async(t,e)=>fl()?(Lr.log("Mock API: updateSessionUsage called",{runnerId:t,sessionId:e}),{id:e,runnerId:t,usage:0}):ti(`/api/v1/agent_runners/${t}/sessions/${e}/update_usage`,{method:"POST"}),mZ="netlifydb_readonly",LMe=async t=>(await ti(`/api/v1/sites/${t}/database?role=${mZ}`,{raw:!0})).json(),DMe=async t=>{if(fl())return Lr.log("Mock API: siteHasDatabase called",{siteId:t}),!1;try{return await ti(`/api/v1/sites/${t}/database?role=${mZ}`,{raw:!0,expectStatuses:[404]}),!0}catch(e){if(e?.message?.includes("404"))return!1;Lr.warn("siteHasDatabase check inconclusive",{siteId:t,error:e?.message});return}},MMe=async(t,e)=>(await ti(`/api/v1/sites/${t}/database/branch/${encodeURIComponent(e)}?role=${mZ}`,{raw:!0})).json(),UMe=async t=>ti(`/api/v1/sites/${t}/database`,{method:"POST",json:{}}),FMe=async(t,e)=>ti(`/api/v1/sites/${t}/database/branch`,{method:"POST",json:{branch_id:e}}),FDt=1e4,jMe=async t=>{Lr.log(`Downloading from S3: ${new URL(t).host}`);let e=await fetch(t,{method:"GET",signal:AbortSignal.timeout(FDt)});if(!e.ok)throw new Error(`S3 download failed with status ${e.status}`);return Buffer.from(await e.arrayBuffer())},v0=async(t,e,{maxRetries:r=3,baseDelayMs:n=500,contentType:i="text/plain"}={})=>{Lr.log(`Uploading to S3: ${new URL(t).host}`);for(let s=1;s<=r;s++)try{let o=await fetch(t,{method:"PUT",body:e,headers:{"Content-Type":i}});if(!o.ok)throw new Error(`S3 upload failed with status ${o.status}`);return o}catch(o){if(s===r)throw o;let a=n*2**(s-1);Lr.warn(`S3 upload attempt ${s}/${r} failed: ${o.message}. Retrying in ${a}ms...`),await new Promise(c=>setTimeout(c,a))}};var Zp=Ee("ai_gateway"),gZ=null;var b0=async()=>{if(gZ)return gZ;Zp.log("Fetching available AI gateway providers");let t=await fetch(`${xMe().apiUrl}/api/v1/ai-gateway/providers`);if(!t.ok)throw new Error(`Failed to fetch AI gateway providers: ${t.statusText}`);let e=await t.json();return gZ=e,Zp.log("Cached AI gateway providers",{providerCount:Object.keys(e.providers).length}),e},jDt=async(t,e)=>{let n=(await b0()).providers[t];if(!n)return Zp.log(`Provider '${t}' not found`),!1;let i=n.models.includes(e);return Zp.log(`Model validation for ${t}/${e}`,{isAvailable:i}),i},qDt=async t=>{let e=await b0(),r=Object.values(e.providers).some(n=>n.models.includes(t));return Zp.log(`Model validation across all providers for ${t}`,{isAvailable:r}),r},qMe=async({config:t})=>{let e,r,n,i,s=!t.site?.published_deploy;if(!(s?t.accountId:t.siteId))throw new Error(`No entity id for ${s?"account":"site"}`);let a=async()=>{clearTimeout(n),Zp.log("Requesting AI gateway information");let l=await(s?OMe(t.accountId,t.id,t.sessionId):PMe(t.siteId,t.id,t.sessionId));if({token:e,url:i}=l,r=l.expires_at?l.expires_at*1e3:void 0,process.env.NETLIFY_AI_GATEWAY_KEY=e,process.env.NETLIFY_AI_GATEWAY_BASE_URL=i,Zp.log("Got AI gateway information",{token:!!e,expiresAt:r,url:i}),r){let u=r-Date.now()-6e4;u>0&&(n=setTimeout(()=>{a()},u))}};return await Promise.all([a(),b0()]),{get url(){return i},get token(){return e},isModelAvailableForProvider:jDt,isModelAvailable:qDt}};import BDt from"crypto";import{createWriteStream as zDt}from"fs";import w0 from"fs/promises";import R0 from"path";import VDt from"process";import{Readable as HDt,Transform as GDt}from"stream";import{pipeline as WDt}from"stream/promises";async function PD(t,e){let{maxRetries:r,baseDelay:n,onRetry:i,shouldRetry:s}=e,o;for(let a=1;a<=r;a++)try{return await t()}catch(c){if(o=c,a===r||s&&!s(o))throw o;i&&i(a,o),await new Promise(l=>setTimeout(l,n*a))}throw o}var T0=Ee("asset_fetch"),CD=100*1024*1024,YDt=6e4,BMe=6,KDt=3,JDt=300,ZDt=t=>{if(!bl(t))return!1;switch(t.kind){case"network":case"timeout":case"http_5xx":return!0;case"http_4xx":return t.status===404;default:return!1}},XDt=t=>BDt.createHash("sha1").update(t).digest("hex").slice(0,8),QDt=t=>typeof t=="string"&&t.length>0&&t!=="."&&t!==".."&&t===R0.basename(t),eMt=async t=>{try{return await w0.stat(t),!0}catch{return!1}},tMt=t=>decodeURIComponent(new URL(t).pathname),_Z=t=>R0.basename(t)||"attachment",rMt=(t,e)=>{let r=R0.extname(t);return`${t.slice(0,t.length-r.length)}-${XDt(e)}${r}`},nMt=t=>{let e=new Map;for(let r of t)e.set(_Z(r),(e.get(_Z(r))??0)+1);return t.map(r=>{let n=_Z(r);return(e.get(n)??0)>1?rMt(n,r):n})},zMe=t=>{let e=t?.name;return e==="TimeoutError"||e==="AbortError"?"timeout":"network"},iMt=async(t,e)=>{let r;try{r=await fetch(t,{signal:AbortSignal.timeout(YDt)})}catch(a){throw new $o(`Asset fetch failed: ${a?.message||a}`,zMe(a))}if(!r.ok)throw await r.body?.cancel(),new $o(`Asset download failed: ${r.status} ${r.statusText}`,r.status>=500?"http_5xx":"http_4xx",r.status);let n=r.headers.get("content-length");if(n&&Number(n)>CD)throw new $o(`Asset too large: ${n} bytes (max ${CD})`,"too_large");if(!r.body)throw new $o("Asset download failed: missing response body","network");let i=`${e}.part`,s=0,o=new GDt({transform(a,c,l){if(s+=a.length,s>CD){l(new $o(`Asset too large: exceeded ${CD} bytes`,"too_large"));return}l(null,a)}});try{await WDt(HDt.fromWeb(r.body),o,zDt(i))}catch(a){throw await w0.rm(i,{force:!0}),bl(a)?a:new $o(`Asset body read failed: ${a?.message||a}`,zMe(a))}try{await w0.rename(i,e)}catch(a){throw await w0.rm(i,{force:!0}),a}},sMt=async(t,e,r)=>{if(!QDt(t))return T0.warn(`Skipping attachments for unsafe session id: ${t}`),[];if(!Array.isArray(e)||e.length===0)return[];let n=R0.join(r,Qr,Fs,t);await w0.mkdir(n,{recursive:!0});let i=e.filter(o=>typeof o=="string"&&o.length>0),s=nMt(i.map(tMt));return i.map((o,a)=>({sessionId:t,url:o,dest:R0.join(n,s[a])}))},VMe=async({assetMap:t,cwd:e=VDt.cwd()})=>{let r=Object.entries(t??{});if(r.length===0)return;let n=(await Promise.all(r.map(([a,c])=>sMt(a,c,e)))).flat();if(n.length===0)return;let i={};for(let a of n)i[a.sessionId]=(i[a.sessionId]??0)+1;T0.info(`Reconciling ${n.length} attachment(s) across ${Object.keys(i).length} session(s)`);let s={},o=async a=>{if(await eMt(a.dest))return;let c=performance.now(),l=new URL(a.url).pathname;try{await PD(()=>iMt(a.url,a.dest),{maxRetries:KDt,baseDelay:JDt,shouldRetry:ZDt,onRetry:(u,d)=>{let f=bl(d)?d.kind:"unknown";be.inc("assets.fetch_retry",1,{kind:f}),T0.info(`Retrying asset download session=${a.sessionId} key=${l} kind=${f} attempt=${u}`)}})}catch(u){let d=bl(u)?u.kind:"unknown",f=bl(u)?u.status:void 0;throw T0.error(`Asset download failed session=${a.sessionId} key=${new URL(a.url).pathname} kind=${d} status=${f??"-"} elapsedMs=${Math.round(performance.now()-c)} message=${u?.message||u}`),u}s[a.sessionId]=(s[a.sessionId]??0)+1};for(let a=0;a<n.length;a+=BMe){let c=n.slice(a,a+BMe);await Promise.all(c.map(o))}for(let[a,c]of Object.entries(i)){let l=s[a]??0;T0.info(`Session ${a}: fetched ${l} attachment(s), ${c-l} already present`)}};import{Buffer as HMe}from"buffer";import oMt from"path";var GMe=Ee("repo"),gn=(t,e={})=>Gn("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),ND=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{GMe.info("Getting runner diffs");let n=await cMt(r),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!e){let m=uMt(s);await dMt(m,r)}GMe.info("Changes after processing"),await SZ(r);let o=await vZ(s,r);if(await yZ(o,r),i=await lMt(r),!i)return{hasChanges:!1,ignored:o};await gn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await gn(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await WMe(r),{hasChanges:!1,ignored:o};let u=await gn(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await gn(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let _=await gn(["diff",t.sha,"HEAD","--binary"],a),y=String(_.stdout??"");f!==y&&(p=HMe.from(y).toString("base64"))}await WMe(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(h.diffBinary=HMe.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},WMe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await gn(["reset","--soft","HEAD~1"],{cwd:t})},yZ=async(t=[],e=process.cwd())=>{await gn(["add",".",...t],{cwd:e})},SZ=async(t=process.cwd())=>{let e=await gn(["status","-s"],{cwd:t});return String(e.stdout??"")},YMe=/.. (.+)?\.log$/,aMt=[YMe],cMt=async(t=process.cwd())=>{let e=await SZ(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
716
716
|
`).filter(i=>aMt.some(o=>o instanceof RegExp?o.test(i):i===o)?!1:i[1]?.trim()!=="")).length!==0,status:e}},lMt=async(t=process.cwd())=>{try{return await gn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},EZ=async(t=process.cwd())=>{let{stdout:e}=await gn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},KMe=async(t=process.cwd())=>{let{stdout:e}=await gn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},vZ=async(t,e=process.cwd())=>{t||=await SZ(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(`
|
|
717
717
|
`).forEach(i=>{r.forEach(o=>{let a=i===`?? ${o}`,c=i.startsWith(`?? ${o}/`)||i.startsWith(`?? ${o}${oMt.sep}`);(a||c)&&n.push(`:!${o}`)});let s=i.match(YMe)?.[1];s&&n.push(`:!${s}.log`)}),n},JMe=async(t=process.cwd())=>{await gn(["reset","--hard","HEAD"],{cwd:t})},ZMe=async(t=process.cwd())=>{let e=await gn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
718
718
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},uMt=t=>{let e=t.split(`
|
package/dist/index.js
CHANGED
|
@@ -98,7 +98,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
98
98
|
`,LF:`
|
|
99
99
|
`,concatBytes:lL},wDe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},RDe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:wDe};import{Buffer as IDe}from"buffer";var gte=(t,e)=>t?void 0:CDe.bind(void 0,e),CDe=function*(t,e){if(typeof e!="string"&&!jt(e)&&!IDe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},_te=(t,e)=>t?PDe.bind(void 0,e):ODe.bind(void 0,e),PDe=function*(t,e){yte(t,e),yield e},ODe=function*(t,e){if(yte(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},yte=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
100
100
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
101
|
-
if (condition) { yield value; }`)};import{Buffer as NDe}from"buffer";import{StringDecoder as kDe}from"string_decoder";var JA=(t,e,r)=>{if(r)return;if(t)return{transform:MDe.bind(void 0,new TextEncoder)};let n=new kDe(e);return{transform:DDe.bind(void 0,n),final:LDe.bind(void 0,n)}},MDe=function*(t,e){NDe.isBuffer(e)?yield uo(e):typeof e=="string"?yield t.encode(e):yield e},DDe=function*(t,e){yield jt(e)?t.write(e):e},LDe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Ste}from"util";var dL=Ste(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),XA=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=UDe}=e[r];for await(let i of n(t))yield*XA(i,e,r+1)},Ete=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*$De(r,Number(e),t)},$De=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*XA(n,r,e+1)},vte=Ste(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),UDe=function*(t){yield t};var fL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Tte=(t,e)=>[...e.flatMap(r=>[...bl(r,t,0)]),...S_(t)],bl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=BDe}=e[r];for(let i of n(t))yield*bl(i,e,r+1)},S_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*FDe(r,Number(e),t)},FDe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*bl(n,r,e+1)},BDe=function*(t){yield t};var pL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Ate(t,o,s),l=Tl(e),u=Tl(r),d=l?dL.bind(void 0,XA,a):fL.bind(void 0,bl),f=l||u?dL.bind(void 0,Ete,a):fL.bind(void 0,S_),p=l||u?vte.bind(void 0,a):void 0;return{stream:new jDe({writableObjectMode:n,writableHighWaterMark:bte(n),readableObjectMode:i,readableHighWaterMark:bte(i),transform(m,v,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},QA=(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=Ate(o,r,a);t=Tte(c,t)}return t},Ate=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:gte(n,a)},JA(r,o,n),ZA(r,s,n,c),{transform:t,final:e},{transform:_te(i,a)},mte({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var xte=(t,e)=>{for(let r of zDe(t))GDe(t,r,e)},zDe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),GDe=(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 ${Ia[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>VDe(a,n));r.input=l_(o)},VDe=(t,e)=>{let r=QA(t,e,"utf8",!0);return qDe(r),l_(r)},qDe=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 KDe,appendFileSync as ZDe}from"fs";var ex=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Jd(r,n)&&!hn.has(e)&&HDe(n)&&(t.some(({type:i,value:s})=>i==="native"&&WDe.has(s))||t.every(({type:i})=>qn.has(i))),HDe=t=>t===1||t===2,WDe=new Set(["pipe","overlapped"]),wte=async(t,e,r,n)=>{for await(let i of t)YDe(e)||Ite(i,r,n)},Rte=(t,e,r)=>{for(let n of t)Ite(n,e,r)},YDe=t=>t._readableState.pipes.length>0,Ite=(t,e,r)=>{let n=hA(t);as({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Cte=({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)=>JDe({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},JDe=({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=Pee(t,s,d),p=uo(f),{stdioItems:h,objectMode:m}=e[r],v=XDe([p],h,c,n),{serializedResult:E,finalResult:b=E}=QDe({chunks:v,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});eLe({serializedResult:E,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&tLe(E,h,i),A}catch(S){return n.error=S,A}},XDe=(t,e,r,n)=>{try{return QA(t,e,r,!1)}catch(i){return n.error=i,t}},QDe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:l_(t)};let o=VX(t,r);return n[s]?{serializedResult:o,finalResult:uL(o,!i[s],e)}:{serializedResult:o}},eLe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!ex({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=uL(t,!1,o);try{Rte(a,e,n)}catch(c){r.error??=c}},tLe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>YA.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?ZDe(n,t):(r.add(s),KDe(n,t))}};var Pte=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ho(e,r,"all")]:Array.isArray(e)?[ho(t,r,"all"),...e]:jt(t)&&jt(e)?SD([t,e]):`${t}${e}`};import{once as hL}from"events";var Ote=async(t,e)=>{let[r,n]=await rLe(t);return e.isForcefullyTerminated??=!1,[r,n]},rLe=async t=>{let[e,r]=await Promise.allSettled([hL(t,"spawn"),hL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Nte(t):r.value},Nte=async t=>{try{return await hL(t,"exit")}catch{return Nte(t)}},kte=async t=>{let[e,r]=await t;if(!nLe(e,r)&&mL(e,r))throw new Ai;return[e,r]},nLe=(t,e)=>t===void 0&&e===void 0,mL=(t,e)=>t!==0||e!==null;var Mte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=iLe(t,e,r),o=s?.code==="ETIMEDOUT",a=Cee(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},iLe=(t,e,r)=>t!==void 0?t:mL(e,r)?new Ai:void 0;var Dte=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=oLe(t,e,r),d=lLe({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return cf(d,c,l)},oLe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gA(t,e,r),a=aLe(r),{file:c,commandArguments:l,options:u}=LA(t,e,a);cLe(u);let d=dte(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},aLe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,cLe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&tx("ipcInput"),t&&tx("ipc: true"),r&&tx("detached: true"),n&&tx("cancelSignal")},tx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},lLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=uLe({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}=Mte(c,r),{output:h,error:m=l}=Cte({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),v=h.map((b,A)=>ho(b,r,A)),E=ho(Pte(h,r),r,"all");return fLe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:v,all:E,options:r,command:n,escapedCommand:i,startTime:a})},uLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{xte(s,r);let a=dLe(r);return sLe(...$A(t,e,a))}catch(a){return af({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},dLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:VA(e)}),fLe=({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?qA({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):y_({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 Q$e}from"events";import{spawn as e1e}from"child_process";import Bte from"process";import{once as gL,on as pLe}from"events";var Lte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(ef({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:PA(t)}),hLe({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),hLe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{wA(e,i);let s=Ra(t,e,r),o=new AbortController;try{return await Promise.race([mLe(s,n,o),gLe(s,r,o),_Le(s,r,o)])}catch(a){throw tf(t),a}finally{o.abort(),RA(e,i)}},mLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await gL(t,"message",{signal:r});return n}for await(let[n]of pLe(t,"message",{signal:r}))if(e(n))return n},gLe=async(t,e,{signal:r})=>{await gL(t,"disconnect",{signal:r}),T7(e)},_Le=async(t,e,{signal:r})=>{let[n]=await gL(t,"strict:error",{signal:r});throw bA(n,e)};import{once as Ute,on as yLe}from"events";var Fte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>_L({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),_L=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{ef({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:PA(t)}),wA(e,s);let o=Ra(t,e,r),a=new AbortController,c={};return SLe(t,o,a),ELe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),vLe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},SLe=async(t,e,r)=>{try{await Ute(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ELe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Ute(t,"strict:error",{signal:r.signal});n.error=bA(i,e),r.abort()}catch{}},vLe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of yLe(r,"message",{signal:s.signal}))$te(o),yield c}catch{$te(o)}finally{s.abort(),RA(e,a),n||tf(t),i&&await t}},$te=({error:t})=>{if(t)throw t};var jte=(t,{ipc:e})=>{Object.assign(t,Gte(t,!1,e))},zte=()=>{let t=Bte,e=!0,r=Bte.channel!==void 0;return{...Gte(t,e,r),getCancelSignal:K7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Gte=(t,e,r)=>({sendMessage:MA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Lte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Fte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as TLe}from"child_process";import{PassThrough as bLe,Readable as ALe,Writable as xLe,Duplex as wLe}from"stream";var Vte=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{aL(n);let a=new TLe;RLe(a,n),Object.assign(a,{readable:ILe,writable:CLe,duplex:PLe});let c=af({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=OLe(c,o,i);return{subprocess:a,promise:l}},RLe=(t,e)=>{let r=E_(),n=E_(),i=E_(),s=Array.from({length:e.length-3},E_),o=E_(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},E_=()=>{let t=new bLe;return t.end(),t},ILe=()=>new ALe({read(){}}),CLe=()=>new xLe({write(){}}),PLe=()=>new wLe({read(){},write(){}}),OLe=async(t,e,r)=>cf(t,e,r);import{createReadStream as qte,createWriteStream as Hte}from"fs";import{Buffer as NLe}from"buffer";import{Readable as v_,Writable as kLe,Duplex as MLe}from"stream";var Yte=(t,e)=>KA(DLe,t,e,!1),T_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ia[t]}.`)},Wte={fileNumber:T_,generator:pL,asyncGenerator:pL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:MLe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},DLe={input:{...Wte,fileUrl:({value:t})=>({stream:qte(t)}),filePath:({value:{file:t}})=>({stream:qte(t)}),webStream:({value:t})=>({stream:v_.fromWeb(t)}),iterable:({value:t})=>({stream:v_.from(t)}),asyncIterable:({value:t})=>({stream:v_.from(t)}),string:({value:t})=>({stream:v_.from(t)}),uint8Array:({value:t})=>({stream:v_.from(NLe.from(t))})},output:{...Wte,fileUrl:({value:t})=>({stream:Hte(t)}),filePath:({value:{file:t,append:e}})=>({stream:Hte(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:kLe.fromWeb(t)}),iterable:T_,asyncIterable:T_,string:T_,uint8Array:T_}};import{on as LLe,once as Kte}from"events";import{PassThrough as $Le,getDefaultHighWaterMark as ULe}from"stream";import{finished as Xte}from"stream/promises";function Al(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)SL(i);let e=t.some(({readableObjectMode:i})=>i),r=FLe(t,e),n=new yL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var FLe=(t,e)=>{if(t.length===0)return ULe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},yL=class extends $Le{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(SL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=BLe(this,this.#e,this.#s);let r=GLe({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(SL(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)}},BLe=async(t,e,r)=>{rx(t,Zte);let n=new AbortController;try{await Promise.race([jLe(t,n),zLe(t,e,r,n)])}finally{n.abort(),rx(t,-Zte)}},jLe=async(t,{signal:e})=>{try{await Xte(t,{signal:e,cleanup:!0})}catch(r){throw Qte(t,r),r}},zLe=async(t,e,r,{signal:n})=>{for await(let[i]of LLe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},SL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},GLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{rx(t,Jte);let a=new AbortController;try{await Promise.race([VLe(s,e,a),qLe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),HLe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),rx(t,-Jte)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?EL(t):WLe(t))},VLe=async(t,e,{signal:r})=>{try{await t,r.aborted||EL(e)}catch(n){r.aborted||Qte(e,n)}},qLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Xte(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;ere(o)?i.add(e):tre(t,o)}},HLe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Kte(t,i,{signal:s}),!t.readable)return Kte(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},WLe=t=>{t.writable&&t.end()},Qte=(t,e)=>{ere(e)?EL(t):tre(t,e)},ere=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",EL=t=>{(t.readable||t.writable)&&t.destroy()},tre=(t,e)=>{t.destroyed||(t.once("error",YLe),t.destroy(e))},YLe=()=>{},rx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Zte=2,Jte=1;import{finished as rre}from"stream/promises";var uf=(t,e)=>{t.pipe(e),KLe(t,e),ZLe(t,e)},KLe=async(t,e)=>{if(!(bi(t)||bi(e))){try{await rre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}vL(e)}},vL=t=>{t.writable&&t.end()},ZLe=async(t,e)=>{if(!(bi(t)||bi(e))){try{await rre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}TL(t)}},TL=t=>{t.readable&&t.destroy()};var nre=(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})=>qn.has(c)))JLe(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!qn.has(c)))QLe({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]:Al(s);uf(o,i)}},JLe=(t,e,r,n)=>{r==="output"?uf(t.stdio[n],e):uf(e,t.stdio[n]);let i=XLe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},XLe=["stdin","stdout","stderr"],QLe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;e$e(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},e$e=(t,{signal:e})=>{bi(t)&&El(t,t$e,e)},t$e=2;import{addAbortListener as i$e}from"events";var xl=[];xl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&xl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&xl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var nx=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",bL=Symbol.for("signal-exit emitter"),AL=globalThis,r$e=Object.defineProperty.bind(Object),xL=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(AL[bL])return AL[bL];r$e(AL,bL,{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}},ix=class{},n$e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),wL=class extends ix{onExit(){return()=>{}}load(){}unload(){}},RL=class extends ix{#e=IL.platform==="win32"?"SIGINT":"SIGHUP";#r=new xL;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of xl)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(!nx(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 xl)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,xl.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 nx(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"&&nx(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)}},IL=globalThis.process,{onExit:ire,load:cyt,unload:lyt}=n$e(nx(IL)?new RL(IL):new wL);var sre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ire(()=>{t.kill()});i$e(n,()=>{i()})};var are=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=mA(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=s$e(r,n,i),{sourceStream:d,sourceError:f}=a$e(t,l),{options:p,fileDescriptors:h}=ls.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},s$e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=o$e(t,e,...r),a=xA(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},o$e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(ore,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||_D(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]=sA(r,...n);return{destination:e(ore)(i,s,o),pipeOptions:o}}if(ls.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}`)},ore=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),a$e=(t,e)=>{try{return{sourceStream:rf(t,e)}}catch(r){return{sourceError:r}}};var lre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=c$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw CL({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},c$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return TL(t),n;if(e!==void 0)return vL(r),e},CL=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>af({error:t,command:cre,escapedCommand:cre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),cre="source.pipe(destination)";var ure=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 l$e}from"stream/promises";var dre=(t,e,r)=>{let n=sx.has(e)?d$e(t,e):u$e(t,e);return El(t,p$e,r.signal),El(e,h$e,r.signal),f$e(e),n},u$e=(t,e)=>{let r=Al([t]);return uf(r,e),sx.set(e,r),r},d$e=(t,e)=>{let r=sx.get(e);return r.add(t),r},f$e=async t=>{try{await l$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}sx.delete(t)},sx=new WeakMap,p$e=2,h$e=1;import{aborted as m$e}from"util";var fre=(t,e)=>t===void 0?[]:[g$e(t,e)],g$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await m$e(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw CL({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ox=(t,...e)=>{if(Pt(e[0]))return ox.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=are(t,...e),i=_$e({...n,destination:r});return i.pipe=ox.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},_$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=y$e(t,i);lre({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=dre(e,s,d);return await Promise.race([ure(u),...fre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},y$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as x$e}from"timers/promises";import{on as S$e}from"events";import{getDefaultHighWaterMark as E$e}from"stream";var ax=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return v$e(e,o),hre({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},v$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},PL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;T$e(e,o,t);let a=t.readableObjectMode&&!s;return hre({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},T$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},hre=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=S$e(t,"data",{signal:e.signal,highWaterMark:pre,highWatermark:pre});return b$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},OL=E$e(!0),pre=OL,b$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=A$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*bl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*S_(a)}},A$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[JA(t,r,!e),ZA(t,i,!n,{})].filter(Boolean);var mre=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=w$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([R$e(t),d]);return}let f=cL(c,r),p=PL({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([I$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},w$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!ex({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=PL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await wte(a,t,r,s)},R$e=async t=>{await x$e(),t.readableFlowing===null&&t.resume()},I$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await jA(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await zA(r,{maxBuffer:s})):await of(r,{maxBuffer:s})}catch(a){return gre(wee({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},NL=async t=>{try{return await t}catch(e){return gre(e)}},gre=({bufferedData:t})=>zX(t)?new Uint8Array(t):t;import{finished as C$e}from"stream/promises";var b_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=P$e(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],C$e(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||k$e(a,e,r,n)}finally{o.abort()}},P$e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&O$e(t,r,n),n},O$e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{N$e(e,r),n.call(t,...i)}},N$e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},k$e=(t,e,r,n)=>{if(!M$e(t,e,r,n))throw t},M$e=(t,e,r,n=!0)=>r.propagating?_re(t)||cx(t):(r.propagating=!0,kL(r,e)===n?_re(t):cx(t)),kL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",cx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_re=t=>t?.code==="EPIPE";var yre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>ML({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),ML=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=b_(t,e,l);if(kL(l,e)){await u;return}let[d]=await Promise.all([mre({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 Sre=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Al([t,e].filter(Boolean)):void 0,Ere=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>ML({...D$e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:L$e(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),D$e=({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}},L$e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as $$e}from"events";var vre=t=>Jd(t,"ipc"),Tre=(t,e)=>{let r=hA(t);as({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var bre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=vre(s),a=fo(e,"ipc"),c=fo(r,"ipc");for await(let l of _L({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ree(t,i,c),i.push(l)),o&&Tre(l,s);return i},Are=async(t,e)=>(await Promise.allSettled([t]),e);var xre=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:v,controller:E})=>{let b=Ote(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=yre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),P=Ere({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),O=[],U=bre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),I=U$e(m,t,A),M=F$e(h,A);try{return await Promise.race([Promise.all([{},kte(b),Promise.all(S),P,U,see(t,d),...I,...M]),v,B$e(t,E),...eee(t,s,f,E),...v7({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:E}),...X7({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(B){return f.terminationReason??="other",Promise.all([{error:B},b,Promise.all(S.map(_=>NL(_))),NL(P),Are(U,O),Promise.allSettled(I),Promise.allSettled(M)])}},U$e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:b_(n,i,r)),F$e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>wi(s,{checkOpen:!1})&&!bi(s)).map(({type:i,value:s,stream:o=s})=>b_(o,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),B$e=async(t,{signal:e})=>{let[r]=await $$e(t,"error",{signal:e});throw r};var wre=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),A_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=cs();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},df=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 j$e}from"stream";import{callbackify as z$e}from"util";import{finished as Rre}from"stream/promises";var DL=async t=>{if(t!==void 0)try{await LL(t)}catch{}},Ire=async t=>{if(t!==void 0)try{await $L(t)}catch{}},LL=async t=>{await Rre(t,{cleanup:!0,readable:!1,writable:!0})},$L=async t=>{await Rre(t,{cleanup:!0,readable:!0,writable:!1})},lx=async(t,e)=>{if(await t,e)throw e},ux=(t,e,r)=>{r&&!cx(r)?t.destroy(r):e&&t.destroy()};var Cre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||hn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=UL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=FL(a,o),{read:f,onStdoutDataDone:p}=BL({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new j$e({read:f,destroy:z$e(zL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return jL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},UL=(t,e,r)=>{let n=rf(t,e),i=A_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},FL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:OL},BL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=cs(),o=ax({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){G$e(this,o,s)},onStdoutDataDone:s}},G$e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},jL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await $L(t),await n,await DL(i),await e,r.readable&&r.push(null)}catch(s){await DL(i),Pre(r,s)}},zL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await df(r,e)&&(Pre(t,n),await lx(e,n))},Pre=(t,e)=>{ux(t,t.readable,e)};import{Writable as V$e}from"stream";import{callbackify as Ore}from"util";var Nre=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=GL(t,r,e),o=new V$e({...VL(n,t,i),destroy:Ore(HL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return qL(n,o),o},GL=(t,e,r)=>{let n=xA(t,e),i=A_(r,n,"writableFinal"),s=A_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},VL=(t,e,r)=>({write:q$e.bind(void 0,t),final:Ore(H$e.bind(void 0,t,e,r))}),q$e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},H$e=async(t,e,r)=>{await df(r,e)&&(t.writable&&t.end(),await e)},qL=async(t,e,r)=>{try{await LL(t),e.writable&&e.end()}catch(n){await Ire(r),kre(e,n)}},HL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await df(r,e),await df(n,e)&&(kre(t,i),await lx(e,i))},kre=(t,e)=>{ux(t,t.writable,e)};import{Duplex as W$e}from"stream";import{callbackify as Y$e}from"util";var Mre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||hn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=UL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=GL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=FL(c,a),{read:v,onStdoutDataDone:E}=BL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new W$e({read:v,...VL(u,t,d),destroy:Y$e(K$e.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 jL({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),qL(u,b,c),b},K$e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([zL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),HL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var WL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||hn.has(e),o=rf(t,r),a=ax({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return Z$e(a,o,t)},Z$e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Dre=(t,{encoding:e})=>{let r=wre();t.readable=Cre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Nre.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Mre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=WL.bind(void 0,t,e),t[Symbol.asyncIterator]=WL.bind(void 0,t,e,{})};var Lre=(t,e)=>{for(let[r,n]of X$e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},J$e=(async()=>{})().constructor.prototype,X$e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(J$e,t)]);var $re=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=t1e(t,e,r),{subprocess:f,promise:p}=n1e({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ox.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Lre(f,p),ls.set(f,{options:u,fileDescriptors:d}),f},t1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gA(t,e,r),{file:a,commandArguments:c,options:l}=LA(t,e,r),u=r1e(l),d=Yte(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},r1e=({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}},n1e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=e1e(...$A(t,e,r))}catch(h){return Vte({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;Q$e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];nre(c,a,l),sre(c,r,l);let d={},f=cs();c.kill=S7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Sre(c,r),Dre(c,r),jte(c,r);let p=i1e({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}},i1e=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,v]=await xre({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((S,P)=>ho(S,e,P)),b=ho(m,e,"all"),A=s1e({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:v,context:c,options:e,command:o,escapedCommand:a,startTime:r});return cf(A,n,e)},s1e=({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?y_({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 us,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):qA({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var dx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,o1e(n,t[n],i)]));return{...t,...r}},o1e=(t,e,r)=>a1e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,a1e=new Set(["env",...bD]);var Ca=(t,e,r,n)=>{let i=(o,a,c)=>Ca(o,a,r,c),s=(...o)=>c1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},c1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Pt(s))return i(t,dx(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=l1e({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?Dte(a,c,l):$re(a,c,l,i)},l1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=YX(e)?KX(e,r):[e,...r],[o,a,c]=sA(...s),l=dx(dx(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 Ure=({file:t,commandArguments:e})=>Bre(t,e),Fre=({file:t,commandArguments:e})=>({...Bre(t,e),isSync:!0}),Bre=(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]=u1e(t);return{file:r,commandArguments:n}},u1e=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(d1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},d1e=/ +/g;var jre=(t,e,r)=>{t.sync=e(f1e,r),t.s=t.sync},zre=({options:t})=>Gre(t),f1e=({options:t})=>({...Gre(t),isSync:!0}),Gre=t=>({options:{...p1e(t),...t}}),p1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Vre={preferLocal:!0};var qre=Ca(()=>({})),XEt=Ca(()=>({isSync:!0})),Hre=Ca(Ure),QEt=Ca(Fre),evt=Ca(ree),tvt=Ca(zre,{},Vre,jre),{sendMessage:rvt,getOneMessage:nvt,getEachMessage:ivt,getCancelSignal:svt}=zte();var Wre=!1,Yre=()=>{Wre=!0},fs=()=>Wre;var x_=null,Kre=t=>(x_&&x_.destroy(),x_=new mo({totalAllowedTime:t}),x_),Zre=()=>x_;var mo=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&&fs())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 Xb({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{he.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 Jre={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.0-git.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@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.1.5","@netlify/otel":"^6.0.4","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var _1e=m1e(import.meta.url),y1e=go.dirname(_1e),S1e=g1e(import.meta.url),ff=ye("shell"),YL=new Set,Xre={preferLocal:!0},Mr=(t,e,r)=>{let[n,i]=E1e(e,r),s={...Xre,...i},o=qre(t,n,s);ene(o,s),nne(o);let a=r?.idleTimeout;return a&&a>0&&rne(o,a),o},Qre=(t,e)=>{let r={...Xre,...e},n=Hre(t,r);return ene(n,r),nne(n),e?.idleTimeout&&e.idleTimeout>0&&rne(n,e.idleTimeout),n},E1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ene=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(_o.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Qg).pipe(_o.stdout),t.stderr?.pipe(new Qg).pipe(_o.stderr);return}t.stdout?.pipe(_o.stdout),t.stderr?.pipe(_o.stderr)},KL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_o.kill(-t.pid,e),ff.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return ff.error("Error killing process:",r),!1}},tne=t=>KL(t,"SIGKILL"),rne=(t,e)=>{let r=null,n=()=>{ff.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),KL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ff.log(`Force killing idle process ${t.pid}`),tne(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)},nne=t=>{YL.add(t);let e=Zre();if(e){let r=e.onTimesUp(()=>{ff.log(`Global timer expired, killing process ${t.pid}`),KL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ff.log(`Force killing process ${t.pid} after timeout`),tne(t))},5e3)});t.on("exit",()=>{YL.delete(t),r()}),t.on("error",()=>{YL.delete(t),r()})}};function ps(t,e){if(!_o.env.NETLIFY_LOCAL_MODE)try{let i=S1e.resolve(Jre.name),s=go.dirname(i);for(;s!==go.dirname(s);){let o=go.dirname(s);if(go.basename(o)==="node_modules"){let a=go.join(o,".bin",e);if(fx.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(_o.env.NODE_PATH){let i=go.join(_o.env.NODE_PATH,".bin",e);if(fx.existsSync(i))return i}let r=go.join(t,"node_modules",".bin",e);if(fx.existsSync(r))return r;let n=go.join(y1e,"..","node_modules",".bin",e);if(fx.existsSync(n))return n}var v1e=ye("utils"),T1e=t=>new Promise(e=>{setTimeout(e,t)});var px=(t,e=3e3)=>{let r=!1,n=null,i=[],s=null,o=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return s=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await T1e(e),!n)return r=!1,s=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return o.flush=async()=>{if((r||n)&&s)return await s,o.flush()},o.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},o},Pa=(t,e,r=!1)=>{let n=null,i=null,s=null,o=function(...a){i=a,s=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(s,i),i=null,s=null)},e),c&&(t.apply(s,i),i=null,s=null)};return o.cancel=()=>{clearTimeout(n),n=null,i=null,s=null},o.flush=()=>{if(n){clearTimeout(n);let a=i,c=s;n=null,i=null,s=null,t.apply(c,a)}},o},ine=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):v1e.error("Could not parse JSON",n))}},b1e=t=>t.charAt(0).toUpperCase()+t.slice(1),hs=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():b1e(e)).join(" ");function yo(t,e){e&&t.log(`Skill invoked: ${e}`)}var hx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),sne=(t,e,r=!1)=>{if(r)return;let n=60,i=55,s=".netlify.app",o="agent-",a=6;if(!e)return`${o}${t.slice(0,a)}`;let c=`--${e}${s}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=o.length+a){let u=Math.min(l-o.length,t.length);return`${o}${t.slice(0,u)}`}return t.slice(0,l)};var ZL=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}},A1e=1e4,JL=(t,e=A1e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as one}from"buffer";import x1e from"path";var ane=ye("repo"),lr=(t,e={})=>Mr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),mx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{ane.info("Getting runner diffs");let n=await R1e(r),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!e){let m=C1e(s);await P1e(m,r)}ane.info("Changes after processing"),await QL(r);let o=await t$(s,r);if(await XL(o,r),i=await I1e(r),!i)return{hasChanges:!1,ignored:o};await lr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await lr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await cne(r),{hasChanges:!1,ignored:o};let u=await lr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await lr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let v=await lr(["diff",t.sha,"HEAD","--binary"],a),E=String(v.stdout??"");f!==E&&(p=one.from(E).toString("base64"))}await cne(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(h.diffBinary=one.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},cne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await lr(["reset","--soft","HEAD~1"],{cwd:t})},XL=async(t=[],e=process.cwd())=>{await lr(["add",".",...t],{cwd:e})},QL=async(t=process.cwd())=>{let e=await lr(["status","-s"],{cwd:t});return String(e.stdout??"")},lne=/.. (.+)?\.log$/,w1e=[lne],R1e=async(t=process.cwd())=>{let e=await QL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
101
|
+
if (condition) { yield value; }`)};import{Buffer as NDe}from"buffer";import{StringDecoder as kDe}from"string_decoder";var JA=(t,e,r)=>{if(r)return;if(t)return{transform:MDe.bind(void 0,new TextEncoder)};let n=new kDe(e);return{transform:DDe.bind(void 0,n),final:LDe.bind(void 0,n)}},MDe=function*(t,e){NDe.isBuffer(e)?yield uo(e):typeof e=="string"?yield t.encode(e):yield e},DDe=function*(t,e){yield jt(e)?t.write(e):e},LDe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Ste}from"util";var dL=Ste(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),XA=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=UDe}=e[r];for await(let i of n(t))yield*XA(i,e,r+1)},Ete=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*$De(r,Number(e),t)},$De=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*XA(n,r,e+1)},vte=Ste(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),UDe=function*(t){yield t};var fL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Tte=(t,e)=>[...e.flatMap(r=>[...bl(r,t,0)]),...S_(t)],bl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=BDe}=e[r];for(let i of n(t))yield*bl(i,e,r+1)},S_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*FDe(r,Number(e),t)},FDe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*bl(n,r,e+1)},BDe=function*(t){yield t};var pL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Ate(t,o,s),l=Tl(e),u=Tl(r),d=l?dL.bind(void 0,XA,a):fL.bind(void 0,bl),f=l||u?dL.bind(void 0,Ete,a):fL.bind(void 0,S_),p=l||u?vte.bind(void 0,a):void 0;return{stream:new jDe({writableObjectMode:n,writableHighWaterMark:bte(n),readableObjectMode:i,readableHighWaterMark:bte(i),transform(m,v,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},QA=(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=Ate(o,r,a);t=Tte(c,t)}return t},Ate=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:gte(n,a)},JA(r,o,n),ZA(r,s,n,c),{transform:t,final:e},{transform:_te(i,a)},mte({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var xte=(t,e)=>{for(let r of zDe(t))GDe(t,r,e)},zDe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),GDe=(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 ${Ia[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>VDe(a,n));r.input=l_(o)},VDe=(t,e)=>{let r=QA(t,e,"utf8",!0);return qDe(r),l_(r)},qDe=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 KDe,appendFileSync as ZDe}from"fs";var ex=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Jd(r,n)&&!hn.has(e)&&HDe(n)&&(t.some(({type:i,value:s})=>i==="native"&&WDe.has(s))||t.every(({type:i})=>qn.has(i))),HDe=t=>t===1||t===2,WDe=new Set(["pipe","overlapped"]),wte=async(t,e,r,n)=>{for await(let i of t)YDe(e)||Ite(i,r,n)},Rte=(t,e,r)=>{for(let n of t)Ite(n,e,r)},YDe=t=>t._readableState.pipes.length>0,Ite=(t,e,r)=>{let n=hA(t);as({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Cte=({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)=>JDe({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},JDe=({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=Pee(t,s,d),p=uo(f),{stdioItems:h,objectMode:m}=e[r],v=XDe([p],h,c,n),{serializedResult:E,finalResult:b=E}=QDe({chunks:v,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});eLe({serializedResult:E,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&tLe(E,h,i),A}catch(S){return n.error=S,A}},XDe=(t,e,r,n)=>{try{return QA(t,e,r,!1)}catch(i){return n.error=i,t}},QDe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:l_(t)};let o=VX(t,r);return n[s]?{serializedResult:o,finalResult:uL(o,!i[s],e)}:{serializedResult:o}},eLe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!ex({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=uL(t,!1,o);try{Rte(a,e,n)}catch(c){r.error??=c}},tLe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>YA.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?ZDe(n,t):(r.add(s),KDe(n,t))}};var Pte=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ho(e,r,"all")]:Array.isArray(e)?[ho(t,r,"all"),...e]:jt(t)&&jt(e)?SD([t,e]):`${t}${e}`};import{once as hL}from"events";var Ote=async(t,e)=>{let[r,n]=await rLe(t);return e.isForcefullyTerminated??=!1,[r,n]},rLe=async t=>{let[e,r]=await Promise.allSettled([hL(t,"spawn"),hL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Nte(t):r.value},Nte=async t=>{try{return await hL(t,"exit")}catch{return Nte(t)}},kte=async t=>{let[e,r]=await t;if(!nLe(e,r)&&mL(e,r))throw new Ai;return[e,r]},nLe=(t,e)=>t===void 0&&e===void 0,mL=(t,e)=>t!==0||e!==null;var Mte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=iLe(t,e,r),o=s?.code==="ETIMEDOUT",a=Cee(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},iLe=(t,e,r)=>t!==void 0?t:mL(e,r)?new Ai:void 0;var Dte=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=oLe(t,e,r),d=lLe({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return cf(d,c,l)},oLe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gA(t,e,r),a=aLe(r),{file:c,commandArguments:l,options:u}=LA(t,e,a);cLe(u);let d=dte(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},aLe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,cLe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&tx("ipcInput"),t&&tx("ipc: true"),r&&tx("detached: true"),n&&tx("cancelSignal")},tx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},lLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=uLe({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}=Mte(c,r),{output:h,error:m=l}=Cte({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),v=h.map((b,A)=>ho(b,r,A)),E=ho(Pte(h,r),r,"all");return fLe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:v,all:E,options:r,command:n,escapedCommand:i,startTime:a})},uLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{xte(s,r);let a=dLe(r);return sLe(...$A(t,e,a))}catch(a){return af({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},dLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:VA(e)}),fLe=({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?qA({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):y_({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 Q$e}from"events";import{spawn as e1e}from"child_process";import Bte from"process";import{once as gL,on as pLe}from"events";var Lte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(ef({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:PA(t)}),hLe({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),hLe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{wA(e,i);let s=Ra(t,e,r),o=new AbortController;try{return await Promise.race([mLe(s,n,o),gLe(s,r,o),_Le(s,r,o)])}catch(a){throw tf(t),a}finally{o.abort(),RA(e,i)}},mLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await gL(t,"message",{signal:r});return n}for await(let[n]of pLe(t,"message",{signal:r}))if(e(n))return n},gLe=async(t,e,{signal:r})=>{await gL(t,"disconnect",{signal:r}),T7(e)},_Le=async(t,e,{signal:r})=>{let[n]=await gL(t,"strict:error",{signal:r});throw bA(n,e)};import{once as Ute,on as yLe}from"events";var Fte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>_L({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),_L=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{ef({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:PA(t)}),wA(e,s);let o=Ra(t,e,r),a=new AbortController,c={};return SLe(t,o,a),ELe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),vLe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},SLe=async(t,e,r)=>{try{await Ute(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ELe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Ute(t,"strict:error",{signal:r.signal});n.error=bA(i,e),r.abort()}catch{}},vLe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of yLe(r,"message",{signal:s.signal}))$te(o),yield c}catch{$te(o)}finally{s.abort(),RA(e,a),n||tf(t),i&&await t}},$te=({error:t})=>{if(t)throw t};var jte=(t,{ipc:e})=>{Object.assign(t,Gte(t,!1,e))},zte=()=>{let t=Bte,e=!0,r=Bte.channel!==void 0;return{...Gte(t,e,r),getCancelSignal:K7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Gte=(t,e,r)=>({sendMessage:MA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Lte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Fte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as TLe}from"child_process";import{PassThrough as bLe,Readable as ALe,Writable as xLe,Duplex as wLe}from"stream";var Vte=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{aL(n);let a=new TLe;RLe(a,n),Object.assign(a,{readable:ILe,writable:CLe,duplex:PLe});let c=af({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=OLe(c,o,i);return{subprocess:a,promise:l}},RLe=(t,e)=>{let r=E_(),n=E_(),i=E_(),s=Array.from({length:e.length-3},E_),o=E_(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},E_=()=>{let t=new bLe;return t.end(),t},ILe=()=>new ALe({read(){}}),CLe=()=>new xLe({write(){}}),PLe=()=>new wLe({read(){},write(){}}),OLe=async(t,e,r)=>cf(t,e,r);import{createReadStream as qte,createWriteStream as Hte}from"fs";import{Buffer as NLe}from"buffer";import{Readable as v_,Writable as kLe,Duplex as MLe}from"stream";var Yte=(t,e)=>KA(DLe,t,e,!1),T_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ia[t]}.`)},Wte={fileNumber:T_,generator:pL,asyncGenerator:pL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:MLe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},DLe={input:{...Wte,fileUrl:({value:t})=>({stream:qte(t)}),filePath:({value:{file:t}})=>({stream:qte(t)}),webStream:({value:t})=>({stream:v_.fromWeb(t)}),iterable:({value:t})=>({stream:v_.from(t)}),asyncIterable:({value:t})=>({stream:v_.from(t)}),string:({value:t})=>({stream:v_.from(t)}),uint8Array:({value:t})=>({stream:v_.from(NLe.from(t))})},output:{...Wte,fileUrl:({value:t})=>({stream:Hte(t)}),filePath:({value:{file:t,append:e}})=>({stream:Hte(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:kLe.fromWeb(t)}),iterable:T_,asyncIterable:T_,string:T_,uint8Array:T_}};import{on as LLe,once as Kte}from"events";import{PassThrough as $Le,getDefaultHighWaterMark as ULe}from"stream";import{finished as Xte}from"stream/promises";function Al(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)SL(i);let e=t.some(({readableObjectMode:i})=>i),r=FLe(t,e),n=new yL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var FLe=(t,e)=>{if(t.length===0)return ULe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},yL=class extends $Le{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(SL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=BLe(this,this.#e,this.#s);let r=GLe({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(SL(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)}},BLe=async(t,e,r)=>{rx(t,Zte);let n=new AbortController;try{await Promise.race([jLe(t,n),zLe(t,e,r,n)])}finally{n.abort(),rx(t,-Zte)}},jLe=async(t,{signal:e})=>{try{await Xte(t,{signal:e,cleanup:!0})}catch(r){throw Qte(t,r),r}},zLe=async(t,e,r,{signal:n})=>{for await(let[i]of LLe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},SL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},GLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{rx(t,Jte);let a=new AbortController;try{await Promise.race([VLe(s,e,a),qLe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),HLe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),rx(t,-Jte)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?EL(t):WLe(t))},VLe=async(t,e,{signal:r})=>{try{await t,r.aborted||EL(e)}catch(n){r.aborted||Qte(e,n)}},qLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Xte(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;ere(o)?i.add(e):tre(t,o)}},HLe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Kte(t,i,{signal:s}),!t.readable)return Kte(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},WLe=t=>{t.writable&&t.end()},Qte=(t,e)=>{ere(e)?EL(t):tre(t,e)},ere=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",EL=t=>{(t.readable||t.writable)&&t.destroy()},tre=(t,e)=>{t.destroyed||(t.once("error",YLe),t.destroy(e))},YLe=()=>{},rx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Zte=2,Jte=1;import{finished as rre}from"stream/promises";var uf=(t,e)=>{t.pipe(e),KLe(t,e),ZLe(t,e)},KLe=async(t,e)=>{if(!(bi(t)||bi(e))){try{await rre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}vL(e)}},vL=t=>{t.writable&&t.end()},ZLe=async(t,e)=>{if(!(bi(t)||bi(e))){try{await rre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}TL(t)}},TL=t=>{t.readable&&t.destroy()};var nre=(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})=>qn.has(c)))JLe(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!qn.has(c)))QLe({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]:Al(s);uf(o,i)}},JLe=(t,e,r,n)=>{r==="output"?uf(t.stdio[n],e):uf(e,t.stdio[n]);let i=XLe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},XLe=["stdin","stdout","stderr"],QLe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;e$e(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},e$e=(t,{signal:e})=>{bi(t)&&El(t,t$e,e)},t$e=2;import{addAbortListener as i$e}from"events";var xl=[];xl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&xl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&xl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var nx=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",bL=Symbol.for("signal-exit emitter"),AL=globalThis,r$e=Object.defineProperty.bind(Object),xL=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(AL[bL])return AL[bL];r$e(AL,bL,{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}},ix=class{},n$e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),wL=class extends ix{onExit(){return()=>{}}load(){}unload(){}},RL=class extends ix{#e=IL.platform==="win32"?"SIGINT":"SIGHUP";#r=new xL;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of xl)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(!nx(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 xl)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,xl.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 nx(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"&&nx(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)}},IL=globalThis.process,{onExit:ire,load:cyt,unload:lyt}=n$e(nx(IL)?new RL(IL):new wL);var sre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ire(()=>{t.kill()});i$e(n,()=>{i()})};var are=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=mA(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=s$e(r,n,i),{sourceStream:d,sourceError:f}=a$e(t,l),{options:p,fileDescriptors:h}=ls.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},s$e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=o$e(t,e,...r),a=xA(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},o$e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(ore,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||_D(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]=sA(r,...n);return{destination:e(ore)(i,s,o),pipeOptions:o}}if(ls.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}`)},ore=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),a$e=(t,e)=>{try{return{sourceStream:rf(t,e)}}catch(r){return{sourceError:r}}};var lre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=c$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw CL({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},c$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return TL(t),n;if(e!==void 0)return vL(r),e},CL=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>af({error:t,command:cre,escapedCommand:cre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),cre="source.pipe(destination)";var ure=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 l$e}from"stream/promises";var dre=(t,e,r)=>{let n=sx.has(e)?d$e(t,e):u$e(t,e);return El(t,p$e,r.signal),El(e,h$e,r.signal),f$e(e),n},u$e=(t,e)=>{let r=Al([t]);return uf(r,e),sx.set(e,r),r},d$e=(t,e)=>{let r=sx.get(e);return r.add(t),r},f$e=async t=>{try{await l$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}sx.delete(t)},sx=new WeakMap,p$e=2,h$e=1;import{aborted as m$e}from"util";var fre=(t,e)=>t===void 0?[]:[g$e(t,e)],g$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await m$e(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw CL({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ox=(t,...e)=>{if(Pt(e[0]))return ox.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=are(t,...e),i=_$e({...n,destination:r});return i.pipe=ox.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},_$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=y$e(t,i);lre({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=dre(e,s,d);return await Promise.race([ure(u),...fre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},y$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as x$e}from"timers/promises";import{on as S$e}from"events";import{getDefaultHighWaterMark as E$e}from"stream";var ax=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return v$e(e,o),hre({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},v$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},PL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;T$e(e,o,t);let a=t.readableObjectMode&&!s;return hre({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},T$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},hre=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=S$e(t,"data",{signal:e.signal,highWaterMark:pre,highWatermark:pre});return b$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},OL=E$e(!0),pre=OL,b$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=A$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*bl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*S_(a)}},A$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[JA(t,r,!e),ZA(t,i,!n,{})].filter(Boolean);var mre=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=w$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([R$e(t),d]);return}let f=cL(c,r),p=PL({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([I$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},w$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!ex({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=PL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await wte(a,t,r,s)},R$e=async t=>{await x$e(),t.readableFlowing===null&&t.resume()},I$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await jA(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await zA(r,{maxBuffer:s})):await of(r,{maxBuffer:s})}catch(a){return gre(wee({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},NL=async t=>{try{return await t}catch(e){return gre(e)}},gre=({bufferedData:t})=>zX(t)?new Uint8Array(t):t;import{finished as C$e}from"stream/promises";var b_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=P$e(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],C$e(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||k$e(a,e,r,n)}finally{o.abort()}},P$e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&O$e(t,r,n),n},O$e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{N$e(e,r),n.call(t,...i)}},N$e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},k$e=(t,e,r,n)=>{if(!M$e(t,e,r,n))throw t},M$e=(t,e,r,n=!0)=>r.propagating?_re(t)||cx(t):(r.propagating=!0,kL(r,e)===n?_re(t):cx(t)),kL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",cx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_re=t=>t?.code==="EPIPE";var yre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>ML({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),ML=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=b_(t,e,l);if(kL(l,e)){await u;return}let[d]=await Promise.all([mre({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 Sre=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Al([t,e].filter(Boolean)):void 0,Ere=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>ML({...D$e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:L$e(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),D$e=({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}},L$e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as $$e}from"events";var vre=t=>Jd(t,"ipc"),Tre=(t,e)=>{let r=hA(t);as({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var bre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=vre(s),a=fo(e,"ipc"),c=fo(r,"ipc");for await(let l of _L({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ree(t,i,c),i.push(l)),o&&Tre(l,s);return i},Are=async(t,e)=>(await Promise.allSettled([t]),e);var xre=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:v,controller:E})=>{let b=Ote(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=yre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),P=Ere({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),O=[],U=bre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),I=U$e(m,t,A),M=F$e(h,A);try{return await Promise.race([Promise.all([{},kte(b),Promise.all(S),P,U,see(t,d),...I,...M]),v,B$e(t,E),...eee(t,s,f,E),...v7({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:E}),...X7({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(B){return f.terminationReason??="other",Promise.all([{error:B},b,Promise.all(S.map(_=>NL(_))),NL(P),Are(U,O),Promise.allSettled(I),Promise.allSettled(M)])}},U$e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:b_(n,i,r)),F$e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>wi(s,{checkOpen:!1})&&!bi(s)).map(({type:i,value:s,stream:o=s})=>b_(o,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),B$e=async(t,{signal:e})=>{let[r]=await $$e(t,"error",{signal:e});throw r};var wre=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),A_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=cs();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},df=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 j$e}from"stream";import{callbackify as z$e}from"util";import{finished as Rre}from"stream/promises";var DL=async t=>{if(t!==void 0)try{await LL(t)}catch{}},Ire=async t=>{if(t!==void 0)try{await $L(t)}catch{}},LL=async t=>{await Rre(t,{cleanup:!0,readable:!1,writable:!0})},$L=async t=>{await Rre(t,{cleanup:!0,readable:!0,writable:!1})},lx=async(t,e)=>{if(await t,e)throw e},ux=(t,e,r)=>{r&&!cx(r)?t.destroy(r):e&&t.destroy()};var Cre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||hn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=UL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=FL(a,o),{read:f,onStdoutDataDone:p}=BL({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new j$e({read:f,destroy:z$e(zL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return jL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},UL=(t,e,r)=>{let n=rf(t,e),i=A_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},FL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:OL},BL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=cs(),o=ax({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){G$e(this,o,s)},onStdoutDataDone:s}},G$e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},jL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await $L(t),await n,await DL(i),await e,r.readable&&r.push(null)}catch(s){await DL(i),Pre(r,s)}},zL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await df(r,e)&&(Pre(t,n),await lx(e,n))},Pre=(t,e)=>{ux(t,t.readable,e)};import{Writable as V$e}from"stream";import{callbackify as Ore}from"util";var Nre=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=GL(t,r,e),o=new V$e({...VL(n,t,i),destroy:Ore(HL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return qL(n,o),o},GL=(t,e,r)=>{let n=xA(t,e),i=A_(r,n,"writableFinal"),s=A_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},VL=(t,e,r)=>({write:q$e.bind(void 0,t),final:Ore(H$e.bind(void 0,t,e,r))}),q$e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},H$e=async(t,e,r)=>{await df(r,e)&&(t.writable&&t.end(),await e)},qL=async(t,e,r)=>{try{await LL(t),e.writable&&e.end()}catch(n){await Ire(r),kre(e,n)}},HL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await df(r,e),await df(n,e)&&(kre(t,i),await lx(e,i))},kre=(t,e)=>{ux(t,t.writable,e)};import{Duplex as W$e}from"stream";import{callbackify as Y$e}from"util";var Mre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||hn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=UL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=GL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=FL(c,a),{read:v,onStdoutDataDone:E}=BL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new W$e({read:v,...VL(u,t,d),destroy:Y$e(K$e.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 jL({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),qL(u,b,c),b},K$e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([zL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),HL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var WL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||hn.has(e),o=rf(t,r),a=ax({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return Z$e(a,o,t)},Z$e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Dre=(t,{encoding:e})=>{let r=wre();t.readable=Cre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Nre.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Mre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=WL.bind(void 0,t,e),t[Symbol.asyncIterator]=WL.bind(void 0,t,e,{})};var Lre=(t,e)=>{for(let[r,n]of X$e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},J$e=(async()=>{})().constructor.prototype,X$e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(J$e,t)]);var $re=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=t1e(t,e,r),{subprocess:f,promise:p}=n1e({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ox.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Lre(f,p),ls.set(f,{options:u,fileDescriptors:d}),f},t1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gA(t,e,r),{file:a,commandArguments:c,options:l}=LA(t,e,r),u=r1e(l),d=Yte(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},r1e=({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}},n1e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=e1e(...$A(t,e,r))}catch(h){return Vte({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;Q$e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];nre(c,a,l),sre(c,r,l);let d={},f=cs();c.kill=S7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Sre(c,r),Dre(c,r),jte(c,r);let p=i1e({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}},i1e=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,v]=await xre({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((S,P)=>ho(S,e,P)),b=ho(m,e,"all"),A=s1e({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:v,context:c,options:e,command:o,escapedCommand:a,startTime:r});return cf(A,n,e)},s1e=({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?y_({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 us,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):qA({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var dx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,o1e(n,t[n],i)]));return{...t,...r}},o1e=(t,e,r)=>a1e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,a1e=new Set(["env",...bD]);var Ca=(t,e,r,n)=>{let i=(o,a,c)=>Ca(o,a,r,c),s=(...o)=>c1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},c1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Pt(s))return i(t,dx(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=l1e({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?Dte(a,c,l):$re(a,c,l,i)},l1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=YX(e)?KX(e,r):[e,...r],[o,a,c]=sA(...s),l=dx(dx(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 Ure=({file:t,commandArguments:e})=>Bre(t,e),Fre=({file:t,commandArguments:e})=>({...Bre(t,e),isSync:!0}),Bre=(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]=u1e(t);return{file:r,commandArguments:n}},u1e=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(d1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},d1e=/ +/g;var jre=(t,e,r)=>{t.sync=e(f1e,r),t.s=t.sync},zre=({options:t})=>Gre(t),f1e=({options:t})=>({...Gre(t),isSync:!0}),Gre=t=>({options:{...p1e(t),...t}}),p1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Vre={preferLocal:!0};var qre=Ca(()=>({})),XEt=Ca(()=>({isSync:!0})),Hre=Ca(Ure),QEt=Ca(Fre),evt=Ca(ree),tvt=Ca(zre,{},Vre,jre),{sendMessage:rvt,getOneMessage:nvt,getEachMessage:ivt,getCancelSignal:svt}=zte();var Wre=!1,Yre=()=>{Wre=!0},fs=()=>Wre;var x_=null,Kre=t=>(x_&&x_.destroy(),x_=new mo({totalAllowedTime:t}),x_),Zre=()=>x_;var mo=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&&fs())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 Xb({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{he.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 Jre={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.0-git.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:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@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.1.5","@netlify/otel":"^6.0.4","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var _1e=m1e(import.meta.url),y1e=go.dirname(_1e),S1e=g1e(import.meta.url),ff=ye("shell"),YL=new Set,Xre={preferLocal:!0},Mr=(t,e,r)=>{let[n,i]=E1e(e,r),s={...Xre,...i},o=qre(t,n,s);ene(o,s),nne(o);let a=r?.idleTimeout;return a&&a>0&&rne(o,a),o},Qre=(t,e)=>{let r={...Xre,...e},n=Hre(t,r);return ene(n,r),nne(n),e?.idleTimeout&&e.idleTimeout>0&&rne(n,e.idleTimeout),n},E1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ene=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(_o.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Qg).pipe(_o.stdout),t.stderr?.pipe(new Qg).pipe(_o.stderr);return}t.stdout?.pipe(_o.stdout),t.stderr?.pipe(_o.stderr)},KL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_o.kill(-t.pid,e),ff.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return ff.error("Error killing process:",r),!1}},tne=t=>KL(t,"SIGKILL"),rne=(t,e)=>{let r=null,n=()=>{ff.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),KL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ff.log(`Force killing idle process ${t.pid}`),tne(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)},nne=t=>{YL.add(t);let e=Zre();if(e){let r=e.onTimesUp(()=>{ff.log(`Global timer expired, killing process ${t.pid}`),KL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ff.log(`Force killing process ${t.pid} after timeout`),tne(t))},5e3)});t.on("exit",()=>{YL.delete(t),r()}),t.on("error",()=>{YL.delete(t),r()})}};function ps(t,e){if(!_o.env.NETLIFY_LOCAL_MODE)try{let i=S1e.resolve(Jre.name),s=go.dirname(i);for(;s!==go.dirname(s);){let o=go.dirname(s);if(go.basename(o)==="node_modules"){let a=go.join(o,".bin",e);if(fx.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(_o.env.NODE_PATH){let i=go.join(_o.env.NODE_PATH,".bin",e);if(fx.existsSync(i))return i}let r=go.join(t,"node_modules",".bin",e);if(fx.existsSync(r))return r;let n=go.join(y1e,"..","node_modules",".bin",e);if(fx.existsSync(n))return n}var v1e=ye("utils"),T1e=t=>new Promise(e=>{setTimeout(e,t)});var px=(t,e=3e3)=>{let r=!1,n=null,i=[],s=null,o=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return s=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await T1e(e),!n)return r=!1,s=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return o.flush=async()=>{if((r||n)&&s)return await s,o.flush()},o.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},o},Pa=(t,e,r=!1)=>{let n=null,i=null,s=null,o=function(...a){i=a,s=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(s,i),i=null,s=null)},e),c&&(t.apply(s,i),i=null,s=null)};return o.cancel=()=>{clearTimeout(n),n=null,i=null,s=null},o.flush=()=>{if(n){clearTimeout(n);let a=i,c=s;n=null,i=null,s=null,t.apply(c,a)}},o},ine=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):v1e.error("Could not parse JSON",n))}},b1e=t=>t.charAt(0).toUpperCase()+t.slice(1),hs=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():b1e(e)).join(" ");function yo(t,e){e&&t.log(`Skill invoked: ${e}`)}var hx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),sne=(t,e,r=!1)=>{if(r)return;let n=60,i=55,s=".netlify.app",o="agent-",a=6;if(!e)return`${o}${t.slice(0,a)}`;let c=`--${e}${s}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=o.length+a){let u=Math.min(l-o.length,t.length);return`${o}${t.slice(0,u)}`}return t.slice(0,l)};var ZL=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}},A1e=1e4,JL=(t,e=A1e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as one}from"buffer";import x1e from"path";var ane=ye("repo"),lr=(t,e={})=>Mr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),mx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{ane.info("Getting runner diffs");let n=await R1e(r),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!e){let m=C1e(s);await P1e(m,r)}ane.info("Changes after processing"),await QL(r);let o=await t$(s,r);if(await XL(o,r),i=await I1e(r),!i)return{hasChanges:!1,ignored:o};await lr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await lr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await cne(r),{hasChanges:!1,ignored:o};let u=await lr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await lr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let v=await lr(["diff",t.sha,"HEAD","--binary"],a),E=String(v.stdout??"");f!==E&&(p=one.from(E).toString("base64"))}await cne(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(h.diffBinary=one.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},cne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await lr(["reset","--soft","HEAD~1"],{cwd:t})},XL=async(t=[],e=process.cwd())=>{await lr(["add",".",...t],{cwd:e})},QL=async(t=process.cwd())=>{let e=await lr(["status","-s"],{cwd:t});return String(e.stdout??"")},lne=/.. (.+)?\.log$/,w1e=[lne],R1e=async(t=process.cwd())=>{let e=await QL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
102
|
`).filter(i=>w1e.some(o=>o instanceof RegExp?o.test(i):i===o)?!1:i[1]?.trim()!=="")).length!==0,status:e}},I1e=async(t=process.cwd())=>{try{return await lr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},e$=async(t=process.cwd())=>{let{stdout:e}=await lr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},une=async(t=process.cwd())=>{let{stdout:e}=await lr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},t$=async(t,e=process.cwd())=>{t||=await QL(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(`
|
|
103
103
|
`).forEach(i=>{r.forEach(o=>{let a=i===`?? ${o}`,c=i.startsWith(`?? ${o}/`)||i.startsWith(`?? ${o}${x1e.sep}`);(a||c)&&n.push(`:!${o}`)});let s=i.match(lne)?.[1];s&&n.push(`:!${s}.log`)}),n},dne=async(t=process.cwd())=>{await lr(["reset","--hard","HEAD"],{cwd:t})},fne=async(t=process.cwd())=>{let e=await lr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
104
104
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},C1e=t=>{let e=t.split(`
|
package/package.json
CHANGED