@netlify/agent-runner-cli 1.149.0-test.0 → 1.149.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -99,7 +99,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
99
99
|
`,LF:`
|
|
100
100
|
`,concatBytes:hL},MDe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},DDe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:MDe};import{Buffer as LDe}from"buffer";var wte=(t,e)=>t?void 0:$De.bind(void 0,e),$De=function*(t,e){if(typeof e!="string"&&!jt(e)&&!LDe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Rte=(t,e)=>t?UDe.bind(void 0,e):FDe.bind(void 0,e),UDe=function*(t,e){Ite(t,e),yield e},FDe=function*(t,e){if(Ite(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},Ite=(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 BDe}from"buffer";import{StringDecoder as jDe}from"string_decoder";var tx=(t,e,r)=>{if(r)return;if(t)return{transform:zDe.bind(void 0,new TextEncoder)};let n=new jDe(e);return{transform:GDe.bind(void 0,n),final:VDe.bind(void 0,n)}},zDe=function*(t,e){BDe.isBuffer(e)?yield ps(e):typeof e=="string"?yield t.encode(e):yield e},GDe=function*(t,e){yield jt(e)?t.write(e):e},VDe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Cte}from"util";var gL=Cte(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),rx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=HDe}=e[r];for await(let i of n(t))yield*rx(i,e,r+1)},Pte=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*rx(n,r,e+1)},Ote=Cte(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),HDe=function*(t){yield t};var _L=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Nte=(t,e)=>[...e.flatMap(r=>[...xl(r,t,0)]),...E_(t)],xl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=YDe}=e[r];for(let i of n(t))yield*xl(i,e,r+1)},E_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*WDe(r,Number(e),t)},WDe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*xl(n,r,e+1)},YDe=function*(t){yield t};var yL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Mte(t,s,o),l=Al(e),u=Al(r),d=l?gL.bind(void 0,rx,a):_L.bind(void 0,xl),f=l||u?gL.bind(void 0,Pte,a):_L.bind(void 0,E_),p=l||u?Ote.bind(void 0,a):void 0;return{stream:new KDe({writableObjectMode:n,writableHighWaterMark:kte(n),readableObjectMode:i,readableHighWaterMark:kte(i),transform(m,v,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},nx=(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=Mte(s,r,a);t=Nte(c,t)}return t},Mte=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:wte(n,a)},tx(r,s,n),ex(r,o,n,c),{transform:t,final:e},{transform:Rte(i,a)},xte({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Dte=(t,e)=>{for(let r of ZDe(t))JDe(t,r,e)},ZDe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),JDe=(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 ${Ca[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>XDe(a,n));r.input=u_(s)},XDe=(t,e)=>{let r=nx(t,e,"utf8",!0);return QDe(r),u_(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 nLe,appendFileSync as iLe}from"fs";var ix=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Qd(r,n)&&!gn.has(e)&&eLe(n)&&(t.some(({type:i,value:o})=>i==="native"&&tLe.has(o))||t.every(({type:i})=>Yn.has(i))),eLe=t=>t===1||t===2,tLe=new Set(["pipe","overlapped"]),Lte=async(t,e,r,n)=>{for await(let i of t)rLe(e)||Ute(i,r,n)},$te=(t,e,r)=>{for(let n of t)Ute(n,e,r)},rLe=t=>t._readableState.pipes.length>0,Ute=(t,e,r)=>{let n=yA(t);lo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Fte=({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)=>oLe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},oLe=({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=Bee(t,o,d),p=ps(f),{stdioItems:h,objectMode:m}=e[r],v=sLe([p],h,c,n),{serializedResult:S,finalResult:b=S}=aLe({chunks:v,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});cLe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&lLe(S,h,i),A}catch(y){return n.error=y,A}},sLe=(t,e,r,n)=>{try{return nx(t,e,r,!1)}catch(i){return n.error=i,t}},aLe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:u_(t)};let s=eQ(t,r);return n[o]?{serializedResult:s,finalResult:mL(s,!i[o],e)}:{serializedResult:s}},cLe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!ix({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=mL(t,!1,s);try{$te(a,e,n)}catch(c){r.error??=c}},lLe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>XA.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?iLe(n,t):(r.add(o),nLe(n,t))}};var Bte=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,gs(e,r,"all")]:Array.isArray(e)?[gs(t,r,"all"),...e]:jt(t)&&jt(e)?AD([t,e]):`${t}${e}`};import{once as SL}from"events";var jte=async(t,e)=>{let[r,n]=await uLe(t);return e.isForcefullyTerminated??=!1,[r,n]},uLe=async t=>{let[e,r]=await Promise.allSettled([SL(t,"spawn"),SL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?zte(t):r.value},zte=async t=>{try{return await SL(t,"exit")}catch{return zte(t)}},Gte=async t=>{let[e,r]=await t;if(!dLe(e,r)&&EL(e,r))throw new Ri;return[e,r]},dLe=(t,e)=>t===void 0&&e===void 0,EL=(t,e)=>t!==0||e!==null;var Vte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=fLe(t,e,r),s=o?.code==="ETIMEDOUT",a=Fee(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},fLe=(t,e,r)=>t!==void 0?t:EL(e,r)?new Ri:void 0;var qte=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=hLe(t,e,r),d=_Le({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return uf(d,c,l)},hLe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=EA(t,e,r),a=mLe(r),{file:c,commandArguments:l,options:u}=BA(t,e,a);gLe(u);let d=vte(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},mLe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,gLe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&ox("ipcInput"),t&&ox("ipc: true"),r&&ox("detached: true"),n&&ox("cancelSignal")},ox=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},_Le=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=yLe({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}=Vte(c,r),{output:h,error:m=l}=Fte({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),v=h.map((b,A)=>gs(b,r,A)),S=gs(Bte(h,r),r,"all");return ELe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:v,all:S,options:r,command:n,escapedCommand:i,startTime:a})},yLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Dte(o,r);let a=SLe(r);return pLe(...jA(t,e,a))}catch(a){return lf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},SLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:YA(e)}),ELe=({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?KA({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):S_({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 a1e}from"events";import{spawn as c1e}from"child_process";import Zte from"process";import{once as vL,on as vLe}from"events";var Hte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(rf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:MA(t)}),TLe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),TLe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{PA(e,i);let o=Ia(t,e,r),s=new AbortController;try{return await Promise.race([bLe(o,n,s),ALe(o,r,s),xLe(o,r,s)])}catch(a){throw nf(t),a}finally{s.abort(),OA(e,i)}},bLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await vL(t,"message",{signal:r});return n}for await(let[n]of vLe(t,"message",{signal:r}))if(e(n))return n},ALe=async(t,e,{signal:r})=>{await vL(t,"disconnect",{signal:r}),N7(e)},xLe=async(t,e,{signal:r})=>{let[n]=await vL(t,"strict:error",{signal:r});throw RA(n,e)};import{once as Yte,on as wLe}from"events";var Kte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>TL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),TL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{rf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:MA(t)}),PA(e,o);let s=Ia(t,e,r),a=new AbortController,c={};return RLe(t,s,a),ILe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),CLe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},RLe=async(t,e,r)=>{try{await Yte(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ILe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Yte(t,"strict:error",{signal:r.signal});n.error=RA(i,e),r.abort()}catch{}},CLe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of wLe(r,"message",{signal:o.signal}))Wte(s),yield c}catch{Wte(s)}finally{o.abort(),OA(e,a),n||nf(t),i&&await t}},Wte=({error:t})=>{if(t)throw t};var Jte=(t,{ipc:e})=>{Object.assign(t,Qte(t,!1,e))},Xte=()=>{let t=Zte,e=!0,r=Zte.channel!==void 0;return{...Qte(t,e,r),getCancelSignal:oee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Qte=(t,e,r)=>({sendMessage:UA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Hte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Kte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as PLe}from"child_process";import{PassThrough as OLe,Readable as NLe,Writable as kLe,Duplex as MLe}from"stream";var ere=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{fL(n);let a=new PLe;DLe(a,n),Object.assign(a,{readable:LLe,writable:$Le,duplex:ULe});let c=lf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=FLe(c,s,i);return{subprocess:a,promise:l}},DLe=(t,e)=>{let r=v_(),n=v_(),i=v_(),o=Array.from({length:e.length-3},v_),s=v_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},v_=()=>{let t=new OLe;return t.end(),t},LLe=()=>new NLe({read(){}}),$Le=()=>new kLe({write(){}}),ULe=()=>new MLe({read(){},write(){}}),FLe=async(t,e,r)=>uf(t,e,r);import{createReadStream as tre,createWriteStream as rre}from"fs";import{Buffer as BLe}from"buffer";import{Readable as T_,Writable as jLe,Duplex as zLe}from"stream";var ire=(t,e)=>QA(GLe,t,e,!1),b_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ca[t]}.`)},nre={fileNumber:b_,generator:yL,asyncGenerator:yL,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(){}},GLe={input:{...nre,fileUrl:({value:t})=>({stream:tre(t)}),filePath:({value:{file:t}})=>({stream:tre(t)}),webStream:({value:t})=>({stream:T_.fromWeb(t)}),iterable:({value:t})=>({stream:T_.from(t)}),asyncIterable:({value:t})=>({stream:T_.from(t)}),string:({value:t})=>({stream:T_.from(t)}),uint8Array:({value:t})=>({stream:T_.from(BLe.from(t))})},output:{...nre,fileUrl:({value:t})=>({stream:rre(t)}),filePath:({value:{file:t,append:e}})=>({stream:rre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:jLe.fromWeb(t)}),iterable:b_,asyncIterable:b_,string:b_,uint8Array:b_}};import{on as VLe,once as ore}from"events";import{PassThrough as qLe,getDefaultHighWaterMark as HLe}from"stream";import{finished as cre}from"stream/promises";function wl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)AL(i);let e=t.some(({readableObjectMode:i})=>i),r=WLe(t,e),n=new bL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var WLe=(t,e)=>{if(t.length===0)return HLe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},bL=class extends qLe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(AL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=YLe(this,this.#e,this.#o);let r=JLe({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(AL(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)}},YLe=async(t,e,r)=>{sx(t,sre);let n=new AbortController;try{await Promise.race([KLe(t,n),ZLe(t,e,r,n)])}finally{n.abort(),sx(t,-sre)}},KLe=async(t,{signal:e})=>{try{await cre(t,{signal:e,cleanup:!0})}catch(r){throw lre(t,r),r}},ZLe=async(t,e,r,{signal:n})=>{for await(let[i]of VLe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},AL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},JLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{sx(t,are);let a=new AbortController;try{await Promise.race([XLe(o,e,a),QLe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),e$e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),sx(t,-are)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?xL(t):t$e(t))},XLe=async(t,e,{signal:r})=>{try{await t,r.aborted||xL(e)}catch(n){r.aborted||lre(e,n)}},QLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await cre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;ure(s)?i.add(e):dre(t,s)}},e$e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await ore(t,i,{signal:o}),!t.readable)return ore(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},t$e=t=>{t.writable&&t.end()},lre=(t,e)=>{ure(e)?xL(t):dre(t,e)},ure=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",xL=t=>{(t.readable||t.writable)&&t.destroy()},dre=(t,e)=>{t.destroyed||(t.once("error",r$e),t.destroy(e))},r$e=()=>{},sx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},sre=2,are=1;import{finished as fre}from"stream/promises";var ff=(t,e)=>{t.pipe(e),n$e(t,e),i$e(t,e)},n$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await fre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}wL(e)}},wL=t=>{t.writable&&t.end()},i$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await fre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}RL(t)}},RL=t=>{t.readable&&t.destroy()};var pre=(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)))o$e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))a$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]:wl(o);ff(s,i)}},o$e=(t,e,r,n)=>{r==="output"?ff(t.stdio[n],e):ff(e,t.stdio[n]);let i=s$e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},s$e=["stdin","stdout","stderr"],a$e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;c$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])},c$e=(t,{signal:e})=>{wi(t)&&Tl(t,l$e,e)},l$e=2;import{addAbortListener as f$e}from"events";var Rl=[];Rl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Rl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Rl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ax=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",IL=Symbol.for("signal-exit emitter"),CL=globalThis,u$e=Object.defineProperty.bind(Object),PL=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(CL[IL])return CL[IL];u$e(CL,IL,{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}},cx=class{},d$e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),OL=class extends cx{onExit(){return()=>{}}load(){}unload(){}},NL=class extends cx{#e=kL.platform==="win32"?"SIGINT":"SIGHUP";#r=new PL;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Rl)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(!ax(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 Rl)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,Rl.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 ax(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"&&ax(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)}},kL=globalThis.process,{onExit:hre,load:uyt,unload:dyt}=d$e(ax(kL)?new NL(kL):new OL);var mre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=hre(()=>{t.kill()});f$e(n,()=>{i()})};var _re=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=SA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=p$e(r,n,i),{sourceStream:d,sourceError:f}=m$e(t,l),{options:p,fileDescriptors:h}=fo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},p$e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=h$e(t,e,...r),a=CA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},h$e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(gre,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||TD(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]=lA(r,...n);return{destination:e(gre)(i,o,s),pipeOptions:s}}if(fo.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}`)},gre=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),m$e=(t,e)=>{try{return{sourceStream:of(t,e)}}catch(r){return{sourceError:r}}};var Sre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=g$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ML({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},g$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return RL(t),n;if(e!==void 0)return wL(r),e},ML=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>lf({error:t,command:yre,escapedCommand:yre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),yre="source.pipe(destination)";var Ere=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 _$e}from"stream/promises";var vre=(t,e,r)=>{let n=lx.has(e)?S$e(t,e):y$e(t,e);return Tl(t,v$e,r.signal),Tl(e,T$e,r.signal),E$e(e),n},y$e=(t,e)=>{let r=wl([t]);return ff(r,e),lx.set(e,r),r},S$e=(t,e)=>{let r=lx.get(e);return r.add(t),r},E$e=async t=>{try{await _$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}lx.delete(t)},lx=new WeakMap,v$e=2,T$e=1;import{aborted as b$e}from"util";var Tre=(t,e)=>t===void 0?[]:[A$e(t,e)],A$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await b$e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ML({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var ux=(t,...e)=>{if(Pt(e[0]))return ux.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=_re(t,...e),i=x$e({...n,destination:r});return i.pipe=ux.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},x$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=w$e(t,i);Sre({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=vre(e,o,d);return await Promise.race([Ere(u),...Tre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},w$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as k$e}from"timers/promises";import{on as R$e}from"events";import{getDefaultHighWaterMark as I$e}from"stream";var dx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return C$e(e,s),Are({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},C$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},DL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;P$e(e,s,t);let a=t.readableObjectMode&&!o;return Are({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},P$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Are=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=R$e(t,"data",{signal:e.signal,highWaterMark:bre,highWatermark:bre});return O$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},LL=I$e(!0),bre=LL,O$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=N$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*xl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*E_(a)}},N$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[tx(t,r,!e),ex(t,i,!n,{})].filter(Boolean);var xre=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=M$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([D$e(t),d]);return}let f=pL(c,r),p=DL({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([L$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},M$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!ix({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=DL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Lte(a,t,r,o)},D$e=async t=>{await k$e(),t.readableFlowing===null&&t.resume()},L$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await qA(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await HA(r,{maxBuffer:o})):await cf(r,{maxBuffer:o})}catch(a){return wre(Lee({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},$L=async t=>{try{return await t}catch(e){return wre(e)}},wre=({bufferedData:t})=>XX(t)?new Uint8Array(t):t;import{finished as $$e}from"stream/promises";var A_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=U$e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],$$e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||j$e(a,e,r,n)}finally{s.abort()}},U$e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&F$e(t,r,n),n},F$e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{B$e(e,r),n.call(t,...i)}},B$e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},j$e=(t,e,r,n)=>{if(!z$e(t,e,r,n))throw t},z$e=(t,e,r,n=!0)=>r.propagating?Rre(t)||fx(t):(r.propagating=!0,UL(r,e)===n?Rre(t):fx(t)),UL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",fx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Rre=t=>t?.code==="EPIPE";var Ire=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>FL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),FL=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=A_(t,e,l);if(UL(l,e)){await u;return}let[d]=await Promise.all([xre({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 Cre=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?wl([t,e].filter(Boolean)):void 0,Pre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>FL({...G$e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:V$e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),G$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}},V$e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as q$e}from"events";var Ore=t=>Qd(t,"ipc"),Nre=(t,e)=>{let r=yA(t);lo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var kre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ore(o),a=hs(e,"ipc"),c=hs(r,"ipc");for await(let l of TL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&($ee(t,i,c),i.push(l)),s&&Nre(l,o);return i},Mre=async(t,e)=>(await Promise.allSettled([t]),e);var Dre=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 b=jte(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=Ire({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),R=Pre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),C=[],P=kre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:C,verboseInfo:p}),I=H$e(m,t,A),k=W$e(h,A);try{return await Promise.race([Promise.all([{},Gte(b),Promise.all(y),R,P,mee(t,d),...I,...k]),v,Y$e(t,S),...uee(t,o,f,S),...O7({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...cee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},b,Promise.all(y.map(_=>$L(_))),$L(R),Mre(P,C),Promise.allSettled(I),Promise.allSettled(k)])}},H$e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:A_(n,i,r)),W$e=(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})=>A_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),Y$e=async(t,{signal:e})=>{let[r]=await q$e(t,"error",{signal:e});throw r};var Lre=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),x_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=uo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},pf=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 K$e}from"stream";import{callbackify as Z$e}from"util";import{finished as $re}from"stream/promises";var BL=async t=>{if(t!==void 0)try{await jL(t)}catch{}},Ure=async t=>{if(t!==void 0)try{await zL(t)}catch{}},jL=async t=>{await $re(t,{cleanup:!0,readable:!1,writable:!0})},zL=async t=>{await $re(t,{cleanup:!0,readable:!0,writable:!1})},px=async(t,e)=>{if(await t,e)throw e},hx=(t,e,r)=>{r&&!fx(r)?t.destroy(r):e&&t.destroy()};var Fre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||gn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=GL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=VL(a,s),{read:f,onStdoutDataDone:p}=qL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new K$e({read:f,destroy:Z$e(WL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return HL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},GL=(t,e,r)=>{let n=of(t,e),i=x_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},VL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:LL},qL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=uo(),s=dx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){J$e(this,s,o)},onStdoutDataDone:o}},J$e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},HL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await zL(t),await n,await BL(i),await e,r.readable&&r.push(null)}catch(o){await BL(i),Bre(r,o)}},WL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await pf(r,e)&&(Bre(t,n),await px(e,n))},Bre=(t,e)=>{hx(t,t.readable,e)};import{Writable as X$e}from"stream";import{callbackify as jre}from"util";var zre=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=YL(t,r,e),s=new X$e({...KL(n,t,i),destroy:jre(JL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return ZL(n,s),s},YL=(t,e,r)=>{let n=CA(t,e),i=x_(r,n,"writableFinal"),o=x_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},KL=(t,e,r)=>({write:Q$e.bind(void 0,t),final:jre(e1e.bind(void 0,t,e,r))}),Q$e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},e1e=async(t,e,r)=>{await pf(r,e)&&(t.writable&&t.end(),await e)},ZL=async(t,e,r)=>{try{await jL(t),e.writable&&e.end()}catch(n){await Ure(r),Gre(e,n)}},JL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await pf(r,e),await pf(n,e)&&(Gre(t,i),await px(e,i))},Gre=(t,e)=>{hx(t,t.writable,e)};import{Duplex as t1e}from"stream";import{callbackify as r1e}from"util";var Vre=({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}=GL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=YL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=VL(c,a),{read:v,onStdoutDataDone:S}=qL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new t1e({read:v,...KL(u,t,d),destroy:r1e(n1e.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 HL({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),ZL(u,b,c),b},n1e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([WL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),JL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var XL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||gn.has(e),s=of(t,r),a=dx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return i1e(a,s,t)},i1e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var qre=(t,{encoding:e})=>{let r=Lre();t.readable=Fre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=zre.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Vre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=XL.bind(void 0,t,e),t[Symbol.asyncIterator]=XL.bind(void 0,t,e,{})};var Hre=(t,e)=>{for(let[r,n]of s1e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},o1e=(async()=>{})().constructor.prototype,s1e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(o1e,t)]);var Wre=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=l1e(t,e,r),{subprocess:f,promise:p}=d1e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=ux.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Hre(f,p),fo.set(f,{options:u,fileDescriptors:d}),f},l1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=EA(t,e,r),{file:a,commandArguments:c,options:l}=BA(t,e,r),u=u1e(l),d=ire(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},u1e=({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}},d1e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=c1e(...jA(t,e,r))}catch(h){return ere({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;a1e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];pre(c,a,l),mre(c,r,l);let d={},f=uo();c.kill=C7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Cre(c,r),qre(c,r),Jte(c,r);let p=f1e({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}},f1e=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 Dre({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((y,R)=>gs(y,e,R)),b=gs(m,e,"all"),A=p1e({errorInfo:d,exitCode:f,signal:p,stdio:S,all:b,ipcOutput:v,context:c,options:e,command:s,escapedCommand:a,startTime:r});return uf(A,n,e)},p1e=({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?S_({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 po,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):KA({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var mx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,h1e(n,t[n],i)]));return{...t,...r}},h1e=(t,e,r)=>m1e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,m1e=new Set(["env",...ID]);var Pa=(t,e,r,n)=>{let i=(s,a,c)=>Pa(s,a,r,c),o=(...s)=>g1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},g1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Pt(o))return i(t,mx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=_1e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?qte(a,c,l):Wre(a,c,l,i)},_1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=iQ(e)?oQ(e,r):[e,...r],[s,a,c]=lA(...o),l=mx(mx(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 Yre=({file:t,commandArguments:e})=>Zre(t,e),Kre=({file:t,commandArguments:e})=>({...Zre(t,e),isSync:!0}),Zre=(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]=y1e(t);return{file:r,commandArguments:n}},y1e=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(S1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},S1e=/ +/g;var Jre=(t,e,r)=>{t.sync=e(E1e,r),t.s=t.sync},Xre=({options:t})=>Qre(t),E1e=({options:t})=>({...Qre(t),isSync:!0}),Qre=t=>({options:{...v1e(t),...t}}),v1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},ene={preferLocal:!0};var tne=Pa(()=>({})),evt=Pa(()=>({isSync:!0})),rne=Pa(Yre),tvt=Pa(Kre),rvt=Pa(fee),nvt=Pa(Xre,{},ene,Jre),{sendMessage:ivt,getOneMessage:ovt,getEachMessage:svt,getCancelSignal:avt}=Xte();var nne=!1,ine=()=>{nne=!0},mo=()=>nne;var w_=null,one=t=>(w_&&w_.destroy(),w_=new _s({totalAllowedTime:t}),w_),sne=()=>w_;var _s=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&&mo())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 tA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ye.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 ane={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.0-test.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 x1e=b1e(import.meta.url),w1e=ys.dirname(x1e),R1e=A1e(import.meta.url),hf=he("shell"),QL=new Set,cne={preferLocal:!0},lr=(t,e,r)=>{let[n,i]=I1e(e,r),o={...cne,...i},s=tne(t,n,o);une(s,o),pne(s);let a=r?.idleTimeout;return a&&a>0&&fne(s,a),s},lne=(t,e)=>{let r={...cne,...e},n=rne(t,r);return une(n,r),pne(n),e?.idleTimeout&&e.idleTimeout>0&&fne(n,e.idleTimeout),n},I1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},une=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ss.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new t_).pipe(Ss.stdout),t.stderr?.pipe(new t_).pipe(Ss.stderr);return}t.stdout?.pipe(Ss.stdout),t.stderr?.pipe(Ss.stderr)},e$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ss.kill(-t.pid,e),hf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return hf.error("Error killing process:",r),!1}},dne=t=>e$(t,"SIGKILL"),fne=(t,e)=>{let r=null,n=()=>{hf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),e$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hf.log(`Force killing idle process ${t.pid}`),dne(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)},pne=t=>{QL.add(t);let e=sne();if(e){let r=e.onTimesUp(()=>{hf.log(`Global timer expired, killing process ${t.pid}`),e$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hf.log(`Force killing process ${t.pid} after timeout`),dne(t))},5e3)});t.on("exit",()=>{QL.delete(t),r()}),t.on("error",()=>{QL.delete(t),r()})}};function _x(t,e){return!!Pi(t,e)}function Pi(t,e){if(!Ss.env.NETLIFY_LOCAL_MODE)try{let i=R1e.resolve(ane.name),o=ys.dirname(i);for(;o!==ys.dirname(o);){let s=ys.dirname(o);if(ys.basename(s)==="node_modules"){let a=ys.join(s,".bin",e);if(gx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ss.env.NODE_PATH){let i=ys.join(Ss.env.NODE_PATH,".bin",e);if(gx.existsSync(i))return i}let r=ys.join(t,"node_modules",".bin",e);if(gx.existsSync(r))return r;let n=ys.join(w1e,"..","node_modules",".bin",e);if(gx.existsSync(n))return n}var C1e=he("utils"),P1e=t=>new Promise(e=>{setTimeout(e,t)});var yx=(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 P1e(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},Oa=(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},hne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):C1e.error("Could not parse JSON",n))}},O1e=t=>t.charAt(0).toUpperCase()+t.slice(1),go=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():O1e(e)).join(" ");function Es(t,e){e&&t.log(`Skill invoked: ${e}`)}var Sx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),mne=(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 t$=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}},N1e=1e4,r$=(t,e=N1e)=>{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 gne}from"buffer";import k1e from"path";var _ne=he("repo"),Xr=(t,e={})=>lr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Ex=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{_ne.info("Getting runner diffs");let n=await D1e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=$1e(o);await U1e(m,r)}_ne.info("Changes after processing"),await i$(r);let s=await o$(o,r);if(await n$(s,r),i=await L1e(r),!i)return{hasChanges:!1,ignored:s};await Xr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Xr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await yne(r),{hasChanges:!1,ignored:s};let u=await Xr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Xr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let v=await Xr(["diff",t.sha,"HEAD","--binary"],a),S=String(v.stdout??"");f!==S&&(p=gne.from(S).toString("base64"))}await yne(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=gne.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},yne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xr(["reset","--soft","HEAD~1"],{cwd:t})},n$=async(t=[],e=process.cwd())=>{await Xr(["add",".",...t],{cwd:e})},i$=async(t=process.cwd())=>{let e=await Xr(["status","-s"],{cwd:t});return String(e.stdout??"")},Sne=/.. (.+)?\.log$/,M1e=[Sne],D1e=async(t=process.cwd())=>{let e=await i$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
|
+
if (condition) { yield value; }`)};import{Buffer as BDe}from"buffer";import{StringDecoder as jDe}from"string_decoder";var tx=(t,e,r)=>{if(r)return;if(t)return{transform:zDe.bind(void 0,new TextEncoder)};let n=new jDe(e);return{transform:GDe.bind(void 0,n),final:VDe.bind(void 0,n)}},zDe=function*(t,e){BDe.isBuffer(e)?yield ps(e):typeof e=="string"?yield t.encode(e):yield e},GDe=function*(t,e){yield jt(e)?t.write(e):e},VDe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Cte}from"util";var gL=Cte(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),rx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=HDe}=e[r];for await(let i of n(t))yield*rx(i,e,r+1)},Pte=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*rx(n,r,e+1)},Ote=Cte(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),HDe=function*(t){yield t};var _L=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Nte=(t,e)=>[...e.flatMap(r=>[...xl(r,t,0)]),...E_(t)],xl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=YDe}=e[r];for(let i of n(t))yield*xl(i,e,r+1)},E_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*WDe(r,Number(e),t)},WDe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*xl(n,r,e+1)},YDe=function*(t){yield t};var yL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Mte(t,s,o),l=Al(e),u=Al(r),d=l?gL.bind(void 0,rx,a):_L.bind(void 0,xl),f=l||u?gL.bind(void 0,Pte,a):_L.bind(void 0,E_),p=l||u?Ote.bind(void 0,a):void 0;return{stream:new KDe({writableObjectMode:n,writableHighWaterMark:kte(n),readableObjectMode:i,readableHighWaterMark:kte(i),transform(m,v,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},nx=(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=Mte(s,r,a);t=Nte(c,t)}return t},Mte=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:wte(n,a)},tx(r,s,n),ex(r,o,n,c),{transform:t,final:e},{transform:Rte(i,a)},xte({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Dte=(t,e)=>{for(let r of ZDe(t))JDe(t,r,e)},ZDe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),JDe=(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 ${Ca[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>XDe(a,n));r.input=u_(s)},XDe=(t,e)=>{let r=nx(t,e,"utf8",!0);return QDe(r),u_(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 nLe,appendFileSync as iLe}from"fs";var ix=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Qd(r,n)&&!gn.has(e)&&eLe(n)&&(t.some(({type:i,value:o})=>i==="native"&&tLe.has(o))||t.every(({type:i})=>Yn.has(i))),eLe=t=>t===1||t===2,tLe=new Set(["pipe","overlapped"]),Lte=async(t,e,r,n)=>{for await(let i of t)rLe(e)||Ute(i,r,n)},$te=(t,e,r)=>{for(let n of t)Ute(n,e,r)},rLe=t=>t._readableState.pipes.length>0,Ute=(t,e,r)=>{let n=yA(t);lo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Fte=({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)=>oLe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},oLe=({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=Bee(t,o,d),p=ps(f),{stdioItems:h,objectMode:m}=e[r],v=sLe([p],h,c,n),{serializedResult:S,finalResult:b=S}=aLe({chunks:v,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});cLe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&lLe(S,h,i),A}catch(y){return n.error=y,A}},sLe=(t,e,r,n)=>{try{return nx(t,e,r,!1)}catch(i){return n.error=i,t}},aLe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:u_(t)};let s=eQ(t,r);return n[o]?{serializedResult:s,finalResult:mL(s,!i[o],e)}:{serializedResult:s}},cLe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!ix({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=mL(t,!1,s);try{$te(a,e,n)}catch(c){r.error??=c}},lLe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>XA.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?iLe(n,t):(r.add(o),nLe(n,t))}};var Bte=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,gs(e,r,"all")]:Array.isArray(e)?[gs(t,r,"all"),...e]:jt(t)&&jt(e)?AD([t,e]):`${t}${e}`};import{once as SL}from"events";var jte=async(t,e)=>{let[r,n]=await uLe(t);return e.isForcefullyTerminated??=!1,[r,n]},uLe=async t=>{let[e,r]=await Promise.allSettled([SL(t,"spawn"),SL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?zte(t):r.value},zte=async t=>{try{return await SL(t,"exit")}catch{return zte(t)}},Gte=async t=>{let[e,r]=await t;if(!dLe(e,r)&&EL(e,r))throw new Ri;return[e,r]},dLe=(t,e)=>t===void 0&&e===void 0,EL=(t,e)=>t!==0||e!==null;var Vte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=fLe(t,e,r),s=o?.code==="ETIMEDOUT",a=Fee(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},fLe=(t,e,r)=>t!==void 0?t:EL(e,r)?new Ri:void 0;var qte=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=hLe(t,e,r),d=_Le({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return uf(d,c,l)},hLe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=EA(t,e,r),a=mLe(r),{file:c,commandArguments:l,options:u}=BA(t,e,a);gLe(u);let d=vte(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},mLe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,gLe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&ox("ipcInput"),t&&ox("ipc: true"),r&&ox("detached: true"),n&&ox("cancelSignal")},ox=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},_Le=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=yLe({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}=Vte(c,r),{output:h,error:m=l}=Fte({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),v=h.map((b,A)=>gs(b,r,A)),S=gs(Bte(h,r),r,"all");return ELe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:v,all:S,options:r,command:n,escapedCommand:i,startTime:a})},yLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Dte(o,r);let a=SLe(r);return pLe(...jA(t,e,a))}catch(a){return lf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},SLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:YA(e)}),ELe=({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?KA({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):S_({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 a1e}from"events";import{spawn as c1e}from"child_process";import Zte from"process";import{once as vL,on as vLe}from"events";var Hte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(rf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:MA(t)}),TLe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),TLe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{PA(e,i);let o=Ia(t,e,r),s=new AbortController;try{return await Promise.race([bLe(o,n,s),ALe(o,r,s),xLe(o,r,s)])}catch(a){throw nf(t),a}finally{s.abort(),OA(e,i)}},bLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await vL(t,"message",{signal:r});return n}for await(let[n]of vLe(t,"message",{signal:r}))if(e(n))return n},ALe=async(t,e,{signal:r})=>{await vL(t,"disconnect",{signal:r}),N7(e)},xLe=async(t,e,{signal:r})=>{let[n]=await vL(t,"strict:error",{signal:r});throw RA(n,e)};import{once as Yte,on as wLe}from"events";var Kte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>TL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),TL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{rf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:MA(t)}),PA(e,o);let s=Ia(t,e,r),a=new AbortController,c={};return RLe(t,s,a),ILe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),CLe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},RLe=async(t,e,r)=>{try{await Yte(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ILe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Yte(t,"strict:error",{signal:r.signal});n.error=RA(i,e),r.abort()}catch{}},CLe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of wLe(r,"message",{signal:o.signal}))Wte(s),yield c}catch{Wte(s)}finally{o.abort(),OA(e,a),n||nf(t),i&&await t}},Wte=({error:t})=>{if(t)throw t};var Jte=(t,{ipc:e})=>{Object.assign(t,Qte(t,!1,e))},Xte=()=>{let t=Zte,e=!0,r=Zte.channel!==void 0;return{...Qte(t,e,r),getCancelSignal:oee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Qte=(t,e,r)=>({sendMessage:UA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Hte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Kte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as PLe}from"child_process";import{PassThrough as OLe,Readable as NLe,Writable as kLe,Duplex as MLe}from"stream";var ere=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{fL(n);let a=new PLe;DLe(a,n),Object.assign(a,{readable:LLe,writable:$Le,duplex:ULe});let c=lf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=FLe(c,s,i);return{subprocess:a,promise:l}},DLe=(t,e)=>{let r=v_(),n=v_(),i=v_(),o=Array.from({length:e.length-3},v_),s=v_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},v_=()=>{let t=new OLe;return t.end(),t},LLe=()=>new NLe({read(){}}),$Le=()=>new kLe({write(){}}),ULe=()=>new MLe({read(){},write(){}}),FLe=async(t,e,r)=>uf(t,e,r);import{createReadStream as tre,createWriteStream as rre}from"fs";import{Buffer as BLe}from"buffer";import{Readable as T_,Writable as jLe,Duplex as zLe}from"stream";var ire=(t,e)=>QA(GLe,t,e,!1),b_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ca[t]}.`)},nre={fileNumber:b_,generator:yL,asyncGenerator:yL,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(){}},GLe={input:{...nre,fileUrl:({value:t})=>({stream:tre(t)}),filePath:({value:{file:t}})=>({stream:tre(t)}),webStream:({value:t})=>({stream:T_.fromWeb(t)}),iterable:({value:t})=>({stream:T_.from(t)}),asyncIterable:({value:t})=>({stream:T_.from(t)}),string:({value:t})=>({stream:T_.from(t)}),uint8Array:({value:t})=>({stream:T_.from(BLe.from(t))})},output:{...nre,fileUrl:({value:t})=>({stream:rre(t)}),filePath:({value:{file:t,append:e}})=>({stream:rre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:jLe.fromWeb(t)}),iterable:b_,asyncIterable:b_,string:b_,uint8Array:b_}};import{on as VLe,once as ore}from"events";import{PassThrough as qLe,getDefaultHighWaterMark as HLe}from"stream";import{finished as cre}from"stream/promises";function wl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)AL(i);let e=t.some(({readableObjectMode:i})=>i),r=WLe(t,e),n=new bL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var WLe=(t,e)=>{if(t.length===0)return HLe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},bL=class extends qLe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(AL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=YLe(this,this.#e,this.#o);let r=JLe({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(AL(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)}},YLe=async(t,e,r)=>{sx(t,sre);let n=new AbortController;try{await Promise.race([KLe(t,n),ZLe(t,e,r,n)])}finally{n.abort(),sx(t,-sre)}},KLe=async(t,{signal:e})=>{try{await cre(t,{signal:e,cleanup:!0})}catch(r){throw lre(t,r),r}},ZLe=async(t,e,r,{signal:n})=>{for await(let[i]of VLe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},AL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},JLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{sx(t,are);let a=new AbortController;try{await Promise.race([XLe(o,e,a),QLe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),e$e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),sx(t,-are)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?xL(t):t$e(t))},XLe=async(t,e,{signal:r})=>{try{await t,r.aborted||xL(e)}catch(n){r.aborted||lre(e,n)}},QLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await cre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;ure(s)?i.add(e):dre(t,s)}},e$e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await ore(t,i,{signal:o}),!t.readable)return ore(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},t$e=t=>{t.writable&&t.end()},lre=(t,e)=>{ure(e)?xL(t):dre(t,e)},ure=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",xL=t=>{(t.readable||t.writable)&&t.destroy()},dre=(t,e)=>{t.destroyed||(t.once("error",r$e),t.destroy(e))},r$e=()=>{},sx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},sre=2,are=1;import{finished as fre}from"stream/promises";var ff=(t,e)=>{t.pipe(e),n$e(t,e),i$e(t,e)},n$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await fre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}wL(e)}},wL=t=>{t.writable&&t.end()},i$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await fre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}RL(t)}},RL=t=>{t.readable&&t.destroy()};var pre=(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)))o$e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))a$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]:wl(o);ff(s,i)}},o$e=(t,e,r,n)=>{r==="output"?ff(t.stdio[n],e):ff(e,t.stdio[n]);let i=s$e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},s$e=["stdin","stdout","stderr"],a$e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;c$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])},c$e=(t,{signal:e})=>{wi(t)&&Tl(t,l$e,e)},l$e=2;import{addAbortListener as f$e}from"events";var Rl=[];Rl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Rl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Rl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ax=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",IL=Symbol.for("signal-exit emitter"),CL=globalThis,u$e=Object.defineProperty.bind(Object),PL=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(CL[IL])return CL[IL];u$e(CL,IL,{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}},cx=class{},d$e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),OL=class extends cx{onExit(){return()=>{}}load(){}unload(){}},NL=class extends cx{#e=kL.platform==="win32"?"SIGINT":"SIGHUP";#r=new PL;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Rl)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(!ax(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 Rl)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,Rl.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 ax(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"&&ax(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)}},kL=globalThis.process,{onExit:hre,load:uyt,unload:dyt}=d$e(ax(kL)?new NL(kL):new OL);var mre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=hre(()=>{t.kill()});f$e(n,()=>{i()})};var _re=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=SA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=p$e(r,n,i),{sourceStream:d,sourceError:f}=m$e(t,l),{options:p,fileDescriptors:h}=fo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},p$e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=h$e(t,e,...r),a=CA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},h$e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(gre,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||TD(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]=lA(r,...n);return{destination:e(gre)(i,o,s),pipeOptions:s}}if(fo.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}`)},gre=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),m$e=(t,e)=>{try{return{sourceStream:of(t,e)}}catch(r){return{sourceError:r}}};var Sre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=g$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ML({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},g$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return RL(t),n;if(e!==void 0)return wL(r),e},ML=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>lf({error:t,command:yre,escapedCommand:yre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),yre="source.pipe(destination)";var Ere=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 _$e}from"stream/promises";var vre=(t,e,r)=>{let n=lx.has(e)?S$e(t,e):y$e(t,e);return Tl(t,v$e,r.signal),Tl(e,T$e,r.signal),E$e(e),n},y$e=(t,e)=>{let r=wl([t]);return ff(r,e),lx.set(e,r),r},S$e=(t,e)=>{let r=lx.get(e);return r.add(t),r},E$e=async t=>{try{await _$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}lx.delete(t)},lx=new WeakMap,v$e=2,T$e=1;import{aborted as b$e}from"util";var Tre=(t,e)=>t===void 0?[]:[A$e(t,e)],A$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await b$e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ML({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var ux=(t,...e)=>{if(Pt(e[0]))return ux.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=_re(t,...e),i=x$e({...n,destination:r});return i.pipe=ux.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},x$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=w$e(t,i);Sre({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=vre(e,o,d);return await Promise.race([Ere(u),...Tre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},w$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as k$e}from"timers/promises";import{on as R$e}from"events";import{getDefaultHighWaterMark as I$e}from"stream";var dx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return C$e(e,s),Are({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},C$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},DL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;P$e(e,s,t);let a=t.readableObjectMode&&!o;return Are({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},P$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Are=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=R$e(t,"data",{signal:e.signal,highWaterMark:bre,highWatermark:bre});return O$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},LL=I$e(!0),bre=LL,O$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=N$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*xl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*E_(a)}},N$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[tx(t,r,!e),ex(t,i,!n,{})].filter(Boolean);var xre=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=M$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([D$e(t),d]);return}let f=pL(c,r),p=DL({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([L$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},M$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!ix({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=DL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Lte(a,t,r,o)},D$e=async t=>{await k$e(),t.readableFlowing===null&&t.resume()},L$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await qA(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await HA(r,{maxBuffer:o})):await cf(r,{maxBuffer:o})}catch(a){return wre(Lee({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},$L=async t=>{try{return await t}catch(e){return wre(e)}},wre=({bufferedData:t})=>XX(t)?new Uint8Array(t):t;import{finished as $$e}from"stream/promises";var A_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=U$e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],$$e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||j$e(a,e,r,n)}finally{s.abort()}},U$e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&F$e(t,r,n),n},F$e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{B$e(e,r),n.call(t,...i)}},B$e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},j$e=(t,e,r,n)=>{if(!z$e(t,e,r,n))throw t},z$e=(t,e,r,n=!0)=>r.propagating?Rre(t)||fx(t):(r.propagating=!0,UL(r,e)===n?Rre(t):fx(t)),UL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",fx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Rre=t=>t?.code==="EPIPE";var Ire=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>FL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),FL=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=A_(t,e,l);if(UL(l,e)){await u;return}let[d]=await Promise.all([xre({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 Cre=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?wl([t,e].filter(Boolean)):void 0,Pre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>FL({...G$e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:V$e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),G$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}},V$e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as q$e}from"events";var Ore=t=>Qd(t,"ipc"),Nre=(t,e)=>{let r=yA(t);lo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var kre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ore(o),a=hs(e,"ipc"),c=hs(r,"ipc");for await(let l of TL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&($ee(t,i,c),i.push(l)),s&&Nre(l,o);return i},Mre=async(t,e)=>(await Promise.allSettled([t]),e);var Dre=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 b=jte(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=Ire({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),R=Pre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),C=[],P=kre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:C,verboseInfo:p}),I=H$e(m,t,A),k=W$e(h,A);try{return await Promise.race([Promise.all([{},Gte(b),Promise.all(y),R,P,mee(t,d),...I,...k]),v,Y$e(t,S),...uee(t,o,f,S),...O7({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...cee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},b,Promise.all(y.map(_=>$L(_))),$L(R),Mre(P,C),Promise.allSettled(I),Promise.allSettled(k)])}},H$e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:A_(n,i,r)),W$e=(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})=>A_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),Y$e=async(t,{signal:e})=>{let[r]=await q$e(t,"error",{signal:e});throw r};var Lre=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),x_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=uo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},pf=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 K$e}from"stream";import{callbackify as Z$e}from"util";import{finished as $re}from"stream/promises";var BL=async t=>{if(t!==void 0)try{await jL(t)}catch{}},Ure=async t=>{if(t!==void 0)try{await zL(t)}catch{}},jL=async t=>{await $re(t,{cleanup:!0,readable:!1,writable:!0})},zL=async t=>{await $re(t,{cleanup:!0,readable:!0,writable:!1})},px=async(t,e)=>{if(await t,e)throw e},hx=(t,e,r)=>{r&&!fx(r)?t.destroy(r):e&&t.destroy()};var Fre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||gn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=GL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=VL(a,s),{read:f,onStdoutDataDone:p}=qL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new K$e({read:f,destroy:Z$e(WL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return HL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},GL=(t,e,r)=>{let n=of(t,e),i=x_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},VL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:LL},qL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=uo(),s=dx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){J$e(this,s,o)},onStdoutDataDone:o}},J$e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},HL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await zL(t),await n,await BL(i),await e,r.readable&&r.push(null)}catch(o){await BL(i),Bre(r,o)}},WL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await pf(r,e)&&(Bre(t,n),await px(e,n))},Bre=(t,e)=>{hx(t,t.readable,e)};import{Writable as X$e}from"stream";import{callbackify as jre}from"util";var zre=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=YL(t,r,e),s=new X$e({...KL(n,t,i),destroy:jre(JL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return ZL(n,s),s},YL=(t,e,r)=>{let n=CA(t,e),i=x_(r,n,"writableFinal"),o=x_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},KL=(t,e,r)=>({write:Q$e.bind(void 0,t),final:jre(e1e.bind(void 0,t,e,r))}),Q$e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},e1e=async(t,e,r)=>{await pf(r,e)&&(t.writable&&t.end(),await e)},ZL=async(t,e,r)=>{try{await jL(t),e.writable&&e.end()}catch(n){await Ure(r),Gre(e,n)}},JL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await pf(r,e),await pf(n,e)&&(Gre(t,i),await px(e,i))},Gre=(t,e)=>{hx(t,t.writable,e)};import{Duplex as t1e}from"stream";import{callbackify as r1e}from"util";var Vre=({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}=GL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=YL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=VL(c,a),{read:v,onStdoutDataDone:S}=qL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new t1e({read:v,...KL(u,t,d),destroy:r1e(n1e.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 HL({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),ZL(u,b,c),b},n1e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([WL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),JL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var XL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||gn.has(e),s=of(t,r),a=dx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return i1e(a,s,t)},i1e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var qre=(t,{encoding:e})=>{let r=Lre();t.readable=Fre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=zre.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Vre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=XL.bind(void 0,t,e),t[Symbol.asyncIterator]=XL.bind(void 0,t,e,{})};var Hre=(t,e)=>{for(let[r,n]of s1e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},o1e=(async()=>{})().constructor.prototype,s1e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(o1e,t)]);var Wre=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=l1e(t,e,r),{subprocess:f,promise:p}=d1e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=ux.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Hre(f,p),fo.set(f,{options:u,fileDescriptors:d}),f},l1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=EA(t,e,r),{file:a,commandArguments:c,options:l}=BA(t,e,r),u=u1e(l),d=ire(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},u1e=({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}},d1e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=c1e(...jA(t,e,r))}catch(h){return ere({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;a1e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];pre(c,a,l),mre(c,r,l);let d={},f=uo();c.kill=C7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Cre(c,r),qre(c,r),Jte(c,r);let p=f1e({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}},f1e=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 Dre({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((y,R)=>gs(y,e,R)),b=gs(m,e,"all"),A=p1e({errorInfo:d,exitCode:f,signal:p,stdio:S,all:b,ipcOutput:v,context:c,options:e,command:s,escapedCommand:a,startTime:r});return uf(A,n,e)},p1e=({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?S_({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 po,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):KA({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var mx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,h1e(n,t[n],i)]));return{...t,...r}},h1e=(t,e,r)=>m1e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,m1e=new Set(["env",...ID]);var Pa=(t,e,r,n)=>{let i=(s,a,c)=>Pa(s,a,r,c),o=(...s)=>g1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},g1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Pt(o))return i(t,mx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=_1e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?qte(a,c,l):Wre(a,c,l,i)},_1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=iQ(e)?oQ(e,r):[e,...r],[s,a,c]=lA(...o),l=mx(mx(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 Yre=({file:t,commandArguments:e})=>Zre(t,e),Kre=({file:t,commandArguments:e})=>({...Zre(t,e),isSync:!0}),Zre=(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]=y1e(t);return{file:r,commandArguments:n}},y1e=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(S1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},S1e=/ +/g;var Jre=(t,e,r)=>{t.sync=e(E1e,r),t.s=t.sync},Xre=({options:t})=>Qre(t),E1e=({options:t})=>({...Qre(t),isSync:!0}),Qre=t=>({options:{...v1e(t),...t}}),v1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},ene={preferLocal:!0};var tne=Pa(()=>({})),evt=Pa(()=>({isSync:!0})),rne=Pa(Yre),tvt=Pa(Kre),rvt=Pa(fee),nvt=Pa(Xre,{},ene,Jre),{sendMessage:ivt,getOneMessage:ovt,getEachMessage:svt,getCancelSignal:avt}=Xte();var nne=!1,ine=()=>{nne=!0},mo=()=>nne;var w_=null,one=t=>(w_&&w_.destroy(),w_=new _s({totalAllowedTime:t}),w_),sne=()=>w_;var _s=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&&mo())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 tA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ye.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 ane={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.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 x1e=b1e(import.meta.url),w1e=ys.dirname(x1e),R1e=A1e(import.meta.url),hf=he("shell"),QL=new Set,cne={preferLocal:!0},lr=(t,e,r)=>{let[n,i]=I1e(e,r),o={...cne,...i},s=tne(t,n,o);une(s,o),pne(s);let a=r?.idleTimeout;return a&&a>0&&fne(s,a),s},lne=(t,e)=>{let r={...cne,...e},n=rne(t,r);return une(n,r),pne(n),e?.idleTimeout&&e.idleTimeout>0&&fne(n,e.idleTimeout),n},I1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},une=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ss.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new t_).pipe(Ss.stdout),t.stderr?.pipe(new t_).pipe(Ss.stderr);return}t.stdout?.pipe(Ss.stdout),t.stderr?.pipe(Ss.stderr)},e$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ss.kill(-t.pid,e),hf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return hf.error("Error killing process:",r),!1}},dne=t=>e$(t,"SIGKILL"),fne=(t,e)=>{let r=null,n=()=>{hf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),e$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hf.log(`Force killing idle process ${t.pid}`),dne(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)},pne=t=>{QL.add(t);let e=sne();if(e){let r=e.onTimesUp(()=>{hf.log(`Global timer expired, killing process ${t.pid}`),e$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hf.log(`Force killing process ${t.pid} after timeout`),dne(t))},5e3)});t.on("exit",()=>{QL.delete(t),r()}),t.on("error",()=>{QL.delete(t),r()})}};function _x(t,e){return!!Pi(t,e)}function Pi(t,e){if(!Ss.env.NETLIFY_LOCAL_MODE)try{let i=R1e.resolve(ane.name),o=ys.dirname(i);for(;o!==ys.dirname(o);){let s=ys.dirname(o);if(ys.basename(s)==="node_modules"){let a=ys.join(s,".bin",e);if(gx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ss.env.NODE_PATH){let i=ys.join(Ss.env.NODE_PATH,".bin",e);if(gx.existsSync(i))return i}let r=ys.join(t,"node_modules",".bin",e);if(gx.existsSync(r))return r;let n=ys.join(w1e,"..","node_modules",".bin",e);if(gx.existsSync(n))return n}var C1e=he("utils"),P1e=t=>new Promise(e=>{setTimeout(e,t)});var yx=(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 P1e(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},Oa=(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},hne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):C1e.error("Could not parse JSON",n))}},O1e=t=>t.charAt(0).toUpperCase()+t.slice(1),go=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():O1e(e)).join(" ");function Es(t,e){e&&t.log(`Skill invoked: ${e}`)}var Sx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),mne=(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 t$=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}},N1e=1e4,r$=(t,e=N1e)=>{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 gne}from"buffer";import k1e from"path";var _ne=he("repo"),Xr=(t,e={})=>lr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Ex=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{_ne.info("Getting runner diffs");let n=await D1e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=$1e(o);await U1e(m,r)}_ne.info("Changes after processing"),await i$(r);let s=await o$(o,r);if(await n$(s,r),i=await L1e(r),!i)return{hasChanges:!1,ignored:s};await Xr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Xr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await yne(r),{hasChanges:!1,ignored:s};let u=await Xr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Xr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let v=await Xr(["diff",t.sha,"HEAD","--binary"],a),S=String(v.stdout??"");f!==S&&(p=gne.from(S).toString("base64"))}await yne(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=gne.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},yne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xr(["reset","--soft","HEAD~1"],{cwd:t})},n$=async(t=[],e=process.cwd())=>{await Xr(["add",".",...t],{cwd:e})},i$=async(t=process.cwd())=>{let e=await Xr(["status","-s"],{cwd:t});return String(e.stdout??"")},Sne=/.. (.+)?\.log$/,M1e=[Sne],D1e=async(t=process.cwd())=>{let e=await i$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
103
103
|
`).filter(i=>M1e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},L1e=async(t=process.cwd())=>{try{return await Xr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},R_=async(t=process.cwd())=>{let{stdout:e}=await Xr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Ene=async(t=process.cwd())=>{let{stdout:e}=await Xr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},o$=async(t,e=process.cwd())=>{t||=await i$(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}${k1e.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Sne)?.[1];o&&n.push(`:!${o}.log`)}),n},vne=async(t=process.cwd())=>{await Xr(["reset","--hard","HEAD"],{cwd:t})},Tne=async(t=process.cwd())=>{let e=await Xr(["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))},$1e=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:J6},eyt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},tyt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:eyt};import{Buffer as ryt}from"buffer";var Lbe=(t,e)=>t?void 0:nyt.bind(void 0,e),nyt=function*(t,e){if(typeof e!="string"&&!Pr(e)&&!ryt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Dbe=(t,e)=>t?iyt.bind(void 0,e):syt.bind(void 0,e),iyt=function*(t,e){Mbe(t,e),yield e},syt=function*(t,e){if(Mbe(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},Mbe=(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 oyt}from"buffer";import{StringDecoder as ayt}from"string_decoder";var lC=(t,e,r)=>{if(r)return;if(t)return{transform:cyt.bind(void 0,new TextEncoder)};let n=new ayt(e);return{transform:lyt.bind(void 0,n),final:uyt.bind(void 0,n)}},cyt=function*(t,e){oyt.isBuffer(e)?yield yc(e):typeof e=="string"?yield t.encode(e):yield e},lyt=function*(t,e){yield Pr(e)?t.write(e):e},uyt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Ube}from"util";var X6=Ube(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),uC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=fyt}=e[r];for await(let i of n(t))yield*uC(i,e,r+1)},Fbe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*dyt(r,Number(e),t)},dyt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*uC(n,r,e+1)},jbe=Ube(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),fyt=function*(t){yield t};var Q6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},qbe=(t,e)=>[...e.flatMap(r=>[...$f(r,t,0)]),...zb(t)],$f=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=hyt}=e[r];for(let i of n(t))yield*$f(i,e,r+1)},zb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*pyt(r,Number(e),t)},pyt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*$f(n,r,e+1)},hyt=function*(t){yield t};var e3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=zbe(t,o,s),l=kf(e),u=kf(r),d=l?X6.bind(void 0,uC,a):Q6.bind(void 0,$f),f=l||u?X6.bind(void 0,Fbe,a):Q6.bind(void 0,zb),p=l||u?jbe.bind(void 0,a):void 0;return{stream:new myt({writableObjectMode:n,writableHighWaterMark:Bbe(n),readableObjectMode:i,readableHighWaterMark:Bbe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},dC=(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=zbe(o,r,a);t=qbe(c,t)}return t},zbe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Lbe(n,a)},lC(r,o,n),cC(r,s,n,c),{transform:t,final:e},{transform:Dbe(i,a)},$be({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Vbe=(t,e)=>{for(let r of gyt(t))_yt(t,r,e)},gyt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),_yt=(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 ${yu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>yyt(a,n));r.input=kb(o)},yyt=(t,e)=>{let r=dC(t,e,"utf8",!0);return Syt(r),kb(r)},Syt=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 Tyt,appendFileSync as wyt}from"fs";var fC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&xg(r,n)&&!Di.has(e)&&Eyt(n)&&(t.some(({type:i,value:s})=>i==="native"&&vyt.has(s))||t.every(({type:i})=>Ss.has(i))),Eyt=t=>t===1||t===2,vyt=new Set(["pipe","overlapped"]),Hbe=async(t,e,r,n)=>{for await(let i of t)byt(e)||Wbe(i,r,n)},Gbe=(t,e,r)=>{for(let n of t)Wbe(n,e,r)},byt=t=>t._readableState.pipes.length>0,Wbe=(t,e,r)=>{let n=AP(t);Qo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Ybe=({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)=>Ryt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Ryt=({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=Kve(t,s,d),p=yc(f),{stdioItems:h,objectMode:m}=e[r],_=Ayt([p],h,c,n),{serializedResult:y,finalResult:v=y}=xyt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Iyt({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&&Oyt(y,h,i),S}catch(g){return n.error=g,S}},Ayt=(t,e,r,n)=>{try{return dC(t,e,r,!1)}catch(i){return n.error=i,t}},xyt=({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=lSe(t,r);return n[s]?{serializedResult:o,finalResult:Z6(o,!i[s],e)}:{serializedResult:o}},Iyt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!fC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=Z6(t,!1,o);try{Gbe(a,e,n)}catch(c){r.error??=c}},Oyt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>oC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?wyt(n,t):(r.add(s),Tyt(n,t))}};var Kbe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,vc(e,r,"all")]:Array.isArray(e)?[vc(t,r,"all"),...e]:Pr(t)&&Pr(e)?o6([t,e]):`${t}${e}`};import{once as t3}from"events";var Jbe=async(t,e)=>{let[r,n]=await Pyt(t);return e.isForcefullyTerminated??=!1,[r,n]},Pyt=async t=>{let[e,r]=await Promise.allSettled([t3(t,"spawn"),t3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Zbe(t):r.value},Zbe=async t=>{try{return await t3(t,"exit")}catch{return Zbe(t)}},Xbe=async t=>{let[e,r]=await t;if(!Cyt(e,r)&&r3(e,r))throw new eo;return[e,r]},Cyt=(t,e)=>t===void 0&&e===void 0,r3=(t,e)=>t!==0||e!==null;var Qbe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Nyt(t,e,r),o=s?.code==="ETIMEDOUT",a=Yve(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Nyt=(t,e,r)=>t!==void 0?t:r3(e,r)?new eo:void 0;var eTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=$yt(t,e,r),d=Myt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Mg(d,c,l)},$yt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=IP(t,e,r),a=Lyt(r),{file:c,commandArguments:l,options:u}=YP(t,e,a);Dyt(u);let d=Pbe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Lyt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Dyt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&pC("ipcInput"),t&&pC("ipc: true"),r&&pC("detached: true"),n&&pC("cancelSignal")},pC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Myt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Uyt({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}=Qbe(c,r),{output:h,error:m=l}=Ybe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>vc(v,r,S)),y=vc(Kbe(h,r),r,"all");return jyt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Uyt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Vbe(s,r);let a=Fyt(r);return kyt(...KP(t,e,a))}catch(a){return Dg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Fyt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:rC(e)}),jyt=({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?nC({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 xEt}from"events";import{spawn as IEt}from"child_process";import sTe from"process";import{once as n3,on as qyt}from"events";var tTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Pg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:BP(t)}),Byt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Byt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{UP(e,i);let s=_u(t,e,r),o=new AbortController;try{return await Promise.race([zyt(s,n,o),Vyt(s,r,o),Hyt(s,r,o)])}catch(a){throw Cg(t),a}finally{o.abort(),FP(e,i)}},zyt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await n3(t,"message",{signal:r});return n}for await(let[n]of qyt(t,"message",{signal:r}))if(e(n))return n},Vyt=async(t,e,{signal:r})=>{await n3(t,"disconnect",{signal:r}),qEe(e)},Hyt=async(t,e,{signal:r})=>{let[n]=await n3(t,"strict:error",{signal:r});throw LP(n,e)};import{once as nTe,on as Gyt}from"events";var iTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>i3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),i3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Pg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:BP(t)}),UP(e,s);let o=_u(t,e,r),a=new AbortController,c={};return Wyt(t,o,a),Yyt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Kyt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Wyt=async(t,e,r)=>{try{await nTe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Yyt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await nTe(t,"strict:error",{signal:r.signal});n.error=LP(i,e),r.abort()}catch{}},Kyt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Gyt(r,"message",{signal:s.signal}))rTe(o),yield c}catch{rTe(o)}finally{s.abort(),FP(e,a),n||Cg(t),i&&await t}},rTe=({error:t})=>{if(t)throw t};var oTe=(t,{ipc:e})=>{Object.assign(t,cTe(t,!1,e))},aTe=()=>{let t=sTe,e=!0,r=sTe.channel!==void 0;return{...cTe(t,e,r),getCancelSignal:hve.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},cTe=(t,e,r)=>({sendMessage:GP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:tTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:iTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Jyt}from"child_process";import{PassThrough as Zyt,Readable as Xyt,Writable as Qyt,Duplex as eSt}from"stream";var lTe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{Y6(n);let a=new Jyt;tSt(a,n),Object.assign(a,{readable:rSt,writable:nSt,duplex:iSt});let c=Dg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=sSt(c,o,i);return{subprocess:a,promise:l}},tSt=(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 Zyt;return t.end(),t},rSt=()=>new Xyt({read(){}}),nSt=()=>new Qyt({write(){}}),iSt=()=>new eSt({read(){},write(){}}),sSt=async(t,e,r)=>Mg(t,e,r);import{createReadStream as uTe,createWriteStream as dTe}from"fs";import{Buffer as oSt}from"buffer";import{Readable as Hb,Writable as aSt,Duplex as cSt}from"stream";var pTe=(t,e)=>aC(lSt,t,e,!1),Gb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${yu[t]}.`)},fTe={fileNumber:Gb,generator:e3,asyncGenerator:e3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:cSt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},lSt={input:{...fTe,fileUrl:({value:t})=>({stream:uTe(t)}),filePath:({value:{file:t}})=>({stream:uTe(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(oSt.from(t))})},output:{...fTe,fileUrl:({value:t})=>({stream:dTe(t)}),filePath:({value:{file:t,append:e}})=>({stream:dTe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:aSt.fromWeb(t)}),iterable:Gb,asyncIterable:Gb,string:Gb,uint8Array:Gb}};import{on as uSt,once as hTe}from"events";import{PassThrough as dSt,getDefaultHighWaterMark as fSt}from"stream";import{finished as _Te}from"stream/promises";function Lf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)o3(i);let e=t.some(({readableObjectMode:i})=>i),r=pSt(t,e),n=new s3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var pSt=(t,e)=>{if(t.length===0)return fSt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},s3=class extends dSt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(o3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=hSt(this,this.#e,this.#s);let r=_St({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(o3(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)}},hSt=async(t,e,r)=>{hC(t,mTe);let n=new AbortController;try{await Promise.race([mSt(t,n),gSt(t,e,r,n)])}finally{n.abort(),hC(t,-mTe)}},mSt=async(t,{signal:e})=>{try{await _Te(t,{signal:e,cleanup:!0})}catch(r){throw yTe(t,r),r}},gSt=async(t,e,r,{signal:n})=>{for await(let[i]of uSt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},o3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},_St=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{hC(t,gTe);let a=new AbortController;try{await Promise.race([ySt(s,e,a),SSt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),ESt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),hC(t,-gTe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?a3(t):vSt(t))},ySt=async(t,e,{signal:r})=>{try{await t,r.aborted||a3(e)}catch(n){r.aborted||yTe(e,n)}},SSt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await _Te(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;STe(o)?i.add(e):ETe(t,o)}},ESt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await hTe(t,i,{signal:s}),!t.readable)return hTe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},vSt=t=>{t.writable&&t.end()},yTe=(t,e)=>{STe(e)?a3(t):ETe(t,e)},STe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",a3=t=>{(t.readable||t.writable)&&t.destroy()},ETe=(t,e)=>{t.destroyed||(t.once("error",bSt),t.destroy(e))},bSt=()=>{},hC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},mTe=2,gTe=1;import{finished as vTe}from"stream/promises";var Fg=(t,e)=>{t.pipe(e),TSt(t,e),wSt(t,e)},TSt=async(t,e)=>{if(!(Qs(t)||Qs(e))){try{await vTe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}c3(e)}},c3=t=>{t.writable&&t.end()},wSt=async(t,e)=>{if(!(Qs(t)||Qs(e))){try{await vTe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}l3(t)}},l3=t=>{t.readable&&t.destroy()};var bTe=(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)))RSt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ss.has(c)))xSt({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]:Lf(s);Fg(o,i)}},RSt=(t,e,r,n)=>{r==="output"?Fg(t.stdio[n],e):Fg(e,t.stdio[n]);let i=ASt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},ASt=["stdin","stdout","stderr"],xSt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;ISt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},ISt=(t,{signal:e})=>{Qs(t)&&Cf(t,OSt,e)},OSt=2;import{addAbortListener as NSt}from"events";var Df=[];Df.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Df.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Df.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var mC=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",u3=Symbol.for("signal-exit emitter"),d3=globalThis,PSt=Object.defineProperty.bind(Object),f3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(d3[u3])return d3[u3];PSt(d3,u3,{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}},gC=class{},CSt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),p3=class extends gC{onExit(){return()=>{}}load(){}unload(){}},h3=class extends gC{#e=m3.platform==="win32"?"SIGINT":"SIGHUP";#r=new f3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Df)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(!mC(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 Df)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,Df.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 mC(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"&&mC(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)}},m3=globalThis.process,{onExit:TTe,load:Oar,unload:Par}=CSt(mC(m3)?new h3(m3):new p3);var wTe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=TTe(()=>{t.kill()});NSt(n,()=>{i()})};var ATe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=xP(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=kSt(r,n,i),{sourceStream:d,sourceError:f}=LSt(t,l),{options:p,fileDescriptors:h}=ta.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},kSt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=$St(t,e,...r),a=MP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},$St=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(RTe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||i6(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]=_P(r,...n);return{destination:e(RTe)(i,s,o),pipeOptions:o}}if(ta.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}`)},RTe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),LSt=(t,e)=>{try{return{sourceStream:Ng(t,e)}}catch(r){return{sourceError:r}}};var ITe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=DSt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw g3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},DSt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return l3(t),n;if(e!==void 0)return c3(r),e},g3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Dg({error:t,command:xTe,escapedCommand:xTe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),xTe="source.pipe(destination)";var OTe=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 MSt}from"stream/promises";var PTe=(t,e,r)=>{let n=_C.has(e)?FSt(t,e):USt(t,e);return Cf(t,qSt,r.signal),Cf(e,BSt,r.signal),jSt(e),n},USt=(t,e)=>{let r=Lf([t]);return Fg(r,e),_C.set(e,r),r},FSt=(t,e)=>{let r=_C.get(e);return r.add(t),r},jSt=async t=>{try{await MSt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}_C.delete(t)},_C=new WeakMap,qSt=2,BSt=1;import{aborted as zSt}from"util";var CTe=(t,e)=>t===void 0?[]:[VSt(t,e)],VSt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await zSt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw g3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var yC=(t,...e)=>{if(_r(e[0]))return yC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ATe(t,...e),i=HSt({...n,destination:r});return i.pipe=yC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},HSt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=GSt(t,i);ITe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=PTe(e,s,d);return await Promise.race([OTe(u),...CTe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},GSt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as QSt}from"timers/promises";import{on as WSt}from"events";import{getDefaultHighWaterMark as YSt}from"stream";var SC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return KSt(e,o),kTe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},KSt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},_3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;JSt(e,o,t);let a=t.readableObjectMode&&!s;return kTe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},JSt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},kTe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=WSt(t,"data",{signal:e.signal,highWaterMark:NTe,highWatermark:NTe});return ZSt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},y3=YSt(!0),NTe=y3,ZSt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=XSt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*$f(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*zb(a)}},XSt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[lC(t,r,!e),cC(t,i,!n,{})].filter(Boolean);var $Te=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=eEt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([tEt(t),d]);return}let f=K6(c,r),p=_3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([rEt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},eEt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!fC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=_3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Hbe(a,t,r,s)},tEt=async t=>{await QSt(),t.readableFlowing===null&&t.resume()},rEt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await QP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await eC(r,{maxBuffer:s})):await Lg(r,{maxBuffer:s})}catch(a){return LTe(Hve({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},S3=async t=>{try{return await t}catch(e){return LTe(e)}},LTe=({bufferedData:t})=>aSe(t)?new Uint8Array(t):t;import{finished as nEt}from"stream/promises";var Wb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=iEt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],nEt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||aEt(a,e,r,n)}finally{o.abort()}},iEt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&sEt(t,r,n),n},sEt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{oEt(e,r),n.call(t,...i)}},oEt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},aEt=(t,e,r,n)=>{if(!cEt(t,e,r,n))throw t},cEt=(t,e,r,n=!0)=>r.propagating?DTe(t)||EC(t):(r.propagating=!0,E3(r,e)===n?DTe(t):EC(t)),E3=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",EC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",DTe=t=>t?.code==="EPIPE";var MTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>v3({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),v3=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(E3(l,e)){await u;return}let[d]=await Promise.all([$Te({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 UTe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Lf([t,e].filter(Boolean)):void 0,FTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>v3({...lEt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:uEt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),lEt=({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}},uEt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as dEt}from"events";var jTe=t=>xg(t,"ipc"),qTe=(t,e)=>{let r=AP(t);Qo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var BTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=jTe(s),a=Sc(e,"ipc"),c=Sc(r,"ipc");for await(let l of i3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Gve(t,i,c),i.push(l)),o&&qTe(l,s);return i},zTe=async(t,e)=>(await Promise.allSettled([t]),e);var VTe=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=Jbe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=MTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=FTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),O=[],x=BTe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),R=fEt(m,t,S),P=pEt(h,S);try{return await Promise.race([Promise.all([{},Xbe(v),Promise.all(g),w,x,wve(t,d),...R,...P]),_,hEt(t,y),...Sve(t,s,f,y),...jEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),..._ve({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=>S3(b))),S3(w),zTe(x,O),Promise.allSettled(R),Promise.allSettled(P)])}},fEt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Wb(n,i,r)),pEt=(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"}))),hEt=async(t,{signal:e})=>{let[r]=await dEt(t,"error",{signal:e});throw r};var HTe=()=>({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=ea();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},jg=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 mEt}from"stream";import{callbackify as gEt}from"util";import{finished as GTe}from"stream/promises";var b3=async t=>{if(t!==void 0)try{await T3(t)}catch{}},WTe=async t=>{if(t!==void 0)try{await w3(t)}catch{}},T3=async t=>{await GTe(t,{cleanup:!0,readable:!1,writable:!0})},w3=async t=>{await GTe(t,{cleanup:!0,readable:!0,writable:!1})},vC=async(t,e)=>{if(await t,e)throw e},bC=(t,e,r)=>{r&&!EC(r)?t.destroy(r):e&&t.destroy()};var YTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Di.has(r),{subprocessStdout:a,waitReadableDestroy:c}=R3(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=A3(a,o),{read:f,onStdoutDataDone:p}=x3({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new mEt({read:f,destroy:gEt(O3.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return I3({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},R3=(t,e,r)=>{let n=Ng(t,e),i=Yb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},A3=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:y3},x3=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ea(),o=SC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){_Et(this,o,s)},onStdoutDataDone:s}},_Et=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},I3=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await w3(t),await n,await b3(i),await e,r.readable&&r.push(null)}catch(s){await b3(i),KTe(r,s)}},O3=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await jg(r,e)&&(KTe(t,n),await vC(e,n))},KTe=(t,e)=>{bC(t,t.readable,e)};import{Writable as yEt}from"stream";import{callbackify as JTe}from"util";var ZTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=P3(t,r,e),o=new yEt({...C3(n,t,i),destroy:JTe(k3.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return N3(n,o),o},P3=(t,e,r)=>{let n=MP(t,e),i=Yb(r,n,"writableFinal"),s=Yb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},C3=(t,e,r)=>({write:SEt.bind(void 0,t),final:JTe(EEt.bind(void 0,t,e,r))}),SEt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},EEt=async(t,e,r)=>{await jg(r,e)&&(t.writable&&t.end(),await e)},N3=async(t,e,r)=>{try{await T3(t),e.writable&&e.end()}catch(n){await WTe(r),XTe(e,n)}},k3=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await jg(r,e),await jg(n,e)&&(XTe(t,i),await vC(e,i))},XTe=(t,e)=>{bC(t,t.writable,e)};import{Duplex as vEt}from"stream";import{callbackify as bEt}from"util";var QTe=({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}=R3(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=P3(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=A3(c,a),{read:_,onStdoutDataDone:y}=x3({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new vEt({read:_,...C3(u,t,d),destroy:bEt(TEt.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 I3({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),N3(u,v,c),v},TEt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([O3({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),k3({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var $3=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Di.has(e),o=Ng(t,r),a=SC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return wEt(a,o,t)},wEt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var ewe=(t,{encoding:e})=>{let r=HTe();t.readable=YTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=ZTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=QTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=$3.bind(void 0,t,e),t[Symbol.asyncIterator]=$3.bind(void 0,t,e,{})};var twe=(t,e)=>{for(let[r,n]of AEt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},REt=(async()=>{})().constructor.prototype,AEt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(REt,t)]);var rwe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=OEt(t,e,r),{subprocess:f,promise:p}=CEt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=yC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),twe(f,p),ta.set(f,{options:u,fileDescriptors:d}),f},OEt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=IP(t,e,r),{file:a,commandArguments:c,options:l}=YP(t,e,r),u=PEt(l),d=pTe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},PEt=({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}},CEt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=IEt(...KP(t,e,r))}catch(h){return lTe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;xEt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];bTe(c,a,l),wTe(c,r,l);let d={},f=ea();c.kill=UEe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=UTe(c,r),ewe(c,r),oTe(c,r);let p=NEt({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}},NEt=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 VTe({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)=>vc(g,e,w)),v=vc(m,e,"all"),S=kEt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Mg(S,n,e)},kEt=({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 ra,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):nC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var TC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,$Et(n,t[n],i)]));return{...t,...r}},$Et=(t,e,r)=>LEt.has(t)&&_r(e)&&_r(r)?{...e,...r}:r,LEt=new Set(["env",...u6]);var Su=(t,e,r,n)=>{let i=(o,a,c)=>Su(o,a,r,c),s=(...o)=>DEt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},DEt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(_r(s))return i(t,TC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=MEt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?eTe(a,c,l):rwe(a,c,l,i)},MEt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=pSe(e)?hSe(e,r):[e,...r],[o,a,c]=_P(...s),l=TC(TC(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 nwe=({file:t,commandArguments:e})=>swe(t,e),iwe=({file:t,commandArguments:e})=>({...swe(t,e),isSync:!0}),swe=(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]=UEt(t);return{file:r,commandArguments:n}},UEt=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(FEt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},FEt=/ +/g;var owe=(t,e,r)=>{t.sync=e(jEt,r),t.s=t.sync},awe=({options:t})=>cwe(t),jEt=({options:t})=>({...cwe(t),isSync:!0}),cwe=t=>({options:{...qEt(t),...t}}),qEt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},lwe={preferLocal:!0};var uwe=Su(()=>({})),Sur=Su(()=>({isSync:!0})),dwe=Su(nwe),Eur=Su(iwe),vur=Su(vve),bur=Su(awe,{},lwe,owe),{sendMessage:Tur,getOneMessage:wur,getEachMessage:Rur,getCancelSignal:Aur}=aTe();import{Transform as BEt}from"stream";var zEt=["NETLIFY_AI_GATEWAY_KEY"];function VEt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...zEt])]}function HEt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function GEt(){let e=VEt().map(r=>process.env[r]).filter(r=>!(!r||HEt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Es(t){if(typeof t!="string")return t;let e=GEt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(WEt(n),"g");r=r.replace(i,"******")}),r}function WEt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Kb=class extends BEt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Es(i);n(null,s)}},wC=Symbol("maskedWrite");function fwe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[wC]){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[wC]=!0,process.stdout.write=r}if(!process.stderr.write[wC]){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[wC]=!0,process.stderr.write=r}}}var pwe=!1,hwe=()=>{pwe=!0},gi=()=>pwe;var Jb=null,mwe=t=>(Jb&&Jb.destroy(),Jb=new bc({totalAllowedTime:t}),Jb),gwe=()=>Jb;var bc=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&&gi())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 mP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Ae.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 _we={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.0-test.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 ZEt=KEt(import.meta.url),XEt=Tc.dirname(ZEt),QEt=JEt(import.meta.url),qg=Ee("shell"),L3=new Set,ywe={preferLocal:!0},Hn=(t,e,r)=>{let[n,i]=evt(e,r),s={...ywe,...i},o=uwe(t,n,s);Ewe(o,s),Twe(o);let a=r?.idleTimeout;return a&&a>0&&bwe(o,a),o},Swe=(t,e)=>{let r={...ywe,...e},n=dwe(t,r);return Ewe(n,r),Twe(n),e?.idleTimeout&&e.idleTimeout>0&&bwe(n,e.idleTimeout),n},evt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ewe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(wc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Kb).pipe(wc.stdout),t.stderr?.pipe(new Kb).pipe(wc.stderr);return}t.stdout?.pipe(wc.stdout),t.stderr?.pipe(wc.stderr)},D3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(wc.kill(-t.pid,e),qg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qg.error("Error killing process:",r),!1}},vwe=t=>D3(t,"SIGKILL"),bwe=(t,e)=>{let r=null,n=()=>{qg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),D3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing idle process ${t.pid}`),vwe(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)},Twe=t=>{L3.add(t);let e=gwe();if(e){let r=e.onTimesUp(()=>{qg.log(`Global timer expired, killing process ${t.pid}`),D3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing process ${t.pid} after timeout`),vwe(t))},5e3)});t.on("exit",()=>{L3.delete(t),r()}),t.on("error",()=>{L3.delete(t),r()})}};function ia(t,e){if(!wc.env.NETLIFY_LOCAL_MODE)try{let i=QEt.resolve(_we.name),s=Tc.dirname(i);for(;s!==Tc.dirname(s);){let o=Tc.dirname(s);if(Tc.basename(o)==="node_modules"){let a=Tc.join(o,".bin",e);if(RC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(wc.env.NODE_PATH){let i=Tc.join(wc.env.NODE_PATH,".bin",e);if(RC.existsSync(i))return i}let r=Tc.join(t,"node_modules",".bin",e);if(RC.existsSync(r))return r;let n=Tc.join(XEt,"..","node_modules",".bin",e);if(RC.existsSync(n))return n}import BL from"process";import{fileURLToPath as m$t}from"url";import{createRequire as g$t}from"module";import zL from"path";var tvt="__netlify__getTracer",rvt="__netlify__shutdownTracers",mt=(t,e)=>globalThis[tvt]?.(t,e),wwe=async()=>globalThis[rvt]?.();function Mf(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 l$t}from"timers/promises";ke();import wTt from"process";ke();var Avt=(t,e)=>{e.recordException(t),e.setStatus({code:xn.ERROR})};var xc=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}=_0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>y0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=_0e(r,n,i),c=this._tracer.startSpan(e,s,o);return y0e(c,s,a)}};function _0e(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 y0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:Avt,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 Yg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var gW=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=I0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Yg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Yg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=I0e(this._rawAttributes),this._schemaUrl=xvt(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,Yg(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(Yg(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=Ivt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function _W(t,e){return gW.FromAttributeList(Object.entries(t),e)}function I0e(t){return t.map(([e,r])=>Yg(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function xvt(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 Ivt(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}},O0e=new cT;var lT=Symbol.for("io.opentelemetry.js.api.logs"),Kg=globalThis;function P0e(t,e,r){return n=>n===t?e:r}var yW=1;var SW=class{getLogger(e,r,n){return new cT}},YC=new SW;var KC=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):O0e}};var uT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new KC(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:YC}_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 JC=class t{constructor(){this._proxyLoggerProvider=new uT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Kg[lT]?this.getLoggerProvider():(Kg[lT]=P0e(yW,e,YC),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Kg[lT])===null||e===void 0?void 0:e.call(Kg,yW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Kg[lT],this._proxyLoggerProvider=new uT}};var C0e=JC.getInstance();function N0e(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 k0e(t){t.forEach(e=>e.disable())}function EW(t){let e=t.tracerProvider||zt.getTracerProvider(),r=t.meterProvider||aT.getMeterProvider(),n=t.loggerProvider||C0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return N0e(i,e,r,n),()=>{k0e(i)}}Nc();var sk=$n(bY(),1);ke();Nc();var xIe=t=>{throw TypeError(t)},AY=(t,e,r)=>e.has(t)||xIe("Cannot "+r),ik=(t,e,r)=>(AY(t,e,"read from private field"),r?r.call(t):e.get(t)),TY=(t,e,r)=>e.has(t)?xIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),wIe=(t,e,r,n)=>(AY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),TTt=(t,e,r)=>(AY(t,e,"access private method"),r),RIe="__netlify__getTracer",RTt="__netlify__shutdownTracers",ATt="__nfOTLPTrace",PT,CT,RY,IIe,xTt=class{constructor(){TY(this,RY),TY(this,PT),TY(this,CT),wIe(this,PT,new e_(TTt(this,RY,IIe),this)),wIe(this,CT,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(ik(this,CT).debug(`export ${t.length.toString()} spans`),ik(this,PT).isCalled){e({code:Wn.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(ATt,JSON.stringify(ITt(t))),e({code:Wn.SUCCESS})}shutdown(){return ik(this,PT).call()}};PT=new WeakMap;CT=new WeakMap;RY=new WeakSet;IIe=function(){return ik(this,CT).debug("Shutting down"),Promise.resolve()};function ITt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:nk(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:wY(e.startTime),endTimeUnixNano:wY(e.endTime),attributes:nk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:wY(n.time),attributes:nk(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:nk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function nk(t){return Object.keys(t).map(e=>OIe(e,t[e]))}function OIe(t,e){return{key:t,value:PIe(e)}}function PIe(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(PIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>OIe(r,n))}}:{}}function wY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var AIe={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"}},CIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,RIe))return;let e=wTt.version.slice(1),r=_W({"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??[OTt()],i=new sk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Cc});let s=t.instrumentations??[];EW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,RIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new xc(zt.getTracer(a,c)):new xc(zt.getTracer(AIe.name,AIe.version))}}),Object.defineProperty(globalThis,RTt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},OTt=()=>new sk.SimpleSpanProcessor(new xTt);ke();Nc();var NT=$n(bY(),1);ke();import*as ok from"diagnostics_channel";var NIe=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?xn.ERROR:xn.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 xc?t:new xc(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){ok.subscribe(t,e);let r=()=>ok.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:xn.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 VLe=$n(BLe(),1);var jL=Ee("tracing"),zLe=8e3,u$t=5e3,Hw=async(t=u$t)=>{try{await Promise.race([wwe(),l$t(t)])}catch(e){jL.warn("Failed to flush tracers on shutdown",e)}},HLe=async(t,e,r)=>{if(!mt()){let n=[new NT.SimpleSpanProcessor(new uJ),new NT.SimpleSpanProcessor(new VLe.OTLPTraceExporter({url:r.exporterUrl}))];await CIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new NIe({skipHeaders:!0})]})}return r.traceparent?(Gn.setGlobalPropagator(new Cc),Gn.extract(Ft.active(),{traceparent:r.traceparent,isRemote:!0})):Ft.active()};function Ht(t,e,r){return jL.log(`\u23F3 TRACE: ${e} starting...`),Mf(t,e,r)}var uJ=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(", ")}]`:"";jL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&jL.log(` \u274C Error: ${e.status.message}`)}};function dJ(){return rt().captureLlmContentEnabled}function GLe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function qL(t,e,r){let n={role:t,parts:[{type:"text",content:Es(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function WLe(t,e,r,n){if(!t.length)return;let i=mt();if(!i)return;let s=dJ(),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>zLe?`${a.message.slice(0,zLe)}\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":qL("assistant",p)}:{}}}).end(u)})}import{readdir as d$t,rm as f$t}from"fs/promises";import{join as p$t}from"path";async function YLe(t,e=[]){let n=(await d$t(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>f$t(p$t(t,i),{recursive:!0,force:!0})))}var h$t=700,KLe=t=>t.mode==="create"&&(t.accountType===El||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=h$t);var _$t=zL.dirname(m$t(import.meta.url)),JLe=g$t(import.meta.url),y$t=zL.resolve(_$t,"scripts/scaffold.js"),S$t="scripts/scaffold.js",E$t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,fJ=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},v$t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),b$t=t=>{let e=fJ(t);return e==="node"||e.endsWith("/node")},Qc=t=>{if(typeof t!="string")return!1;let e=t.match(E$t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&v$t(fJ(e[r]));)r+=1;if(r>=e.length||!b$t(e[r]))return!1;let n=e[r+1];return n?fJ(n).includes(S$t):!1},oy=Ee("create_stage"),ZLe="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.",T$t=`${ZLe}
|
|
581
|
+
if (condition) { yield value; }`)};import{Buffer as oyt}from"buffer";import{StringDecoder as ayt}from"string_decoder";var lC=(t,e,r)=>{if(r)return;if(t)return{transform:cyt.bind(void 0,new TextEncoder)};let n=new ayt(e);return{transform:lyt.bind(void 0,n),final:uyt.bind(void 0,n)}},cyt=function*(t,e){oyt.isBuffer(e)?yield yc(e):typeof e=="string"?yield t.encode(e):yield e},lyt=function*(t,e){yield Pr(e)?t.write(e):e},uyt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Ube}from"util";var X6=Ube(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),uC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=fyt}=e[r];for await(let i of n(t))yield*uC(i,e,r+1)},Fbe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*dyt(r,Number(e),t)},dyt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*uC(n,r,e+1)},jbe=Ube(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),fyt=function*(t){yield t};var Q6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},qbe=(t,e)=>[...e.flatMap(r=>[...$f(r,t,0)]),...zb(t)],$f=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=hyt}=e[r];for(let i of n(t))yield*$f(i,e,r+1)},zb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*pyt(r,Number(e),t)},pyt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*$f(n,r,e+1)},hyt=function*(t){yield t};var e3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=zbe(t,o,s),l=kf(e),u=kf(r),d=l?X6.bind(void 0,uC,a):Q6.bind(void 0,$f),f=l||u?X6.bind(void 0,Fbe,a):Q6.bind(void 0,zb),p=l||u?jbe.bind(void 0,a):void 0;return{stream:new myt({writableObjectMode:n,writableHighWaterMark:Bbe(n),readableObjectMode:i,readableHighWaterMark:Bbe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},dC=(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=zbe(o,r,a);t=qbe(c,t)}return t},zbe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Lbe(n,a)},lC(r,o,n),cC(r,s,n,c),{transform:t,final:e},{transform:Dbe(i,a)},$be({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Vbe=(t,e)=>{for(let r of gyt(t))_yt(t,r,e)},gyt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),_yt=(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 ${yu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>yyt(a,n));r.input=kb(o)},yyt=(t,e)=>{let r=dC(t,e,"utf8",!0);return Syt(r),kb(r)},Syt=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 Tyt,appendFileSync as wyt}from"fs";var fC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&xg(r,n)&&!Di.has(e)&&Eyt(n)&&(t.some(({type:i,value:s})=>i==="native"&&vyt.has(s))||t.every(({type:i})=>Ss.has(i))),Eyt=t=>t===1||t===2,vyt=new Set(["pipe","overlapped"]),Hbe=async(t,e,r,n)=>{for await(let i of t)byt(e)||Wbe(i,r,n)},Gbe=(t,e,r)=>{for(let n of t)Wbe(n,e,r)},byt=t=>t._readableState.pipes.length>0,Wbe=(t,e,r)=>{let n=AP(t);Qo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Ybe=({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)=>Ryt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Ryt=({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=Kve(t,s,d),p=yc(f),{stdioItems:h,objectMode:m}=e[r],_=Ayt([p],h,c,n),{serializedResult:y,finalResult:v=y}=xyt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Iyt({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&&Oyt(y,h,i),S}catch(g){return n.error=g,S}},Ayt=(t,e,r,n)=>{try{return dC(t,e,r,!1)}catch(i){return n.error=i,t}},xyt=({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=lSe(t,r);return n[s]?{serializedResult:o,finalResult:Z6(o,!i[s],e)}:{serializedResult:o}},Iyt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!fC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=Z6(t,!1,o);try{Gbe(a,e,n)}catch(c){r.error??=c}},Oyt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>oC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?wyt(n,t):(r.add(s),Tyt(n,t))}};var Kbe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,vc(e,r,"all")]:Array.isArray(e)?[vc(t,r,"all"),...e]:Pr(t)&&Pr(e)?o6([t,e]):`${t}${e}`};import{once as t3}from"events";var Jbe=async(t,e)=>{let[r,n]=await Pyt(t);return e.isForcefullyTerminated??=!1,[r,n]},Pyt=async t=>{let[e,r]=await Promise.allSettled([t3(t,"spawn"),t3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Zbe(t):r.value},Zbe=async t=>{try{return await t3(t,"exit")}catch{return Zbe(t)}},Xbe=async t=>{let[e,r]=await t;if(!Cyt(e,r)&&r3(e,r))throw new eo;return[e,r]},Cyt=(t,e)=>t===void 0&&e===void 0,r3=(t,e)=>t!==0||e!==null;var Qbe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Nyt(t,e,r),o=s?.code==="ETIMEDOUT",a=Yve(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Nyt=(t,e,r)=>t!==void 0?t:r3(e,r)?new eo:void 0;var eTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=$yt(t,e,r),d=Myt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Mg(d,c,l)},$yt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=IP(t,e,r),a=Lyt(r),{file:c,commandArguments:l,options:u}=YP(t,e,a);Dyt(u);let d=Pbe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Lyt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Dyt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&pC("ipcInput"),t&&pC("ipc: true"),r&&pC("detached: true"),n&&pC("cancelSignal")},pC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Myt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Uyt({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}=Qbe(c,r),{output:h,error:m=l}=Ybe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>vc(v,r,S)),y=vc(Kbe(h,r),r,"all");return jyt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Uyt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Vbe(s,r);let a=Fyt(r);return kyt(...KP(t,e,a))}catch(a){return Dg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Fyt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:rC(e)}),jyt=({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?nC({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 xEt}from"events";import{spawn as IEt}from"child_process";import sTe from"process";import{once as n3,on as qyt}from"events";var tTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Pg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:BP(t)}),Byt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Byt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{UP(e,i);let s=_u(t,e,r),o=new AbortController;try{return await Promise.race([zyt(s,n,o),Vyt(s,r,o),Hyt(s,r,o)])}catch(a){throw Cg(t),a}finally{o.abort(),FP(e,i)}},zyt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await n3(t,"message",{signal:r});return n}for await(let[n]of qyt(t,"message",{signal:r}))if(e(n))return n},Vyt=async(t,e,{signal:r})=>{await n3(t,"disconnect",{signal:r}),qEe(e)},Hyt=async(t,e,{signal:r})=>{let[n]=await n3(t,"strict:error",{signal:r});throw LP(n,e)};import{once as nTe,on as Gyt}from"events";var iTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>i3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),i3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Pg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:BP(t)}),UP(e,s);let o=_u(t,e,r),a=new AbortController,c={};return Wyt(t,o,a),Yyt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Kyt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Wyt=async(t,e,r)=>{try{await nTe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Yyt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await nTe(t,"strict:error",{signal:r.signal});n.error=LP(i,e),r.abort()}catch{}},Kyt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Gyt(r,"message",{signal:s.signal}))rTe(o),yield c}catch{rTe(o)}finally{s.abort(),FP(e,a),n||Cg(t),i&&await t}},rTe=({error:t})=>{if(t)throw t};var oTe=(t,{ipc:e})=>{Object.assign(t,cTe(t,!1,e))},aTe=()=>{let t=sTe,e=!0,r=sTe.channel!==void 0;return{...cTe(t,e,r),getCancelSignal:hve.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},cTe=(t,e,r)=>({sendMessage:GP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:tTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:iTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Jyt}from"child_process";import{PassThrough as Zyt,Readable as Xyt,Writable as Qyt,Duplex as eSt}from"stream";var lTe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{Y6(n);let a=new Jyt;tSt(a,n),Object.assign(a,{readable:rSt,writable:nSt,duplex:iSt});let c=Dg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=sSt(c,o,i);return{subprocess:a,promise:l}},tSt=(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 Zyt;return t.end(),t},rSt=()=>new Xyt({read(){}}),nSt=()=>new Qyt({write(){}}),iSt=()=>new eSt({read(){},write(){}}),sSt=async(t,e,r)=>Mg(t,e,r);import{createReadStream as uTe,createWriteStream as dTe}from"fs";import{Buffer as oSt}from"buffer";import{Readable as Hb,Writable as aSt,Duplex as cSt}from"stream";var pTe=(t,e)=>aC(lSt,t,e,!1),Gb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${yu[t]}.`)},fTe={fileNumber:Gb,generator:e3,asyncGenerator:e3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:cSt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},lSt={input:{...fTe,fileUrl:({value:t})=>({stream:uTe(t)}),filePath:({value:{file:t}})=>({stream:uTe(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(oSt.from(t))})},output:{...fTe,fileUrl:({value:t})=>({stream:dTe(t)}),filePath:({value:{file:t,append:e}})=>({stream:dTe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:aSt.fromWeb(t)}),iterable:Gb,asyncIterable:Gb,string:Gb,uint8Array:Gb}};import{on as uSt,once as hTe}from"events";import{PassThrough as dSt,getDefaultHighWaterMark as fSt}from"stream";import{finished as _Te}from"stream/promises";function Lf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)o3(i);let e=t.some(({readableObjectMode:i})=>i),r=pSt(t,e),n=new s3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var pSt=(t,e)=>{if(t.length===0)return fSt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},s3=class extends dSt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(o3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=hSt(this,this.#e,this.#s);let r=_St({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(o3(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)}},hSt=async(t,e,r)=>{hC(t,mTe);let n=new AbortController;try{await Promise.race([mSt(t,n),gSt(t,e,r,n)])}finally{n.abort(),hC(t,-mTe)}},mSt=async(t,{signal:e})=>{try{await _Te(t,{signal:e,cleanup:!0})}catch(r){throw yTe(t,r),r}},gSt=async(t,e,r,{signal:n})=>{for await(let[i]of uSt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},o3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},_St=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{hC(t,gTe);let a=new AbortController;try{await Promise.race([ySt(s,e,a),SSt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),ESt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),hC(t,-gTe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?a3(t):vSt(t))},ySt=async(t,e,{signal:r})=>{try{await t,r.aborted||a3(e)}catch(n){r.aborted||yTe(e,n)}},SSt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await _Te(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;STe(o)?i.add(e):ETe(t,o)}},ESt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await hTe(t,i,{signal:s}),!t.readable)return hTe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},vSt=t=>{t.writable&&t.end()},yTe=(t,e)=>{STe(e)?a3(t):ETe(t,e)},STe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",a3=t=>{(t.readable||t.writable)&&t.destroy()},ETe=(t,e)=>{t.destroyed||(t.once("error",bSt),t.destroy(e))},bSt=()=>{},hC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},mTe=2,gTe=1;import{finished as vTe}from"stream/promises";var Fg=(t,e)=>{t.pipe(e),TSt(t,e),wSt(t,e)},TSt=async(t,e)=>{if(!(Qs(t)||Qs(e))){try{await vTe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}c3(e)}},c3=t=>{t.writable&&t.end()},wSt=async(t,e)=>{if(!(Qs(t)||Qs(e))){try{await vTe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}l3(t)}},l3=t=>{t.readable&&t.destroy()};var bTe=(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)))RSt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ss.has(c)))xSt({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]:Lf(s);Fg(o,i)}},RSt=(t,e,r,n)=>{r==="output"?Fg(t.stdio[n],e):Fg(e,t.stdio[n]);let i=ASt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},ASt=["stdin","stdout","stderr"],xSt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;ISt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},ISt=(t,{signal:e})=>{Qs(t)&&Cf(t,OSt,e)},OSt=2;import{addAbortListener as NSt}from"events";var Df=[];Df.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Df.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Df.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var mC=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",u3=Symbol.for("signal-exit emitter"),d3=globalThis,PSt=Object.defineProperty.bind(Object),f3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(d3[u3])return d3[u3];PSt(d3,u3,{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}},gC=class{},CSt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),p3=class extends gC{onExit(){return()=>{}}load(){}unload(){}},h3=class extends gC{#e=m3.platform==="win32"?"SIGINT":"SIGHUP";#r=new f3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Df)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(!mC(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 Df)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,Df.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 mC(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"&&mC(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)}},m3=globalThis.process,{onExit:TTe,load:Oar,unload:Par}=CSt(mC(m3)?new h3(m3):new p3);var wTe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=TTe(()=>{t.kill()});NSt(n,()=>{i()})};var ATe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=xP(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=kSt(r,n,i),{sourceStream:d,sourceError:f}=LSt(t,l),{options:p,fileDescriptors:h}=ta.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},kSt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=$St(t,e,...r),a=MP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},$St=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(RTe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||i6(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]=_P(r,...n);return{destination:e(RTe)(i,s,o),pipeOptions:o}}if(ta.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}`)},RTe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),LSt=(t,e)=>{try{return{sourceStream:Ng(t,e)}}catch(r){return{sourceError:r}}};var ITe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=DSt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw g3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},DSt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return l3(t),n;if(e!==void 0)return c3(r),e},g3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Dg({error:t,command:xTe,escapedCommand:xTe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),xTe="source.pipe(destination)";var OTe=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 MSt}from"stream/promises";var PTe=(t,e,r)=>{let n=_C.has(e)?FSt(t,e):USt(t,e);return Cf(t,qSt,r.signal),Cf(e,BSt,r.signal),jSt(e),n},USt=(t,e)=>{let r=Lf([t]);return Fg(r,e),_C.set(e,r),r},FSt=(t,e)=>{let r=_C.get(e);return r.add(t),r},jSt=async t=>{try{await MSt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}_C.delete(t)},_C=new WeakMap,qSt=2,BSt=1;import{aborted as zSt}from"util";var CTe=(t,e)=>t===void 0?[]:[VSt(t,e)],VSt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await zSt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw g3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var yC=(t,...e)=>{if(_r(e[0]))return yC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ATe(t,...e),i=HSt({...n,destination:r});return i.pipe=yC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},HSt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=GSt(t,i);ITe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=PTe(e,s,d);return await Promise.race([OTe(u),...CTe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},GSt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as QSt}from"timers/promises";import{on as WSt}from"events";import{getDefaultHighWaterMark as YSt}from"stream";var SC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return KSt(e,o),kTe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},KSt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},_3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;JSt(e,o,t);let a=t.readableObjectMode&&!s;return kTe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},JSt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},kTe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=WSt(t,"data",{signal:e.signal,highWaterMark:NTe,highWatermark:NTe});return ZSt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},y3=YSt(!0),NTe=y3,ZSt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=XSt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*$f(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*zb(a)}},XSt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[lC(t,r,!e),cC(t,i,!n,{})].filter(Boolean);var $Te=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=eEt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([tEt(t),d]);return}let f=K6(c,r),p=_3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([rEt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},eEt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!fC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=_3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Hbe(a,t,r,s)},tEt=async t=>{await QSt(),t.readableFlowing===null&&t.resume()},rEt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await QP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await eC(r,{maxBuffer:s})):await Lg(r,{maxBuffer:s})}catch(a){return LTe(Hve({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},S3=async t=>{try{return await t}catch(e){return LTe(e)}},LTe=({bufferedData:t})=>aSe(t)?new Uint8Array(t):t;import{finished as nEt}from"stream/promises";var Wb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=iEt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],nEt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||aEt(a,e,r,n)}finally{o.abort()}},iEt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&sEt(t,r,n),n},sEt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{oEt(e,r),n.call(t,...i)}},oEt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},aEt=(t,e,r,n)=>{if(!cEt(t,e,r,n))throw t},cEt=(t,e,r,n=!0)=>r.propagating?DTe(t)||EC(t):(r.propagating=!0,E3(r,e)===n?DTe(t):EC(t)),E3=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",EC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",DTe=t=>t?.code==="EPIPE";var MTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>v3({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),v3=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(E3(l,e)){await u;return}let[d]=await Promise.all([$Te({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 UTe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Lf([t,e].filter(Boolean)):void 0,FTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>v3({...lEt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:uEt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),lEt=({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}},uEt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as dEt}from"events";var jTe=t=>xg(t,"ipc"),qTe=(t,e)=>{let r=AP(t);Qo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var BTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=jTe(s),a=Sc(e,"ipc"),c=Sc(r,"ipc");for await(let l of i3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Gve(t,i,c),i.push(l)),o&&qTe(l,s);return i},zTe=async(t,e)=>(await Promise.allSettled([t]),e);var VTe=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=Jbe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=MTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=FTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),O=[],x=BTe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),R=fEt(m,t,S),P=pEt(h,S);try{return await Promise.race([Promise.all([{},Xbe(v),Promise.all(g),w,x,wve(t,d),...R,...P]),_,hEt(t,y),...Sve(t,s,f,y),...jEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),..._ve({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=>S3(b))),S3(w),zTe(x,O),Promise.allSettled(R),Promise.allSettled(P)])}},fEt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Wb(n,i,r)),pEt=(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"}))),hEt=async(t,{signal:e})=>{let[r]=await dEt(t,"error",{signal:e});throw r};var HTe=()=>({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=ea();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},jg=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 mEt}from"stream";import{callbackify as gEt}from"util";import{finished as GTe}from"stream/promises";var b3=async t=>{if(t!==void 0)try{await T3(t)}catch{}},WTe=async t=>{if(t!==void 0)try{await w3(t)}catch{}},T3=async t=>{await GTe(t,{cleanup:!0,readable:!1,writable:!0})},w3=async t=>{await GTe(t,{cleanup:!0,readable:!0,writable:!1})},vC=async(t,e)=>{if(await t,e)throw e},bC=(t,e,r)=>{r&&!EC(r)?t.destroy(r):e&&t.destroy()};var YTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Di.has(r),{subprocessStdout:a,waitReadableDestroy:c}=R3(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=A3(a,o),{read:f,onStdoutDataDone:p}=x3({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new mEt({read:f,destroy:gEt(O3.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return I3({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},R3=(t,e,r)=>{let n=Ng(t,e),i=Yb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},A3=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:y3},x3=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ea(),o=SC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){_Et(this,o,s)},onStdoutDataDone:s}},_Et=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},I3=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await w3(t),await n,await b3(i),await e,r.readable&&r.push(null)}catch(s){await b3(i),KTe(r,s)}},O3=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await jg(r,e)&&(KTe(t,n),await vC(e,n))},KTe=(t,e)=>{bC(t,t.readable,e)};import{Writable as yEt}from"stream";import{callbackify as JTe}from"util";var ZTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=P3(t,r,e),o=new yEt({...C3(n,t,i),destroy:JTe(k3.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return N3(n,o),o},P3=(t,e,r)=>{let n=MP(t,e),i=Yb(r,n,"writableFinal"),s=Yb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},C3=(t,e,r)=>({write:SEt.bind(void 0,t),final:JTe(EEt.bind(void 0,t,e,r))}),SEt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},EEt=async(t,e,r)=>{await jg(r,e)&&(t.writable&&t.end(),await e)},N3=async(t,e,r)=>{try{await T3(t),e.writable&&e.end()}catch(n){await WTe(r),XTe(e,n)}},k3=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await jg(r,e),await jg(n,e)&&(XTe(t,i),await vC(e,i))},XTe=(t,e)=>{bC(t,t.writable,e)};import{Duplex as vEt}from"stream";import{callbackify as bEt}from"util";var QTe=({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}=R3(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=P3(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=A3(c,a),{read:_,onStdoutDataDone:y}=x3({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new vEt({read:_,...C3(u,t,d),destroy:bEt(TEt.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 I3({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),N3(u,v,c),v},TEt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([O3({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),k3({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var $3=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Di.has(e),o=Ng(t,r),a=SC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return wEt(a,o,t)},wEt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var ewe=(t,{encoding:e})=>{let r=HTe();t.readable=YTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=ZTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=QTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=$3.bind(void 0,t,e),t[Symbol.asyncIterator]=$3.bind(void 0,t,e,{})};var twe=(t,e)=>{for(let[r,n]of AEt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},REt=(async()=>{})().constructor.prototype,AEt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(REt,t)]);var rwe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=OEt(t,e,r),{subprocess:f,promise:p}=CEt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=yC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),twe(f,p),ta.set(f,{options:u,fileDescriptors:d}),f},OEt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=IP(t,e,r),{file:a,commandArguments:c,options:l}=YP(t,e,r),u=PEt(l),d=pTe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},PEt=({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}},CEt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=IEt(...KP(t,e,r))}catch(h){return lTe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;xEt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];bTe(c,a,l),wTe(c,r,l);let d={},f=ea();c.kill=UEe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=UTe(c,r),ewe(c,r),oTe(c,r);let p=NEt({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}},NEt=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 VTe({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)=>vc(g,e,w)),v=vc(m,e,"all"),S=kEt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Mg(S,n,e)},kEt=({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 ra,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):nC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var TC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,$Et(n,t[n],i)]));return{...t,...r}},$Et=(t,e,r)=>LEt.has(t)&&_r(e)&&_r(r)?{...e,...r}:r,LEt=new Set(["env",...u6]);var Su=(t,e,r,n)=>{let i=(o,a,c)=>Su(o,a,r,c),s=(...o)=>DEt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},DEt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(_r(s))return i(t,TC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=MEt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?eTe(a,c,l):rwe(a,c,l,i)},MEt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=pSe(e)?hSe(e,r):[e,...r],[o,a,c]=_P(...s),l=TC(TC(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 nwe=({file:t,commandArguments:e})=>swe(t,e),iwe=({file:t,commandArguments:e})=>({...swe(t,e),isSync:!0}),swe=(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]=UEt(t);return{file:r,commandArguments:n}},UEt=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(FEt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},FEt=/ +/g;var owe=(t,e,r)=>{t.sync=e(jEt,r),t.s=t.sync},awe=({options:t})=>cwe(t),jEt=({options:t})=>({...cwe(t),isSync:!0}),cwe=t=>({options:{...qEt(t),...t}}),qEt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},lwe={preferLocal:!0};var uwe=Su(()=>({})),Sur=Su(()=>({isSync:!0})),dwe=Su(nwe),Eur=Su(iwe),vur=Su(vve),bur=Su(awe,{},lwe,owe),{sendMessage:Tur,getOneMessage:wur,getEachMessage:Rur,getCancelSignal:Aur}=aTe();import{Transform as BEt}from"stream";var zEt=["NETLIFY_AI_GATEWAY_KEY"];function VEt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...zEt])]}function HEt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function GEt(){let e=VEt().map(r=>process.env[r]).filter(r=>!(!r||HEt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Es(t){if(typeof t!="string")return t;let e=GEt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(WEt(n),"g");r=r.replace(i,"******")}),r}function WEt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Kb=class extends BEt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Es(i);n(null,s)}},wC=Symbol("maskedWrite");function fwe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[wC]){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[wC]=!0,process.stdout.write=r}if(!process.stderr.write[wC]){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[wC]=!0,process.stderr.write=r}}}var pwe=!1,hwe=()=>{pwe=!0},gi=()=>pwe;var Jb=null,mwe=t=>(Jb&&Jb.destroy(),Jb=new bc({totalAllowedTime:t}),Jb),gwe=()=>Jb;var bc=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&&gi())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 mP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Ae.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 _we={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.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 ZEt=KEt(import.meta.url),XEt=Tc.dirname(ZEt),QEt=JEt(import.meta.url),qg=Ee("shell"),L3=new Set,ywe={preferLocal:!0},Hn=(t,e,r)=>{let[n,i]=evt(e,r),s={...ywe,...i},o=uwe(t,n,s);Ewe(o,s),Twe(o);let a=r?.idleTimeout;return a&&a>0&&bwe(o,a),o},Swe=(t,e)=>{let r={...ywe,...e},n=dwe(t,r);return Ewe(n,r),Twe(n),e?.idleTimeout&&e.idleTimeout>0&&bwe(n,e.idleTimeout),n},evt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ewe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(wc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Kb).pipe(wc.stdout),t.stderr?.pipe(new Kb).pipe(wc.stderr);return}t.stdout?.pipe(wc.stdout),t.stderr?.pipe(wc.stderr)},D3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(wc.kill(-t.pid,e),qg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qg.error("Error killing process:",r),!1}},vwe=t=>D3(t,"SIGKILL"),bwe=(t,e)=>{let r=null,n=()=>{qg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),D3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing idle process ${t.pid}`),vwe(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)},Twe=t=>{L3.add(t);let e=gwe();if(e){let r=e.onTimesUp(()=>{qg.log(`Global timer expired, killing process ${t.pid}`),D3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing process ${t.pid} after timeout`),vwe(t))},5e3)});t.on("exit",()=>{L3.delete(t),r()}),t.on("error",()=>{L3.delete(t),r()})}};function ia(t,e){if(!wc.env.NETLIFY_LOCAL_MODE)try{let i=QEt.resolve(_we.name),s=Tc.dirname(i);for(;s!==Tc.dirname(s);){let o=Tc.dirname(s);if(Tc.basename(o)==="node_modules"){let a=Tc.join(o,".bin",e);if(RC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(wc.env.NODE_PATH){let i=Tc.join(wc.env.NODE_PATH,".bin",e);if(RC.existsSync(i))return i}let r=Tc.join(t,"node_modules",".bin",e);if(RC.existsSync(r))return r;let n=Tc.join(XEt,"..","node_modules",".bin",e);if(RC.existsSync(n))return n}import BL from"process";import{fileURLToPath as m$t}from"url";import{createRequire as g$t}from"module";import zL from"path";var tvt="__netlify__getTracer",rvt="__netlify__shutdownTracers",mt=(t,e)=>globalThis[tvt]?.(t,e),wwe=async()=>globalThis[rvt]?.();function Mf(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 l$t}from"timers/promises";ke();import wTt from"process";ke();var Avt=(t,e)=>{e.recordException(t),e.setStatus({code:xn.ERROR})};var xc=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}=_0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>y0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=_0e(r,n,i),c=this._tracer.startSpan(e,s,o);return y0e(c,s,a)}};function _0e(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 y0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:Avt,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 Yg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var gW=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=I0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Yg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Yg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=I0e(this._rawAttributes),this._schemaUrl=xvt(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,Yg(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(Yg(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=Ivt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function _W(t,e){return gW.FromAttributeList(Object.entries(t),e)}function I0e(t){return t.map(([e,r])=>Yg(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function xvt(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 Ivt(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}},O0e=new cT;var lT=Symbol.for("io.opentelemetry.js.api.logs"),Kg=globalThis;function P0e(t,e,r){return n=>n===t?e:r}var yW=1;var SW=class{getLogger(e,r,n){return new cT}},YC=new SW;var KC=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):O0e}};var uT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new KC(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:YC}_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 JC=class t{constructor(){this._proxyLoggerProvider=new uT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Kg[lT]?this.getLoggerProvider():(Kg[lT]=P0e(yW,e,YC),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Kg[lT])===null||e===void 0?void 0:e.call(Kg,yW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Kg[lT],this._proxyLoggerProvider=new uT}};var C0e=JC.getInstance();function N0e(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 k0e(t){t.forEach(e=>e.disable())}function EW(t){let e=t.tracerProvider||zt.getTracerProvider(),r=t.meterProvider||aT.getMeterProvider(),n=t.loggerProvider||C0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return N0e(i,e,r,n),()=>{k0e(i)}}Nc();var sk=$n(bY(),1);ke();Nc();var xIe=t=>{throw TypeError(t)},AY=(t,e,r)=>e.has(t)||xIe("Cannot "+r),ik=(t,e,r)=>(AY(t,e,"read from private field"),r?r.call(t):e.get(t)),TY=(t,e,r)=>e.has(t)?xIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),wIe=(t,e,r,n)=>(AY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),TTt=(t,e,r)=>(AY(t,e,"access private method"),r),RIe="__netlify__getTracer",RTt="__netlify__shutdownTracers",ATt="__nfOTLPTrace",PT,CT,RY,IIe,xTt=class{constructor(){TY(this,RY),TY(this,PT),TY(this,CT),wIe(this,PT,new e_(TTt(this,RY,IIe),this)),wIe(this,CT,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(ik(this,CT).debug(`export ${t.length.toString()} spans`),ik(this,PT).isCalled){e({code:Wn.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(ATt,JSON.stringify(ITt(t))),e({code:Wn.SUCCESS})}shutdown(){return ik(this,PT).call()}};PT=new WeakMap;CT=new WeakMap;RY=new WeakSet;IIe=function(){return ik(this,CT).debug("Shutting down"),Promise.resolve()};function ITt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:nk(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:wY(e.startTime),endTimeUnixNano:wY(e.endTime),attributes:nk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:wY(n.time),attributes:nk(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:nk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function nk(t){return Object.keys(t).map(e=>OIe(e,t[e]))}function OIe(t,e){return{key:t,value:PIe(e)}}function PIe(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(PIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>OIe(r,n))}}:{}}function wY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var AIe={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"}},CIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,RIe))return;let e=wTt.version.slice(1),r=_W({"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??[OTt()],i=new sk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Cc});let s=t.instrumentations??[];EW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,RIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new xc(zt.getTracer(a,c)):new xc(zt.getTracer(AIe.name,AIe.version))}}),Object.defineProperty(globalThis,RTt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},OTt=()=>new sk.SimpleSpanProcessor(new xTt);ke();Nc();var NT=$n(bY(),1);ke();import*as ok from"diagnostics_channel";var NIe=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?xn.ERROR:xn.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 xc?t:new xc(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){ok.subscribe(t,e);let r=()=>ok.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:xn.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 VLe=$n(BLe(),1);var jL=Ee("tracing"),zLe=8e3,u$t=5e3,Hw=async(t=u$t)=>{try{await Promise.race([wwe(),l$t(t)])}catch(e){jL.warn("Failed to flush tracers on shutdown",e)}},HLe=async(t,e,r)=>{if(!mt()){let n=[new NT.SimpleSpanProcessor(new uJ),new NT.SimpleSpanProcessor(new VLe.OTLPTraceExporter({url:r.exporterUrl}))];await CIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new NIe({skipHeaders:!0})]})}return r.traceparent?(Gn.setGlobalPropagator(new Cc),Gn.extract(Ft.active(),{traceparent:r.traceparent,isRemote:!0})):Ft.active()};function Ht(t,e,r){return jL.log(`\u23F3 TRACE: ${e} starting...`),Mf(t,e,r)}var uJ=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(", ")}]`:"";jL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&jL.log(` \u274C Error: ${e.status.message}`)}};function dJ(){return rt().captureLlmContentEnabled}function GLe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function qL(t,e,r){let n={role:t,parts:[{type:"text",content:Es(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function WLe(t,e,r,n){if(!t.length)return;let i=mt();if(!i)return;let s=dJ(),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>zLe?`${a.message.slice(0,zLe)}\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":qL("assistant",p)}:{}}}).end(u)})}import{readdir as d$t,rm as f$t}from"fs/promises";import{join as p$t}from"path";async function YLe(t,e=[]){let n=(await d$t(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>f$t(p$t(t,i),{recursive:!0,force:!0})))}var h$t=700,KLe=t=>t.mode==="create"&&(t.accountType===El||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=h$t);var _$t=zL.dirname(m$t(import.meta.url)),JLe=g$t(import.meta.url),y$t=zL.resolve(_$t,"scripts/scaffold.js"),S$t="scripts/scaffold.js",E$t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,fJ=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},v$t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),b$t=t=>{let e=fJ(t);return e==="node"||e.endsWith("/node")},Qc=t=>{if(typeof t!="string")return!1;let e=t.match(E$t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&v$t(fJ(e[r]));)r+=1;if(r>=e.length||!b$t(e[r]))return!1;let n=e[r+1];return n?fJ(n).includes(S$t):!1},oy=Ee("create_stage"),ZLe="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.",T$t=`${ZLe}
|
|
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.`,w$t=`${ZLe}
|
|
584
584
|
|
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:cL},yDe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},SDe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:yDe};import{Buffer as EDe}from"buffer";var mte=(t,e)=>t?void 0:vDe.bind(void 0,e),vDe=function*(t,e){if(typeof e!="string"&&!jt(e)&&!EDe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},gte=(t,e)=>t?TDe.bind(void 0,e):bDe.bind(void 0,e),TDe=function*(t,e){_te(t,e),yield e},bDe=function*(t,e){if(_te(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},_te=(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 ADe}from"buffer";import{StringDecoder as xDe}from"string_decoder";var ZA=(t,e,r)=>{if(r)return;if(t)return{transform:wDe.bind(void 0,new TextEncoder)};let n=new xDe(e);return{transform:RDe.bind(void 0,n),final:IDe.bind(void 0,n)}},wDe=function*(t,e){ADe.isBuffer(e)?yield lo(e):typeof e=="string"?yield t.encode(e):yield e},RDe=function*(t,e){yield jt(e)?t.write(e):e},IDe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as yte}from"util";var uL=yte(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),JA=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=PDe}=e[r];for await(let i of n(t))yield*JA(i,e,r+1)},Ste=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*CDe(r,Number(e),t)},CDe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*JA(n,r,e+1)},Ete=yte(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),PDe=function*(t){yield t};var dL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},vte=(t,e)=>[...e.flatMap(r=>[...Tl(r,t,0)]),...__(t)],Tl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=NDe}=e[r];for(let i of n(t))yield*Tl(i,e,r+1)},__=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ODe(r,Number(e),t)},ODe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Tl(n,r,e+1)},NDe=function*(t){yield t};var fL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=bte(t,o,s),l=vl(e),u=vl(r),d=l?uL.bind(void 0,JA,a):dL.bind(void 0,Tl),f=l||u?uL.bind(void 0,Ste,a):dL.bind(void 0,__),p=l||u?Ete.bind(void 0,a):void 0;return{stream:new kDe({writableObjectMode:n,writableHighWaterMark:Tte(n),readableObjectMode:i,readableHighWaterMark:Tte(i),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},XA=(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=bte(o,r,a);t=vte(c,t)}return t},bte=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:mte(n,a)},ZA(r,o,n),KA(r,s,n,c),{transform:t,final:e},{transform:gte(i,a)},hte({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Ate=(t,e)=>{for(let r of MDe(t))DDe(t,r,e)},MDe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),DDe=(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 ${wa[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>LDe(a,n));r.input=a_(o)},LDe=(t,e)=>{let r=XA(t,e,"utf8",!0);return $De(r),a_(r)},$De=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 jDe,appendFileSync as zDe}from"fs";var QA=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Zd(r,n)&&!hn.has(e)&&UDe(n)&&(t.some(({type:i,value:s})=>i==="native"&&FDe.has(s))||t.every(({type:i})=>qn.has(i))),UDe=t=>t===1||t===2,FDe=new Set(["pipe","overlapped"]),xte=async(t,e,r,n)=>{for await(let i of t)BDe(e)||Rte(i,r,n)},wte=(t,e,r)=>{for(let n of t)Rte(n,e,r)},BDe=t=>t._readableState.pipes.length>0,Rte=(t,e,r)=>{let n=pA(t);ss({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Ite=({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)=>GDe({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},GDe=({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=Cee(t,s,d),p=lo(f),{stdioItems:h,objectMode:m}=e[r],E=VDe([p],h,c,n),{serializedResult:S,finalResult:b=S}=qDe({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});HDe({serializedResult:S,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&&WDe(S,h,i),A}catch(v){return n.error=v,A}},VDe=(t,e,r,n)=>{try{return XA(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:a_(t)};let o=GX(t,r);return n[s]?{serializedResult:o,finalResult:lL(o,!i[s],e)}:{serializedResult:o}},HDe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!QA({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=lL(t,!1,o);try{wte(a,e,n)}catch(c){r.error??=c}},WDe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>WA.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?zDe(n,t):(r.add(s),jDe(n,t))}};var Cte=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,po(e,r,"all")]:Array.isArray(e)?[po(t,r,"all"),...e]:jt(t)&&jt(e)?yD([t,e]):`${t}${e}`};import{once as pL}from"events";var Pte=async(t,e)=>{let[r,n]=await YDe(t);return e.isForcefullyTerminated??=!1,[r,n]},YDe=async t=>{let[e,r]=await Promise.allSettled([pL(t,"spawn"),pL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Ote(t):r.value},Ote=async t=>{try{return await pL(t,"exit")}catch{return Ote(t)}},Nte=async t=>{let[e,r]=await t;if(!KDe(e,r)&&hL(e,r))throw new Ai;return[e,r]},KDe=(t,e)=>t===void 0&&e===void 0,hL=(t,e)=>t!==0||e!==null;var kte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ZDe(t,e,r),o=s?.code==="ETIMEDOUT",a=Iee(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ZDe=(t,e,r)=>t!==void 0?t:hL(e,r)?new Ai:void 0;var Mte=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=XDe(t,e,r),d=tLe({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return af(d,c,l)},XDe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=mA(t,e,r),a=QDe(r),{file:c,commandArguments:l,options:u}=DA(t,e,a);eLe(u);let d=ute(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},QDe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,eLe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&ex("ipcInput"),t&&ex("ipc: true"),r&&ex("detached: true"),n&&ex("cancelSignal")},ex=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},tLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=rLe({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}=kte(c,r),{output:h,error:m=l}=Ite({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),E=h.map((b,A)=>po(b,r,A)),S=po(Cte(h,r),r,"all");return iLe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:E,all:S,options:r,command:n,escapedCommand:i,startTime:a})},rLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Ate(s,r);let a=nLe(r);return JDe(...LA(t,e,a))}catch(a){return of({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},nLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:GA(e)}),iLe=({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?VA({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):g_({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 H$e}from"child_process";import Fte from"process";import{once as mL,on as sLe}from"events";var Dte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Qd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:CA(t)}),oLe({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),oLe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{xA(e,i);let s=xa(t,e,r),o=new AbortController;try{return await Promise.race([aLe(s,n,o),cLe(s,r,o),lLe(s,r,o)])}catch(a){throw ef(t),a}finally{o.abort(),wA(e,i)}},aLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await mL(t,"message",{signal:r});return n}for await(let[n]of sLe(t,"message",{signal:r}))if(e(n))return n},cLe=async(t,e,{signal:r})=>{await mL(t,"disconnect",{signal:r}),v7(e)},lLe=async(t,e,{signal:r})=>{let[n]=await mL(t,"strict:error",{signal:r});throw TA(n,e)};import{once as $te,on as uLe}from"events";var Ute=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>gL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),gL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Qd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:CA(t)}),xA(e,s);let o=xa(t,e,r),a=new AbortController,c={};return dLe(t,o,a),fLe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),pLe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},dLe=async(t,e,r)=>{try{await $te(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},fLe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await $te(t,"strict:error",{signal:r.signal});n.error=TA(i,e),r.abort()}catch{}},pLe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of uLe(r,"message",{signal:s.signal}))Lte(o),yield c}catch{Lte(o)}finally{s.abort(),wA(e,a),n||ef(t),i&&await t}},Lte=({error:t})=>{if(t)throw t};var Bte=(t,{ipc:e})=>{Object.assign(t,zte(t,!1,e))},jte=()=>{let t=Fte,e=!0,r=Fte.channel!==void 0;return{...zte(t,e,r),getCancelSignal:Y7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},zte=(t,e,r)=>({sendMessage:kA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Dte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Ute.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as hLe}from"child_process";import{PassThrough as mLe,Readable as gLe,Writable as _Le,Duplex as yLe}from"stream";var Gte=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{oL(n);let a=new hLe;SLe(a,n),Object.assign(a,{readable:ELe,writable:vLe,duplex:TLe});let c=of({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=bLe(c,o,i);return{subprocess:a,promise:l}},SLe=(t,e)=>{let r=y_(),n=y_(),i=y_(),s=Array.from({length:e.length-3},y_),o=y_(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},y_=()=>{let t=new mLe;return t.end(),t},ELe=()=>new gLe({read(){}}),vLe=()=>new _Le({write(){}}),TLe=()=>new yLe({read(){},write(){}}),bLe=async(t,e,r)=>af(t,e,r);import{createReadStream as Vte,createWriteStream as qte}from"fs";import{Buffer as ALe}from"buffer";import{Readable as S_,Writable as xLe,Duplex as wLe}from"stream";var Wte=(t,e)=>YA(RLe,t,e,!1),E_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${wa[t]}.`)},Hte={fileNumber:E_,generator:fL,asyncGenerator:fL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:wLe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},RLe={input:{...Hte,fileUrl:({value:t})=>({stream:Vte(t)}),filePath:({value:{file:t}})=>({stream:Vte(t)}),webStream:({value:t})=>({stream:S_.fromWeb(t)}),iterable:({value:t})=>({stream:S_.from(t)}),asyncIterable:({value:t})=>({stream:S_.from(t)}),string:({value:t})=>({stream:S_.from(t)}),uint8Array:({value:t})=>({stream:S_.from(ALe.from(t))})},output:{...Hte,fileUrl:({value:t})=>({stream:qte(t)}),filePath:({value:{file:t,append:e}})=>({stream:qte(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:xLe.fromWeb(t)}),iterable:E_,asyncIterable:E_,string:E_,uint8Array:E_}};import{on as ILe,once as Yte}from"events";import{PassThrough as CLe,getDefaultHighWaterMark as PLe}from"stream";import{finished as Jte}from"stream/promises";function bl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)yL(i);let e=t.some(({readableObjectMode:i})=>i),r=OLe(t,e),n=new _L({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var OLe=(t,e)=>{if(t.length===0)return PLe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},_L=class extends CLe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(yL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=NLe(this,this.#e,this.#s);let r=DLe({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(yL(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)}},NLe=async(t,e,r)=>{tx(t,Kte);let n=new AbortController;try{await Promise.race([kLe(t,n),MLe(t,e,r,n)])}finally{n.abort(),tx(t,-Kte)}},kLe=async(t,{signal:e})=>{try{await Jte(t,{signal:e,cleanup:!0})}catch(r){throw Xte(t,r),r}},MLe=async(t,e,r,{signal:n})=>{for await(let[i]of ILe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},yL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},DLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{tx(t,Zte);let a=new AbortController;try{await Promise.race([LLe(s,e,a),$Le({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),ULe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),tx(t,-Zte)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?SL(t):FLe(t))},LLe=async(t,e,{signal:r})=>{try{await t,r.aborted||SL(e)}catch(n){r.aborted||Xte(e,n)}},$Le=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Jte(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Qte(o)?i.add(e):ere(t,o)}},ULe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Yte(t,i,{signal:s}),!t.readable)return Yte(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},FLe=t=>{t.writable&&t.end()},Xte=(t,e)=>{Qte(e)?SL(t):ere(t,e)},Qte=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",SL=t=>{(t.readable||t.writable)&&t.destroy()},ere=(t,e)=>{t.destroyed||(t.once("error",BLe),t.destroy(e))},BLe=()=>{},tx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Kte=2,Zte=1;import{finished as tre}from"stream/promises";var lf=(t,e)=>{t.pipe(e),jLe(t,e),zLe(t,e)},jLe=async(t,e)=>{if(!(bi(t)||bi(e))){try{await tre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}EL(e)}},EL=t=>{t.writable&&t.end()},zLe=async(t,e)=>{if(!(bi(t)||bi(e))){try{await tre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}vL(t)}},vL=t=>{t.readable&&t.destroy()};var rre=(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)))GLe(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]:bl(s);lf(o,i)}},GLe=(t,e,r,n)=>{r==="output"?lf(t.stdio[n],e):lf(e,t.stdio[n]);let i=VLe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},VLe=["stdin","stdout","stderr"],qLe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;HLe(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},HLe=(t,{signal:e})=>{bi(t)&&Sl(t,WLe,e)},WLe=2;import{addAbortListener as ZLe}from"events";var Al=[];Al.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Al.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Al.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var rx=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",TL=Symbol.for("signal-exit emitter"),bL=globalThis,YLe=Object.defineProperty.bind(Object),AL=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(bL[TL])return bL[TL];YLe(bL,TL,{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}},nx=class{},KLe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),xL=class extends nx{onExit(){return()=>{}}load(){}unload(){}},wL=class extends nx{#e=RL.platform==="win32"?"SIGINT":"SIGHUP";#r=new AL;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Al)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(!rx(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 Al)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,Al.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 rx(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"&&rx(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)}},RL=globalThis.process,{onExit:nre,load:W_t,unload:Y_t}=KLe(rx(RL)?new wL(RL):new xL);var ire=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=nre(()=>{t.kill()});ZLe(n,()=>{i()})};var ore=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=hA(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=JLe(r,n,i),{sourceStream:d,sourceError:f}=QLe(t,l),{options:p,fileDescriptors:h}=as.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},JLe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=XLe(t,e,...r),a=AA(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},XLe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(sre,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||gD(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]=iA(r,...n);return{destination:e(sre)(i,s,o),pipeOptions:o}}if(as.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}`)},sre=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),QLe=(t,e)=>{try{return{sourceStream:tf(t,e)}}catch(r){return{sourceError:r}}};var cre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=e$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw IL({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},e$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return vL(t),n;if(e!==void 0)return EL(r),e},IL=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>of({error:t,command:are,escapedCommand:are,fileDescriptors:e,options:r,startTime:n,isSync:!1}),are="source.pipe(destination)";var lre=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 t$e}from"stream/promises";var ure=(t,e,r)=>{let n=ix.has(e)?n$e(t,e):r$e(t,e);return Sl(t,s$e,r.signal),Sl(e,o$e,r.signal),i$e(e),n},r$e=(t,e)=>{let r=bl([t]);return lf(r,e),ix.set(e,r),r},n$e=(t,e)=>{let r=ix.get(e);return r.add(t),r},i$e=async t=>{try{await t$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ix.delete(t)},ix=new WeakMap,s$e=2,o$e=1;import{aborted as a$e}from"util";var dre=(t,e)=>t===void 0?[]:[c$e(t,e)],c$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await a$e(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw IL({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var sx=(t,...e)=>{if(Pt(e[0]))return sx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ore(t,...e),i=l$e({...n,destination:r});return i.pipe=sx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},l$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=u$e(t,i);cre({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=ure(e,s,d);return await Promise.race([lre(u),...dre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},u$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as _$e}from"timers/promises";import{on as d$e}from"events";import{getDefaultHighWaterMark as f$e}from"stream";var ox=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return p$e(e,o),pre({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},p$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},CL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;h$e(e,o,t);let a=t.readableObjectMode&&!s;return pre({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},h$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},pre=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=d$e(t,"data",{signal:e.signal,highWaterMark:fre,highWatermark:fre});return m$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},PL=f$e(!0),fre=PL,m$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=g$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Tl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*__(a)}},g$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[ZA(t,r,!e),KA(t,i,!n,{})].filter(Boolean);var hre=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=y$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([S$e(t),d]);return}let f=aL(c,r),p=CL({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([E$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},y$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!QA({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=CL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await xte(a,t,r,s)},S$e=async t=>{await _$e(),t.readableFlowing===null&&t.resume()},E$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await BA(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await jA(r,{maxBuffer:s})):await sf(r,{maxBuffer:s})}catch(a){return mre(xee({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},OL=async t=>{try{return await t}catch(e){return mre(e)}},mre=({bufferedData:t})=>jX(t)?new Uint8Array(t):t;import{finished as v$e}from"stream/promises";var v_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=T$e(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],v$e(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||x$e(a,e,r,n)}finally{o.abort()}},T$e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&b$e(t,r,n),n},b$e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{A$e(e,r),n.call(t,...i)}},A$e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},x$e=(t,e,r,n)=>{if(!w$e(t,e,r,n))throw t},w$e=(t,e,r,n=!0)=>r.propagating?gre(t)||ax(t):(r.propagating=!0,NL(r,e)===n?gre(t):ax(t)),NL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ax=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",gre=t=>t?.code==="EPIPE";var _re=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>kL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),kL=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=v_(t,e,l);if(NL(l,e)){await u;return}let[d]=await Promise.all([hre({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 yre=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?bl([t,e].filter(Boolean)):void 0,Sre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>kL({...R$e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:I$e(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),R$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}},I$e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as C$e}from"events";var Ere=t=>Zd(t,"ipc"),vre=(t,e)=>{let r=pA(t);ss({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Tre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Ere(s),a=uo(e,"ipc"),c=uo(r,"ipc");for await(let l of gL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(wee(t,i,c),i.push(l)),o&&vre(l,s);return i},bre=async(t,e)=>(await Promise.allSettled([t]),e);var Are=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:E,controller:S})=>{let b=Pte(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=_re({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),P=Sre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),O=[],U=Tre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),I=P$e(m,t,A),M=O$e(h,A);try{return await Promise.race([Promise.all([{},Nte(b),Promise.all(v),P,U,iee(t,d),...I,...M]),E,N$e(t,S),...Q7(t,s,f,S),...E7({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...J7({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(B){return f.terminationReason??="other",Promise.all([{error:B},b,Promise.all(v.map(_=>OL(_))),OL(P),bre(U,O),Promise.allSettled(I),Promise.allSettled(M)])}},P$e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:v_(n,i,r)),O$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})=>v_(o,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),N$e=async(t,{signal:e})=>{let[r]=await C$e(t,"error",{signal:e});throw r};var xre=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),T_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=os();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},uf=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 k$e}from"stream";import{callbackify as M$e}from"util";import{finished as wre}from"stream/promises";var ML=async t=>{if(t!==void 0)try{await DL(t)}catch{}},Rre=async t=>{if(t!==void 0)try{await LL(t)}catch{}},DL=async t=>{await wre(t,{cleanup:!0,readable:!1,writable:!0})},LL=async t=>{await wre(t,{cleanup:!0,readable:!0,writable:!1})},cx=async(t,e)=>{if(await t,e)throw e},lx=(t,e,r)=>{r&&!ax(r)?t.destroy(r):e&&t.destroy()};var Ire=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||hn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=$L(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=UL(a,o),{read:f,onStdoutDataDone:p}=FL({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new k$e({read:f,destroy:M$e(jL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return BL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},$L=(t,e,r)=>{let n=tf(t,e),i=T_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},UL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:PL},FL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=os(),o=ox({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){D$e(this,o,s)},onStdoutDataDone:s}},D$e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},BL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await LL(t),await n,await ML(i),await e,r.readable&&r.push(null)}catch(s){await ML(i),Cre(r,s)}},jL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await uf(r,e)&&(Cre(t,n),await cx(e,n))},Cre=(t,e)=>{lx(t,t.readable,e)};import{Writable as L$e}from"stream";import{callbackify as Pre}from"util";var Ore=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=zL(t,r,e),o=new L$e({...GL(n,t,i),destroy:Pre(qL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return VL(n,o),o},zL=(t,e,r)=>{let n=AA(t,e),i=T_(r,n,"writableFinal"),s=T_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},GL=(t,e,r)=>({write:$$e.bind(void 0,t),final:Pre(U$e.bind(void 0,t,e,r))}),$$e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},U$e=async(t,e,r)=>{await uf(r,e)&&(t.writable&&t.end(),await e)},VL=async(t,e,r)=>{try{await DL(t),e.writable&&e.end()}catch(n){await Rre(r),Nre(e,n)}},qL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await uf(r,e),await uf(n,e)&&(Nre(t,i),await cx(e,i))},Nre=(t,e)=>{lx(t,t.writable,e)};import{Duplex as F$e}from"stream";import{callbackify as B$e}from"util";var kre=({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}=$L(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=zL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=UL(c,a),{read:E,onStdoutDataDone:S}=FL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new F$e({read:E,...GL(u,t,d),destroy:B$e(j$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 BL({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),VL(u,b,c),b},j$e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([jL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),qL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var HL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||hn.has(e),o=tf(t,r),a=ox({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 Mre=(t,{encoding:e})=>{let r=xre();t.readable=Ire.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Ore.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=kre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=HL.bind(void 0,t,e),t[Symbol.asyncIterator]=HL.bind(void 0,t,e,{})};var Dre=(t,e)=>{for(let[r,n]of V$e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},G$e=(async()=>{})().constructor.prototype,V$e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(G$e,t)]);var Lre=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=W$e(t,e,r),{subprocess:f,promise:p}=K$e({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=sx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Dre(f,p),as.set(f,{options:u,fileDescriptors:d}),f},W$e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=mA(t,e,r),{file:a,commandArguments:c,options:l}=DA(t,e,r),u=Y$e(l),d=Wte(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Y$e=({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}},K$e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=H$e(...LA(t,e,r))}catch(h){return Gte({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];rre(c,a,l),ire(c,r,l);let d={},f=os();c.kill=y7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=yre(c,r),Mre(c,r),Bte(c,r);let p=Z$e({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}},Z$e=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,E]=await Are({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((v,P)=>po(v,e,P)),b=po(m,e,"all"),A=J$e({errorInfo:d,exitCode:f,signal:p,stdio:S,all:b,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return af(A,n,e)},J$e=({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?g_({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof cs,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):VA({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var ux=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,X$e(n,t[n],i)]));return{...t,...r}},X$e=(t,e,r)=>Q$e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,Q$e=new Set(["env",...TD]);var Ra=(t,e,r,n)=>{let i=(o,a,c)=>Ra(o,a,r,c),s=(...o)=>e1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},e1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Pt(s))return i(t,ux(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=t1e({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?Mte(a,c,l):Lre(a,c,l,i)},t1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=WX(e)?YX(e,r):[e,...r],[o,a,c]=iA(...s),l=ux(ux(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 $re=({file:t,commandArguments:e})=>Fre(t,e),Ure=({file:t,commandArguments:e})=>({...Fre(t,e),isSync:!0}),Fre=(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]=r1e(t);return{file:r,commandArguments:n}},r1e=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(n1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},n1e=/ +/g;var Bre=(t,e,r)=>{t.sync=e(i1e,r),t.s=t.sync},jre=({options:t})=>zre(t),i1e=({options:t})=>({...zre(t),isSync:!0}),zre=t=>({options:{...s1e(t),...t}}),s1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Gre={preferLocal:!0};var Vre=Ra(()=>({})),$Et=Ra(()=>({isSync:!0})),qre=Ra($re),UEt=Ra(Ure),FEt=Ra(tee),BEt=Ra(jre,{},Gre,Bre),{sendMessage:jEt,getOneMessage:zEt,getEachMessage:GEt,getCancelSignal:VEt}=jte();var Hre=!1,Wre=()=>{Hre=!0},us=()=>Hre;var b_=null,Yre=t=>(b_&&b_.destroy(),b_=new ho({totalAllowedTime:t}),b_),Kre=()=>b_;var ho=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&&us())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 Zb({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ye.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 Zre={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.0-test.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 l1e=a1e(import.meta.url),u1e=mo.dirname(l1e),d1e=c1e(import.meta.url),df=_e("shell"),WL=new Set,Jre={preferLocal:!0},kr=(t,e,r)=>{let[n,i]=f1e(e,r),s={...Jre,...i},o=Vre(t,n,s);Qre(o,s),rne(o);let a=r?.idleTimeout;return a&&a>0&&tne(o,a),o},Xre=(t,e)=>{let r={...Jre,...e},n=qre(t,r);return Qre(n,r),rne(n),e?.idleTimeout&&e.idleTimeout>0&&tne(n,e.idleTimeout),n},f1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Qre=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(go.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Xg).pipe(go.stdout),t.stderr?.pipe(new Xg).pipe(go.stderr);return}t.stdout?.pipe(go.stdout),t.stderr?.pipe(go.stderr)},YL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(go.kill(-t.pid,e),df.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return df.error("Error killing process:",r),!1}},ene=t=>YL(t,"SIGKILL"),tne=(t,e)=>{let r=null,n=()=>{df.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),YL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(df.log(`Force killing idle process ${t.pid}`),ene(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)},rne=t=>{WL.add(t);let e=Kre();if(e){let r=e.onTimesUp(()=>{df.log(`Global timer expired, killing process ${t.pid}`),YL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(df.log(`Force killing process ${t.pid} after timeout`),ene(t))},5e3)});t.on("exit",()=>{WL.delete(t),r()}),t.on("error",()=>{WL.delete(t),r()})}};function ds(t,e){if(!go.env.NETLIFY_LOCAL_MODE)try{let i=d1e.resolve(Zre.name),s=mo.dirname(i);for(;s!==mo.dirname(s);){let o=mo.dirname(s);if(mo.basename(o)==="node_modules"){let a=mo.join(o,".bin",e);if(dx.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(go.env.NODE_PATH){let i=mo.join(go.env.NODE_PATH,".bin",e);if(dx.existsSync(i))return i}let r=mo.join(t,"node_modules",".bin",e);if(dx.existsSync(r))return r;let n=mo.join(u1e,"..","node_modules",".bin",e);if(dx.existsSync(n))return n}var p1e=_e("utils"),h1e=t=>new Promise(e=>{setTimeout(e,t)});var fx=(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 h1e(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},Ia=(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},nne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):p1e.error("Could not parse JSON",n))}},m1e=t=>t.charAt(0).toUpperCase()+t.slice(1),fs=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():m1e(e)).join(" ");function _o(t,e){e&&t.log(`Skill invoked: ${e}`)}var px=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),ine=(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 KL=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}},g1e=1e4,ZL=(t,e=g1e)=>{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 sne}from"buffer";import _1e from"path";var one=_e("repo"),Kr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),hx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{one.info("Getting runner diffs");let n=await S1e(r),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!e){let m=v1e(s);await T1e(m,r)}one.info("Changes after processing"),await XL(r);let o=await e$(s,r);if(await JL(o,r),i=await E1e(r),!i)return{hasChanges:!1,ignored:o};await Kr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Kr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await ane(r),{hasChanges:!1,ignored:o};let u=await Kr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Kr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await Kr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(p=sne.from(S).toString("base64"))}await ane(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(h.diffBinary=sne.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},ane=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Kr(["reset","--soft","HEAD~1"],{cwd:t})},JL=async(t=[],e=process.cwd())=>{await Kr(["add",".",...t],{cwd:e})},XL=async(t=process.cwd())=>{let e=await Kr(["status","-s"],{cwd:t});return String(e.stdout??"")},cne=/.. (.+)?\.log$/,y1e=[cne],S1e=async(t=process.cwd())=>{let e=await XL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
101
|
+
if (condition) { yield value; }`)};import{Buffer as ADe}from"buffer";import{StringDecoder as xDe}from"string_decoder";var ZA=(t,e,r)=>{if(r)return;if(t)return{transform:wDe.bind(void 0,new TextEncoder)};let n=new xDe(e);return{transform:RDe.bind(void 0,n),final:IDe.bind(void 0,n)}},wDe=function*(t,e){ADe.isBuffer(e)?yield lo(e):typeof e=="string"?yield t.encode(e):yield e},RDe=function*(t,e){yield jt(e)?t.write(e):e},IDe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as yte}from"util";var uL=yte(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),JA=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=PDe}=e[r];for await(let i of n(t))yield*JA(i,e,r+1)},Ste=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*CDe(r,Number(e),t)},CDe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*JA(n,r,e+1)},Ete=yte(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),PDe=function*(t){yield t};var dL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},vte=(t,e)=>[...e.flatMap(r=>[...Tl(r,t,0)]),...__(t)],Tl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=NDe}=e[r];for(let i of n(t))yield*Tl(i,e,r+1)},__=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ODe(r,Number(e),t)},ODe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Tl(n,r,e+1)},NDe=function*(t){yield t};var fL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=bte(t,o,s),l=vl(e),u=vl(r),d=l?uL.bind(void 0,JA,a):dL.bind(void 0,Tl),f=l||u?uL.bind(void 0,Ste,a):dL.bind(void 0,__),p=l||u?Ete.bind(void 0,a):void 0;return{stream:new kDe({writableObjectMode:n,writableHighWaterMark:Tte(n),readableObjectMode:i,readableHighWaterMark:Tte(i),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},XA=(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=bte(o,r,a);t=vte(c,t)}return t},bte=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:mte(n,a)},ZA(r,o,n),KA(r,s,n,c),{transform:t,final:e},{transform:gte(i,a)},hte({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Ate=(t,e)=>{for(let r of MDe(t))DDe(t,r,e)},MDe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),DDe=(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 ${wa[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>LDe(a,n));r.input=a_(o)},LDe=(t,e)=>{let r=XA(t,e,"utf8",!0);return $De(r),a_(r)},$De=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 jDe,appendFileSync as zDe}from"fs";var QA=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Zd(r,n)&&!hn.has(e)&&UDe(n)&&(t.some(({type:i,value:s})=>i==="native"&&FDe.has(s))||t.every(({type:i})=>qn.has(i))),UDe=t=>t===1||t===2,FDe=new Set(["pipe","overlapped"]),xte=async(t,e,r,n)=>{for await(let i of t)BDe(e)||Rte(i,r,n)},wte=(t,e,r)=>{for(let n of t)Rte(n,e,r)},BDe=t=>t._readableState.pipes.length>0,Rte=(t,e,r)=>{let n=pA(t);ss({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Ite=({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)=>GDe({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},GDe=({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=Cee(t,s,d),p=lo(f),{stdioItems:h,objectMode:m}=e[r],E=VDe([p],h,c,n),{serializedResult:S,finalResult:b=S}=qDe({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});HDe({serializedResult:S,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&&WDe(S,h,i),A}catch(v){return n.error=v,A}},VDe=(t,e,r,n)=>{try{return XA(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:a_(t)};let o=GX(t,r);return n[s]?{serializedResult:o,finalResult:lL(o,!i[s],e)}:{serializedResult:o}},HDe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!QA({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=lL(t,!1,o);try{wte(a,e,n)}catch(c){r.error??=c}},WDe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>WA.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?zDe(n,t):(r.add(s),jDe(n,t))}};var Cte=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,po(e,r,"all")]:Array.isArray(e)?[po(t,r,"all"),...e]:jt(t)&&jt(e)?yD([t,e]):`${t}${e}`};import{once as pL}from"events";var Pte=async(t,e)=>{let[r,n]=await YDe(t);return e.isForcefullyTerminated??=!1,[r,n]},YDe=async t=>{let[e,r]=await Promise.allSettled([pL(t,"spawn"),pL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Ote(t):r.value},Ote=async t=>{try{return await pL(t,"exit")}catch{return Ote(t)}},Nte=async t=>{let[e,r]=await t;if(!KDe(e,r)&&hL(e,r))throw new Ai;return[e,r]},KDe=(t,e)=>t===void 0&&e===void 0,hL=(t,e)=>t!==0||e!==null;var kte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ZDe(t,e,r),o=s?.code==="ETIMEDOUT",a=Iee(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ZDe=(t,e,r)=>t!==void 0?t:hL(e,r)?new Ai:void 0;var Mte=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=XDe(t,e,r),d=tLe({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return af(d,c,l)},XDe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=mA(t,e,r),a=QDe(r),{file:c,commandArguments:l,options:u}=DA(t,e,a);eLe(u);let d=ute(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},QDe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,eLe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&ex("ipcInput"),t&&ex("ipc: true"),r&&ex("detached: true"),n&&ex("cancelSignal")},ex=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},tLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=rLe({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}=kte(c,r),{output:h,error:m=l}=Ite({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),E=h.map((b,A)=>po(b,r,A)),S=po(Cte(h,r),r,"all");return iLe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:E,all:S,options:r,command:n,escapedCommand:i,startTime:a})},rLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Ate(s,r);let a=nLe(r);return JDe(...LA(t,e,a))}catch(a){return of({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},nLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:GA(e)}),iLe=({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?VA({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):g_({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 H$e}from"child_process";import Fte from"process";import{once as mL,on as sLe}from"events";var Dte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Qd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:CA(t)}),oLe({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),oLe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{xA(e,i);let s=xa(t,e,r),o=new AbortController;try{return await Promise.race([aLe(s,n,o),cLe(s,r,o),lLe(s,r,o)])}catch(a){throw ef(t),a}finally{o.abort(),wA(e,i)}},aLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await mL(t,"message",{signal:r});return n}for await(let[n]of sLe(t,"message",{signal:r}))if(e(n))return n},cLe=async(t,e,{signal:r})=>{await mL(t,"disconnect",{signal:r}),v7(e)},lLe=async(t,e,{signal:r})=>{let[n]=await mL(t,"strict:error",{signal:r});throw TA(n,e)};import{once as $te,on as uLe}from"events";var Ute=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>gL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),gL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Qd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:CA(t)}),xA(e,s);let o=xa(t,e,r),a=new AbortController,c={};return dLe(t,o,a),fLe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),pLe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},dLe=async(t,e,r)=>{try{await $te(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},fLe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await $te(t,"strict:error",{signal:r.signal});n.error=TA(i,e),r.abort()}catch{}},pLe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of uLe(r,"message",{signal:s.signal}))Lte(o),yield c}catch{Lte(o)}finally{s.abort(),wA(e,a),n||ef(t),i&&await t}},Lte=({error:t})=>{if(t)throw t};var Bte=(t,{ipc:e})=>{Object.assign(t,zte(t,!1,e))},jte=()=>{let t=Fte,e=!0,r=Fte.channel!==void 0;return{...zte(t,e,r),getCancelSignal:Y7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},zte=(t,e,r)=>({sendMessage:kA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Dte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Ute.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as hLe}from"child_process";import{PassThrough as mLe,Readable as gLe,Writable as _Le,Duplex as yLe}from"stream";var Gte=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{oL(n);let a=new hLe;SLe(a,n),Object.assign(a,{readable:ELe,writable:vLe,duplex:TLe});let c=of({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=bLe(c,o,i);return{subprocess:a,promise:l}},SLe=(t,e)=>{let r=y_(),n=y_(),i=y_(),s=Array.from({length:e.length-3},y_),o=y_(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},y_=()=>{let t=new mLe;return t.end(),t},ELe=()=>new gLe({read(){}}),vLe=()=>new _Le({write(){}}),TLe=()=>new yLe({read(){},write(){}}),bLe=async(t,e,r)=>af(t,e,r);import{createReadStream as Vte,createWriteStream as qte}from"fs";import{Buffer as ALe}from"buffer";import{Readable as S_,Writable as xLe,Duplex as wLe}from"stream";var Wte=(t,e)=>YA(RLe,t,e,!1),E_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${wa[t]}.`)},Hte={fileNumber:E_,generator:fL,asyncGenerator:fL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:wLe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},RLe={input:{...Hte,fileUrl:({value:t})=>({stream:Vte(t)}),filePath:({value:{file:t}})=>({stream:Vte(t)}),webStream:({value:t})=>({stream:S_.fromWeb(t)}),iterable:({value:t})=>({stream:S_.from(t)}),asyncIterable:({value:t})=>({stream:S_.from(t)}),string:({value:t})=>({stream:S_.from(t)}),uint8Array:({value:t})=>({stream:S_.from(ALe.from(t))})},output:{...Hte,fileUrl:({value:t})=>({stream:qte(t)}),filePath:({value:{file:t,append:e}})=>({stream:qte(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:xLe.fromWeb(t)}),iterable:E_,asyncIterable:E_,string:E_,uint8Array:E_}};import{on as ILe,once as Yte}from"events";import{PassThrough as CLe,getDefaultHighWaterMark as PLe}from"stream";import{finished as Jte}from"stream/promises";function bl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)yL(i);let e=t.some(({readableObjectMode:i})=>i),r=OLe(t,e),n=new _L({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var OLe=(t,e)=>{if(t.length===0)return PLe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},_L=class extends CLe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(yL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=NLe(this,this.#e,this.#s);let r=DLe({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(yL(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)}},NLe=async(t,e,r)=>{tx(t,Kte);let n=new AbortController;try{await Promise.race([kLe(t,n),MLe(t,e,r,n)])}finally{n.abort(),tx(t,-Kte)}},kLe=async(t,{signal:e})=>{try{await Jte(t,{signal:e,cleanup:!0})}catch(r){throw Xte(t,r),r}},MLe=async(t,e,r,{signal:n})=>{for await(let[i]of ILe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},yL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},DLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{tx(t,Zte);let a=new AbortController;try{await Promise.race([LLe(s,e,a),$Le({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),ULe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),tx(t,-Zte)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?SL(t):FLe(t))},LLe=async(t,e,{signal:r})=>{try{await t,r.aborted||SL(e)}catch(n){r.aborted||Xte(e,n)}},$Le=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Jte(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Qte(o)?i.add(e):ere(t,o)}},ULe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Yte(t,i,{signal:s}),!t.readable)return Yte(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},FLe=t=>{t.writable&&t.end()},Xte=(t,e)=>{Qte(e)?SL(t):ere(t,e)},Qte=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",SL=t=>{(t.readable||t.writable)&&t.destroy()},ere=(t,e)=>{t.destroyed||(t.once("error",BLe),t.destroy(e))},BLe=()=>{},tx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Kte=2,Zte=1;import{finished as tre}from"stream/promises";var lf=(t,e)=>{t.pipe(e),jLe(t,e),zLe(t,e)},jLe=async(t,e)=>{if(!(bi(t)||bi(e))){try{await tre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}EL(e)}},EL=t=>{t.writable&&t.end()},zLe=async(t,e)=>{if(!(bi(t)||bi(e))){try{await tre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}vL(t)}},vL=t=>{t.readable&&t.destroy()};var rre=(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)))GLe(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]:bl(s);lf(o,i)}},GLe=(t,e,r,n)=>{r==="output"?lf(t.stdio[n],e):lf(e,t.stdio[n]);let i=VLe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},VLe=["stdin","stdout","stderr"],qLe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;HLe(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},HLe=(t,{signal:e})=>{bi(t)&&Sl(t,WLe,e)},WLe=2;import{addAbortListener as ZLe}from"events";var Al=[];Al.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Al.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Al.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var rx=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",TL=Symbol.for("signal-exit emitter"),bL=globalThis,YLe=Object.defineProperty.bind(Object),AL=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(bL[TL])return bL[TL];YLe(bL,TL,{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}},nx=class{},KLe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),xL=class extends nx{onExit(){return()=>{}}load(){}unload(){}},wL=class extends nx{#e=RL.platform==="win32"?"SIGINT":"SIGHUP";#r=new AL;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Al)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(!rx(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 Al)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,Al.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 rx(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"&&rx(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)}},RL=globalThis.process,{onExit:nre,load:W_t,unload:Y_t}=KLe(rx(RL)?new wL(RL):new xL);var ire=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=nre(()=>{t.kill()});ZLe(n,()=>{i()})};var ore=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=hA(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=JLe(r,n,i),{sourceStream:d,sourceError:f}=QLe(t,l),{options:p,fileDescriptors:h}=as.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},JLe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=XLe(t,e,...r),a=AA(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},XLe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(sre,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||gD(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]=iA(r,...n);return{destination:e(sre)(i,s,o),pipeOptions:o}}if(as.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}`)},sre=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),QLe=(t,e)=>{try{return{sourceStream:tf(t,e)}}catch(r){return{sourceError:r}}};var cre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=e$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw IL({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},e$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return vL(t),n;if(e!==void 0)return EL(r),e},IL=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>of({error:t,command:are,escapedCommand:are,fileDescriptors:e,options:r,startTime:n,isSync:!1}),are="source.pipe(destination)";var lre=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 t$e}from"stream/promises";var ure=(t,e,r)=>{let n=ix.has(e)?n$e(t,e):r$e(t,e);return Sl(t,s$e,r.signal),Sl(e,o$e,r.signal),i$e(e),n},r$e=(t,e)=>{let r=bl([t]);return lf(r,e),ix.set(e,r),r},n$e=(t,e)=>{let r=ix.get(e);return r.add(t),r},i$e=async t=>{try{await t$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ix.delete(t)},ix=new WeakMap,s$e=2,o$e=1;import{aborted as a$e}from"util";var dre=(t,e)=>t===void 0?[]:[c$e(t,e)],c$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await a$e(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw IL({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var sx=(t,...e)=>{if(Pt(e[0]))return sx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ore(t,...e),i=l$e({...n,destination:r});return i.pipe=sx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},l$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=u$e(t,i);cre({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=ure(e,s,d);return await Promise.race([lre(u),...dre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},u$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as _$e}from"timers/promises";import{on as d$e}from"events";import{getDefaultHighWaterMark as f$e}from"stream";var ox=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return p$e(e,o),pre({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},p$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},CL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;h$e(e,o,t);let a=t.readableObjectMode&&!s;return pre({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},h$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},pre=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=d$e(t,"data",{signal:e.signal,highWaterMark:fre,highWatermark:fre});return m$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},PL=f$e(!0),fre=PL,m$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=g$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Tl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*__(a)}},g$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[ZA(t,r,!e),KA(t,i,!n,{})].filter(Boolean);var hre=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=y$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([S$e(t),d]);return}let f=aL(c,r),p=CL({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([E$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},y$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!QA({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=CL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await xte(a,t,r,s)},S$e=async t=>{await _$e(),t.readableFlowing===null&&t.resume()},E$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await BA(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await jA(r,{maxBuffer:s})):await sf(r,{maxBuffer:s})}catch(a){return mre(xee({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},OL=async t=>{try{return await t}catch(e){return mre(e)}},mre=({bufferedData:t})=>jX(t)?new Uint8Array(t):t;import{finished as v$e}from"stream/promises";var v_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=T$e(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],v$e(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||x$e(a,e,r,n)}finally{o.abort()}},T$e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&b$e(t,r,n),n},b$e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{A$e(e,r),n.call(t,...i)}},A$e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},x$e=(t,e,r,n)=>{if(!w$e(t,e,r,n))throw t},w$e=(t,e,r,n=!0)=>r.propagating?gre(t)||ax(t):(r.propagating=!0,NL(r,e)===n?gre(t):ax(t)),NL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ax=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",gre=t=>t?.code==="EPIPE";var _re=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>kL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),kL=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=v_(t,e,l);if(NL(l,e)){await u;return}let[d]=await Promise.all([hre({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 yre=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?bl([t,e].filter(Boolean)):void 0,Sre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>kL({...R$e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:I$e(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),R$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}},I$e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as C$e}from"events";var Ere=t=>Zd(t,"ipc"),vre=(t,e)=>{let r=pA(t);ss({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Tre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Ere(s),a=uo(e,"ipc"),c=uo(r,"ipc");for await(let l of gL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(wee(t,i,c),i.push(l)),o&&vre(l,s);return i},bre=async(t,e)=>(await Promise.allSettled([t]),e);var Are=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:E,controller:S})=>{let b=Pte(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=_re({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),P=Sre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),O=[],U=Tre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),I=P$e(m,t,A),M=O$e(h,A);try{return await Promise.race([Promise.all([{},Nte(b),Promise.all(v),P,U,iee(t,d),...I,...M]),E,N$e(t,S),...Q7(t,s,f,S),...E7({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...J7({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(B){return f.terminationReason??="other",Promise.all([{error:B},b,Promise.all(v.map(_=>OL(_))),OL(P),bre(U,O),Promise.allSettled(I),Promise.allSettled(M)])}},P$e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:v_(n,i,r)),O$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})=>v_(o,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),N$e=async(t,{signal:e})=>{let[r]=await C$e(t,"error",{signal:e});throw r};var xre=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),T_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=os();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},uf=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 k$e}from"stream";import{callbackify as M$e}from"util";import{finished as wre}from"stream/promises";var ML=async t=>{if(t!==void 0)try{await DL(t)}catch{}},Rre=async t=>{if(t!==void 0)try{await LL(t)}catch{}},DL=async t=>{await wre(t,{cleanup:!0,readable:!1,writable:!0})},LL=async t=>{await wre(t,{cleanup:!0,readable:!0,writable:!1})},cx=async(t,e)=>{if(await t,e)throw e},lx=(t,e,r)=>{r&&!ax(r)?t.destroy(r):e&&t.destroy()};var Ire=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||hn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=$L(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=UL(a,o),{read:f,onStdoutDataDone:p}=FL({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new k$e({read:f,destroy:M$e(jL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return BL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},$L=(t,e,r)=>{let n=tf(t,e),i=T_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},UL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:PL},FL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=os(),o=ox({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){D$e(this,o,s)},onStdoutDataDone:s}},D$e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},BL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await LL(t),await n,await ML(i),await e,r.readable&&r.push(null)}catch(s){await ML(i),Cre(r,s)}},jL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await uf(r,e)&&(Cre(t,n),await cx(e,n))},Cre=(t,e)=>{lx(t,t.readable,e)};import{Writable as L$e}from"stream";import{callbackify as Pre}from"util";var Ore=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=zL(t,r,e),o=new L$e({...GL(n,t,i),destroy:Pre(qL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return VL(n,o),o},zL=(t,e,r)=>{let n=AA(t,e),i=T_(r,n,"writableFinal"),s=T_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},GL=(t,e,r)=>({write:$$e.bind(void 0,t),final:Pre(U$e.bind(void 0,t,e,r))}),$$e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},U$e=async(t,e,r)=>{await uf(r,e)&&(t.writable&&t.end(),await e)},VL=async(t,e,r)=>{try{await DL(t),e.writable&&e.end()}catch(n){await Rre(r),Nre(e,n)}},qL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await uf(r,e),await uf(n,e)&&(Nre(t,i),await cx(e,i))},Nre=(t,e)=>{lx(t,t.writable,e)};import{Duplex as F$e}from"stream";import{callbackify as B$e}from"util";var kre=({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}=$L(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=zL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=UL(c,a),{read:E,onStdoutDataDone:S}=FL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new F$e({read:E,...GL(u,t,d),destroy:B$e(j$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 BL({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),VL(u,b,c),b},j$e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([jL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),qL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var HL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||hn.has(e),o=tf(t,r),a=ox({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 Mre=(t,{encoding:e})=>{let r=xre();t.readable=Ire.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Ore.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=kre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=HL.bind(void 0,t,e),t[Symbol.asyncIterator]=HL.bind(void 0,t,e,{})};var Dre=(t,e)=>{for(let[r,n]of V$e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},G$e=(async()=>{})().constructor.prototype,V$e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(G$e,t)]);var Lre=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=W$e(t,e,r),{subprocess:f,promise:p}=K$e({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=sx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Dre(f,p),as.set(f,{options:u,fileDescriptors:d}),f},W$e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=mA(t,e,r),{file:a,commandArguments:c,options:l}=DA(t,e,r),u=Y$e(l),d=Wte(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Y$e=({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}},K$e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=H$e(...LA(t,e,r))}catch(h){return Gte({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];rre(c,a,l),ire(c,r,l);let d={},f=os();c.kill=y7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=yre(c,r),Mre(c,r),Bte(c,r);let p=Z$e({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}},Z$e=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,E]=await Are({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((v,P)=>po(v,e,P)),b=po(m,e,"all"),A=J$e({errorInfo:d,exitCode:f,signal:p,stdio:S,all:b,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return af(A,n,e)},J$e=({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?g_({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof cs,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):VA({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var ux=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,X$e(n,t[n],i)]));return{...t,...r}},X$e=(t,e,r)=>Q$e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,Q$e=new Set(["env",...TD]);var Ra=(t,e,r,n)=>{let i=(o,a,c)=>Ra(o,a,r,c),s=(...o)=>e1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},e1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Pt(s))return i(t,ux(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=t1e({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?Mte(a,c,l):Lre(a,c,l,i)},t1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=WX(e)?YX(e,r):[e,...r],[o,a,c]=iA(...s),l=ux(ux(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 $re=({file:t,commandArguments:e})=>Fre(t,e),Ure=({file:t,commandArguments:e})=>({...Fre(t,e),isSync:!0}),Fre=(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]=r1e(t);return{file:r,commandArguments:n}},r1e=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(n1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},n1e=/ +/g;var Bre=(t,e,r)=>{t.sync=e(i1e,r),t.s=t.sync},jre=({options:t})=>zre(t),i1e=({options:t})=>({...zre(t),isSync:!0}),zre=t=>({options:{...s1e(t),...t}}),s1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Gre={preferLocal:!0};var Vre=Ra(()=>({})),$Et=Ra(()=>({isSync:!0})),qre=Ra($re),UEt=Ra(Ure),FEt=Ra(tee),BEt=Ra(jre,{},Gre,Bre),{sendMessage:jEt,getOneMessage:zEt,getEachMessage:GEt,getCancelSignal:VEt}=jte();var Hre=!1,Wre=()=>{Hre=!0},us=()=>Hre;var b_=null,Yre=t=>(b_&&b_.destroy(),b_=new ho({totalAllowedTime:t}),b_),Kre=()=>b_;var ho=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&&us())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 Zb({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ye.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 Zre={name:"@netlify/agent-runner-cli",type:"module",version:"1.149.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 l1e=a1e(import.meta.url),u1e=mo.dirname(l1e),d1e=c1e(import.meta.url),df=_e("shell"),WL=new Set,Jre={preferLocal:!0},kr=(t,e,r)=>{let[n,i]=f1e(e,r),s={...Jre,...i},o=Vre(t,n,s);Qre(o,s),rne(o);let a=r?.idleTimeout;return a&&a>0&&tne(o,a),o},Xre=(t,e)=>{let r={...Jre,...e},n=qre(t,r);return Qre(n,r),rne(n),e?.idleTimeout&&e.idleTimeout>0&&tne(n,e.idleTimeout),n},f1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Qre=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(go.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Xg).pipe(go.stdout),t.stderr?.pipe(new Xg).pipe(go.stderr);return}t.stdout?.pipe(go.stdout),t.stderr?.pipe(go.stderr)},YL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(go.kill(-t.pid,e),df.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return df.error("Error killing process:",r),!1}},ene=t=>YL(t,"SIGKILL"),tne=(t,e)=>{let r=null,n=()=>{df.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),YL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(df.log(`Force killing idle process ${t.pid}`),ene(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)},rne=t=>{WL.add(t);let e=Kre();if(e){let r=e.onTimesUp(()=>{df.log(`Global timer expired, killing process ${t.pid}`),YL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(df.log(`Force killing process ${t.pid} after timeout`),ene(t))},5e3)});t.on("exit",()=>{WL.delete(t),r()}),t.on("error",()=>{WL.delete(t),r()})}};function ds(t,e){if(!go.env.NETLIFY_LOCAL_MODE)try{let i=d1e.resolve(Zre.name),s=mo.dirname(i);for(;s!==mo.dirname(s);){let o=mo.dirname(s);if(mo.basename(o)==="node_modules"){let a=mo.join(o,".bin",e);if(dx.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(go.env.NODE_PATH){let i=mo.join(go.env.NODE_PATH,".bin",e);if(dx.existsSync(i))return i}let r=mo.join(t,"node_modules",".bin",e);if(dx.existsSync(r))return r;let n=mo.join(u1e,"..","node_modules",".bin",e);if(dx.existsSync(n))return n}var p1e=_e("utils"),h1e=t=>new Promise(e=>{setTimeout(e,t)});var fx=(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 h1e(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},Ia=(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},nne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):p1e.error("Could not parse JSON",n))}},m1e=t=>t.charAt(0).toUpperCase()+t.slice(1),fs=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():m1e(e)).join(" ");function _o(t,e){e&&t.log(`Skill invoked: ${e}`)}var px=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),ine=(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 KL=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}},g1e=1e4,ZL=(t,e=g1e)=>{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 sne}from"buffer";import _1e from"path";var one=_e("repo"),Kr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),hx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{one.info("Getting runner diffs");let n=await S1e(r),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!e){let m=v1e(s);await T1e(m,r)}one.info("Changes after processing"),await XL(r);let o=await e$(s,r);if(await JL(o,r),i=await E1e(r),!i)return{hasChanges:!1,ignored:o};await Kr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Kr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await ane(r),{hasChanges:!1,ignored:o};let u=await Kr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Kr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await Kr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(p=sne.from(S).toString("base64"))}await ane(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(h.diffBinary=sne.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},ane=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Kr(["reset","--soft","HEAD~1"],{cwd:t})},JL=async(t=[],e=process.cwd())=>{await Kr(["add",".",...t],{cwd:e})},XL=async(t=process.cwd())=>{let e=await Kr(["status","-s"],{cwd:t});return String(e.stdout??"")},cne=/.. (.+)?\.log$/,y1e=[cne],S1e=async(t=process.cwd())=>{let e=await XL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
102
|
`).filter(i=>y1e.some(o=>o instanceof RegExp?o.test(i):i===o)?!1:i[1]?.trim()!=="")).length!==0,status:e}},E1e=async(t=process.cwd())=>{try{return await Kr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},QL=async(t=process.cwd())=>{let{stdout:e}=await Kr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},lne=async(t=process.cwd())=>{let{stdout:e}=await Kr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},e$=async(t,e=process.cwd())=>{t||=await XL(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}${_1e.sep}`);(a||c)&&n.push(`:!${o}`)});let s=i.match(cne)?.[1];s&&n.push(`:!${s}.log`)}),n},une=async(t=process.cwd())=>{await Kr(["reset","--hard","HEAD"],{cwd:t})},dne=async(t=process.cwd())=>{let e=await Kr(["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))},v1e=t=>{let e=t.split(`
|