@netlify/agent-runner-cli 2.13.0-code-diff-setup-reqs.1 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -383,7 +383,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
383
383
|
`,LF:`
|
|
384
384
|
`,concatBytes:z5},dmt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},fmt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:dmt};import{Buffer as pmt}from"buffer";var _xe=(t,e)=>t?void 0:hmt.bind(void 0,e),hmt=function*(t,e){if(typeof e!="string"&&!Kr(e)&&!pmt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},yxe=(t,e)=>t?mmt.bind(void 0,e):gmt.bind(void 0,e),mmt=function*(t,e){Sxe(t,e),yield e},gmt=function*(t,e){if(Sxe(t,e),typeof e!="string"&&!Kr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Sxe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
385
385
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
386
|
-
if (condition) { yield value; }`)};import{Buffer as _mt}from"buffer";import{StringDecoder as ymt}from"string_decoder";var NM=(t,e,r)=>{if(r)return;if(t)return{transform:Smt.bind(void 0,new TextEncoder)};let n=new ymt(e);return{transform:vmt.bind(void 0,n),final:Emt.bind(void 0,n)}},Smt=function*(t,e){_mt.isBuffer(e)?yield Eu(e):typeof e=="string"?yield t.encode(e):yield e},vmt=function*(t,e){yield Kr(e)?t.write(e):e},Emt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as vxe}from"util";var B5=vxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$M=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=wmt}=e[r];for await(let i of n(t))yield*$M(i,e,r+1)},Exe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*bmt(r,Number(e),t)},bmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$M(n,r,e+1)},bxe=vxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),wmt=function*(t){yield t};var q5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},wxe=(t,e)=>[...e.flatMap(r=>[...rh(r,t,0)]),...cR(t)],rh=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Amt}=e[r];for(let i of n(t))yield*rh(i,e,r+1)},cR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Tmt(r,Number(e),t)},Tmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*rh(n,r,e+1)},Amt=function*(t){yield t};var V5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Axe(t,s,o),u=th(e),l=th(r),d=u?B5.bind(void 0,$M,a):q5.bind(void 0,rh),f=u||l?B5.bind(void 0,Exe,a):q5.bind(void 0,cR),p=u||l?bxe.bind(void 0,a):void 0;return{stream:new Rmt({writableObjectMode:n,writableHighWaterMark:Txe(n),readableObjectMode:i,readableHighWaterMark:Txe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},DM=(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=Axe(s,r,a);t=wxe(c,t)}return t},Axe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:_xe(n,a)},NM(r,s,n),kM(r,o,n,c),{transform:t,final:e},{transform:yxe(i,a)},gxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Rxe=(t,e)=>{for(let r of xmt(t))Imt(t,r,e)},xmt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Imt=(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 ${pd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Omt(a,n));r.input=JA(s)},Omt=(t,e)=>{let r=DM(t,e,"utf8",!0);return Pmt(r),JA(r)},Pmt=t=>{let e=t.find(r=>typeof r!="string"&&!Kr(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 $mt,appendFileSync as Dmt}from"fs";var MM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sy(r,n)&&!go.has(e)&&Cmt(n)&&(t.some(({type:i,value:o})=>i==="native"&&kmt.has(o))||t.every(({type:i})=>Qo.has(i))),Cmt=t=>t===1||t===2,kmt=new Set(["pipe","overlapped"]),xxe=async(t,e,r,n)=>{for await(let i of t)Nmt(e)||Oxe(i,r,n)},Ixe=(t,e,r)=>{for(let n of t)Oxe(n,e,r)},Nmt=t=>t._readableState.pipes.length>0,Oxe=(t,e,r)=>{let n=ZD(t);sc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Pxe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,u)=>Mmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Mmt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=CRe(t,o,d),p=Eu(f),{stdioItems:h,objectMode:m}=e[r],_=Lmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Umt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Fmt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?v:void 0;try{return n.error===void 0&&zmt(y,h,i),A}catch(S){return n.error=S,A}},Lmt=(t,e,r,n)=>{try{return DM(t,e,r,!1)}catch(i){return n.error=i,t}},Umt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:JA(t)};let s=Gwe(t,r);return n[o]?{serializedResult:s,finalResult:j5(s,!i[o],e)}:{serializedResult:s}},Fmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!MM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=j5(t,!1,s);try{Ixe(a,e,n)}catch(c){r.error??=c}},zmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>PM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?Dmt(n,t):(r.add(o),$mt(n,t))}};var Cxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Tu(e,r,"all")]:Array.isArray(e)?[Tu(t,r,"all"),...e]:Kr(t)&&Kr(e)?Z9([t,e]):`${t}${e}`};import{once as G5}from"events";var kxe=async(t,e)=>{let[r,n]=await jmt(t);return e.isForcefullyTerminated??=!1,[r,n]},jmt=async t=>{let[e,r]=await Promise.allSettled([G5(t,"spawn"),G5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Nxe(t):r.value},Nxe=async t=>{try{return await G5(t,"exit")}catch{return Nxe(t)}},$xe=async t=>{let[e,r]=await t;if(!Bmt(e,r)&&H5(e,r))throw new ua;return[e,r]},Bmt=(t,e)=>t===void 0&&e===void 0,H5=(t,e)=>t!==0||e!==null;var Dxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=qmt(t,e,r),s=o?.code==="ETIMEDOUT",a=PRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},qmt=(t,e,r)=>t!==void 0?t:H5(e,r)?new ua:void 0;var Mxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Gmt(t,e,r),d=Kmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Oy(d,c,u)},Gmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),a=Hmt(r),{file:c,commandArguments:u,options:l}=yM(t,e,a);Wmt(l);let d=fxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Hmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Wmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LM("ipcInput"),t&&LM("ipc: true"),r&&LM("detached: true"),n&&LM("cancelSignal")},LM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Kmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=Ymt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=Dxe(c,r),{output:h,error:m=u}=Pxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Tu(v,r,A)),y=Tu(Cxe(h,r),r,"all");return Xmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Ymt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Rxe(o,r);let a=Zmt(r);return Vmt(...SM(t,e,a))}catch(a){return Iy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Zmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RM(e)}),Xmt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?xM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):aR({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as U_t}from"events";import{spawn as F_t}from"child_process";import jxe from"process";import{once as W5,on as Jmt}from"events";var Lxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(by({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),Qmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Qmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cM(e,i);let o=fd(t,e,r),s=new AbortController;try{return await Promise.race([egt(o,n,s),tgt(o,r,s),rgt(o,r,s)])}catch(a){throw wy(t),a}finally{s.abort(),uM(e,i)}},egt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await W5(t,"message",{signal:r});return n}for await(let[n]of Jmt(t,"message",{signal:r}))if(e(n))return n},tgt=async(t,e,{signal:r})=>{await W5(t,"disconnect",{signal:r}),wAe(e)},rgt=async(t,e,{signal:r})=>{let[n]=await W5(t,"strict:error",{signal:r});throw oM(n,e)};import{once as Fxe,on as ngt}from"events";var zxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>K5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),K5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{by({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),cM(e,o);let s=fd(t,e,r),a=new AbortController,c={};return igt(t,s,a),ogt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),sgt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},igt=async(t,e,r)=>{try{await Fxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ogt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Fxe(t,"strict:error",{signal:r.signal});n.error=oM(i,e),r.abort()}catch{}},sgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of ngt(r,"message",{signal:o.signal}))Uxe(s),yield c}catch{Uxe(s)}finally{o.abort(),uM(e,a),n||wy(t),i&&await t}},Uxe=({error:t})=>{if(t)throw t};var Bxe=(t,{ipc:e})=>{Object.assign(t,Vxe(t,!1,e))},qxe=()=>{let t=jxe,e=!0,r=jxe.channel!==void 0;return{...Vxe(t,e,r),getCancelSignal:ZAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Vxe=(t,e,r)=>({sendMessage:gM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Lxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:zxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as agt}from"child_process";import{PassThrough as cgt,Readable as ugt,Writable as lgt,Duplex as dgt}from"stream";var Gxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{U5(n);let a=new agt;fgt(a,n),Object.assign(a,{readable:pgt,writable:hgt,duplex:mgt});let c=Iy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=ggt(c,s,i);return{subprocess:a,promise:u}},fgt=(t,e)=>{let r=uR(),n=uR(),i=uR(),o=Array.from({length:e.length-3},uR),s=uR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},uR=()=>{let t=new cgt;return t.end(),t},pgt=()=>new ugt({read(){}}),hgt=()=>new lgt({write(){}}),mgt=()=>new dgt({read(){},write(){}}),ggt=async(t,e,r)=>Oy(t,e,r);import{createReadStream as Hxe,createWriteStream as Wxe}from"fs";import{Buffer as _gt}from"buffer";import{Readable as lR,Writable as ygt,Duplex as Sgt}from"stream";var Yxe=(t,e)=>CM(vgt,t,e,!1),dR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Kxe={fileNumber:dR,generator:V5,asyncGenerator:V5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Sgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},vgt={input:{...Kxe,fileUrl:({value:t})=>({stream:Hxe(t)}),filePath:({value:{file:t}})=>({stream:Hxe(t)}),webStream:({value:t})=>({stream:lR.fromWeb(t)}),iterable:({value:t})=>({stream:lR.from(t)}),asyncIterable:({value:t})=>({stream:lR.from(t)}),string:({value:t})=>({stream:lR.from(t)}),uint8Array:({value:t})=>({stream:lR.from(_gt.from(t))})},output:{...Kxe,fileUrl:({value:t})=>({stream:Wxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Wxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:ygt.fromWeb(t)}),iterable:dR,asyncIterable:dR,string:dR,uint8Array:dR}};import{on as Egt,once as Zxe}from"events";import{PassThrough as bgt,getDefaultHighWaterMark as wgt}from"stream";import{finished as Qxe}from"stream/promises";function nh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Z5(i);let e=t.some(({readableObjectMode:i})=>i),r=Tgt(t,e),n=new Y5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Tgt=(t,e)=>{if(t.length===0)return wgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},Y5=class extends bgt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(Z5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Agt(this,this.#e,this.#o);let r=Igt({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(Z5(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)}},Agt=async(t,e,r)=>{UM(t,Xxe);let n=new AbortController;try{await Promise.race([Rgt(t,n),xgt(t,e,r,n)])}finally{n.abort(),UM(t,-Xxe)}},Rgt=async(t,{signal:e})=>{try{await Qxe(t,{signal:e,cleanup:!0})}catch(r){throw eIe(t,r),r}},xgt=async(t,e,r,{signal:n})=>{for await(let[i]of Egt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},Z5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Igt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{UM(t,Jxe);let a=new AbortController;try{await Promise.race([Ogt(o,e,a),Pgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Cgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),UM(t,-Jxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?X5(t):kgt(t))},Ogt=async(t,e,{signal:r})=>{try{await t,r.aborted||X5(e)}catch(n){r.aborted||eIe(e,n)}},Pgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Qxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;tIe(s)?i.add(e):rIe(t,s)}},Cgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Zxe(t,i,{signal:o}),!t.readable)return Zxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},kgt=t=>{t.writable&&t.end()},eIe=(t,e)=>{tIe(e)?X5(t):rIe(t,e)},tIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",X5=t=>{(t.readable||t.writable)&&t.destroy()},rIe=(t,e)=>{t.destroyed||(t.once("error",Ngt),t.destroy(e))},Ngt=()=>{},UM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Xxe=2,Jxe=1;import{finished as nIe}from"stream/promises";var Cy=(t,e)=>{t.pipe(e),$gt(t,e),Dgt(t,e)},$gt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await nIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}J5(e)}},J5=t=>{t.writable&&t.end()},Dgt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await nIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}Q5(t)}},Q5=t=>{t.readable&&t.destroy()};var iIe=(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})=>Qo.has(c)))Mgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qo.has(c)))Ugt({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]:nh(o);Cy(s,i)}},Mgt=(t,e,r,n)=>{r==="output"?Cy(t.stdio[n],e):Cy(e,t.stdio[n]);let i=Lgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Lgt=["stdin","stdout","stderr"],Ugt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Fgt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Fgt=(t,{signal:e})=>{ca(t)&&Qp(t,zgt,e)},zgt=2;import{addAbortListener as qgt}from"events";var ih=[];ih.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ih.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ih.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FM=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",e8=Symbol.for("signal-exit emitter"),t8=globalThis,jgt=Object.defineProperty.bind(Object),r8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(t8[e8])return t8[e8];jgt(t8,e8,{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}},zM=class{},Bgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),n8=class extends zM{onExit(){return()=>{}}load(){}unload(){}},i8=class extends zM{#e=o8.platform==="win32"?"SIGINT":"SIGHUP";#r=new r8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ih)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(!FM(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 ih)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,ih.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 FM(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"&&FM(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)}},o8=globalThis.process,{onExit:oIe,load:Wfr,unload:Kfr}=Bgt(FM(o8)?new i8(o8):new n8);var sIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=oIe(()=>{t.kill()});qgt(n,()=>{i()})};var cIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=XD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=Vgt(r,n,i),{sourceStream:d,sourceError:f}=Hgt(t,u),{options:p,fileDescriptors:h}=cc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},Vgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Ggt(t,e,...r),a=aM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Ggt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(aIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||K9(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]=jD(r,...n);return{destination:e(aIe)(i,o,s),pipeOptions:s}}if(cc.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}`)},aIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Hgt=(t,e)=>{try{return{sourceStream:Ty(t,e)}}catch(r){return{sourceError:r}}};var lIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Wgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw s8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Wgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return Q5(t),n;if(e!==void 0)return J5(r),e},s8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Iy({error:t,command:uIe,escapedCommand:uIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),uIe="source.pipe(destination)";var dIe=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 Kgt}from"stream/promises";var fIe=(t,e,r)=>{let n=jM.has(e)?Zgt(t,e):Ygt(t,e);return Qp(t,Jgt,r.signal),Qp(e,Qgt,r.signal),Xgt(e),n},Ygt=(t,e)=>{let r=nh([t]);return Cy(r,e),jM.set(e,r),r},Zgt=(t,e)=>{let r=jM.get(e);return r.add(t),r},Xgt=async t=>{try{await Kgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jM.delete(t)},jM=new WeakMap,Jgt=2,Qgt=1;import{aborted as e_t}from"util";var pIe=(t,e)=>t===void 0?[]:[t_t(t,e)],t_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await e_t(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw s8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var BM=(t,...e)=>{if(Ar(e[0]))return BM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=cIe(t,...e),i=r_t({...n,destination:r});return i.pipe=BM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},r_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=n_t(t,i);lIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=fIe(e,o,d);return await Promise.race([dIe(l),...pIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},n_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as l_t}from"timers/promises";import{on as i_t}from"events";import{getDefaultHighWaterMark as o_t}from"stream";var qM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return s_t(e,s),mIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},s_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},a8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;a_t(e,s,t);let a=t.readableObjectMode&&!o;return mIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},a_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},mIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=i_t(t,"data",{signal:e.signal,highWaterMark:hIe,highWatermark:hIe});return c_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},c8=o_t(!0),hIe=c8,c_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=u_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*rh(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cR(a)}},u_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NM(t,r,!e),kM(t,i,!n,{})].filter(Boolean);var gIe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=d_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([f_t(t),d]);return}let f=F5(c,r),p=a8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([p_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},d_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!MM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=a8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await xxe(a,t,r,o)},f_t=async t=>{await l_t(),t.readableFlowing===null&&t.resume()},p_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await wM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await TM(r,{maxBuffer:o})):await xy(r,{maxBuffer:o})}catch(a){return _Ie(xRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},u8=async t=>{try{return await t}catch(e){return _Ie(e)}},_Ie=({bufferedData:t})=>qwe(t)?new Uint8Array(t):t;import{finished as h_t}from"stream/promises";var fR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=m_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],h_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||y_t(a,e,r,n)}finally{s.abort()}},m_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&g_t(t,r,n),n},g_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{__t(e,r),n.call(t,...i)}},__t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},y_t=(t,e,r,n)=>{if(!S_t(t,e,r,n))throw t},S_t=(t,e,r,n=!0)=>r.propagating?yIe(t)||VM(t):(r.propagating=!0,l8(r,e)===n?yIe(t):VM(t)),l8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yIe=t=>t?.code==="EPIPE";var SIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>d8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),d8=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=fR(t,e,u);if(l8(u,e)){await l;return}let[d]=await Promise.all([gIe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var vIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?nh([t,e].filter(Boolean)):void 0,EIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>d8({...v_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:E_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),v_t=({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}},E_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as b_t}from"events";var bIe=t=>Sy(t,"ipc"),wIe=(t,e)=>{let r=ZD(t);sc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var TIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=bIe(o),a=bu(e,"ipc"),c=bu(r,"ipc");for await(let u of K5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(IRe(t,i,c),i.push(u)),s&&wIe(u,o);return i},AIe=async(t,e)=>(await Promise.allSettled([t]),e);var RIe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=kxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=SIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=EIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=[],R=TIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=w_t(m,t,A),O=T_t(h,A);try{return await Promise.race([Promise.all([{},$xe(v),Promise.all(S),b,R,sRe(t,d),...C,...O]),_,A_t(t,y),...tRe(t,o,f,y),...bAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...QAe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},v,Promise.all(S.map(T=>u8(T))),u8(b),AIe(R,E),Promise.allSettled(C),Promise.allSettled(O)])}},w_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:fR(n,i,r)),T_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>da(o,{checkOpen:!1})&&!ca(o)).map(({type:i,value:o,stream:s=o})=>fR(s,n,e,{isSameDirection:Qo.has(i),stopOnExit:i==="native"}))),A_t=async(t,{signal:e})=>{let[r]=await b_t(t,"error",{signal:e});throw r};var xIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),pR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ac();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},ky=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 R_t}from"stream";import{callbackify as x_t}from"util";import{finished as IIe}from"stream/promises";var f8=async t=>{if(t!==void 0)try{await p8(t)}catch{}},OIe=async t=>{if(t!==void 0)try{await h8(t)}catch{}},p8=async t=>{await IIe(t,{cleanup:!0,readable:!1,writable:!0})},h8=async t=>{await IIe(t,{cleanup:!0,readable:!0,writable:!1})},GM=async(t,e)=>{if(await t,e)throw e},HM=(t,e,r)=>{r&&!VM(r)?t.destroy(r):e&&t.destroy()};var PIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||go.has(r),{subprocessStdout:a,waitReadableDestroy:c}=m8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=g8(a,s),{read:f,onStdoutDataDone:p}=_8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new R_t({read:f,destroy:x_t(S8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return y8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},m8=(t,e,r)=>{let n=Ty(t,e),i=pR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},g8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:c8},_8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ac(),s=qM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){I_t(this,s,o)},onStdoutDataDone:o}},I_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},y8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await h8(t),await n,await f8(i),await e,r.readable&&r.push(null)}catch(o){await f8(i),CIe(r,o)}},S8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ky(r,e)&&(CIe(t,n),await GM(e,n))},CIe=(t,e)=>{HM(t,t.readable,e)};import{Writable as O_t}from"stream";import{callbackify as kIe}from"util";var NIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=v8(t,r,e),s=new O_t({...E8(n,t,i),destroy:kIe(w8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return b8(n,s),s},v8=(t,e,r)=>{let n=aM(t,e),i=pR(r,n,"writableFinal"),o=pR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},E8=(t,e,r)=>({write:P_t.bind(void 0,t),final:kIe(C_t.bind(void 0,t,e,r))}),P_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},C_t=async(t,e,r)=>{await ky(r,e)&&(t.writable&&t.end(),await e)},b8=async(t,e,r)=>{try{await p8(t),e.writable&&e.end()}catch(n){await OIe(r),$Ie(e,n)}},w8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ky(r,e),await ky(n,e)&&($Ie(t,i),await GM(e,i))},$Ie=(t,e)=>{HM(t,t.writable,e)};import{Duplex as k_t}from"stream";import{callbackify as N_t}from"util";var DIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||go.has(r),{subprocessStdout:c,waitReadableDestroy:u}=m8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=v8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=g8(c,a),{read:_,onStdoutDataDone:y}=_8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new k_t({read:_,...E8(l,t,d),destroy:N_t($_t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return y8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),b8(l,v,c),v},$_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([S8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),w8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var T8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||go.has(e),s=Ty(t,r),a=qM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return D_t(a,s,t)},D_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var MIe=(t,{encoding:e})=>{let r=xIe();t.readable=PIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=NIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=DIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=T8.bind(void 0,t,e),t[Symbol.asyncIterator]=T8.bind(void 0,t,e,{})};var LIe=(t,e)=>{for(let[r,n]of L_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},M_t=(async()=>{})().constructor.prototype,L_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(M_t,t)]);var UIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=z_t(t,e,r),{subprocess:f,promise:p}=B_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=BM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),LIe(f,p),cc.set(f,{options:l,fileDescriptors:d}),f},z_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),{file:a,commandArguments:c,options:u}=yM(t,e,r),l=j_t(u),d=Yxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},j_t=({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}},B_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=F_t(...SM(t,e,r))}catch(h){return Gxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;U_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];iIe(c,a,u),sIe(c,r,u);let d={},f=ac();c.kill=vAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=vIe(c,r),MIe(c,r),Bxe(c,r);let p=q_t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},q_t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await RIe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((S,b)=>Tu(S,e,b)),v=Tu(m,e,"all"),A=V_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Oy(A,n,e)},V_t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?aR({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof uc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):xM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var WM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,G_t(n,t[n],i)]));return{...t,...r}},G_t=(t,e,r)=>H_t.has(t)&&Ar(e)&&Ar(r)?{...e,...r}:r,H_t=new Set(["env",...e5]);var hd=(t,e,r,n)=>{let i=(s,a,c)=>hd(s,a,r,c),o=(...s)=>W_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},W_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ar(o))return i(t,WM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=K_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?Mxe(a,c,u):UIe(a,c,u,i)},K_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Ywe(e)?Zwe(e,r):[e,...r],[s,a,c]=jD(...o),u=WM(WM(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var FIe=({file:t,commandArguments:e})=>jIe(t,e),zIe=({file:t,commandArguments:e})=>({...jIe(t,e),isSync:!0}),jIe=(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]=Y_t(t);return{file:r,commandArguments:n}},Y_t=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(Z_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Z_t=/ +/g;var BIe=(t,e,r)=>{t.sync=e(X_t,r),t.s=t.sync},qIe=({options:t})=>VIe(t),X_t=({options:t})=>({...VIe(t),isSync:!0}),VIe=t=>({options:{...J_t(t),...t}}),J_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},GIe={preferLocal:!0};var HIe=hd(()=>({})),Lmr=hd(()=>({isSync:!0})),WIe=hd(FIe),Umr=hd(zIe),Fmr=hd(nRe),zmr=hd(qIe,{},GIe,BIe),{sendMessage:jmr,getOneMessage:Bmr,getEachMessage:qmr,getCancelSignal:Vmr}=qxe();var KIe=!1,YIe,Q_t=t=>{YIe??=t},ZIe=t=>{KIe=!0,Q_t(t)},Gn=()=>KIe,Au=()=>YIe,XIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var hR=null,JIe=t=>(hR&&hR.destroy(),hR=new es({totalAllowedTime:t}),hR),QIe=()=>hR;var es=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Gn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await ok({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{K.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var eOe={name:"@netlify/agent-runner-cli",type:"module",version:"2.13.0-code-diff-setup-reqs.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var nyt=tyt(import.meta.url),iyt=Ru.dirname(nyt),oyt=ryt(import.meta.url),Ny=oe("shell"),A8=new Set,tOe={preferLocal:!0},vt=(t,e,r)=>{let[n,i]=syt(e,r),o={...tOe,...i},s=HIe(t,n,o);nOe(s,o),sOe(s);let a=r?.idleTimeout;return a&&a>0&&oOe(s,a),s},rOe=(t,e)=>{let r={...tOe,...e},n=WIe(t,r);return nOe(n,r),sOe(n),e?.idleTimeout&&e.idleTimeout>0&&oOe(n,e.idleTimeout),n},syt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},nOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||dc.env.NETLIFY_LOCAL_QUIET==="true")return;if(dc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Lw).pipe(dc.stdout),t.stderr?.pipe(new Lw).pipe(dc.stderr);return}t.stdout?.pipe(dc.stdout),t.stderr?.pipe(dc.stderr)},R8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(dc.kill(-t.pid,e),Ny.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Ny.error("Error killing process:",r),!1}},iOe=t=>R8(t,"SIGKILL"),oOe=(t,e)=>{let r=null,n=()=>{Ny.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),R8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing idle process ${t.pid}`),iOe(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)},sOe=t=>{A8.add(t);let e=QIe();if(e){let r=e.onTimesUp(()=>{Ny.log(`Global timer expired, killing process ${t.pid}`),R8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing process ${t.pid} after timeout`),iOe(t))},5e3)});t.on("exit",()=>{A8.delete(t),r()}),t.on("error",()=>{A8.delete(t),r()})}};function YM(t,e){return!!fa(t,e)}function fa(t,e){if(!dc.env.NETLIFY_LOCAL_MODE)try{let i=oyt.resolve(eOe.name),o=Ru.dirname(i);for(;o!==Ru.dirname(o);){let s=Ru.dirname(o);if(Ru.basename(s)==="node_modules"){let a=Ru.join(s,".bin",e);if(KM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(dc.env.NODE_PATH){let i=Ru.join(dc.env.NODE_PATH,".bin",e);if(KM.existsSync(i))return i}let r=Ru.join(t,"node_modules",".bin",e);if(KM.existsSync(r))return r;let n=Ru.join(iyt,"..","node_modules",".bin",e);if(KM.existsSync(n))return n}var $y=oe("repo"),pOe="runner-diffs-",x8=t=>`${pOe}${t}-`,hOe=async t=>{let e=XM.tmpdir(),r;try{r=await mi.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(pOe)&&!n.startsWith(x8(t))).map(n=>mi.rm(ts.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},aOe=async t=>{let e=ayt("sha256");for await(let r of cyt(t))e.update(r);return e.digest("hex")},cOe=async(t,e)=>t.size===e.size&&await aOe(t.path)===await aOe(e.path),mOe=/.. (.+)?\.log$/,uyt=[mOe],lyt=1,uOe=t=>{let e=t.split(`
|
|
386
|
+
if (condition) { yield value; }`)};import{Buffer as _mt}from"buffer";import{StringDecoder as ymt}from"string_decoder";var NM=(t,e,r)=>{if(r)return;if(t)return{transform:Smt.bind(void 0,new TextEncoder)};let n=new ymt(e);return{transform:vmt.bind(void 0,n),final:Emt.bind(void 0,n)}},Smt=function*(t,e){_mt.isBuffer(e)?yield Eu(e):typeof e=="string"?yield t.encode(e):yield e},vmt=function*(t,e){yield Kr(e)?t.write(e):e},Emt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as vxe}from"util";var B5=vxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$M=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=wmt}=e[r];for await(let i of n(t))yield*$M(i,e,r+1)},Exe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*bmt(r,Number(e),t)},bmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$M(n,r,e+1)},bxe=vxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),wmt=function*(t){yield t};var q5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},wxe=(t,e)=>[...e.flatMap(r=>[...rh(r,t,0)]),...cR(t)],rh=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Amt}=e[r];for(let i of n(t))yield*rh(i,e,r+1)},cR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Tmt(r,Number(e),t)},Tmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*rh(n,r,e+1)},Amt=function*(t){yield t};var V5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Axe(t,s,o),u=th(e),l=th(r),d=u?B5.bind(void 0,$M,a):q5.bind(void 0,rh),f=u||l?B5.bind(void 0,Exe,a):q5.bind(void 0,cR),p=u||l?bxe.bind(void 0,a):void 0;return{stream:new Rmt({writableObjectMode:n,writableHighWaterMark:Txe(n),readableObjectMode:i,readableHighWaterMark:Txe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},DM=(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=Axe(s,r,a);t=wxe(c,t)}return t},Axe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:_xe(n,a)},NM(r,s,n),kM(r,o,n,c),{transform:t,final:e},{transform:yxe(i,a)},gxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Rxe=(t,e)=>{for(let r of xmt(t))Imt(t,r,e)},xmt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Imt=(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 ${pd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Omt(a,n));r.input=JA(s)},Omt=(t,e)=>{let r=DM(t,e,"utf8",!0);return Pmt(r),JA(r)},Pmt=t=>{let e=t.find(r=>typeof r!="string"&&!Kr(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 $mt,appendFileSync as Dmt}from"fs";var MM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sy(r,n)&&!go.has(e)&&Cmt(n)&&(t.some(({type:i,value:o})=>i==="native"&&kmt.has(o))||t.every(({type:i})=>Qo.has(i))),Cmt=t=>t===1||t===2,kmt=new Set(["pipe","overlapped"]),xxe=async(t,e,r,n)=>{for await(let i of t)Nmt(e)||Oxe(i,r,n)},Ixe=(t,e,r)=>{for(let n of t)Oxe(n,e,r)},Nmt=t=>t._readableState.pipes.length>0,Oxe=(t,e,r)=>{let n=ZD(t);sc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Pxe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,u)=>Mmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Mmt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=CRe(t,o,d),p=Eu(f),{stdioItems:h,objectMode:m}=e[r],_=Lmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Umt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Fmt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?v:void 0;try{return n.error===void 0&&zmt(y,h,i),A}catch(S){return n.error=S,A}},Lmt=(t,e,r,n)=>{try{return DM(t,e,r,!1)}catch(i){return n.error=i,t}},Umt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:JA(t)};let s=Gwe(t,r);return n[o]?{serializedResult:s,finalResult:j5(s,!i[o],e)}:{serializedResult:s}},Fmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!MM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=j5(t,!1,s);try{Ixe(a,e,n)}catch(c){r.error??=c}},zmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>PM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?Dmt(n,t):(r.add(o),$mt(n,t))}};var Cxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Tu(e,r,"all")]:Array.isArray(e)?[Tu(t,r,"all"),...e]:Kr(t)&&Kr(e)?Z9([t,e]):`${t}${e}`};import{once as G5}from"events";var kxe=async(t,e)=>{let[r,n]=await jmt(t);return e.isForcefullyTerminated??=!1,[r,n]},jmt=async t=>{let[e,r]=await Promise.allSettled([G5(t,"spawn"),G5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Nxe(t):r.value},Nxe=async t=>{try{return await G5(t,"exit")}catch{return Nxe(t)}},$xe=async t=>{let[e,r]=await t;if(!Bmt(e,r)&&H5(e,r))throw new ua;return[e,r]},Bmt=(t,e)=>t===void 0&&e===void 0,H5=(t,e)=>t!==0||e!==null;var Dxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=qmt(t,e,r),s=o?.code==="ETIMEDOUT",a=PRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},qmt=(t,e,r)=>t!==void 0?t:H5(e,r)?new ua:void 0;var Mxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Gmt(t,e,r),d=Kmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Oy(d,c,u)},Gmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),a=Hmt(r),{file:c,commandArguments:u,options:l}=yM(t,e,a);Wmt(l);let d=fxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Hmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Wmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LM("ipcInput"),t&&LM("ipc: true"),r&&LM("detached: true"),n&&LM("cancelSignal")},LM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Kmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=Ymt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=Dxe(c,r),{output:h,error:m=u}=Pxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Tu(v,r,A)),y=Tu(Cxe(h,r),r,"all");return Xmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Ymt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Rxe(o,r);let a=Zmt(r);return Vmt(...SM(t,e,a))}catch(a){return Iy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Zmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RM(e)}),Xmt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?xM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):aR({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as U_t}from"events";import{spawn as F_t}from"child_process";import jxe from"process";import{once as W5,on as Jmt}from"events";var Lxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(by({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),Qmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Qmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cM(e,i);let o=fd(t,e,r),s=new AbortController;try{return await Promise.race([egt(o,n,s),tgt(o,r,s),rgt(o,r,s)])}catch(a){throw wy(t),a}finally{s.abort(),uM(e,i)}},egt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await W5(t,"message",{signal:r});return n}for await(let[n]of Jmt(t,"message",{signal:r}))if(e(n))return n},tgt=async(t,e,{signal:r})=>{await W5(t,"disconnect",{signal:r}),wAe(e)},rgt=async(t,e,{signal:r})=>{let[n]=await W5(t,"strict:error",{signal:r});throw oM(n,e)};import{once as Fxe,on as ngt}from"events";var zxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>K5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),K5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{by({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),cM(e,o);let s=fd(t,e,r),a=new AbortController,c={};return igt(t,s,a),ogt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),sgt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},igt=async(t,e,r)=>{try{await Fxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ogt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Fxe(t,"strict:error",{signal:r.signal});n.error=oM(i,e),r.abort()}catch{}},sgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of ngt(r,"message",{signal:o.signal}))Uxe(s),yield c}catch{Uxe(s)}finally{o.abort(),uM(e,a),n||wy(t),i&&await t}},Uxe=({error:t})=>{if(t)throw t};var Bxe=(t,{ipc:e})=>{Object.assign(t,Vxe(t,!1,e))},qxe=()=>{let t=jxe,e=!0,r=jxe.channel!==void 0;return{...Vxe(t,e,r),getCancelSignal:ZAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Vxe=(t,e,r)=>({sendMessage:gM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Lxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:zxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as agt}from"child_process";import{PassThrough as cgt,Readable as ugt,Writable as lgt,Duplex as dgt}from"stream";var Gxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{U5(n);let a=new agt;fgt(a,n),Object.assign(a,{readable:pgt,writable:hgt,duplex:mgt});let c=Iy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=ggt(c,s,i);return{subprocess:a,promise:u}},fgt=(t,e)=>{let r=uR(),n=uR(),i=uR(),o=Array.from({length:e.length-3},uR),s=uR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},uR=()=>{let t=new cgt;return t.end(),t},pgt=()=>new ugt({read(){}}),hgt=()=>new lgt({write(){}}),mgt=()=>new dgt({read(){},write(){}}),ggt=async(t,e,r)=>Oy(t,e,r);import{createReadStream as Hxe,createWriteStream as Wxe}from"fs";import{Buffer as _gt}from"buffer";import{Readable as lR,Writable as ygt,Duplex as Sgt}from"stream";var Yxe=(t,e)=>CM(vgt,t,e,!1),dR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Kxe={fileNumber:dR,generator:V5,asyncGenerator:V5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Sgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},vgt={input:{...Kxe,fileUrl:({value:t})=>({stream:Hxe(t)}),filePath:({value:{file:t}})=>({stream:Hxe(t)}),webStream:({value:t})=>({stream:lR.fromWeb(t)}),iterable:({value:t})=>({stream:lR.from(t)}),asyncIterable:({value:t})=>({stream:lR.from(t)}),string:({value:t})=>({stream:lR.from(t)}),uint8Array:({value:t})=>({stream:lR.from(_gt.from(t))})},output:{...Kxe,fileUrl:({value:t})=>({stream:Wxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Wxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:ygt.fromWeb(t)}),iterable:dR,asyncIterable:dR,string:dR,uint8Array:dR}};import{on as Egt,once as Zxe}from"events";import{PassThrough as bgt,getDefaultHighWaterMark as wgt}from"stream";import{finished as Qxe}from"stream/promises";function nh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Z5(i);let e=t.some(({readableObjectMode:i})=>i),r=Tgt(t,e),n=new Y5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Tgt=(t,e)=>{if(t.length===0)return wgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},Y5=class extends bgt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(Z5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Agt(this,this.#e,this.#o);let r=Igt({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(Z5(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)}},Agt=async(t,e,r)=>{UM(t,Xxe);let n=new AbortController;try{await Promise.race([Rgt(t,n),xgt(t,e,r,n)])}finally{n.abort(),UM(t,-Xxe)}},Rgt=async(t,{signal:e})=>{try{await Qxe(t,{signal:e,cleanup:!0})}catch(r){throw eIe(t,r),r}},xgt=async(t,e,r,{signal:n})=>{for await(let[i]of Egt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},Z5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Igt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{UM(t,Jxe);let a=new AbortController;try{await Promise.race([Ogt(o,e,a),Pgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Cgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),UM(t,-Jxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?X5(t):kgt(t))},Ogt=async(t,e,{signal:r})=>{try{await t,r.aborted||X5(e)}catch(n){r.aborted||eIe(e,n)}},Pgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Qxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;tIe(s)?i.add(e):rIe(t,s)}},Cgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Zxe(t,i,{signal:o}),!t.readable)return Zxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},kgt=t=>{t.writable&&t.end()},eIe=(t,e)=>{tIe(e)?X5(t):rIe(t,e)},tIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",X5=t=>{(t.readable||t.writable)&&t.destroy()},rIe=(t,e)=>{t.destroyed||(t.once("error",Ngt),t.destroy(e))},Ngt=()=>{},UM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Xxe=2,Jxe=1;import{finished as nIe}from"stream/promises";var Cy=(t,e)=>{t.pipe(e),$gt(t,e),Dgt(t,e)},$gt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await nIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}J5(e)}},J5=t=>{t.writable&&t.end()},Dgt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await nIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}Q5(t)}},Q5=t=>{t.readable&&t.destroy()};var iIe=(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})=>Qo.has(c)))Mgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qo.has(c)))Ugt({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]:nh(o);Cy(s,i)}},Mgt=(t,e,r,n)=>{r==="output"?Cy(t.stdio[n],e):Cy(e,t.stdio[n]);let i=Lgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Lgt=["stdin","stdout","stderr"],Ugt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Fgt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Fgt=(t,{signal:e})=>{ca(t)&&Qp(t,zgt,e)},zgt=2;import{addAbortListener as qgt}from"events";var ih=[];ih.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ih.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ih.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FM=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",e8=Symbol.for("signal-exit emitter"),t8=globalThis,jgt=Object.defineProperty.bind(Object),r8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(t8[e8])return t8[e8];jgt(t8,e8,{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}},zM=class{},Bgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),n8=class extends zM{onExit(){return()=>{}}load(){}unload(){}},i8=class extends zM{#e=o8.platform==="win32"?"SIGINT":"SIGHUP";#r=new r8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ih)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(!FM(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 ih)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,ih.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 FM(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"&&FM(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)}},o8=globalThis.process,{onExit:oIe,load:Wfr,unload:Kfr}=Bgt(FM(o8)?new i8(o8):new n8);var sIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=oIe(()=>{t.kill()});qgt(n,()=>{i()})};var cIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=XD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=Vgt(r,n,i),{sourceStream:d,sourceError:f}=Hgt(t,u),{options:p,fileDescriptors:h}=cc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},Vgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Ggt(t,e,...r),a=aM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Ggt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(aIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||K9(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]=jD(r,...n);return{destination:e(aIe)(i,o,s),pipeOptions:s}}if(cc.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}`)},aIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Hgt=(t,e)=>{try{return{sourceStream:Ty(t,e)}}catch(r){return{sourceError:r}}};var lIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Wgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw s8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Wgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return Q5(t),n;if(e!==void 0)return J5(r),e},s8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Iy({error:t,command:uIe,escapedCommand:uIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),uIe="source.pipe(destination)";var dIe=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 Kgt}from"stream/promises";var fIe=(t,e,r)=>{let n=jM.has(e)?Zgt(t,e):Ygt(t,e);return Qp(t,Jgt,r.signal),Qp(e,Qgt,r.signal),Xgt(e),n},Ygt=(t,e)=>{let r=nh([t]);return Cy(r,e),jM.set(e,r),r},Zgt=(t,e)=>{let r=jM.get(e);return r.add(t),r},Xgt=async t=>{try{await Kgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jM.delete(t)},jM=new WeakMap,Jgt=2,Qgt=1;import{aborted as e_t}from"util";var pIe=(t,e)=>t===void 0?[]:[t_t(t,e)],t_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await e_t(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw s8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var BM=(t,...e)=>{if(Ar(e[0]))return BM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=cIe(t,...e),i=r_t({...n,destination:r});return i.pipe=BM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},r_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=n_t(t,i);lIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=fIe(e,o,d);return await Promise.race([dIe(l),...pIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},n_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as l_t}from"timers/promises";import{on as i_t}from"events";import{getDefaultHighWaterMark as o_t}from"stream";var qM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return s_t(e,s),mIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},s_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},a8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;a_t(e,s,t);let a=t.readableObjectMode&&!o;return mIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},a_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},mIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=i_t(t,"data",{signal:e.signal,highWaterMark:hIe,highWatermark:hIe});return c_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},c8=o_t(!0),hIe=c8,c_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=u_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*rh(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cR(a)}},u_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NM(t,r,!e),kM(t,i,!n,{})].filter(Boolean);var gIe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=d_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([f_t(t),d]);return}let f=F5(c,r),p=a8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([p_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},d_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!MM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=a8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await xxe(a,t,r,o)},f_t=async t=>{await l_t(),t.readableFlowing===null&&t.resume()},p_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await wM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await TM(r,{maxBuffer:o})):await xy(r,{maxBuffer:o})}catch(a){return _Ie(xRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},u8=async t=>{try{return await t}catch(e){return _Ie(e)}},_Ie=({bufferedData:t})=>qwe(t)?new Uint8Array(t):t;import{finished as h_t}from"stream/promises";var fR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=m_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],h_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||y_t(a,e,r,n)}finally{s.abort()}},m_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&g_t(t,r,n),n},g_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{__t(e,r),n.call(t,...i)}},__t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},y_t=(t,e,r,n)=>{if(!S_t(t,e,r,n))throw t},S_t=(t,e,r,n=!0)=>r.propagating?yIe(t)||VM(t):(r.propagating=!0,l8(r,e)===n?yIe(t):VM(t)),l8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yIe=t=>t?.code==="EPIPE";var SIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>d8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),d8=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=fR(t,e,u);if(l8(u,e)){await l;return}let[d]=await Promise.all([gIe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var vIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?nh([t,e].filter(Boolean)):void 0,EIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>d8({...v_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:E_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),v_t=({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}},E_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as b_t}from"events";var bIe=t=>Sy(t,"ipc"),wIe=(t,e)=>{let r=ZD(t);sc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var TIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=bIe(o),a=bu(e,"ipc"),c=bu(r,"ipc");for await(let u of K5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(IRe(t,i,c),i.push(u)),s&&wIe(u,o);return i},AIe=async(t,e)=>(await Promise.allSettled([t]),e);var RIe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=kxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=SIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=EIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=[],R=TIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=w_t(m,t,A),O=T_t(h,A);try{return await Promise.race([Promise.all([{},$xe(v),Promise.all(S),b,R,sRe(t,d),...C,...O]),_,A_t(t,y),...tRe(t,o,f,y),...bAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...QAe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},v,Promise.all(S.map(T=>u8(T))),u8(b),AIe(R,E),Promise.allSettled(C),Promise.allSettled(O)])}},w_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:fR(n,i,r)),T_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>da(o,{checkOpen:!1})&&!ca(o)).map(({type:i,value:o,stream:s=o})=>fR(s,n,e,{isSameDirection:Qo.has(i),stopOnExit:i==="native"}))),A_t=async(t,{signal:e})=>{let[r]=await b_t(t,"error",{signal:e});throw r};var xIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),pR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ac();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},ky=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 R_t}from"stream";import{callbackify as x_t}from"util";import{finished as IIe}from"stream/promises";var f8=async t=>{if(t!==void 0)try{await p8(t)}catch{}},OIe=async t=>{if(t!==void 0)try{await h8(t)}catch{}},p8=async t=>{await IIe(t,{cleanup:!0,readable:!1,writable:!0})},h8=async t=>{await IIe(t,{cleanup:!0,readable:!0,writable:!1})},GM=async(t,e)=>{if(await t,e)throw e},HM=(t,e,r)=>{r&&!VM(r)?t.destroy(r):e&&t.destroy()};var PIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||go.has(r),{subprocessStdout:a,waitReadableDestroy:c}=m8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=g8(a,s),{read:f,onStdoutDataDone:p}=_8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new R_t({read:f,destroy:x_t(S8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return y8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},m8=(t,e,r)=>{let n=Ty(t,e),i=pR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},g8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:c8},_8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ac(),s=qM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){I_t(this,s,o)},onStdoutDataDone:o}},I_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},y8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await h8(t),await n,await f8(i),await e,r.readable&&r.push(null)}catch(o){await f8(i),CIe(r,o)}},S8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ky(r,e)&&(CIe(t,n),await GM(e,n))},CIe=(t,e)=>{HM(t,t.readable,e)};import{Writable as O_t}from"stream";import{callbackify as kIe}from"util";var NIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=v8(t,r,e),s=new O_t({...E8(n,t,i),destroy:kIe(w8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return b8(n,s),s},v8=(t,e,r)=>{let n=aM(t,e),i=pR(r,n,"writableFinal"),o=pR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},E8=(t,e,r)=>({write:P_t.bind(void 0,t),final:kIe(C_t.bind(void 0,t,e,r))}),P_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},C_t=async(t,e,r)=>{await ky(r,e)&&(t.writable&&t.end(),await e)},b8=async(t,e,r)=>{try{await p8(t),e.writable&&e.end()}catch(n){await OIe(r),$Ie(e,n)}},w8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ky(r,e),await ky(n,e)&&($Ie(t,i),await GM(e,i))},$Ie=(t,e)=>{HM(t,t.writable,e)};import{Duplex as k_t}from"stream";import{callbackify as N_t}from"util";var DIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||go.has(r),{subprocessStdout:c,waitReadableDestroy:u}=m8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=v8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=g8(c,a),{read:_,onStdoutDataDone:y}=_8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new k_t({read:_,...E8(l,t,d),destroy:N_t($_t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return y8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),b8(l,v,c),v},$_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([S8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),w8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var T8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||go.has(e),s=Ty(t,r),a=qM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return D_t(a,s,t)},D_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var MIe=(t,{encoding:e})=>{let r=xIe();t.readable=PIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=NIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=DIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=T8.bind(void 0,t,e),t[Symbol.asyncIterator]=T8.bind(void 0,t,e,{})};var LIe=(t,e)=>{for(let[r,n]of L_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},M_t=(async()=>{})().constructor.prototype,L_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(M_t,t)]);var UIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=z_t(t,e,r),{subprocess:f,promise:p}=B_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=BM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),LIe(f,p),cc.set(f,{options:l,fileDescriptors:d}),f},z_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),{file:a,commandArguments:c,options:u}=yM(t,e,r),l=j_t(u),d=Yxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},j_t=({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}},B_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=F_t(...SM(t,e,r))}catch(h){return Gxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;U_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];iIe(c,a,u),sIe(c,r,u);let d={},f=ac();c.kill=vAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=vIe(c,r),MIe(c,r),Bxe(c,r);let p=q_t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},q_t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await RIe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((S,b)=>Tu(S,e,b)),v=Tu(m,e,"all"),A=V_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Oy(A,n,e)},V_t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?aR({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof uc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):xM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var WM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,G_t(n,t[n],i)]));return{...t,...r}},G_t=(t,e,r)=>H_t.has(t)&&Ar(e)&&Ar(r)?{...e,...r}:r,H_t=new Set(["env",...e5]);var hd=(t,e,r,n)=>{let i=(s,a,c)=>hd(s,a,r,c),o=(...s)=>W_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},W_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ar(o))return i(t,WM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=K_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?Mxe(a,c,u):UIe(a,c,u,i)},K_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Ywe(e)?Zwe(e,r):[e,...r],[s,a,c]=jD(...o),u=WM(WM(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var FIe=({file:t,commandArguments:e})=>jIe(t,e),zIe=({file:t,commandArguments:e})=>({...jIe(t,e),isSync:!0}),jIe=(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]=Y_t(t);return{file:r,commandArguments:n}},Y_t=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(Z_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Z_t=/ +/g;var BIe=(t,e,r)=>{t.sync=e(X_t,r),t.s=t.sync},qIe=({options:t})=>VIe(t),X_t=({options:t})=>({...VIe(t),isSync:!0}),VIe=t=>({options:{...J_t(t),...t}}),J_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},GIe={preferLocal:!0};var HIe=hd(()=>({})),Lmr=hd(()=>({isSync:!0})),WIe=hd(FIe),Umr=hd(zIe),Fmr=hd(nRe),zmr=hd(qIe,{},GIe,BIe),{sendMessage:jmr,getOneMessage:Bmr,getEachMessage:qmr,getCancelSignal:Vmr}=qxe();var KIe=!1,YIe,Q_t=t=>{YIe??=t},ZIe=t=>{KIe=!0,Q_t(t)},Gn=()=>KIe,Au=()=>YIe,XIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var hR=null,JIe=t=>(hR&&hR.destroy(),hR=new es({totalAllowedTime:t}),hR),QIe=()=>hR;var es=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Gn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await ok({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{K.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var eOe={name:"@netlify/agent-runner-cli",type:"module",version:"2.13.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var nyt=tyt(import.meta.url),iyt=Ru.dirname(nyt),oyt=ryt(import.meta.url),Ny=oe("shell"),A8=new Set,tOe={preferLocal:!0},vt=(t,e,r)=>{let[n,i]=syt(e,r),o={...tOe,...i},s=HIe(t,n,o);nOe(s,o),sOe(s);let a=r?.idleTimeout;return a&&a>0&&oOe(s,a),s},rOe=(t,e)=>{let r={...tOe,...e},n=WIe(t,r);return nOe(n,r),sOe(n),e?.idleTimeout&&e.idleTimeout>0&&oOe(n,e.idleTimeout),n},syt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},nOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||dc.env.NETLIFY_LOCAL_QUIET==="true")return;if(dc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Lw).pipe(dc.stdout),t.stderr?.pipe(new Lw).pipe(dc.stderr);return}t.stdout?.pipe(dc.stdout),t.stderr?.pipe(dc.stderr)},R8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(dc.kill(-t.pid,e),Ny.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Ny.error("Error killing process:",r),!1}},iOe=t=>R8(t,"SIGKILL"),oOe=(t,e)=>{let r=null,n=()=>{Ny.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),R8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing idle process ${t.pid}`),iOe(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)},sOe=t=>{A8.add(t);let e=QIe();if(e){let r=e.onTimesUp(()=>{Ny.log(`Global timer expired, killing process ${t.pid}`),R8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing process ${t.pid} after timeout`),iOe(t))},5e3)});t.on("exit",()=>{A8.delete(t),r()}),t.on("error",()=>{A8.delete(t),r()})}};function YM(t,e){return!!fa(t,e)}function fa(t,e){if(!dc.env.NETLIFY_LOCAL_MODE)try{let i=oyt.resolve(eOe.name),o=Ru.dirname(i);for(;o!==Ru.dirname(o);){let s=Ru.dirname(o);if(Ru.basename(s)==="node_modules"){let a=Ru.join(s,".bin",e);if(KM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(dc.env.NODE_PATH){let i=Ru.join(dc.env.NODE_PATH,".bin",e);if(KM.existsSync(i))return i}let r=Ru.join(t,"node_modules",".bin",e);if(KM.existsSync(r))return r;let n=Ru.join(iyt,"..","node_modules",".bin",e);if(KM.existsSync(n))return n}var $y=oe("repo"),pOe="runner-diffs-",x8=t=>`${pOe}${t}-`,hOe=async t=>{let e=XM.tmpdir(),r;try{r=await mi.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(pOe)&&!n.startsWith(x8(t))).map(n=>mi.rm(ts.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},aOe=async t=>{let e=ayt("sha256");for await(let r of cyt(t))e.update(r);return e.digest("hex")},cOe=async(t,e)=>t.size===e.size&&await aOe(t.path)===await aOe(e.path),mOe=/.. (.+)?\.log$/,uyt=[mOe],lyt=1,uOe=t=>{let e=t.split(`
|
|
387
387
|
`).reduce((r,n)=>{if(!n)return r;let[i,o,,...s]=n,a=s.join(""),c=i.trim(),u=o.trim();return r[a]?r[a].change=u:r[a]={filePath:a,stage:c,change:u},r},{});return Object.values(e)},dyt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),lOe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return Rn(r?`${e}: ${r}`:e)},fyt=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),dOe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),pyt=(t,e)=>{try{let r=new URL(t),n=new URL(e);return["https:","http:"].includes(n.protocol)&&n.protocol===r.protocol&&n.host===r.host&&dOe(n)===dOe(r)&&n.password!==""}catch{return!1}},fOe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},ZM=500,mR=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},Hn=class{constructor(e=process.cwd()){this.cwd=e}getRoot(){return this.root??=this.run(["rev-parse","--show-toplevel"],{stdout:"pipe"}).then(({stdout:e})=>String(e).trim()),this.root}async restorePausedWork(e){let r="restore";try{let n=await this.restorePausedFiles(e);r="stage",await this.stageBuildSetup();let i=await this.getRoot(),o=new Set(n.changedFiles),s=(await this.listIndexEntries(n.deletedFiles,{cwd:i})).filter(({filePath:a})=>!o.has(a));return await this.unstageFiles(n.changedFiles,{cwd:i}),s.length>0&&await mi.writeFile(await this.getSetupMetadataPath(),JSON.stringify(s)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new mR(r,n)}}run(e,r={}){return vt("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){$y.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!r){let u=uOe(o);await this.discardSetupOnlyChanges(u)}$y.info("Changes after processing"),await this.getStatus();let s=await this.getIgnoredPathspecs(o);if(await this.stageFiles(s),await this.excludeUnchangedSetupDescendants(),i=await this.hasStagedChanges(),!i)return{hasChanges:!1,ignored:s};await this.run(["commit","-m","Agent runner [skip ci]"]);let a=await mi.mkdtemp(ts.join(XM.tmpdir(),x8(e.sessionId))),c=await this.writeDiffFiles({config:e,diffDir:a,target:{commit:"HEAD"},ignored:s});return await this.rollbackIfLocal(),c.hasChanges&&K.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c}async getStatus(){let e=await this.run(["-c","status.relativePaths=true","status","-s"]);return String(e.stdout??"")}async hasAgentChanges(){let e=await this.getStatus();return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
388
388
|
`).filter(i=>uyt.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}}async getCurrentCommitSha(){let{stdout:e}=await this.run(["rev-parse","HEAD"]);return String(e??"").trim()}async reset(){await this.run(["reset","--hard","HEAD"]),await mi.rm(await this.getSetupMetadataPath(),{force:!0})}async discardSetupOnlyChanges(e){let r=e.filter(n=>n.stage&&!n.change).map(n=>n.filePath);r.length!==0&&await this.run(["restore","--staged","--worktree","--pathspec-from-file=-"],{input:r.join(`
|
|
389
389
|
`)})}async stageBuildSetup(){await mi.rm(await this.getSetupMetadataPath(),{force:!0});let e=await this.getIgnoredPathspecs();await this.stageFiles(e)}getSetupMetadataPath(){return this.setupMetadataPath??=this.getRoot().then(async e=>{let{stdout:r}=await this.run(["rev-parse","--git-path","netlify-agent-runner-setup.json"],{cwd:e,stdout:"pipe"});return ts.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=ZM){let o=e.slice(i,i+ZM).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...fOe,...r});for(let a of String(s??"").split("\0").filter(Boolean))n.push({filePath:a.slice(a.indexOf(" ")+1),entry:a})}return n}async excludeUnchangedSetupDescendants(e){let r;try{r=JSON.parse(await mi.readFile(await this.getSetupMetadataPath(),"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}let i={cwd:await this.getRoot(),env:e},o=new Map((await this.listIndexEntries(r.map(({filePath:a})=>a),i)).map(({filePath:a,entry:c})=>[a,c])),s=r.filter(({filePath:a,entry:c})=>o.get(a)===c);s.length!==0&&await this.run(["update-index","--force-remove","-z","--stdin"],{...i,input:s.map(({filePath:a})=>a).join("\0")})}async getIgnoredPathspecs(e){e||=await this.getStatus();let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return e.split(`
|
package/dist/bin.js
CHANGED
|
@@ -594,7 +594,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
594
594
|
`,LF:`
|
|
595
595
|
`,concatBytes:JQ},Bzt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Vzt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Bzt};import{Buffer as Hzt}from"buffer";var HLe=(t,e)=>t?void 0:Gzt.bind(void 0,e),Gzt=function*(t,e){if(typeof e!="string"&&!xn(e)&&!Hzt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},GLe=(t,e)=>t?Wzt.bind(void 0,e):Kzt.bind(void 0,e),Wzt=function*(t,e){WLe(t,e),yield e},Kzt=function*(t,e){if(WLe(t,e),typeof e!="string"&&!xn(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},WLe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
596
596
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
597
|
-
if (condition) { yield value; }`)};import{Buffer as Yzt}from"buffer";import{StringDecoder as Jzt}from"string_decoder";var lU=(t,e,r)=>{if(r)return;if(t)return{transform:Zzt.bind(void 0,new TextEncoder)};let n=new Jzt(e);return{transform:Xzt.bind(void 0,n),final:Qzt.bind(void 0,n)}},Zzt=function*(t,e){Yzt.isBuffer(e)?yield Rl(e):typeof e=="string"?yield t.encode(e):yield e},Xzt=function*(t,e){yield xn(e)?t.write(e):e},Qzt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as KLe}from"util";var XQ=KLe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),dU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=tqt}=e[r];for await(let i of n(t))yield*dU(i,e,r+1)},YLe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*eqt(r,Number(e),t)},eqt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*dU(n,r,e+1)},JLe=KLe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),tqt=function*(t){yield t};var QQ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},ZLe=(t,e)=>[...e.flatMap(r=>[...Dm(r,t,0)]),...yx(t)],Dm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=nqt}=e[r];for(let i of n(t))yield*Dm(i,e,r+1)},yx=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*rqt(r,Number(e),t)},rqt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Dm(n,r,e+1)},nqt=function*(t){yield t};var e7=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=QLe(t,o,s),u=$m(e),l=$m(r),d=u?XQ.bind(void 0,dU,a):QQ.bind(void 0,Dm),f=u||l?XQ.bind(void 0,YLe,a):QQ.bind(void 0,yx),p=u||l?JLe.bind(void 0,a):void 0;return{stream:new iqt({writableObjectMode:n,writableHighWaterMark:XLe(n),readableObjectMode:i,readableHighWaterMark:XLe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},fU=(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=QLe(o,r,a);t=ZLe(c,t)}return t},QLe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:HLe(n,a)},lU(r,o,n),uU(r,s,n,c),{transform:t,final:e},{transform:GLe(i,a)},VLe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var eMe=(t,e)=>{for(let r of sqt(t))oqt(t,r,e)},sqt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),oqt=(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 ${$f[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>aqt(a,n));r.input=cx(o)},aqt=(t,e)=>{let r=fU(t,e,"utf8",!0);return cqt(r),cx(r)},cqt=t=>{let e=t.find(r=>typeof r!="string"&&!xn(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 fqt,appendFileSync as pqt}from"fs";var pU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&oE(r,n)&&!ro.has(e)&&uqt(n)&&(t.some(({type:i,value:s})=>i==="native"&&lqt.has(s))||t.every(({type:i})=>Zo.has(i))),uqt=t=>t===1||t===2,lqt=new Set(["pipe","overlapped"]),tMe=async(t,e,r,n)=>{for await(let i of t)dqt(e)||nMe(i,r,n)},rMe=(t,e,r)=>{for(let n of t)nMe(n,e,r)},dqt=t=>t._readableState.pipes.length>0,nMe=(t,e,r)=>{let n=x1(t);iu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var iMe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>hqt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},hqt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=sLe(t,s,d),p=Rl(f),{stdioItems:h,objectMode:m}=e[r],g=mqt([p],h,c,n),{serializedResult:y,finalResult:E=y}=gqt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});_qt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&yqt(y,h,i),S}catch(_){return n.error=_,S}},mqt=(t,e,r,n)=>{try{return fU(t,e,r,!1)}catch(i){return n.error=i,t}},gqt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:cx(t)};let o=SNe(t,r);return n[s]?{serializedResult:o,finalResult:ZQ(o,!i[s],e)}:{serializedResult:o}},_qt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!pU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=ZQ(t,!1,o);try{rMe(a,e,n)}catch(c){r.error??=c}},yqt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>aU.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?pqt(n,t):(r.add(s),fqt(n,t))}};var sMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Il(e,r,"all")]:Array.isArray(e)?[Il(t,r,"all"),...e]:xn(t)&&xn(e)?oQ([t,e]):`${t}${e}`};import{once as t7}from"events";var oMe=async(t,e)=>{let[r,n]=await Sqt(t);return e.isForcefullyTerminated??=!1,[r,n]},Sqt=async t=>{let[e,r]=await Promise.allSettled([t7(t,"spawn"),t7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?aMe(t):r.value},aMe=async t=>{try{return await t7(t,"exit")}catch{return aMe(t)}},cMe=async t=>{let[e,r]=await t;if(!Eqt(e,r)&&r7(e,r))throw new Ka;return[e,r]},Eqt=(t,e)=>t===void 0&&e===void 0,r7=(t,e)=>t!==0||e!==null;var uMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=vqt(t,e,r),o=s?.code==="ETIMEDOUT",a=iLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},vqt=(t,e,r)=>t!==void 0?t:r7(e,r)?new Ka:void 0;var lMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=wqt(t,e,r),d=Rqt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return gE(d,c,u)},wqt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),a=Tqt(r),{file:c,commandArguments:u,options:l}=Y1(t,e,a);Aqt(l);let d=jLe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},Tqt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Aqt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&hU("ipcInput"),t&&hU("ipc: true"),r&&hU("detached: true"),n&&hU("cancelSignal")},hU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Rqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=xqt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=uMe(c,r),{output:h,error:m=u}=iMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,S)=>Il(E,r,S)),y=Il(sMe(h,r),r,"all");return Iqt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},xqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{eMe(s,r);let a=Oqt(r);return bqt(...J1(t,e,a))}catch(a){return mE({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Oqt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:nU(e)}),Iqt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?iU({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):_x({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as g2t}from"events";import{spawn as _2t}from"child_process";import mMe from"process";import{once as n7,on as Pqt}from"events";var dMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(uE({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),Cqt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Cqt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{F1(e,i);let s=Nf(t,e,r),o=new AbortController;try{return await Promise.race([kqt(s,n,o),Nqt(s,r,o),$qt(s,r,o)])}catch(a){throw lE(t),a}finally{o.abort(),j1(e,i)}},kqt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await n7(t,"message",{signal:r});return n}for await(let[n]of Pqt(t,"message",{signal:r}))if(e(n))return n},Nqt=async(t,e,{signal:r})=>{await n7(t,"disconnect",{signal:r}),Z$e(e)},$qt=async(t,e,{signal:r})=>{let[n]=await n7(t,"strict:error",{signal:r});throw L1(n,e)};import{once as pMe,on as Dqt}from"events";var hMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>i7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),i7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{uE({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),F1(e,s);let o=Nf(t,e,r),a=new AbortController,c={};return Lqt(t,o,a),Mqt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Uqt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Lqt=async(t,e,r)=>{try{await pMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Mqt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await pMe(t,"strict:error",{signal:r.signal});n.error=L1(i,e),r.abort()}catch{}},Uqt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Dqt(r,"message",{signal:s.signal}))fMe(o),yield c}catch{fMe(o)}finally{s.abort(),j1(e,a),n||lE(t),i&&await t}},fMe=({error:t})=>{if(t)throw t};var gMe=(t,{ipc:e})=>{Object.assign(t,yMe(t,!1,e))},_Me=()=>{let t=mMe,e=!0,r=mMe.channel!==void 0;return{...yMe(t,e,r),getCancelSignal:TDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},yMe=(t,e,r)=>({sendMessage:W1.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:dMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:hMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Fqt}from"child_process";import{PassThrough as jqt,Readable as zqt,Writable as qqt,Duplex as Bqt}from"stream";var SMe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{KQ(n);let a=new Fqt;Vqt(a,n),Object.assign(a,{readable:Hqt,writable:Gqt,duplex:Wqt});let c=mE({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Kqt(c,o,i);return{subprocess:a,promise:u}},Vqt=(t,e)=>{let r=Sx(),n=Sx(),i=Sx(),s=Array.from({length:e.length-3},Sx),o=Sx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Sx=()=>{let t=new jqt;return t.end(),t},Hqt=()=>new zqt({read(){}}),Gqt=()=>new qqt({write(){}}),Wqt=()=>new Bqt({read(){},write(){}}),Kqt=async(t,e,r)=>gE(t,e,r);import{createReadStream as EMe,createWriteStream as vMe}from"fs";import{Buffer as Yqt}from"buffer";import{Readable as Ex,Writable as Jqt,Duplex as Zqt}from"stream";var wMe=(t,e)=>cU(Xqt,t,e,!1),vx=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$f[t]}.`)},bMe={fileNumber:vx,generator:e7,asyncGenerator:e7,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Zqt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Xqt={input:{...bMe,fileUrl:({value:t})=>({stream:EMe(t)}),filePath:({value:{file:t}})=>({stream:EMe(t)}),webStream:({value:t})=>({stream:Ex.fromWeb(t)}),iterable:({value:t})=>({stream:Ex.from(t)}),asyncIterable:({value:t})=>({stream:Ex.from(t)}),string:({value:t})=>({stream:Ex.from(t)}),uint8Array:({value:t})=>({stream:Ex.from(Yqt.from(t))})},output:{...bMe,fileUrl:({value:t})=>({stream:vMe(t)}),filePath:({value:{file:t,append:e}})=>({stream:vMe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Jqt.fromWeb(t)}),iterable:vx,asyncIterable:vx,string:vx,uint8Array:vx}};import{on as Qqt,once as TMe}from"events";import{PassThrough as eBt,getDefaultHighWaterMark as tBt}from"stream";import{finished as xMe}from"stream/promises";function Lm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)o7(i);let e=t.some(({readableObjectMode:i})=>i),r=rBt(t,e),n=new s7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var rBt=(t,e)=>{if(t.length===0)return tBt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},s7=class extends eBt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(o7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=nBt(this,this.#e,this.#s);let r=oBt({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(o7(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)}},nBt=async(t,e,r)=>{mU(t,AMe);let n=new AbortController;try{await Promise.race([iBt(t,n),sBt(t,e,r,n)])}finally{n.abort(),mU(t,-AMe)}},iBt=async(t,{signal:e})=>{try{await xMe(t,{signal:e,cleanup:!0})}catch(r){throw OMe(t,r),r}},sBt=async(t,e,r,{signal:n})=>{for await(let[i]of Qqt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},o7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},oBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{mU(t,RMe);let a=new AbortController;try{await Promise.race([aBt(s,e,a),cBt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),uBt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),mU(t,-RMe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?a7(t):lBt(t))},aBt=async(t,e,{signal:r})=>{try{await t,r.aborted||a7(e)}catch(n){r.aborted||OMe(e,n)}},cBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await xMe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;IMe(o)?i.add(e):PMe(t,o)}},uBt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await TMe(t,i,{signal:s}),!t.readable)return TMe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},lBt=t=>{t.writable&&t.end()},OMe=(t,e)=>{IMe(e)?a7(t):PMe(t,e)},IMe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",a7=t=>{(t.readable||t.writable)&&t.destroy()},PMe=(t,e)=>{t.destroyed||(t.once("error",dBt),t.destroy(e))},dBt=()=>{},mU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},AMe=2,RMe=1;import{finished as CMe}from"stream/promises";var yE=(t,e)=>{t.pipe(e),fBt(t,e),pBt(t,e)},fBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await CMe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}c7(e)}},c7=t=>{t.writable&&t.end()},pBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await CMe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}u7(t)}},u7=t=>{t.readable&&t.destroy()};var kMe=(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})=>Zo.has(c)))hBt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Zo.has(c)))gBt({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]:Lm(s);yE(o,i)}},hBt=(t,e,r,n)=>{r==="output"?yE(t.stdio[n],e):yE(e,t.stdio[n]);let i=mBt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},mBt=["stdin","stdout","stderr"],gBt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;_Bt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},_Bt=(t,{signal:e})=>{Wa(t)&&km(t,yBt,e)},yBt=2;import{addAbortListener as vBt}from"events";var Mm=[];Mm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Mm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Mm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var gU=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",l7=Symbol.for("signal-exit emitter"),d7=globalThis,SBt=Object.defineProperty.bind(Object),f7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(d7[l7])return d7[l7];SBt(d7,l7,{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}},_U=class{},EBt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),p7=class extends _U{onExit(){return()=>{}}load(){}unload(){}},h7=class extends _U{#e=m7.platform==="win32"?"SIGINT":"SIGHUP";#r=new f7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Mm)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(!gU(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 Mm)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,Mm.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 gU(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"&&gU(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)}},m7=globalThis.process,{onExit:NMe,load:_2r,unload:y2r}=EBt(gU(m7)?new h7(m7):new p7);var $Me=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=NMe(()=>{t.kill()});vBt(n,()=>{i()})};var LMe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=O1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=bBt(r,n,i),{sourceStream:d,sourceError:f}=TBt(t,u),{options:p,fileDescriptors:h}=ou.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},bBt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=wBt(t,e,...r),a=U1(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},wBt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(DMe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||iQ(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]=y1(r,...n);return{destination:e(DMe)(i,s,o),pipeOptions:o}}if(ou.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}`)},DMe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),TBt=(t,e)=>{try{return{sourceStream:dE(t,e)}}catch(r){return{sourceError:r}}};var UMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=ABt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw g7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},ABt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return u7(t),n;if(e!==void 0)return c7(r),e},g7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>mE({error:t,command:MMe,escapedCommand:MMe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),MMe="source.pipe(destination)";var FMe=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 RBt}from"stream/promises";var jMe=(t,e,r)=>{let n=yU.has(e)?OBt(t,e):xBt(t,e);return km(t,PBt,r.signal),km(e,CBt,r.signal),IBt(e),n},xBt=(t,e)=>{let r=Lm([t]);return yE(r,e),yU.set(e,r),r},OBt=(t,e)=>{let r=yU.get(e);return r.add(t),r},IBt=async t=>{try{await RBt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}yU.delete(t)},yU=new WeakMap,PBt=2,CBt=1;import{aborted as kBt}from"util";var zMe=(t,e)=>t===void 0?[]:[NBt(t,e)],NBt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await kBt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw g7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var SU=(t,...e)=>{if(Qr(e[0]))return SU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=LMe(t,...e),i=$Bt({...n,destination:r});return i.pipe=SU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},$Bt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=DBt(t,i);UMe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=jMe(e,s,d);return await Promise.race([FMe(l),...zMe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},DBt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as qBt}from"timers/promises";import{on as LBt}from"events";import{getDefaultHighWaterMark as MBt}from"stream";var EU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return UBt(e,o),BMe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},UBt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},_7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;FBt(e,o,t);let a=t.readableObjectMode&&!s;return BMe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},FBt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},BMe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=LBt(t,"data",{signal:e.signal,highWaterMark:qMe,highWatermark:qMe});return jBt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},y7=MBt(!0),qMe=y7,jBt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=zBt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Dm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*yx(a)}},zBt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[lU(t,r,!e),uU(t,i,!n,{})].filter(Boolean);var VMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=BBt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([VBt(t),d]);return}let f=YQ(c,r),p=_7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([HBt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},BBt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!pU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=_7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await tMe(a,t,r,s)},VBt=async t=>{await qBt(),t.readableFlowing===null&&t.resume()},HBt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await eU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await tU(r,{maxBuffer:s})):await hE(r,{maxBuffer:s})}catch(a){return HMe(tLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},S7=async t=>{try{return await t}catch(e){return HMe(e)}},HMe=({bufferedData:t})=>_Ne(t)?new Uint8Array(t):t;import{finished as GBt}from"stream/promises";var bx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=WBt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],GBt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||JBt(a,e,r,n)}finally{o.abort()}},WBt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&KBt(t,r,n),n},KBt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{YBt(e,r),n.call(t,...i)}},YBt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},JBt=(t,e,r,n)=>{if(!ZBt(t,e,r,n))throw t},ZBt=(t,e,r,n=!0)=>r.propagating?GMe(t)||vU(t):(r.propagating=!0,E7(r,e)===n?GMe(t):vU(t)),E7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",vU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",GMe=t=>t?.code==="EPIPE";var WMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>v7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),v7=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=bx(t,e,u);if(E7(u,e)){await l;return}let[d]=await Promise.all([VMe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var KMe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Lm([t,e].filter(Boolean)):void 0,YMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>v7({...XBt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:QBt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),XBt=({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}},QBt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as e2t}from"events";var JMe=t=>oE(t,"ipc"),ZMe=(t,e)=>{let r=x1(t);iu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var XMe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=JMe(s),a=xl(e,"ipc"),c=xl(r,"ipc");for await(let u of i7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(rLe(t,i,c),i.push(u)),o&&ZMe(u,s);return i},QMe=async(t,e)=>(await Promise.allSettled([t]),e);var e1e=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:y})=>{let E=oMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=WMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=YMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=XMe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=t2t(m,t,S),I=r2t(h,S);try{return await Promise.race([Promise.all([{},cMe(E),Promise.all(_),w,R,$De(t,d),...T,...I]),g,n2t(t,y),...IDe(t,s,f,y),...J$e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...xDe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(_.map(O=>S7(O))),S7(w),QMe(R,b),Promise.allSettled(T),Promise.allSettled(I)])}},t2t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:bx(n,i,r)),r2t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ja(s,{checkOpen:!1})&&!Wa(s)).map(({type:i,value:s,stream:o=s})=>bx(o,n,e,{isSameDirection:Zo.has(i),stopOnExit:i==="native"}))),n2t=async(t,{signal:e})=>{let[r]=await e2t(t,"error",{signal:e});throw r};var t1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),wx=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=su();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},SE=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 i2t}from"stream";import{callbackify as s2t}from"util";import{finished as r1e}from"stream/promises";var b7=async t=>{if(t!==void 0)try{await w7(t)}catch{}},n1e=async t=>{if(t!==void 0)try{await T7(t)}catch{}},w7=async t=>{await r1e(t,{cleanup:!0,readable:!1,writable:!0})},T7=async t=>{await r1e(t,{cleanup:!0,readable:!0,writable:!1})},bU=async(t,e)=>{if(await t,e)throw e},wU=(t,e,r)=>{r&&!vU(r)?t.destroy(r):e&&t.destroy()};var i1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ro.has(r),{subprocessStdout:a,waitReadableDestroy:c}=A7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=R7(a,o),{read:f,onStdoutDataDone:p}=x7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new i2t({read:f,destroy:s2t(I7.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return O7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},A7=(t,e,r)=>{let n=dE(t,e),i=wx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},R7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:y7},x7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=su(),o=EU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){o2t(this,o,s)},onStdoutDataDone:s}},o2t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},O7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await T7(t),await n,await b7(i),await e,r.readable&&r.push(null)}catch(s){await b7(i),s1e(r,s)}},I7=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await SE(r,e)&&(s1e(t,n),await bU(e,n))},s1e=(t,e)=>{wU(t,t.readable,e)};import{Writable as a2t}from"stream";import{callbackify as o1e}from"util";var a1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=P7(t,r,e),o=new a2t({...C7(n,t,i),destroy:o1e(N7.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return k7(n,o),o},P7=(t,e,r)=>{let n=U1(t,e),i=wx(r,n,"writableFinal"),s=wx(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},C7=(t,e,r)=>({write:c2t.bind(void 0,t),final:o1e(u2t.bind(void 0,t,e,r))}),c2t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},u2t=async(t,e,r)=>{await SE(r,e)&&(t.writable&&t.end(),await e)},k7=async(t,e,r)=>{try{await w7(t),e.writable&&e.end()}catch(n){await n1e(r),c1e(e,n)}},N7=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await SE(r,e),await SE(n,e)&&(c1e(t,i),await bU(e,i))},c1e=(t,e)=>{wU(t,t.writable,e)};import{Duplex as l2t}from"stream";import{callbackify as d2t}from"util";var u1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ro.has(r),{subprocessStdout:c,waitReadableDestroy:u}=A7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=P7(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=R7(c,a),{read:g,onStdoutDataDone:y}=x7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new l2t({read:g,...C7(l,t,d),destroy:d2t(f2t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return O7({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:l}),k7(l,E,c),E},f2t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([I7({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),N7({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var $7=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ro.has(e),o=dE(t,r),a=EU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return p2t(a,o,t)},p2t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var l1e=(t,{encoding:e})=>{let r=t1e();t.readable=i1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=a1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=u1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=$7.bind(void 0,t,e),t[Symbol.asyncIterator]=$7.bind(void 0,t,e,{})};var d1e=(t,e)=>{for(let[r,n]of m2t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},h2t=(async()=>{})().constructor.prototype,m2t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(h2t,t)]);var f1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=y2t(t,e,r),{subprocess:f,promise:p}=E2t({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=SU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),d1e(f,p),ou.set(f,{options:l,fileDescriptors:d}),f},y2t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),{file:a,commandArguments:c,options:u}=Y1(t,e,r),l=S2t(u),d=wMe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},S2t=({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}},E2t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=_2t(...J1(t,e,r))}catch(h){return SMe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;g2t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];kMe(c,a,u),$Me(c,r,u);let d={},f=su();c.kill=K$e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=KMe(c,r),l1e(c,r),gMe(c,r);let p=v2t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},v2t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,g]=await e1e({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((_,w)=>Il(_,e,w)),E=Il(m,e,"all"),S=b2t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return gE(S,n,e)},b2t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?_x({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof au,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):iU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var TU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,w2t(n,t[n],i)]));return{...t,...r}},w2t=(t,e,r)=>T2t.has(t)&&Qr(e)&&Qr(r)?{...e,...r}:r,T2t=new Set(["env",...lQ]);var Df=(t,e,r,n)=>{let i=(o,a,c)=>Df(o,a,r,c),s=(...o)=>A2t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},A2t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Qr(s))return i(t,TU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=R2t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?lMe(a,c,u):f1e(a,c,u,i)},R2t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=wNe(e)?TNe(e,r):[e,...r],[o,a,c]=y1(...s),u=TU(TU(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var p1e=({file:t,commandArguments:e})=>m1e(t,e),h1e=({file:t,commandArguments:e})=>({...m1e(t,e),isSync:!0}),m1e=(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]=x2t(t);return{file:r,commandArguments:n}},x2t=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(O2t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},O2t=/ +/g;var g1e=(t,e,r)=>{t.sync=e(I2t,r),t.s=t.sync},_1e=({options:t})=>y1e(t),I2t=({options:t})=>({...y1e(t),isSync:!0}),y1e=t=>({options:{...P2t(t),...t}}),P2t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},S1e={preferLocal:!0};var E1e=Df(()=>({})),a4r=Df(()=>({isSync:!0})),v1e=Df(p1e),c4r=Df(h1e),u4r=Df(CDe),l4r=Df(_1e,{},S1e,g1e),{sendMessage:d4r,getOneMessage:f4r,getEachMessage:p4r,getCancelSignal:h4r}=_Me();import{Transform as C2t}from"stream";var k2t=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function N2t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...k2t])]}function $2t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function D2t(){let e=N2t().map(r=>process.env[r]).filter(r=>!(!r||$2t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ei(t){if(typeof t!="string")return t;let e=D2t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(L2t(n),"g");r=r.replace(i,"******")}),r}function L2t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Tx=class extends C2t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ei(i);n(null,s)}},AU=Symbol("maskedWrite");function b1e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[AU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stdout.write=r}if(!process.stderr.write[AU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stderr.write=r}}}var w1e=!1,T1e,D7=t=>{T1e??=t},A1e=t=>{w1e=!0,D7(t)},en=()=>w1e,Xo=()=>T1e,R1e=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Ax=null,x1e=t=>(Ax&&Ax.destroy(),Ax=new Qo({totalAllowedTime:t}),Ax),O1e=()=>Ax;var Qo=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&&en())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await vD({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{X.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var I1e={name:"@netlify/agent-runner-cli",type:"module",version:"2.13.0-code-diff-setup-reqs.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var j2t=U2t(import.meta.url),z2t=Pl.dirname(j2t),q2t=F2t(import.meta.url),EE=he("shell"),L7=new Set,P1e={preferLocal:!0},Ut=(t,e,r)=>{let[n,i]=B2t(e,r),s={...P1e,...i},o=E1e(t,n,s);k1e(o,s),D1e(o);let a=r?.idleTimeout;return a&&a>0&&$1e(o,a),o},C1e=(t,e)=>{let r={...P1e,...e},n=v1e(t,r);return k1e(n,r),D1e(n),e?.idleTimeout&&e.idleTimeout>0&&$1e(n,e.idleTimeout),n},B2t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},k1e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||uu.env.NETLIFY_LOCAL_QUIET==="true")return;if(uu.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Tx).pipe(uu.stdout),t.stderr?.pipe(new Tx).pipe(uu.stderr);return}t.stdout?.pipe(uu.stdout),t.stderr?.pipe(uu.stderr)},M7=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(uu.kill(-t.pid,e),EE.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return EE.error("Error killing process:",r),!1}},N1e=t=>M7(t,"SIGKILL"),$1e=(t,e)=>{let r=null,n=()=>{EE.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),M7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing idle process ${t.pid}`),N1e(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)},D1e=t=>{L7.add(t);let e=O1e();if(e){let r=e.onTimesUp(()=>{EE.log(`Global timer expired, killing process ${t.pid}`),M7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing process ${t.pid} after timeout`),N1e(t))},5e3)});t.on("exit",()=>{L7.delete(t),r()}),t.on("error",()=>{L7.delete(t),r()})}};function lu(t,e){if(!uu.env.NETLIFY_LOCAL_MODE)try{let i=q2t.resolve(I1e.name),s=Pl.dirname(i);for(;s!==Pl.dirname(s);){let o=Pl.dirname(s);if(Pl.basename(o)==="node_modules"){let a=Pl.join(o,".bin",e);if(RU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(uu.env.NODE_PATH){let i=Pl.join(uu.env.NODE_PATH,".bin",e);if(RU.existsSync(i))return i}let r=Pl.join(t,"node_modules",".bin",e);if(RU.existsSync(r))return r;let n=Pl.join(z2t,"..","node_modules",".bin",e);if(RU.existsSync(n))return n}import Oq from"process";import{fileURLToPath as sXt}from"url";import{createRequire as oXt}from"module";import AI from"path";import{readFileSync as aXt}from"fs";var V2t="__netlify__getTracer",H2t="__netlify__shutdownTracers",$t=(t,e)=>globalThis[V2t]?.(t,e),L1e=async()=>globalThis[H2t]?.();function Rx(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 JZt}from"timers/promises";Ue();import FHt from"process";Ue();var G2t=(t,e)=>{e.recordException(t),e.setStatus({code:qn.ERROR})};var Cl=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}=M1e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>U1e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=M1e(r,n,i),c=this._tracer.startSpan(e,s,o);return U1e(c,s,a)}};function M1e(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??lr.active(),{opts:n,ctx:i,fn:s}}function U1e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:G2t,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)}}Ue();var bE=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var F7=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=K1e(e),n._asyncAttributesPending=e.filter(([i,s])=>bE(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(bE(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=K1e(this._rawAttributes),this._schemaUrl=W2t(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,bE(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&me.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(bE(n)){me.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=K2t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function j7(t,e){return F7.FromAttributeList(Object.entries(t),e)}function K1e(t){return t.map(([e,r])=>bE(r)?[e,r.catch(n=>{me.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function W2t(t){if(typeof t=="string"||t===void 0)return t;me.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function K2t(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;me.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ue();var xx=class{emit(e){}enabled(){return!1}},Y1e=new xx;var Ox=Symbol.for("io.opentelemetry.js.api.logs"),wE=globalThis;function J1e(t,e,r){return n=>n===t?e:r}var z7=1;var q7=class{getLogger(e,r,n){return new xx}},IU=new q7;var PU=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):Y1e}};var Ix=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new PU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:IU}_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 CU=class t{constructor(){this._proxyLoggerProvider=new Ix}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return wE[Ox]?this.getLoggerProvider():(wE[Ox]=J1e(z7,e,IU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=wE[Ox])===null||e===void 0?void 0:e.call(wE,z7))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete wE[Ox],this._proxyLoggerProvider=new Ix}};var Z1e=CU.getInstance();function X1e(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 Q1e(t){t.forEach(e=>e.disable())}function B7(t){let e=t.tracerProvider||Wt.getTracerProvider(),r=t.meterProvider||xR.getMeterProvider(),n=t.loggerProvider||Z1e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return X1e(i,e,r,n),()=>{Q1e(i)}}Ue();var Y2t=zn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function eUe(t){return t.getValue(Y2t)===!0}var TE;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(TE||(TE={}));Ue();var V7="[_0-9a-z-*/]",J2t=`[a-z]${V7}{0,255}`,Z2t=`[a-z0-9]${V7}{0,240}@[a-z]${V7}{0,13}`,X2t=new RegExp(`^(?:${J2t}|${Z2t})$`),Q2t=/^[ -~]{0,255}[!-~]$/,eVt=/,|=/;function H7(t){return X2t.test(t)}function G7(t){return Q2t.test(t)&&!eVt.test(t)}var tVt=32,tUe=512,rUe=",",nUe="=",kU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!H7(e)||!G7(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>tUe)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=rUe+e),e=`${n[0]}${nUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(rUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(nUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!H7(a)||!G7(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>tUe)&&(r.set(a,c),n=u,r.size>=tVt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var NU="traceparent",$U="tracestate",rVt="00",nVt="(?!ff)[\\da-f]{2}",iVt="(?![0]{32})[\\da-f]{32}",sVt="(?![0]{16})[\\da-f]{16}",oVt="[\\da-f]{2}",aVt=new RegExp(`^\\s?(${nVt})-(${iVt})-(${sVt})-(${oVt})(-.*)?\\s?$`);function iUe(t){let e=aVt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Lf=class{inject(e,r,n){let i=Wt.getSpanContext(e);if(!i||eUe(e)||!ws(i))return;let s=`${rVt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||qr.NONE).toString(16)}`;n.set(r,NU,s),i.traceState&&n.set(r,$U,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,NU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=iUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,$U);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new kU(typeof c=="string"?c:void 0)}return Wt.setSpanContext(e,o)}fields(){return[NU,$U]}};var DU=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var Px=class{_isCalled=!1;_deferred=new DU;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var OF=En($ee(),1);Ue();var rze=t=>{throw TypeError(t)},Uee=(t,e,r)=>e.has(t)||rze("Cannot "+r),xF=(t,e,r)=>(Uee(t,e,"read from private field"),r?r.call(t):e.get(t)),Dee=(t,e,r)=>e.has(t)?rze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Qje=(t,e,r,n)=>(Uee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),UHt=(t,e,r)=>(Uee(t,e,"access private method"),r),eze="__netlify__getTracer",jHt="__netlify__shutdownTracers",zHt="__nfOTLPTrace",Yx,Jx,Mee,nze,qHt=class{constructor(){Dee(this,Mee),Dee(this,Yx),Dee(this,Jx),Qje(this,Yx,new Px(UHt(this,Mee,nze),this)),Qje(this,Jx,me.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(xF(this,Jx).debug(`export ${t.length.toString()} spans`),xF(this,Yx).isCalled){e({code:TE.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zHt,JSON.stringify(BHt(t))),e({code:TE.SUCCESS})}shutdown(){return xF(this,Yx).call()}};Yx=new WeakMap;Jx=new WeakMap;Mee=new WeakSet;nze=function(){return xF(this,Jx).debug("Shutting down"),Promise.resolve()};function BHt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:RF(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||qa.SERVER,startTimeUnixNano:Lee(e.startTime),endTimeUnixNano:Lee(e.endTime),attributes:RF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Lee(n.time),attributes:RF(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:RF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function RF(t){return Object.keys(t).map(e=>ize(e,t[e]))}function ize(t,e){return{key:t,value:sze(e)}}function sze(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(sze)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>ize(r,n))}}:{}}function Lee(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var tze={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},oze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,eze))return;let e=FHt.version.slice(1),r=j7({"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??[VHt()],i=new OF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Lf});let s=t.instrumentations??[];B7({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,eze,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Cl(Wt.getTracer(a,c)):new Cl(Wt.getTracer(tze.name,tze.version))}}),Object.defineProperty(globalThis,jHt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},VHt=()=>new OF.SimpleSpanProcessor(new qHt);Ue();var LE=En($ee(),1);Ue();import*as IF from"diagnostics_channel";var aze=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?qn.ERROR:qn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Cl?t:new Cl(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){IF.subscribe(t,e);let r=()=>IF.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:qa.CLIENT},lr.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:qn.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 Y6e=En(H6e(),1);Nse();var G6e=0;var KZt=3*1024*1024,YZt=t=>SI.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Rq=class{constructor(e,r=KZt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=YZt(c);i.length&&s+u>this.maxBytes&&(n.push(i),i=[],s=0),i.push(c),s+=u}i.length&&n.push(i);let o,a=c=>{if(c===n.length){r(o??{code:G6e});return}this.inner.export(n[c],u=>{u.code!==G6e&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var Lv=he("tracing"),W6e=8e3,ZZt=5e3,K6e=t=>t.length>W6e?`${t.slice(0,W6e)}\u2026`:t,bI={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},XZt=Math.ceil(bI.maxQueueSize/bI.maxExportBatchSize)+1,QZt=t=>new LE.BatchSpanProcessor(new Rq(new Y6e.OTLPTraceExporter({url:t,concurrencyLimit:XZt})),bI),yg=async(t=ZZt)=>{try{let e=Symbol("timed out");await Promise.race([L1e(),JZt(t,e)])===e&&Lv.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){Lv.warn("Failed to flush tracers on shutdown",e)}},J6e=async(t,e,r)=>{if(!$t()){let n=[new LE.SimpleSpanProcessor(new Dse),QZt(r.exporterUrl)];await oze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new aze({skipHeaders:!0})]})}return r.traceparent?(Ji.setGlobalPropagator(new Lf),Ji.extract(lr.active(),{traceparent:r.traceparent,isRemote:!0})):lr.active()};function hr(t,e,r){return Lv.log(`\u23F3 TRACE: ${e} starting...`),Rx(t,e,r)}var Dse=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(", ")}]`:"";Lv.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&Lv.log(` \u274C Error: ${e.status.message}`)}};function Lse(){return We().captureLlmContentEnabled}function Z6e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function xq(t,e,r){let n={role:t,parts:[{type:"text",content:Ei(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var eXt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]);function X6e(t,e,r,n){if(!t.length)return;let i=$t();if(!i)return;t.length>bI.maxQueueSize&&Lv.warn(`${t.length} step spans exceed the span queue of ${bI.maxQueueSize}; spans may be dropped`);let s=Lse(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let u=Math.min(n,r+c*o),l=Math.min(n,u+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&eXt.has(a.category)||a.category===ee.AgentMessage&&a.toolCallId!==void 0,f=d?"execute_tool":"chat",p=K6e(a.title||a.type||`step-${a.id??c}`),h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?K6e(a.message):void 0,y=i.startSpan(m,{startTime:u,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":Ei(p),"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&g?d?{"gen_ai.tool.call.result":Ei(g)}:{"gen_ai.output.messages":xq("assistant",g)}:{}}});d&&(a.toolCallId!==void 0&&y.setAttribute("gen_ai.tool.call.id",a.toolCallId),a.toolStatus!==void 0&&y.setAttribute("spark.step.tool_status",a.toolStatus),a.exitCode!==void 0&&y.setAttribute("spark.step.exit_code",a.exitCode),a.toolStatus==="error"&&(y.setAttribute("error.type","tool_error"),y.setStatus({code:qn.ERROR}))),y.end(l)})}import{readdir as tXt,rm as rXt}from"fs/promises";import{join as nXt}from"path";async function Q6e(t,e=[]){let n=(await tXt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>rXt(nXt(t,i),{recursive:!0,force:!0})))}var iXt=300,wI=t=>We().budgetCreditThresholds[t.mode]?.[t.runner]??iXt,TI=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Mse=t=>{let e=wI(t);if(!TI(t,e))return"default";let r=We();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},eWe=t=>{let e=Mse(t),r=wI(t);return{budget_eligible:TI(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var cXt=AI.dirname(sXt(import.meta.url)),tWe=oXt(import.meta.url),uXt=AI.resolve(cXt,"scripts/scaffold.js"),lXt="scripts/scaffold.js",dXt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,Use=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},fXt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),pXt=t=>{let e=Use(t);return e==="node"||e.endsWith("/node")},lo=t=>{if(typeof t!="string")return!1;let e=t.match(dXt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&fXt(Use(e[r]));)r+=1;if(r>=e.length||!pXt(e[r]))return!1;let n=e[r+1];return n?Use(n).includes(lXt):!1},Sg=he("create_stage"),Fse="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.",hXt=`${Fse}
|
|
597
|
+
if (condition) { yield value; }`)};import{Buffer as Yzt}from"buffer";import{StringDecoder as Jzt}from"string_decoder";var lU=(t,e,r)=>{if(r)return;if(t)return{transform:Zzt.bind(void 0,new TextEncoder)};let n=new Jzt(e);return{transform:Xzt.bind(void 0,n),final:Qzt.bind(void 0,n)}},Zzt=function*(t,e){Yzt.isBuffer(e)?yield Rl(e):typeof e=="string"?yield t.encode(e):yield e},Xzt=function*(t,e){yield xn(e)?t.write(e):e},Qzt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as KLe}from"util";var XQ=KLe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),dU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=tqt}=e[r];for await(let i of n(t))yield*dU(i,e,r+1)},YLe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*eqt(r,Number(e),t)},eqt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*dU(n,r,e+1)},JLe=KLe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),tqt=function*(t){yield t};var QQ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},ZLe=(t,e)=>[...e.flatMap(r=>[...Dm(r,t,0)]),...yx(t)],Dm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=nqt}=e[r];for(let i of n(t))yield*Dm(i,e,r+1)},yx=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*rqt(r,Number(e),t)},rqt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Dm(n,r,e+1)},nqt=function*(t){yield t};var e7=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=QLe(t,o,s),u=$m(e),l=$m(r),d=u?XQ.bind(void 0,dU,a):QQ.bind(void 0,Dm),f=u||l?XQ.bind(void 0,YLe,a):QQ.bind(void 0,yx),p=u||l?JLe.bind(void 0,a):void 0;return{stream:new iqt({writableObjectMode:n,writableHighWaterMark:XLe(n),readableObjectMode:i,readableHighWaterMark:XLe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},fU=(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=QLe(o,r,a);t=ZLe(c,t)}return t},QLe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:HLe(n,a)},lU(r,o,n),uU(r,s,n,c),{transform:t,final:e},{transform:GLe(i,a)},VLe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var eMe=(t,e)=>{for(let r of sqt(t))oqt(t,r,e)},sqt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),oqt=(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 ${$f[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>aqt(a,n));r.input=cx(o)},aqt=(t,e)=>{let r=fU(t,e,"utf8",!0);return cqt(r),cx(r)},cqt=t=>{let e=t.find(r=>typeof r!="string"&&!xn(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 fqt,appendFileSync as pqt}from"fs";var pU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&oE(r,n)&&!ro.has(e)&&uqt(n)&&(t.some(({type:i,value:s})=>i==="native"&&lqt.has(s))||t.every(({type:i})=>Zo.has(i))),uqt=t=>t===1||t===2,lqt=new Set(["pipe","overlapped"]),tMe=async(t,e,r,n)=>{for await(let i of t)dqt(e)||nMe(i,r,n)},rMe=(t,e,r)=>{for(let n of t)nMe(n,e,r)},dqt=t=>t._readableState.pipes.length>0,nMe=(t,e,r)=>{let n=x1(t);iu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var iMe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>hqt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},hqt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=sLe(t,s,d),p=Rl(f),{stdioItems:h,objectMode:m}=e[r],g=mqt([p],h,c,n),{serializedResult:y,finalResult:E=y}=gqt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});_qt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&yqt(y,h,i),S}catch(_){return n.error=_,S}},mqt=(t,e,r,n)=>{try{return fU(t,e,r,!1)}catch(i){return n.error=i,t}},gqt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:cx(t)};let o=SNe(t,r);return n[s]?{serializedResult:o,finalResult:ZQ(o,!i[s],e)}:{serializedResult:o}},_qt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!pU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=ZQ(t,!1,o);try{rMe(a,e,n)}catch(c){r.error??=c}},yqt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>aU.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?pqt(n,t):(r.add(s),fqt(n,t))}};var sMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Il(e,r,"all")]:Array.isArray(e)?[Il(t,r,"all"),...e]:xn(t)&&xn(e)?oQ([t,e]):`${t}${e}`};import{once as t7}from"events";var oMe=async(t,e)=>{let[r,n]=await Sqt(t);return e.isForcefullyTerminated??=!1,[r,n]},Sqt=async t=>{let[e,r]=await Promise.allSettled([t7(t,"spawn"),t7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?aMe(t):r.value},aMe=async t=>{try{return await t7(t,"exit")}catch{return aMe(t)}},cMe=async t=>{let[e,r]=await t;if(!Eqt(e,r)&&r7(e,r))throw new Ka;return[e,r]},Eqt=(t,e)=>t===void 0&&e===void 0,r7=(t,e)=>t!==0||e!==null;var uMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=vqt(t,e,r),o=s?.code==="ETIMEDOUT",a=iLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},vqt=(t,e,r)=>t!==void 0?t:r7(e,r)?new Ka:void 0;var lMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=wqt(t,e,r),d=Rqt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return gE(d,c,u)},wqt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),a=Tqt(r),{file:c,commandArguments:u,options:l}=Y1(t,e,a);Aqt(l);let d=jLe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},Tqt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Aqt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&hU("ipcInput"),t&&hU("ipc: true"),r&&hU("detached: true"),n&&hU("cancelSignal")},hU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Rqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=xqt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=uMe(c,r),{output:h,error:m=u}=iMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,S)=>Il(E,r,S)),y=Il(sMe(h,r),r,"all");return Iqt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},xqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{eMe(s,r);let a=Oqt(r);return bqt(...J1(t,e,a))}catch(a){return mE({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Oqt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:nU(e)}),Iqt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?iU({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):_x({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as g2t}from"events";import{spawn as _2t}from"child_process";import mMe from"process";import{once as n7,on as Pqt}from"events";var dMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(uE({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),Cqt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Cqt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{F1(e,i);let s=Nf(t,e,r),o=new AbortController;try{return await Promise.race([kqt(s,n,o),Nqt(s,r,o),$qt(s,r,o)])}catch(a){throw lE(t),a}finally{o.abort(),j1(e,i)}},kqt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await n7(t,"message",{signal:r});return n}for await(let[n]of Pqt(t,"message",{signal:r}))if(e(n))return n},Nqt=async(t,e,{signal:r})=>{await n7(t,"disconnect",{signal:r}),Z$e(e)},$qt=async(t,e,{signal:r})=>{let[n]=await n7(t,"strict:error",{signal:r});throw L1(n,e)};import{once as pMe,on as Dqt}from"events";var hMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>i7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),i7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{uE({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),F1(e,s);let o=Nf(t,e,r),a=new AbortController,c={};return Lqt(t,o,a),Mqt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Uqt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Lqt=async(t,e,r)=>{try{await pMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Mqt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await pMe(t,"strict:error",{signal:r.signal});n.error=L1(i,e),r.abort()}catch{}},Uqt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Dqt(r,"message",{signal:s.signal}))fMe(o),yield c}catch{fMe(o)}finally{s.abort(),j1(e,a),n||lE(t),i&&await t}},fMe=({error:t})=>{if(t)throw t};var gMe=(t,{ipc:e})=>{Object.assign(t,yMe(t,!1,e))},_Me=()=>{let t=mMe,e=!0,r=mMe.channel!==void 0;return{...yMe(t,e,r),getCancelSignal:TDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},yMe=(t,e,r)=>({sendMessage:W1.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:dMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:hMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Fqt}from"child_process";import{PassThrough as jqt,Readable as zqt,Writable as qqt,Duplex as Bqt}from"stream";var SMe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{KQ(n);let a=new Fqt;Vqt(a,n),Object.assign(a,{readable:Hqt,writable:Gqt,duplex:Wqt});let c=mE({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Kqt(c,o,i);return{subprocess:a,promise:u}},Vqt=(t,e)=>{let r=Sx(),n=Sx(),i=Sx(),s=Array.from({length:e.length-3},Sx),o=Sx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Sx=()=>{let t=new jqt;return t.end(),t},Hqt=()=>new zqt({read(){}}),Gqt=()=>new qqt({write(){}}),Wqt=()=>new Bqt({read(){},write(){}}),Kqt=async(t,e,r)=>gE(t,e,r);import{createReadStream as EMe,createWriteStream as vMe}from"fs";import{Buffer as Yqt}from"buffer";import{Readable as Ex,Writable as Jqt,Duplex as Zqt}from"stream";var wMe=(t,e)=>cU(Xqt,t,e,!1),vx=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$f[t]}.`)},bMe={fileNumber:vx,generator:e7,asyncGenerator:e7,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Zqt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Xqt={input:{...bMe,fileUrl:({value:t})=>({stream:EMe(t)}),filePath:({value:{file:t}})=>({stream:EMe(t)}),webStream:({value:t})=>({stream:Ex.fromWeb(t)}),iterable:({value:t})=>({stream:Ex.from(t)}),asyncIterable:({value:t})=>({stream:Ex.from(t)}),string:({value:t})=>({stream:Ex.from(t)}),uint8Array:({value:t})=>({stream:Ex.from(Yqt.from(t))})},output:{...bMe,fileUrl:({value:t})=>({stream:vMe(t)}),filePath:({value:{file:t,append:e}})=>({stream:vMe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Jqt.fromWeb(t)}),iterable:vx,asyncIterable:vx,string:vx,uint8Array:vx}};import{on as Qqt,once as TMe}from"events";import{PassThrough as eBt,getDefaultHighWaterMark as tBt}from"stream";import{finished as xMe}from"stream/promises";function Lm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)o7(i);let e=t.some(({readableObjectMode:i})=>i),r=rBt(t,e),n=new s7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var rBt=(t,e)=>{if(t.length===0)return tBt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},s7=class extends eBt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(o7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=nBt(this,this.#e,this.#s);let r=oBt({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(o7(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)}},nBt=async(t,e,r)=>{mU(t,AMe);let n=new AbortController;try{await Promise.race([iBt(t,n),sBt(t,e,r,n)])}finally{n.abort(),mU(t,-AMe)}},iBt=async(t,{signal:e})=>{try{await xMe(t,{signal:e,cleanup:!0})}catch(r){throw OMe(t,r),r}},sBt=async(t,e,r,{signal:n})=>{for await(let[i]of Qqt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},o7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},oBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{mU(t,RMe);let a=new AbortController;try{await Promise.race([aBt(s,e,a),cBt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),uBt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),mU(t,-RMe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?a7(t):lBt(t))},aBt=async(t,e,{signal:r})=>{try{await t,r.aborted||a7(e)}catch(n){r.aborted||OMe(e,n)}},cBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await xMe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;IMe(o)?i.add(e):PMe(t,o)}},uBt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await TMe(t,i,{signal:s}),!t.readable)return TMe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},lBt=t=>{t.writable&&t.end()},OMe=(t,e)=>{IMe(e)?a7(t):PMe(t,e)},IMe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",a7=t=>{(t.readable||t.writable)&&t.destroy()},PMe=(t,e)=>{t.destroyed||(t.once("error",dBt),t.destroy(e))},dBt=()=>{},mU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},AMe=2,RMe=1;import{finished as CMe}from"stream/promises";var yE=(t,e)=>{t.pipe(e),fBt(t,e),pBt(t,e)},fBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await CMe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}c7(e)}},c7=t=>{t.writable&&t.end()},pBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await CMe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}u7(t)}},u7=t=>{t.readable&&t.destroy()};var kMe=(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})=>Zo.has(c)))hBt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Zo.has(c)))gBt({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]:Lm(s);yE(o,i)}},hBt=(t,e,r,n)=>{r==="output"?yE(t.stdio[n],e):yE(e,t.stdio[n]);let i=mBt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},mBt=["stdin","stdout","stderr"],gBt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;_Bt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},_Bt=(t,{signal:e})=>{Wa(t)&&km(t,yBt,e)},yBt=2;import{addAbortListener as vBt}from"events";var Mm=[];Mm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Mm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Mm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var gU=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",l7=Symbol.for("signal-exit emitter"),d7=globalThis,SBt=Object.defineProperty.bind(Object),f7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(d7[l7])return d7[l7];SBt(d7,l7,{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}},_U=class{},EBt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),p7=class extends _U{onExit(){return()=>{}}load(){}unload(){}},h7=class extends _U{#e=m7.platform==="win32"?"SIGINT":"SIGHUP";#r=new f7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Mm)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(!gU(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 Mm)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,Mm.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 gU(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"&&gU(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)}},m7=globalThis.process,{onExit:NMe,load:_2r,unload:y2r}=EBt(gU(m7)?new h7(m7):new p7);var $Me=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=NMe(()=>{t.kill()});vBt(n,()=>{i()})};var LMe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=O1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=bBt(r,n,i),{sourceStream:d,sourceError:f}=TBt(t,u),{options:p,fileDescriptors:h}=ou.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},bBt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=wBt(t,e,...r),a=U1(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},wBt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(DMe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||iQ(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]=y1(r,...n);return{destination:e(DMe)(i,s,o),pipeOptions:o}}if(ou.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}`)},DMe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),TBt=(t,e)=>{try{return{sourceStream:dE(t,e)}}catch(r){return{sourceError:r}}};var UMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=ABt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw g7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},ABt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return u7(t),n;if(e!==void 0)return c7(r),e},g7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>mE({error:t,command:MMe,escapedCommand:MMe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),MMe="source.pipe(destination)";var FMe=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 RBt}from"stream/promises";var jMe=(t,e,r)=>{let n=yU.has(e)?OBt(t,e):xBt(t,e);return km(t,PBt,r.signal),km(e,CBt,r.signal),IBt(e),n},xBt=(t,e)=>{let r=Lm([t]);return yE(r,e),yU.set(e,r),r},OBt=(t,e)=>{let r=yU.get(e);return r.add(t),r},IBt=async t=>{try{await RBt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}yU.delete(t)},yU=new WeakMap,PBt=2,CBt=1;import{aborted as kBt}from"util";var zMe=(t,e)=>t===void 0?[]:[NBt(t,e)],NBt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await kBt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw g7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var SU=(t,...e)=>{if(Qr(e[0]))return SU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=LMe(t,...e),i=$Bt({...n,destination:r});return i.pipe=SU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},$Bt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=DBt(t,i);UMe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=jMe(e,s,d);return await Promise.race([FMe(l),...zMe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},DBt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as qBt}from"timers/promises";import{on as LBt}from"events";import{getDefaultHighWaterMark as MBt}from"stream";var EU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return UBt(e,o),BMe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},UBt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},_7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;FBt(e,o,t);let a=t.readableObjectMode&&!s;return BMe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},FBt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},BMe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=LBt(t,"data",{signal:e.signal,highWaterMark:qMe,highWatermark:qMe});return jBt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},y7=MBt(!0),qMe=y7,jBt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=zBt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Dm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*yx(a)}},zBt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[lU(t,r,!e),uU(t,i,!n,{})].filter(Boolean);var VMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=BBt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([VBt(t),d]);return}let f=YQ(c,r),p=_7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([HBt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},BBt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!pU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=_7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await tMe(a,t,r,s)},VBt=async t=>{await qBt(),t.readableFlowing===null&&t.resume()},HBt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await eU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await tU(r,{maxBuffer:s})):await hE(r,{maxBuffer:s})}catch(a){return HMe(tLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},S7=async t=>{try{return await t}catch(e){return HMe(e)}},HMe=({bufferedData:t})=>_Ne(t)?new Uint8Array(t):t;import{finished as GBt}from"stream/promises";var bx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=WBt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],GBt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||JBt(a,e,r,n)}finally{o.abort()}},WBt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&KBt(t,r,n),n},KBt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{YBt(e,r),n.call(t,...i)}},YBt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},JBt=(t,e,r,n)=>{if(!ZBt(t,e,r,n))throw t},ZBt=(t,e,r,n=!0)=>r.propagating?GMe(t)||vU(t):(r.propagating=!0,E7(r,e)===n?GMe(t):vU(t)),E7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",vU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",GMe=t=>t?.code==="EPIPE";var WMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>v7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),v7=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=bx(t,e,u);if(E7(u,e)){await l;return}let[d]=await Promise.all([VMe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var KMe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Lm([t,e].filter(Boolean)):void 0,YMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>v7({...XBt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:QBt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),XBt=({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}},QBt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as e2t}from"events";var JMe=t=>oE(t,"ipc"),ZMe=(t,e)=>{let r=x1(t);iu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var XMe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=JMe(s),a=xl(e,"ipc"),c=xl(r,"ipc");for await(let u of i7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(rLe(t,i,c),i.push(u)),o&&ZMe(u,s);return i},QMe=async(t,e)=>(await Promise.allSettled([t]),e);var e1e=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:y})=>{let E=oMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=WMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=YMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=XMe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=t2t(m,t,S),I=r2t(h,S);try{return await Promise.race([Promise.all([{},cMe(E),Promise.all(_),w,R,$De(t,d),...T,...I]),g,n2t(t,y),...IDe(t,s,f,y),...J$e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...xDe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(_.map(O=>S7(O))),S7(w),QMe(R,b),Promise.allSettled(T),Promise.allSettled(I)])}},t2t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:bx(n,i,r)),r2t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ja(s,{checkOpen:!1})&&!Wa(s)).map(({type:i,value:s,stream:o=s})=>bx(o,n,e,{isSameDirection:Zo.has(i),stopOnExit:i==="native"}))),n2t=async(t,{signal:e})=>{let[r]=await e2t(t,"error",{signal:e});throw r};var t1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),wx=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=su();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},SE=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 i2t}from"stream";import{callbackify as s2t}from"util";import{finished as r1e}from"stream/promises";var b7=async t=>{if(t!==void 0)try{await w7(t)}catch{}},n1e=async t=>{if(t!==void 0)try{await T7(t)}catch{}},w7=async t=>{await r1e(t,{cleanup:!0,readable:!1,writable:!0})},T7=async t=>{await r1e(t,{cleanup:!0,readable:!0,writable:!1})},bU=async(t,e)=>{if(await t,e)throw e},wU=(t,e,r)=>{r&&!vU(r)?t.destroy(r):e&&t.destroy()};var i1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ro.has(r),{subprocessStdout:a,waitReadableDestroy:c}=A7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=R7(a,o),{read:f,onStdoutDataDone:p}=x7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new i2t({read:f,destroy:s2t(I7.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return O7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},A7=(t,e,r)=>{let n=dE(t,e),i=wx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},R7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:y7},x7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=su(),o=EU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){o2t(this,o,s)},onStdoutDataDone:s}},o2t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},O7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await T7(t),await n,await b7(i),await e,r.readable&&r.push(null)}catch(s){await b7(i),s1e(r,s)}},I7=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await SE(r,e)&&(s1e(t,n),await bU(e,n))},s1e=(t,e)=>{wU(t,t.readable,e)};import{Writable as a2t}from"stream";import{callbackify as o1e}from"util";var a1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=P7(t,r,e),o=new a2t({...C7(n,t,i),destroy:o1e(N7.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return k7(n,o),o},P7=(t,e,r)=>{let n=U1(t,e),i=wx(r,n,"writableFinal"),s=wx(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},C7=(t,e,r)=>({write:c2t.bind(void 0,t),final:o1e(u2t.bind(void 0,t,e,r))}),c2t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},u2t=async(t,e,r)=>{await SE(r,e)&&(t.writable&&t.end(),await e)},k7=async(t,e,r)=>{try{await w7(t),e.writable&&e.end()}catch(n){await n1e(r),c1e(e,n)}},N7=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await SE(r,e),await SE(n,e)&&(c1e(t,i),await bU(e,i))},c1e=(t,e)=>{wU(t,t.writable,e)};import{Duplex as l2t}from"stream";import{callbackify as d2t}from"util";var u1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ro.has(r),{subprocessStdout:c,waitReadableDestroy:u}=A7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=P7(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=R7(c,a),{read:g,onStdoutDataDone:y}=x7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new l2t({read:g,...C7(l,t,d),destroy:d2t(f2t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return O7({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:l}),k7(l,E,c),E},f2t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([I7({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),N7({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var $7=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ro.has(e),o=dE(t,r),a=EU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return p2t(a,o,t)},p2t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var l1e=(t,{encoding:e})=>{let r=t1e();t.readable=i1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=a1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=u1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=$7.bind(void 0,t,e),t[Symbol.asyncIterator]=$7.bind(void 0,t,e,{})};var d1e=(t,e)=>{for(let[r,n]of m2t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},h2t=(async()=>{})().constructor.prototype,m2t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(h2t,t)]);var f1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=y2t(t,e,r),{subprocess:f,promise:p}=E2t({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=SU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),d1e(f,p),ou.set(f,{options:l,fileDescriptors:d}),f},y2t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),{file:a,commandArguments:c,options:u}=Y1(t,e,r),l=S2t(u),d=wMe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},S2t=({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}},E2t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=_2t(...J1(t,e,r))}catch(h){return SMe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;g2t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];kMe(c,a,u),$Me(c,r,u);let d={},f=su();c.kill=K$e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=KMe(c,r),l1e(c,r),gMe(c,r);let p=v2t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},v2t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,g]=await e1e({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((_,w)=>Il(_,e,w)),E=Il(m,e,"all"),S=b2t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return gE(S,n,e)},b2t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?_x({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof au,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):iU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var TU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,w2t(n,t[n],i)]));return{...t,...r}},w2t=(t,e,r)=>T2t.has(t)&&Qr(e)&&Qr(r)?{...e,...r}:r,T2t=new Set(["env",...lQ]);var Df=(t,e,r,n)=>{let i=(o,a,c)=>Df(o,a,r,c),s=(...o)=>A2t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},A2t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Qr(s))return i(t,TU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=R2t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?lMe(a,c,u):f1e(a,c,u,i)},R2t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=wNe(e)?TNe(e,r):[e,...r],[o,a,c]=y1(...s),u=TU(TU(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var p1e=({file:t,commandArguments:e})=>m1e(t,e),h1e=({file:t,commandArguments:e})=>({...m1e(t,e),isSync:!0}),m1e=(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]=x2t(t);return{file:r,commandArguments:n}},x2t=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(O2t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},O2t=/ +/g;var g1e=(t,e,r)=>{t.sync=e(I2t,r),t.s=t.sync},_1e=({options:t})=>y1e(t),I2t=({options:t})=>({...y1e(t),isSync:!0}),y1e=t=>({options:{...P2t(t),...t}}),P2t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},S1e={preferLocal:!0};var E1e=Df(()=>({})),a4r=Df(()=>({isSync:!0})),v1e=Df(p1e),c4r=Df(h1e),u4r=Df(CDe),l4r=Df(_1e,{},S1e,g1e),{sendMessage:d4r,getOneMessage:f4r,getEachMessage:p4r,getCancelSignal:h4r}=_Me();import{Transform as C2t}from"stream";var k2t=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function N2t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...k2t])]}function $2t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function D2t(){let e=N2t().map(r=>process.env[r]).filter(r=>!(!r||$2t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ei(t){if(typeof t!="string")return t;let e=D2t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(L2t(n),"g");r=r.replace(i,"******")}),r}function L2t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Tx=class extends C2t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ei(i);n(null,s)}},AU=Symbol("maskedWrite");function b1e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[AU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stdout.write=r}if(!process.stderr.write[AU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stderr.write=r}}}var w1e=!1,T1e,D7=t=>{T1e??=t},A1e=t=>{w1e=!0,D7(t)},en=()=>w1e,Xo=()=>T1e,R1e=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Ax=null,x1e=t=>(Ax&&Ax.destroy(),Ax=new Qo({totalAllowedTime:t}),Ax),O1e=()=>Ax;var Qo=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&&en())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await vD({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{X.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var I1e={name:"@netlify/agent-runner-cli",type:"module",version:"2.13.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var j2t=U2t(import.meta.url),z2t=Pl.dirname(j2t),q2t=F2t(import.meta.url),EE=he("shell"),L7=new Set,P1e={preferLocal:!0},Ut=(t,e,r)=>{let[n,i]=B2t(e,r),s={...P1e,...i},o=E1e(t,n,s);k1e(o,s),D1e(o);let a=r?.idleTimeout;return a&&a>0&&$1e(o,a),o},C1e=(t,e)=>{let r={...P1e,...e},n=v1e(t,r);return k1e(n,r),D1e(n),e?.idleTimeout&&e.idleTimeout>0&&$1e(n,e.idleTimeout),n},B2t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},k1e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||uu.env.NETLIFY_LOCAL_QUIET==="true")return;if(uu.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Tx).pipe(uu.stdout),t.stderr?.pipe(new Tx).pipe(uu.stderr);return}t.stdout?.pipe(uu.stdout),t.stderr?.pipe(uu.stderr)},M7=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(uu.kill(-t.pid,e),EE.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return EE.error("Error killing process:",r),!1}},N1e=t=>M7(t,"SIGKILL"),$1e=(t,e)=>{let r=null,n=()=>{EE.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),M7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing idle process ${t.pid}`),N1e(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)},D1e=t=>{L7.add(t);let e=O1e();if(e){let r=e.onTimesUp(()=>{EE.log(`Global timer expired, killing process ${t.pid}`),M7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing process ${t.pid} after timeout`),N1e(t))},5e3)});t.on("exit",()=>{L7.delete(t),r()}),t.on("error",()=>{L7.delete(t),r()})}};function lu(t,e){if(!uu.env.NETLIFY_LOCAL_MODE)try{let i=q2t.resolve(I1e.name),s=Pl.dirname(i);for(;s!==Pl.dirname(s);){let o=Pl.dirname(s);if(Pl.basename(o)==="node_modules"){let a=Pl.join(o,".bin",e);if(RU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(uu.env.NODE_PATH){let i=Pl.join(uu.env.NODE_PATH,".bin",e);if(RU.existsSync(i))return i}let r=Pl.join(t,"node_modules",".bin",e);if(RU.existsSync(r))return r;let n=Pl.join(z2t,"..","node_modules",".bin",e);if(RU.existsSync(n))return n}import Oq from"process";import{fileURLToPath as sXt}from"url";import{createRequire as oXt}from"module";import AI from"path";import{readFileSync as aXt}from"fs";var V2t="__netlify__getTracer",H2t="__netlify__shutdownTracers",$t=(t,e)=>globalThis[V2t]?.(t,e),L1e=async()=>globalThis[H2t]?.();function Rx(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 JZt}from"timers/promises";Ue();import FHt from"process";Ue();var G2t=(t,e)=>{e.recordException(t),e.setStatus({code:qn.ERROR})};var Cl=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}=M1e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>U1e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=M1e(r,n,i),c=this._tracer.startSpan(e,s,o);return U1e(c,s,a)}};function M1e(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??lr.active(),{opts:n,ctx:i,fn:s}}function U1e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:G2t,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)}}Ue();var bE=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var F7=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=K1e(e),n._asyncAttributesPending=e.filter(([i,s])=>bE(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(bE(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=K1e(this._rawAttributes),this._schemaUrl=W2t(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,bE(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&me.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(bE(n)){me.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=K2t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function j7(t,e){return F7.FromAttributeList(Object.entries(t),e)}function K1e(t){return t.map(([e,r])=>bE(r)?[e,r.catch(n=>{me.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function W2t(t){if(typeof t=="string"||t===void 0)return t;me.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function K2t(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;me.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ue();var xx=class{emit(e){}enabled(){return!1}},Y1e=new xx;var Ox=Symbol.for("io.opentelemetry.js.api.logs"),wE=globalThis;function J1e(t,e,r){return n=>n===t?e:r}var z7=1;var q7=class{getLogger(e,r,n){return new xx}},IU=new q7;var PU=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):Y1e}};var Ix=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new PU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:IU}_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 CU=class t{constructor(){this._proxyLoggerProvider=new Ix}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return wE[Ox]?this.getLoggerProvider():(wE[Ox]=J1e(z7,e,IU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=wE[Ox])===null||e===void 0?void 0:e.call(wE,z7))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete wE[Ox],this._proxyLoggerProvider=new Ix}};var Z1e=CU.getInstance();function X1e(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 Q1e(t){t.forEach(e=>e.disable())}function B7(t){let e=t.tracerProvider||Wt.getTracerProvider(),r=t.meterProvider||xR.getMeterProvider(),n=t.loggerProvider||Z1e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return X1e(i,e,r,n),()=>{Q1e(i)}}Ue();var Y2t=zn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function eUe(t){return t.getValue(Y2t)===!0}var TE;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(TE||(TE={}));Ue();var V7="[_0-9a-z-*/]",J2t=`[a-z]${V7}{0,255}`,Z2t=`[a-z0-9]${V7}{0,240}@[a-z]${V7}{0,13}`,X2t=new RegExp(`^(?:${J2t}|${Z2t})$`),Q2t=/^[ -~]{0,255}[!-~]$/,eVt=/,|=/;function H7(t){return X2t.test(t)}function G7(t){return Q2t.test(t)&&!eVt.test(t)}var tVt=32,tUe=512,rUe=",",nUe="=",kU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!H7(e)||!G7(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>tUe)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=rUe+e),e=`${n[0]}${nUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(rUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(nUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!H7(a)||!G7(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>tUe)&&(r.set(a,c),n=u,r.size>=tVt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var NU="traceparent",$U="tracestate",rVt="00",nVt="(?!ff)[\\da-f]{2}",iVt="(?![0]{32})[\\da-f]{32}",sVt="(?![0]{16})[\\da-f]{16}",oVt="[\\da-f]{2}",aVt=new RegExp(`^\\s?(${nVt})-(${iVt})-(${sVt})-(${oVt})(-.*)?\\s?$`);function iUe(t){let e=aVt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Lf=class{inject(e,r,n){let i=Wt.getSpanContext(e);if(!i||eUe(e)||!ws(i))return;let s=`${rVt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||qr.NONE).toString(16)}`;n.set(r,NU,s),i.traceState&&n.set(r,$U,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,NU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=iUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,$U);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new kU(typeof c=="string"?c:void 0)}return Wt.setSpanContext(e,o)}fields(){return[NU,$U]}};var DU=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var Px=class{_isCalled=!1;_deferred=new DU;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var OF=En($ee(),1);Ue();var rze=t=>{throw TypeError(t)},Uee=(t,e,r)=>e.has(t)||rze("Cannot "+r),xF=(t,e,r)=>(Uee(t,e,"read from private field"),r?r.call(t):e.get(t)),Dee=(t,e,r)=>e.has(t)?rze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Qje=(t,e,r,n)=>(Uee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),UHt=(t,e,r)=>(Uee(t,e,"access private method"),r),eze="__netlify__getTracer",jHt="__netlify__shutdownTracers",zHt="__nfOTLPTrace",Yx,Jx,Mee,nze,qHt=class{constructor(){Dee(this,Mee),Dee(this,Yx),Dee(this,Jx),Qje(this,Yx,new Px(UHt(this,Mee,nze),this)),Qje(this,Jx,me.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(xF(this,Jx).debug(`export ${t.length.toString()} spans`),xF(this,Yx).isCalled){e({code:TE.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zHt,JSON.stringify(BHt(t))),e({code:TE.SUCCESS})}shutdown(){return xF(this,Yx).call()}};Yx=new WeakMap;Jx=new WeakMap;Mee=new WeakSet;nze=function(){return xF(this,Jx).debug("Shutting down"),Promise.resolve()};function BHt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:RF(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||qa.SERVER,startTimeUnixNano:Lee(e.startTime),endTimeUnixNano:Lee(e.endTime),attributes:RF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Lee(n.time),attributes:RF(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:RF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function RF(t){return Object.keys(t).map(e=>ize(e,t[e]))}function ize(t,e){return{key:t,value:sze(e)}}function sze(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(sze)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>ize(r,n))}}:{}}function Lee(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var tze={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},oze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,eze))return;let e=FHt.version.slice(1),r=j7({"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??[VHt()],i=new OF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Lf});let s=t.instrumentations??[];B7({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,eze,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Cl(Wt.getTracer(a,c)):new Cl(Wt.getTracer(tze.name,tze.version))}}),Object.defineProperty(globalThis,jHt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},VHt=()=>new OF.SimpleSpanProcessor(new qHt);Ue();var LE=En($ee(),1);Ue();import*as IF from"diagnostics_channel";var aze=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?qn.ERROR:qn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Cl?t:new Cl(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){IF.subscribe(t,e);let r=()=>IF.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:qa.CLIENT},lr.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:qn.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 Y6e=En(H6e(),1);Nse();var G6e=0;var KZt=3*1024*1024,YZt=t=>SI.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Rq=class{constructor(e,r=KZt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=YZt(c);i.length&&s+u>this.maxBytes&&(n.push(i),i=[],s=0),i.push(c),s+=u}i.length&&n.push(i);let o,a=c=>{if(c===n.length){r(o??{code:G6e});return}this.inner.export(n[c],u=>{u.code!==G6e&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var Lv=he("tracing"),W6e=8e3,ZZt=5e3,K6e=t=>t.length>W6e?`${t.slice(0,W6e)}\u2026`:t,bI={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},XZt=Math.ceil(bI.maxQueueSize/bI.maxExportBatchSize)+1,QZt=t=>new LE.BatchSpanProcessor(new Rq(new Y6e.OTLPTraceExporter({url:t,concurrencyLimit:XZt})),bI),yg=async(t=ZZt)=>{try{let e=Symbol("timed out");await Promise.race([L1e(),JZt(t,e)])===e&&Lv.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){Lv.warn("Failed to flush tracers on shutdown",e)}},J6e=async(t,e,r)=>{if(!$t()){let n=[new LE.SimpleSpanProcessor(new Dse),QZt(r.exporterUrl)];await oze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new aze({skipHeaders:!0})]})}return r.traceparent?(Ji.setGlobalPropagator(new Lf),Ji.extract(lr.active(),{traceparent:r.traceparent,isRemote:!0})):lr.active()};function hr(t,e,r){return Lv.log(`\u23F3 TRACE: ${e} starting...`),Rx(t,e,r)}var Dse=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(", ")}]`:"";Lv.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&Lv.log(` \u274C Error: ${e.status.message}`)}};function Lse(){return We().captureLlmContentEnabled}function Z6e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function xq(t,e,r){let n={role:t,parts:[{type:"text",content:Ei(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var eXt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]);function X6e(t,e,r,n){if(!t.length)return;let i=$t();if(!i)return;t.length>bI.maxQueueSize&&Lv.warn(`${t.length} step spans exceed the span queue of ${bI.maxQueueSize}; spans may be dropped`);let s=Lse(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let u=Math.min(n,r+c*o),l=Math.min(n,u+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&eXt.has(a.category)||a.category===ee.AgentMessage&&a.toolCallId!==void 0,f=d?"execute_tool":"chat",p=K6e(a.title||a.type||`step-${a.id??c}`),h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?K6e(a.message):void 0,y=i.startSpan(m,{startTime:u,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":Ei(p),"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&g?d?{"gen_ai.tool.call.result":Ei(g)}:{"gen_ai.output.messages":xq("assistant",g)}:{}}});d&&(a.toolCallId!==void 0&&y.setAttribute("gen_ai.tool.call.id",a.toolCallId),a.toolStatus!==void 0&&y.setAttribute("spark.step.tool_status",a.toolStatus),a.exitCode!==void 0&&y.setAttribute("spark.step.exit_code",a.exitCode),a.toolStatus==="error"&&(y.setAttribute("error.type","tool_error"),y.setStatus({code:qn.ERROR}))),y.end(l)})}import{readdir as tXt,rm as rXt}from"fs/promises";import{join as nXt}from"path";async function Q6e(t,e=[]){let n=(await tXt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>rXt(nXt(t,i),{recursive:!0,force:!0})))}var iXt=300,wI=t=>We().budgetCreditThresholds[t.mode]?.[t.runner]??iXt,TI=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Mse=t=>{let e=wI(t);if(!TI(t,e))return"default";let r=We();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},eWe=t=>{let e=Mse(t),r=wI(t);return{budget_eligible:TI(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var cXt=AI.dirname(sXt(import.meta.url)),tWe=oXt(import.meta.url),uXt=AI.resolve(cXt,"scripts/scaffold.js"),lXt="scripts/scaffold.js",dXt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,Use=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},fXt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),pXt=t=>{let e=Use(t);return e==="node"||e.endsWith("/node")},lo=t=>{if(typeof t!="string")return!1;let e=t.match(dXt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&fXt(Use(e[r]));)r+=1;if(r>=e.length||!pXt(e[r]))return!1;let n=e[r+1];return n?Use(n).includes(lXt):!1},Sg=he("create_stage"),Fse="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.",hXt=`${Fse}
|
|
598
598
|
|
|
599
599
|
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.`,mXt=`${Fse}
|
|
600
600
|
|
package/dist/index.js
CHANGED
|
@@ -382,7 +382,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
382
382
|
`,LF:`
|
|
383
383
|
`,concatBytes:R5},Uht=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Fht={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Uht};import{Buffer as zht}from"buffer";var ZRe=(t,e)=>t?void 0:jht.bind(void 0,e),jht=function*(t,e){if(typeof e!="string"&&!Wr(e)&&!zht.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},XRe=(t,e)=>t?Bht.bind(void 0,e):qht.bind(void 0,e),Bht=function*(t,e){JRe(t,e),yield e},qht=function*(t,e){if(JRe(t,e),typeof e!="string"&&!Wr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},JRe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
384
384
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
385
|
-
if (condition) { yield value; }`)};import{Buffer as Vht}from"buffer";import{StringDecoder as Ght}from"string_decoder";var TM=(t,e,r)=>{if(r)return;if(t)return{transform:Hht.bind(void 0,new TextEncoder)};let n=new Ght(e);return{transform:Wht.bind(void 0,n),final:Kht.bind(void 0,n)}},Hht=function*(t,e){Vht.isBuffer(e)?yield gu(e):typeof e=="string"?yield t.encode(e):yield e},Wht=function*(t,e){yield Wr(e)?t.write(e):e},Kht=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as QRe}from"util";var I5=QRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),AM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Zht}=e[r];for await(let i of n(t))yield*AM(i,e,r+1)},exe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Yht(r,Number(e),t)},Yht=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*AM(n,r,e+1)},txe=QRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Zht=function*(t){yield t};var O5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},rxe=(t,e)=>[...e.flatMap(r=>[...Xp(r,t,0)]),...eR(t)],Xp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Jht}=e[r];for(let i of n(t))yield*Xp(i,e,r+1)},eR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Xht(r,Number(e),t)},Xht=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Xp(n,r,e+1)},Jht=function*(t){yield t};var P5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=ixe(t,s,o),u=Zp(e),l=Zp(r),d=u?I5.bind(void 0,AM,a):O5.bind(void 0,Xp),f=u||l?I5.bind(void 0,exe,a):O5.bind(void 0,eR),p=u||l?txe.bind(void 0,a):void 0;return{stream:new Qht({writableObjectMode:n,writableHighWaterMark:nxe(n),readableObjectMode:i,readableHighWaterMark:nxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},RM=(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=ixe(s,r,a);t=rxe(c,t)}return t},ixe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:ZRe(n,a)},TM(r,s,n),wM(r,o,n,c),{transform:t,final:e},{transform:XRe(i,a)},YRe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var oxe=(t,e)=>{for(let r of emt(t))tmt(t,r,e)},emt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),tmt=(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 ${cd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>rmt(a,n));r.input=VA(s)},rmt=(t,e)=>{let r=RM(t,e,"utf8",!0);return nmt(r),VA(r)},nmt=t=>{let e=t.find(r=>typeof r!="string"&&!Wr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as amt,appendFileSync as cmt}from"fs";var xM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&fy(r,n)&&!po.has(e)&&imt(n)&&(t.some(({type:i,value:o})=>i==="native"&&omt.has(o))||t.every(({type:i})=>Zo.has(i))),imt=t=>t===1||t===2,omt=new Set(["pipe","overlapped"]),sxe=async(t,e,r,n)=>{for await(let i of t)smt(e)||cxe(i,r,n)},axe=(t,e,r)=>{for(let n of t)cxe(n,e,r)},smt=t=>t._readableState.pipes.length>0,cxe=(t,e,r)=>{let n=jD(t);tc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var uxe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,u)=>umt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},umt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=lRe(t,o,d),p=gu(f),{stdioItems:h,objectMode:m}=e[r],_=lmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=dmt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});fmt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?v:void 0;try{return n.error===void 0&&pmt(y,h,i),A}catch(S){return n.error=S,A}},lmt=(t,e,r,n)=>{try{return RM(t,e,r,!1)}catch(i){return n.error=i,t}},dmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:VA(t)};let s=Twe(t,r);return n[o]?{serializedResult:s,finalResult:x5(s,!i[o],e)}:{serializedResult:s}},fmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!xM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=x5(t,!1,s);try{axe(a,e,n)}catch(c){r.error??=c}},pmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>bM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?cmt(n,t):(r.add(o),amt(n,t))}};var lxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Su(e,r,"all")]:Array.isArray(e)?[Su(t,r,"all"),...e]:Wr(t)&&Wr(e)?M9([t,e]):`${t}${e}`};import{once as C5}from"events";var dxe=async(t,e)=>{let[r,n]=await hmt(t);return e.isForcefullyTerminated??=!1,[r,n]},hmt=async t=>{let[e,r]=await Promise.allSettled([C5(t,"spawn"),C5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?fxe(t):r.value},fxe=async t=>{try{return await C5(t,"exit")}catch{return fxe(t)}},pxe=async t=>{let[e,r]=await t;if(!mmt(e,r)&&k5(e,r))throw new oa;return[e,r]},mmt=(t,e)=>t===void 0&&e===void 0,k5=(t,e)=>t!==0||e!==null;var hxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=gmt(t,e,r),s=o?.code==="ETIMEDOUT",a=uRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},gmt=(t,e,r)=>t!==void 0?t:k5(e,r)?new oa:void 0;var mxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=ymt(t,e,r),d=bmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Ey(d,c,u)},ymt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qD(t,e,r),a=Smt(r),{file:c,commandArguments:u,options:l}=uM(t,e,a);vmt(l);let d=GRe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Smt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&IM("ipcInput"),t&&IM("ipc: true"),r&&IM("detached: true"),n&&IM("cancelSignal")},IM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},bmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=Emt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=hxe(c,r),{output:h,error:m=u}=uxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Su(v,r,A)),y=Su(lxe(h,r),r,"all");return Tmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Emt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{oxe(o,r);let a=wmt(r);return _mt(...lM(t,e,a))}catch(a){return by({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:_M(e)}),Tmt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?yM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):QA({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as d_t}from"events";import{spawn as f_t}from"child_process";import vxe from"process";import{once as N5,on as Amt}from"events";var gxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(my({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:nM(t)}),Rmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Rmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{QD(e,i);let o=ad(t,e,r),s=new AbortController;try{return await Promise.race([xmt(o,n,s),Imt(o,r,s),Omt(o,r,s)])}catch(a){throw gy(t),a}finally{s.abort(),eM(e,i)}},xmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await N5(t,"message",{signal:r});return n}for await(let[n]of Amt(t,"message",{signal:r}))if(e(n))return n},Imt=async(t,e,{signal:r})=>{await N5(t,"disconnect",{signal:r}),rAe(e)},Omt=async(t,e,{signal:r})=>{let[n]=await N5(t,"strict:error",{signal:r});throw ZD(n,e)};import{once as yxe,on as Pmt}from"events";var Sxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>$5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),$5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{my({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:nM(t)}),QD(e,o);let s=ad(t,e,r),a=new AbortController,c={};return Cmt(t,s,a),kmt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Nmt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Cmt=async(t,e,r)=>{try{await yxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kmt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await yxe(t,"strict:error",{signal:r.signal});n.error=ZD(i,e),r.abort()}catch{}},Nmt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Pmt(r,"message",{signal:o.signal}))_xe(s),yield c}catch{_xe(s)}finally{o.abort(),eM(e,a),n||gy(t),i&&await t}},_xe=({error:t})=>{if(t)throw t};var bxe=(t,{ipc:e})=>{Object.assign(t,wxe(t,!1,e))},Exe=()=>{let t=vxe,e=!0,r=vxe.channel!==void 0;return{...wxe(t,e,r),getCancelSignal:OAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},wxe=(t,e,r)=>({sendMessage:aM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:gxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Sxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as $mt}from"child_process";import{PassThrough as Dmt,Readable as Mmt,Writable as Lmt,Duplex as Umt}from"stream";var Txe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{T5(n);let a=new $mt;Fmt(a,n),Object.assign(a,{readable:zmt,writable:jmt,duplex:Bmt});let c=by({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=qmt(c,s,i);return{subprocess:a,promise:u}},Fmt=(t,e)=>{let r=tR(),n=tR(),i=tR(),o=Array.from({length:e.length-3},tR),s=tR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},tR=()=>{let t=new Dmt;return t.end(),t},zmt=()=>new Mmt({read(){}}),jmt=()=>new Lmt({write(){}}),Bmt=()=>new Umt({read(){},write(){}}),qmt=async(t,e,r)=>Ey(t,e,r);import{createReadStream as Axe,createWriteStream as Rxe}from"fs";import{Buffer as Vmt}from"buffer";import{Readable as rR,Writable as Gmt,Duplex as Hmt}from"stream";var Ixe=(t,e)=>EM(Wmt,t,e,!1),nR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${cd[t]}.`)},xxe={fileNumber:nR,generator:P5,asyncGenerator:P5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Hmt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Wmt={input:{...xxe,fileUrl:({value:t})=>({stream:Axe(t)}),filePath:({value:{file:t}})=>({stream:Axe(t)}),webStream:({value:t})=>({stream:rR.fromWeb(t)}),iterable:({value:t})=>({stream:rR.from(t)}),asyncIterable:({value:t})=>({stream:rR.from(t)}),string:({value:t})=>({stream:rR.from(t)}),uint8Array:({value:t})=>({stream:rR.from(Vmt.from(t))})},output:{...xxe,fileUrl:({value:t})=>({stream:Rxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Rxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Gmt.fromWeb(t)}),iterable:nR,asyncIterable:nR,string:nR,uint8Array:nR}};import{on as Kmt,once as Oxe}from"events";import{PassThrough as Ymt,getDefaultHighWaterMark as Zmt}from"stream";import{finished as kxe}from"stream/promises";function Jp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)M5(i);let e=t.some(({readableObjectMode:i})=>i),r=Xmt(t,e),n=new D5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Xmt=(t,e)=>{if(t.length===0)return Zmt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},D5=class extends Ymt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(M5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Jmt(this,this.#e,this.#o);let r=tgt({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(M5(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)}},Jmt=async(t,e,r)=>{OM(t,Pxe);let n=new AbortController;try{await Promise.race([Qmt(t,n),egt(t,e,r,n)])}finally{n.abort(),OM(t,-Pxe)}},Qmt=async(t,{signal:e})=>{try{await kxe(t,{signal:e,cleanup:!0})}catch(r){throw Nxe(t,r),r}},egt=async(t,e,r,{signal:n})=>{for await(let[i]of Kmt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},M5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},tgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{OM(t,Cxe);let a=new AbortController;try{await Promise.race([rgt(o,e,a),ngt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),igt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),OM(t,-Cxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?L5(t):ogt(t))},rgt=async(t,e,{signal:r})=>{try{await t,r.aborted||L5(e)}catch(n){r.aborted||Nxe(e,n)}},ngt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await kxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;$xe(s)?i.add(e):Dxe(t,s)}},igt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Oxe(t,i,{signal:o}),!t.readable)return Oxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},ogt=t=>{t.writable&&t.end()},Nxe=(t,e)=>{$xe(e)?L5(t):Dxe(t,e)},$xe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",L5=t=>{(t.readable||t.writable)&&t.destroy()},Dxe=(t,e)=>{t.destroyed||(t.once("error",sgt),t.destroy(e))},sgt=()=>{},OM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Pxe=2,Cxe=1;import{finished as Mxe}from"stream/promises";var Ty=(t,e)=>{t.pipe(e),agt(t,e),cgt(t,e)},agt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await Mxe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}U5(e)}},U5=t=>{t.writable&&t.end()},cgt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await Mxe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}F5(t)}},F5=t=>{t.readable&&t.destroy()};var Lxe=(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})=>Zo.has(c)))ugt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zo.has(c)))dgt({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]:Jp(o);Ty(s,i)}},ugt=(t,e,r,n)=>{r==="output"?Ty(t.stdio[n],e):Ty(e,t.stdio[n]);let i=lgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},lgt=["stdin","stdout","stderr"],dgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;fgt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},fgt=(t,{signal:e})=>{ia(t)&&Kp(t,pgt,e)},pgt=2;import{addAbortListener as ggt}from"events";var Qp=[];Qp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Qp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Qp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var PM=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",z5=Symbol.for("signal-exit emitter"),j5=globalThis,hgt=Object.defineProperty.bind(Object),B5=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(j5[z5])return j5[z5];hgt(j5,z5,{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}},CM=class{},mgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),q5=class extends CM{onExit(){return()=>{}}load(){}unload(){}},V5=class extends CM{#e=G5.platform==="win32"?"SIGINT":"SIGHUP";#r=new B5;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Qp)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(!PM(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 Qp)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,Qp.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 PM(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"&&PM(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)}},G5=globalThis.process,{onExit:Uxe,load:Tfr,unload:Afr}=mgt(PM(G5)?new V5(G5):new q5);var Fxe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Uxe(()=>{t.kill()});ggt(n,()=>{i()})};var jxe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=BD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=_gt(r,n,i),{sourceStream:d,sourceError:f}=Sgt(t,u),{options:p,fileDescriptors:h}=nc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},_gt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=ygt(t,e,...r),a=JD(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},ygt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(zxe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||$9(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]=kD(r,...n);return{destination:e(zxe)(i,o,s),pipeOptions:s}}if(nc.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}`)},zxe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Sgt=(t,e)=>{try{return{sourceStream:_y(t,e)}}catch(r){return{sourceError:r}}};var qxe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=vgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw H5({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},vgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return F5(t),n;if(e!==void 0)return U5(r),e},H5=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>by({error:t,command:Bxe,escapedCommand:Bxe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Bxe="source.pipe(destination)";var Vxe=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 bgt}from"stream/promises";var Gxe=(t,e,r)=>{let n=kM.has(e)?wgt(t,e):Egt(t,e);return Kp(t,Agt,r.signal),Kp(e,Rgt,r.signal),Tgt(e),n},Egt=(t,e)=>{let r=Jp([t]);return Ty(r,e),kM.set(e,r),r},wgt=(t,e)=>{let r=kM.get(e);return r.add(t),r},Tgt=async t=>{try{await bgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kM.delete(t)},kM=new WeakMap,Agt=2,Rgt=1;import{aborted as xgt}from"util";var Hxe=(t,e)=>t===void 0?[]:[Igt(t,e)],Igt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await xgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw H5({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var NM=(t,...e)=>{if(Tr(e[0]))return NM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=jxe(t,...e),i=Ogt({...n,destination:r});return i.pipe=NM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Ogt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Pgt(t,i);qxe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=Gxe(e,o,d);return await Promise.race([Vxe(l),...Hxe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Pgt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Lgt}from"timers/promises";import{on as Cgt}from"events";import{getDefaultHighWaterMark as kgt}from"stream";var $M=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return Ngt(e,s),Kxe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},Ngt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},W5=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;$gt(e,s,t);let a=t.readableObjectMode&&!o;return Kxe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},$gt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Kxe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Cgt(t,"data",{signal:e.signal,highWaterMark:Wxe,highWatermark:Wxe});return Dgt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},K5=kgt(!0),Wxe=K5,Dgt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=Mgt({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Xp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*eR(a)}},Mgt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[TM(t,r,!e),wM(t,i,!n,{})].filter(Boolean);var Yxe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=Ugt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([Fgt(t),d]);return}let f=A5(c,r),p=W5({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zgt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},Ugt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!xM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=W5({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await sxe(a,t,r,o)},Fgt=async t=>{await Lgt(),t.readableFlowing===null&&t.resume()},zgt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await hM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await mM(r,{maxBuffer:o})):await vy(r,{maxBuffer:o})}catch(a){return Zxe(sRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},Y5=async t=>{try{return await t}catch(e){return Zxe(e)}},Zxe=({bufferedData:t})=>Ewe(t)?new Uint8Array(t):t;import{finished as jgt}from"stream/promises";var iR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=Bgt(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],jgt(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Ggt(a,e,r,n)}finally{s.abort()}},Bgt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&qgt(t,r,n),n},qgt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Vgt(e,r),n.call(t,...i)}},Vgt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Ggt=(t,e,r,n)=>{if(!Hgt(t,e,r,n))throw t},Hgt=(t,e,r,n=!0)=>r.propagating?Xxe(t)||DM(t):(r.propagating=!0,Z5(r,e)===n?Xxe(t):DM(t)),Z5=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",DM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Xxe=t=>t?.code==="EPIPE";var Jxe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>X5({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),X5=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=iR(t,e,u);if(Z5(u,e)){await l;return}let[d]=await Promise.all([Yxe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var Qxe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Jp([t,e].filter(Boolean)):void 0,eIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>X5({...Wgt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Kgt(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Wgt=({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}},Kgt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Ygt}from"events";var tIe=t=>fy(t,"ipc"),rIe=(t,e)=>{let r=jD(t);tc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var nIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=tIe(o),a=_u(e,"ipc"),c=_u(r,"ipc");for await(let u of $5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(aRe(t,i,c),i.push(u)),s&&rIe(u,o);return i},iIe=async(t,e)=>(await Promise.allSettled([t]),e);var oIe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=dxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=Jxe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=eIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=[],I=nIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),C=Zgt(m,t,A),P=Xgt(h,A);try{return await Promise.race([Promise.all([{},pxe(v),Promise.all(S),E,I,FAe(t,d),...C,...P]),_,Jgt(t,y),...$Ae(t,o,f,y),...tAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...kAe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},v,Promise.all(S.map(T=>Y5(T))),Y5(E),iIe(I,b),Promise.allSettled(C),Promise.allSettled(P)])}},Zgt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:iR(n,i,r)),Xgt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>aa(o,{checkOpen:!1})&&!ia(o)).map(({type:i,value:o,stream:s=o})=>iR(s,n,e,{isSameDirection:Zo.has(i),stopOnExit:i==="native"}))),Jgt=async(t,{signal:e})=>{let[r]=await Ygt(t,"error",{signal:e});throw r};var sIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),oR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=rc();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Ay=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 Qgt}from"stream";import{callbackify as e_t}from"util";import{finished as aIe}from"stream/promises";var J5=async t=>{if(t!==void 0)try{await Q5(t)}catch{}},cIe=async t=>{if(t!==void 0)try{await e8(t)}catch{}},Q5=async t=>{await aIe(t,{cleanup:!0,readable:!1,writable:!0})},e8=async t=>{await aIe(t,{cleanup:!0,readable:!0,writable:!1})},MM=async(t,e)=>{if(await t,e)throw e},LM=(t,e,r)=>{r&&!DM(r)?t.destroy(r):e&&t.destroy()};var uIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||po.has(r),{subprocessStdout:a,waitReadableDestroy:c}=t8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=r8(a,s),{read:f,onStdoutDataDone:p}=n8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new Qgt({read:f,destroy:e_t(o8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return i8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},t8=(t,e,r)=>{let n=_y(t,e),i=oR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},r8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:K5},n8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=rc(),s=$M({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){t_t(this,s,o)},onStdoutDataDone:o}},t_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},i8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await e8(t),await n,await J5(i),await e,r.readable&&r.push(null)}catch(o){await J5(i),lIe(r,o)}},o8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Ay(r,e)&&(lIe(t,n),await MM(e,n))},lIe=(t,e)=>{LM(t,t.readable,e)};import{Writable as r_t}from"stream";import{callbackify as dIe}from"util";var fIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=s8(t,r,e),s=new r_t({...a8(n,t,i),destroy:dIe(u8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return c8(n,s),s},s8=(t,e,r)=>{let n=JD(t,e),i=oR(r,n,"writableFinal"),o=oR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},a8=(t,e,r)=>({write:n_t.bind(void 0,t),final:dIe(i_t.bind(void 0,t,e,r))}),n_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},i_t=async(t,e,r)=>{await Ay(r,e)&&(t.writable&&t.end(),await e)},c8=async(t,e,r)=>{try{await Q5(t),e.writable&&e.end()}catch(n){await cIe(r),pIe(e,n)}},u8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Ay(r,e),await Ay(n,e)&&(pIe(t,i),await MM(e,i))},pIe=(t,e)=>{LM(t,t.writable,e)};import{Duplex as o_t}from"stream";import{callbackify as s_t}from"util";var hIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||po.has(r),{subprocessStdout:c,waitReadableDestroy:u}=t8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=s8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=r8(c,a),{read:_,onStdoutDataDone:y}=n8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new o_t({read:_,...a8(l,t,d),destroy:s_t(a_t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return i8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),c8(l,v,c),v},a_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([o8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),u8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var l8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||po.has(e),s=_y(t,r),a=$M({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return c_t(a,s,t)},c_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var mIe=(t,{encoding:e})=>{let r=sIe();t.readable=uIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=fIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=hIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=l8.bind(void 0,t,e),t[Symbol.asyncIterator]=l8.bind(void 0,t,e,{})};var gIe=(t,e)=>{for(let[r,n]of l_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},u_t=(async()=>{})().constructor.prototype,l_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(u_t,t)]);var _Ie=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=p_t(t,e,r),{subprocess:f,promise:p}=m_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=NM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),gIe(f,p),nc.set(f,{options:l,fileDescriptors:d}),f},p_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qD(t,e,r),{file:a,commandArguments:c,options:u}=uM(t,e,r),l=h_t(u),d=Ixe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},h_t=({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}},m_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=f_t(...lM(t,e,r))}catch(h){return Txe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;d_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Lxe(c,a,u),Fxe(c,r,u);let d={},f=rc();c.kill=QTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Qxe(c,r),mIe(c,r),bxe(c,r);let p=g_t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},g_t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await oIe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((S,E)=>Su(S,e,E)),v=Su(m,e,"all"),A=__t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Ey(A,n,e)},__t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?QA({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ic,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):yM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var UM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,y_t(n,t[n],i)]));return{...t,...r}},y_t=(t,e,r)=>S_t.has(t)&&Tr(e)&&Tr(r)?{...e,...r}:r,S_t=new Set(["env",...z9]);var ud=(t,e,r,n)=>{let i=(s,a,c)=>ud(s,a,r,c),o=(...s)=>v_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},v_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Tr(o))return i(t,UM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=b_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?mxe(a,c,u):_Ie(a,c,u,i)},b_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Iwe(e)?Owe(e,r):[e,...r],[s,a,c]=kD(...o),u=UM(UM(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var yIe=({file:t,commandArguments:e})=>vIe(t,e),SIe=({file:t,commandArguments:e})=>({...vIe(t,e),isSync:!0}),vIe=(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]=E_t(t);return{file:r,commandArguments:n}},E_t=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(w_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},w_t=/ +/g;var bIe=(t,e,r)=>{t.sync=e(T_t,r),t.s=t.sync},EIe=({options:t})=>wIe(t),T_t=({options:t})=>({...wIe(t),isSync:!0}),wIe=t=>({options:{...A_t(t),...t}}),A_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},TIe={preferLocal:!0};var AIe=ud(()=>({})),hmr=ud(()=>({isSync:!0})),RIe=ud(yIe),mmr=ud(SIe),gmr=ud(MAe),_mr=ud(EIe,{},TIe,bIe),{sendMessage:ymr,getOneMessage:Smr,getEachMessage:vmr,getCancelSignal:bmr}=Exe();var xIe=!1,IIe,R_t=t=>{IIe??=t},OIe=t=>{xIe=!0,R_t(t)},Bn=()=>xIe,vu=()=>IIe,PIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var sR=null,CIe=t=>(sR&&sR.destroy(),sR=new Xo({totalAllowedTime:t}),sR),kIe=()=>sR;var Xo=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&&Bn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await X0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{K.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var NIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.13.0-code-diff-setup-reqs.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var P_t=I_t(import.meta.url),C_t=bu.dirname(P_t),k_t=O_t(import.meta.url),Ry=oe("shell"),d8=new Set,$Ie={preferLocal:!0},bt=(t,e,r)=>{let[n,i]=N_t(e,r),o={...$Ie,...i},s=AIe(t,n,o);MIe(s,o),FIe(s);let a=r?.idleTimeout;return a&&a>0&&UIe(s,a),s},DIe=(t,e)=>{let r={...$Ie,...e},n=RIe(t,r);return MIe(n,r),FIe(n),e?.idleTimeout&&e.idleTimeout>0&&UIe(n,e.idleTimeout),n},N_t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},MIe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||sc.env.NETLIFY_LOCAL_QUIET==="true")return;if(sc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Ow).pipe(sc.stdout),t.stderr?.pipe(new Ow).pipe(sc.stderr);return}t.stdout?.pipe(sc.stdout),t.stderr?.pipe(sc.stderr)},f8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(sc.kill(-t.pid,e),Ry.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Ry.error("Error killing process:",r),!1}},LIe=t=>f8(t,"SIGKILL"),UIe=(t,e)=>{let r=null,n=()=>{Ry.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),f8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing idle process ${t.pid}`),LIe(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)},FIe=t=>{d8.add(t);let e=kIe();if(e){let r=e.onTimesUp(()=>{Ry.log(`Global timer expired, killing process ${t.pid}`),f8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing process ${t.pid} after timeout`),LIe(t))},5e3)});t.on("exit",()=>{d8.delete(t),r()}),t.on("error",()=>{d8.delete(t),r()})}};function ac(t,e){if(!sc.env.NETLIFY_LOCAL_MODE)try{let i=k_t.resolve(NIe.name),o=bu.dirname(i);for(;o!==bu.dirname(o);){let s=bu.dirname(o);if(bu.basename(s)==="node_modules"){let a=bu.join(s,".bin",e);if(FM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(sc.env.NODE_PATH){let i=bu.join(sc.env.NODE_PATH,".bin",e);if(FM.existsSync(i))return i}let r=bu.join(t,"node_modules",".bin",e);if(FM.existsSync(r))return r;let n=bu.join(C_t,"..","node_modules",".bin",e);if(FM.existsSync(n))return n}var xy=oe("repo"),HIe="runner-diffs-",p8=t=>`${HIe}${t}-`,WIe=async t=>{let e=jM.tmpdir(),r;try{r=await di.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(HIe)&&!n.startsWith(p8(t))).map(n=>di.rm(Jo.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},zIe=async t=>{let e=$_t("sha256");for await(let r of D_t(t))e.update(r);return e.digest("hex")},jIe=async(t,e)=>t.size===e.size&&await zIe(t.path)===await zIe(e.path),KIe=/.. (.+)?\.log$/,M_t=[KIe],L_t=1,BIe=t=>{let e=t.split(`
|
|
385
|
+
if (condition) { yield value; }`)};import{Buffer as Vht}from"buffer";import{StringDecoder as Ght}from"string_decoder";var TM=(t,e,r)=>{if(r)return;if(t)return{transform:Hht.bind(void 0,new TextEncoder)};let n=new Ght(e);return{transform:Wht.bind(void 0,n),final:Kht.bind(void 0,n)}},Hht=function*(t,e){Vht.isBuffer(e)?yield gu(e):typeof e=="string"?yield t.encode(e):yield e},Wht=function*(t,e){yield Wr(e)?t.write(e):e},Kht=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as QRe}from"util";var I5=QRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),AM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Zht}=e[r];for await(let i of n(t))yield*AM(i,e,r+1)},exe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Yht(r,Number(e),t)},Yht=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*AM(n,r,e+1)},txe=QRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Zht=function*(t){yield t};var O5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},rxe=(t,e)=>[...e.flatMap(r=>[...Xp(r,t,0)]),...eR(t)],Xp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Jht}=e[r];for(let i of n(t))yield*Xp(i,e,r+1)},eR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Xht(r,Number(e),t)},Xht=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Xp(n,r,e+1)},Jht=function*(t){yield t};var P5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=ixe(t,s,o),u=Zp(e),l=Zp(r),d=u?I5.bind(void 0,AM,a):O5.bind(void 0,Xp),f=u||l?I5.bind(void 0,exe,a):O5.bind(void 0,eR),p=u||l?txe.bind(void 0,a):void 0;return{stream:new Qht({writableObjectMode:n,writableHighWaterMark:nxe(n),readableObjectMode:i,readableHighWaterMark:nxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},RM=(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=ixe(s,r,a);t=rxe(c,t)}return t},ixe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:ZRe(n,a)},TM(r,s,n),wM(r,o,n,c),{transform:t,final:e},{transform:XRe(i,a)},YRe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var oxe=(t,e)=>{for(let r of emt(t))tmt(t,r,e)},emt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),tmt=(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 ${cd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>rmt(a,n));r.input=VA(s)},rmt=(t,e)=>{let r=RM(t,e,"utf8",!0);return nmt(r),VA(r)},nmt=t=>{let e=t.find(r=>typeof r!="string"&&!Wr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as amt,appendFileSync as cmt}from"fs";var xM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&fy(r,n)&&!po.has(e)&&imt(n)&&(t.some(({type:i,value:o})=>i==="native"&&omt.has(o))||t.every(({type:i})=>Zo.has(i))),imt=t=>t===1||t===2,omt=new Set(["pipe","overlapped"]),sxe=async(t,e,r,n)=>{for await(let i of t)smt(e)||cxe(i,r,n)},axe=(t,e,r)=>{for(let n of t)cxe(n,e,r)},smt=t=>t._readableState.pipes.length>0,cxe=(t,e,r)=>{let n=jD(t);tc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var uxe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,u)=>umt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},umt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=lRe(t,o,d),p=gu(f),{stdioItems:h,objectMode:m}=e[r],_=lmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=dmt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});fmt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?v:void 0;try{return n.error===void 0&&pmt(y,h,i),A}catch(S){return n.error=S,A}},lmt=(t,e,r,n)=>{try{return RM(t,e,r,!1)}catch(i){return n.error=i,t}},dmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:VA(t)};let s=Twe(t,r);return n[o]?{serializedResult:s,finalResult:x5(s,!i[o],e)}:{serializedResult:s}},fmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!xM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=x5(t,!1,s);try{axe(a,e,n)}catch(c){r.error??=c}},pmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>bM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?cmt(n,t):(r.add(o),amt(n,t))}};var lxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Su(e,r,"all")]:Array.isArray(e)?[Su(t,r,"all"),...e]:Wr(t)&&Wr(e)?M9([t,e]):`${t}${e}`};import{once as C5}from"events";var dxe=async(t,e)=>{let[r,n]=await hmt(t);return e.isForcefullyTerminated??=!1,[r,n]},hmt=async t=>{let[e,r]=await Promise.allSettled([C5(t,"spawn"),C5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?fxe(t):r.value},fxe=async t=>{try{return await C5(t,"exit")}catch{return fxe(t)}},pxe=async t=>{let[e,r]=await t;if(!mmt(e,r)&&k5(e,r))throw new oa;return[e,r]},mmt=(t,e)=>t===void 0&&e===void 0,k5=(t,e)=>t!==0||e!==null;var hxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=gmt(t,e,r),s=o?.code==="ETIMEDOUT",a=uRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},gmt=(t,e,r)=>t!==void 0?t:k5(e,r)?new oa:void 0;var mxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=ymt(t,e,r),d=bmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Ey(d,c,u)},ymt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qD(t,e,r),a=Smt(r),{file:c,commandArguments:u,options:l}=uM(t,e,a);vmt(l);let d=GRe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Smt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&IM("ipcInput"),t&&IM("ipc: true"),r&&IM("detached: true"),n&&IM("cancelSignal")},IM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},bmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=Emt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=hxe(c,r),{output:h,error:m=u}=uxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Su(v,r,A)),y=Su(lxe(h,r),r,"all");return Tmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Emt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{oxe(o,r);let a=wmt(r);return _mt(...lM(t,e,a))}catch(a){return by({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:_M(e)}),Tmt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?yM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):QA({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as d_t}from"events";import{spawn as f_t}from"child_process";import vxe from"process";import{once as N5,on as Amt}from"events";var gxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(my({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:nM(t)}),Rmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Rmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{QD(e,i);let o=ad(t,e,r),s=new AbortController;try{return await Promise.race([xmt(o,n,s),Imt(o,r,s),Omt(o,r,s)])}catch(a){throw gy(t),a}finally{s.abort(),eM(e,i)}},xmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await N5(t,"message",{signal:r});return n}for await(let[n]of Amt(t,"message",{signal:r}))if(e(n))return n},Imt=async(t,e,{signal:r})=>{await N5(t,"disconnect",{signal:r}),rAe(e)},Omt=async(t,e,{signal:r})=>{let[n]=await N5(t,"strict:error",{signal:r});throw ZD(n,e)};import{once as yxe,on as Pmt}from"events";var Sxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>$5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),$5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{my({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:nM(t)}),QD(e,o);let s=ad(t,e,r),a=new AbortController,c={};return Cmt(t,s,a),kmt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Nmt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Cmt=async(t,e,r)=>{try{await yxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kmt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await yxe(t,"strict:error",{signal:r.signal});n.error=ZD(i,e),r.abort()}catch{}},Nmt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Pmt(r,"message",{signal:o.signal}))_xe(s),yield c}catch{_xe(s)}finally{o.abort(),eM(e,a),n||gy(t),i&&await t}},_xe=({error:t})=>{if(t)throw t};var bxe=(t,{ipc:e})=>{Object.assign(t,wxe(t,!1,e))},Exe=()=>{let t=vxe,e=!0,r=vxe.channel!==void 0;return{...wxe(t,e,r),getCancelSignal:OAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},wxe=(t,e,r)=>({sendMessage:aM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:gxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Sxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as $mt}from"child_process";import{PassThrough as Dmt,Readable as Mmt,Writable as Lmt,Duplex as Umt}from"stream";var Txe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{T5(n);let a=new $mt;Fmt(a,n),Object.assign(a,{readable:zmt,writable:jmt,duplex:Bmt});let c=by({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=qmt(c,s,i);return{subprocess:a,promise:u}},Fmt=(t,e)=>{let r=tR(),n=tR(),i=tR(),o=Array.from({length:e.length-3},tR),s=tR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},tR=()=>{let t=new Dmt;return t.end(),t},zmt=()=>new Mmt({read(){}}),jmt=()=>new Lmt({write(){}}),Bmt=()=>new Umt({read(){},write(){}}),qmt=async(t,e,r)=>Ey(t,e,r);import{createReadStream as Axe,createWriteStream as Rxe}from"fs";import{Buffer as Vmt}from"buffer";import{Readable as rR,Writable as Gmt,Duplex as Hmt}from"stream";var Ixe=(t,e)=>EM(Wmt,t,e,!1),nR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${cd[t]}.`)},xxe={fileNumber:nR,generator:P5,asyncGenerator:P5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Hmt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Wmt={input:{...xxe,fileUrl:({value:t})=>({stream:Axe(t)}),filePath:({value:{file:t}})=>({stream:Axe(t)}),webStream:({value:t})=>({stream:rR.fromWeb(t)}),iterable:({value:t})=>({stream:rR.from(t)}),asyncIterable:({value:t})=>({stream:rR.from(t)}),string:({value:t})=>({stream:rR.from(t)}),uint8Array:({value:t})=>({stream:rR.from(Vmt.from(t))})},output:{...xxe,fileUrl:({value:t})=>({stream:Rxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Rxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Gmt.fromWeb(t)}),iterable:nR,asyncIterable:nR,string:nR,uint8Array:nR}};import{on as Kmt,once as Oxe}from"events";import{PassThrough as Ymt,getDefaultHighWaterMark as Zmt}from"stream";import{finished as kxe}from"stream/promises";function Jp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)M5(i);let e=t.some(({readableObjectMode:i})=>i),r=Xmt(t,e),n=new D5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Xmt=(t,e)=>{if(t.length===0)return Zmt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},D5=class extends Ymt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(M5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Jmt(this,this.#e,this.#o);let r=tgt({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(M5(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)}},Jmt=async(t,e,r)=>{OM(t,Pxe);let n=new AbortController;try{await Promise.race([Qmt(t,n),egt(t,e,r,n)])}finally{n.abort(),OM(t,-Pxe)}},Qmt=async(t,{signal:e})=>{try{await kxe(t,{signal:e,cleanup:!0})}catch(r){throw Nxe(t,r),r}},egt=async(t,e,r,{signal:n})=>{for await(let[i]of Kmt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},M5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},tgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{OM(t,Cxe);let a=new AbortController;try{await Promise.race([rgt(o,e,a),ngt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),igt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),OM(t,-Cxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?L5(t):ogt(t))},rgt=async(t,e,{signal:r})=>{try{await t,r.aborted||L5(e)}catch(n){r.aborted||Nxe(e,n)}},ngt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await kxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;$xe(s)?i.add(e):Dxe(t,s)}},igt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Oxe(t,i,{signal:o}),!t.readable)return Oxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},ogt=t=>{t.writable&&t.end()},Nxe=(t,e)=>{$xe(e)?L5(t):Dxe(t,e)},$xe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",L5=t=>{(t.readable||t.writable)&&t.destroy()},Dxe=(t,e)=>{t.destroyed||(t.once("error",sgt),t.destroy(e))},sgt=()=>{},OM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Pxe=2,Cxe=1;import{finished as Mxe}from"stream/promises";var Ty=(t,e)=>{t.pipe(e),agt(t,e),cgt(t,e)},agt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await Mxe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}U5(e)}},U5=t=>{t.writable&&t.end()},cgt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await Mxe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}F5(t)}},F5=t=>{t.readable&&t.destroy()};var Lxe=(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})=>Zo.has(c)))ugt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zo.has(c)))dgt({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]:Jp(o);Ty(s,i)}},ugt=(t,e,r,n)=>{r==="output"?Ty(t.stdio[n],e):Ty(e,t.stdio[n]);let i=lgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},lgt=["stdin","stdout","stderr"],dgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;fgt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},fgt=(t,{signal:e})=>{ia(t)&&Kp(t,pgt,e)},pgt=2;import{addAbortListener as ggt}from"events";var Qp=[];Qp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Qp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Qp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var PM=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",z5=Symbol.for("signal-exit emitter"),j5=globalThis,hgt=Object.defineProperty.bind(Object),B5=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(j5[z5])return j5[z5];hgt(j5,z5,{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}},CM=class{},mgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),q5=class extends CM{onExit(){return()=>{}}load(){}unload(){}},V5=class extends CM{#e=G5.platform==="win32"?"SIGINT":"SIGHUP";#r=new B5;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Qp)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(!PM(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 Qp)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,Qp.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 PM(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"&&PM(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)}},G5=globalThis.process,{onExit:Uxe,load:Tfr,unload:Afr}=mgt(PM(G5)?new V5(G5):new q5);var Fxe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Uxe(()=>{t.kill()});ggt(n,()=>{i()})};var jxe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=BD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=_gt(r,n,i),{sourceStream:d,sourceError:f}=Sgt(t,u),{options:p,fileDescriptors:h}=nc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},_gt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=ygt(t,e,...r),a=JD(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},ygt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(zxe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||$9(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]=kD(r,...n);return{destination:e(zxe)(i,o,s),pipeOptions:s}}if(nc.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}`)},zxe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Sgt=(t,e)=>{try{return{sourceStream:_y(t,e)}}catch(r){return{sourceError:r}}};var qxe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=vgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw H5({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},vgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return F5(t),n;if(e!==void 0)return U5(r),e},H5=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>by({error:t,command:Bxe,escapedCommand:Bxe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Bxe="source.pipe(destination)";var Vxe=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 bgt}from"stream/promises";var Gxe=(t,e,r)=>{let n=kM.has(e)?wgt(t,e):Egt(t,e);return Kp(t,Agt,r.signal),Kp(e,Rgt,r.signal),Tgt(e),n},Egt=(t,e)=>{let r=Jp([t]);return Ty(r,e),kM.set(e,r),r},wgt=(t,e)=>{let r=kM.get(e);return r.add(t),r},Tgt=async t=>{try{await bgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kM.delete(t)},kM=new WeakMap,Agt=2,Rgt=1;import{aborted as xgt}from"util";var Hxe=(t,e)=>t===void 0?[]:[Igt(t,e)],Igt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await xgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw H5({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var NM=(t,...e)=>{if(Tr(e[0]))return NM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=jxe(t,...e),i=Ogt({...n,destination:r});return i.pipe=NM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Ogt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Pgt(t,i);qxe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=Gxe(e,o,d);return await Promise.race([Vxe(l),...Hxe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Pgt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Lgt}from"timers/promises";import{on as Cgt}from"events";import{getDefaultHighWaterMark as kgt}from"stream";var $M=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return Ngt(e,s),Kxe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},Ngt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},W5=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;$gt(e,s,t);let a=t.readableObjectMode&&!o;return Kxe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},$gt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Kxe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Cgt(t,"data",{signal:e.signal,highWaterMark:Wxe,highWatermark:Wxe});return Dgt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},K5=kgt(!0),Wxe=K5,Dgt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=Mgt({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Xp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*eR(a)}},Mgt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[TM(t,r,!e),wM(t,i,!n,{})].filter(Boolean);var Yxe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=Ugt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([Fgt(t),d]);return}let f=A5(c,r),p=W5({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zgt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},Ugt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!xM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=W5({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await sxe(a,t,r,o)},Fgt=async t=>{await Lgt(),t.readableFlowing===null&&t.resume()},zgt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await hM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await mM(r,{maxBuffer:o})):await vy(r,{maxBuffer:o})}catch(a){return Zxe(sRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},Y5=async t=>{try{return await t}catch(e){return Zxe(e)}},Zxe=({bufferedData:t})=>Ewe(t)?new Uint8Array(t):t;import{finished as jgt}from"stream/promises";var iR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=Bgt(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],jgt(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Ggt(a,e,r,n)}finally{s.abort()}},Bgt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&qgt(t,r,n),n},qgt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Vgt(e,r),n.call(t,...i)}},Vgt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Ggt=(t,e,r,n)=>{if(!Hgt(t,e,r,n))throw t},Hgt=(t,e,r,n=!0)=>r.propagating?Xxe(t)||DM(t):(r.propagating=!0,Z5(r,e)===n?Xxe(t):DM(t)),Z5=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",DM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Xxe=t=>t?.code==="EPIPE";var Jxe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>X5({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),X5=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=iR(t,e,u);if(Z5(u,e)){await l;return}let[d]=await Promise.all([Yxe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var Qxe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Jp([t,e].filter(Boolean)):void 0,eIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>X5({...Wgt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Kgt(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Wgt=({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}},Kgt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Ygt}from"events";var tIe=t=>fy(t,"ipc"),rIe=(t,e)=>{let r=jD(t);tc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var nIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=tIe(o),a=_u(e,"ipc"),c=_u(r,"ipc");for await(let u of $5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(aRe(t,i,c),i.push(u)),s&&rIe(u,o);return i},iIe=async(t,e)=>(await Promise.allSettled([t]),e);var oIe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=dxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=Jxe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=eIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=[],I=nIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),C=Zgt(m,t,A),P=Xgt(h,A);try{return await Promise.race([Promise.all([{},pxe(v),Promise.all(S),E,I,FAe(t,d),...C,...P]),_,Jgt(t,y),...$Ae(t,o,f,y),...tAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...kAe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},v,Promise.all(S.map(T=>Y5(T))),Y5(E),iIe(I,b),Promise.allSettled(C),Promise.allSettled(P)])}},Zgt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:iR(n,i,r)),Xgt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>aa(o,{checkOpen:!1})&&!ia(o)).map(({type:i,value:o,stream:s=o})=>iR(s,n,e,{isSameDirection:Zo.has(i),stopOnExit:i==="native"}))),Jgt=async(t,{signal:e})=>{let[r]=await Ygt(t,"error",{signal:e});throw r};var sIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),oR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=rc();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Ay=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 Qgt}from"stream";import{callbackify as e_t}from"util";import{finished as aIe}from"stream/promises";var J5=async t=>{if(t!==void 0)try{await Q5(t)}catch{}},cIe=async t=>{if(t!==void 0)try{await e8(t)}catch{}},Q5=async t=>{await aIe(t,{cleanup:!0,readable:!1,writable:!0})},e8=async t=>{await aIe(t,{cleanup:!0,readable:!0,writable:!1})},MM=async(t,e)=>{if(await t,e)throw e},LM=(t,e,r)=>{r&&!DM(r)?t.destroy(r):e&&t.destroy()};var uIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||po.has(r),{subprocessStdout:a,waitReadableDestroy:c}=t8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=r8(a,s),{read:f,onStdoutDataDone:p}=n8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new Qgt({read:f,destroy:e_t(o8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return i8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},t8=(t,e,r)=>{let n=_y(t,e),i=oR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},r8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:K5},n8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=rc(),s=$M({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){t_t(this,s,o)},onStdoutDataDone:o}},t_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},i8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await e8(t),await n,await J5(i),await e,r.readable&&r.push(null)}catch(o){await J5(i),lIe(r,o)}},o8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Ay(r,e)&&(lIe(t,n),await MM(e,n))},lIe=(t,e)=>{LM(t,t.readable,e)};import{Writable as r_t}from"stream";import{callbackify as dIe}from"util";var fIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=s8(t,r,e),s=new r_t({...a8(n,t,i),destroy:dIe(u8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return c8(n,s),s},s8=(t,e,r)=>{let n=JD(t,e),i=oR(r,n,"writableFinal"),o=oR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},a8=(t,e,r)=>({write:n_t.bind(void 0,t),final:dIe(i_t.bind(void 0,t,e,r))}),n_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},i_t=async(t,e,r)=>{await Ay(r,e)&&(t.writable&&t.end(),await e)},c8=async(t,e,r)=>{try{await Q5(t),e.writable&&e.end()}catch(n){await cIe(r),pIe(e,n)}},u8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Ay(r,e),await Ay(n,e)&&(pIe(t,i),await MM(e,i))},pIe=(t,e)=>{LM(t,t.writable,e)};import{Duplex as o_t}from"stream";import{callbackify as s_t}from"util";var hIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||po.has(r),{subprocessStdout:c,waitReadableDestroy:u}=t8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=s8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=r8(c,a),{read:_,onStdoutDataDone:y}=n8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new o_t({read:_,...a8(l,t,d),destroy:s_t(a_t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return i8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),c8(l,v,c),v},a_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([o8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),u8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var l8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||po.has(e),s=_y(t,r),a=$M({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return c_t(a,s,t)},c_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var mIe=(t,{encoding:e})=>{let r=sIe();t.readable=uIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=fIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=hIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=l8.bind(void 0,t,e),t[Symbol.asyncIterator]=l8.bind(void 0,t,e,{})};var gIe=(t,e)=>{for(let[r,n]of l_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},u_t=(async()=>{})().constructor.prototype,l_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(u_t,t)]);var _Ie=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=p_t(t,e,r),{subprocess:f,promise:p}=m_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=NM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),gIe(f,p),nc.set(f,{options:l,fileDescriptors:d}),f},p_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qD(t,e,r),{file:a,commandArguments:c,options:u}=uM(t,e,r),l=h_t(u),d=Ixe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},h_t=({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}},m_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=f_t(...lM(t,e,r))}catch(h){return Txe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;d_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Lxe(c,a,u),Fxe(c,r,u);let d={},f=rc();c.kill=QTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Qxe(c,r),mIe(c,r),bxe(c,r);let p=g_t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},g_t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await oIe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((S,E)=>Su(S,e,E)),v=Su(m,e,"all"),A=__t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Ey(A,n,e)},__t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?QA({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ic,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):yM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var UM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,y_t(n,t[n],i)]));return{...t,...r}},y_t=(t,e,r)=>S_t.has(t)&&Tr(e)&&Tr(r)?{...e,...r}:r,S_t=new Set(["env",...z9]);var ud=(t,e,r,n)=>{let i=(s,a,c)=>ud(s,a,r,c),o=(...s)=>v_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},v_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Tr(o))return i(t,UM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=b_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?mxe(a,c,u):_Ie(a,c,u,i)},b_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Iwe(e)?Owe(e,r):[e,...r],[s,a,c]=kD(...o),u=UM(UM(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var yIe=({file:t,commandArguments:e})=>vIe(t,e),SIe=({file:t,commandArguments:e})=>({...vIe(t,e),isSync:!0}),vIe=(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]=E_t(t);return{file:r,commandArguments:n}},E_t=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(w_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},w_t=/ +/g;var bIe=(t,e,r)=>{t.sync=e(T_t,r),t.s=t.sync},EIe=({options:t})=>wIe(t),T_t=({options:t})=>({...wIe(t),isSync:!0}),wIe=t=>({options:{...A_t(t),...t}}),A_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},TIe={preferLocal:!0};var AIe=ud(()=>({})),hmr=ud(()=>({isSync:!0})),RIe=ud(yIe),mmr=ud(SIe),gmr=ud(MAe),_mr=ud(EIe,{},TIe,bIe),{sendMessage:ymr,getOneMessage:Smr,getEachMessage:vmr,getCancelSignal:bmr}=Exe();var xIe=!1,IIe,R_t=t=>{IIe??=t},OIe=t=>{xIe=!0,R_t(t)},Bn=()=>xIe,vu=()=>IIe,PIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var sR=null,CIe=t=>(sR&&sR.destroy(),sR=new Xo({totalAllowedTime:t}),sR),kIe=()=>sR;var Xo=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&&Bn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await X0({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{K.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var NIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.13.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var P_t=I_t(import.meta.url),C_t=bu.dirname(P_t),k_t=O_t(import.meta.url),Ry=oe("shell"),d8=new Set,$Ie={preferLocal:!0},bt=(t,e,r)=>{let[n,i]=N_t(e,r),o={...$Ie,...i},s=AIe(t,n,o);MIe(s,o),FIe(s);let a=r?.idleTimeout;return a&&a>0&&UIe(s,a),s},DIe=(t,e)=>{let r={...$Ie,...e},n=RIe(t,r);return MIe(n,r),FIe(n),e?.idleTimeout&&e.idleTimeout>0&&UIe(n,e.idleTimeout),n},N_t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},MIe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||sc.env.NETLIFY_LOCAL_QUIET==="true")return;if(sc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Ow).pipe(sc.stdout),t.stderr?.pipe(new Ow).pipe(sc.stderr);return}t.stdout?.pipe(sc.stdout),t.stderr?.pipe(sc.stderr)},f8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(sc.kill(-t.pid,e),Ry.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Ry.error("Error killing process:",r),!1}},LIe=t=>f8(t,"SIGKILL"),UIe=(t,e)=>{let r=null,n=()=>{Ry.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),f8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing idle process ${t.pid}`),LIe(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)},FIe=t=>{d8.add(t);let e=kIe();if(e){let r=e.onTimesUp(()=>{Ry.log(`Global timer expired, killing process ${t.pid}`),f8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing process ${t.pid} after timeout`),LIe(t))},5e3)});t.on("exit",()=>{d8.delete(t),r()}),t.on("error",()=>{d8.delete(t),r()})}};function ac(t,e){if(!sc.env.NETLIFY_LOCAL_MODE)try{let i=k_t.resolve(NIe.name),o=bu.dirname(i);for(;o!==bu.dirname(o);){let s=bu.dirname(o);if(bu.basename(s)==="node_modules"){let a=bu.join(s,".bin",e);if(FM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(sc.env.NODE_PATH){let i=bu.join(sc.env.NODE_PATH,".bin",e);if(FM.existsSync(i))return i}let r=bu.join(t,"node_modules",".bin",e);if(FM.existsSync(r))return r;let n=bu.join(C_t,"..","node_modules",".bin",e);if(FM.existsSync(n))return n}var xy=oe("repo"),HIe="runner-diffs-",p8=t=>`${HIe}${t}-`,WIe=async t=>{let e=jM.tmpdir(),r;try{r=await di.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(HIe)&&!n.startsWith(p8(t))).map(n=>di.rm(Jo.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},zIe=async t=>{let e=$_t("sha256");for await(let r of D_t(t))e.update(r);return e.digest("hex")},jIe=async(t,e)=>t.size===e.size&&await zIe(t.path)===await zIe(e.path),KIe=/.. (.+)?\.log$/,M_t=[KIe],L_t=1,BIe=t=>{let e=t.split(`
|
|
386
386
|
`).reduce((r,n)=>{if(!n)return r;let[i,o,,...s]=n,a=s.join(""),c=i.trim(),u=o.trim();return r[a]?r[a].change=u:r[a]={filePath:a,stage:c,change:u},r},{});return Object.values(e)},U_t=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),qIe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return An(r?`${e}: ${r}`:e)},F_t=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),VIe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),z_t=(t,e)=>{try{let r=new URL(t),n=new URL(e);return["https:","http:"].includes(n.protocol)&&n.protocol===r.protocol&&n.host===r.host&&VIe(n)===VIe(r)&&n.password!==""}catch{return!1}},GIe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},zM=500,aR=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},zi=class{constructor(e=process.cwd()){this.cwd=e}getRoot(){return this.root??=this.run(["rev-parse","--show-toplevel"],{stdout:"pipe"}).then(({stdout:e})=>String(e).trim()),this.root}async restorePausedWork(e){let r="restore";try{let n=await this.restorePausedFiles(e);r="stage",await this.stageBuildSetup();let i=await this.getRoot(),o=new Set(n.changedFiles),s=(await this.listIndexEntries(n.deletedFiles,{cwd:i})).filter(({filePath:a})=>!o.has(a));return await this.unstageFiles(n.changedFiles,{cwd:i}),s.length>0&&await di.writeFile(await this.getSetupMetadataPath(),JSON.stringify(s)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new aR(r,n)}}run(e,r={}){return bt("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){xy.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!r){let u=BIe(o);await this.discardSetupOnlyChanges(u)}xy.info("Changes after processing"),await this.getStatus();let s=await this.getIgnoredPathspecs(o);if(await this.stageFiles(s),await this.excludeUnchangedSetupDescendants(),i=await this.hasStagedChanges(),!i)return{hasChanges:!1,ignored:s};await this.run(["commit","-m","Agent runner [skip ci]"]);let a=await di.mkdtemp(Jo.join(jM.tmpdir(),p8(e.sessionId))),c=await this.writeDiffFiles({config:e,diffDir:a,target:{commit:"HEAD"},ignored:s});return await this.rollbackIfLocal(),c.hasChanges&&K.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c}async getStatus(){let e=await this.run(["-c","status.relativePaths=true","status","-s"]);return String(e.stdout??"")}async hasAgentChanges(){let e=await this.getStatus();return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
387
387
|
`).filter(i=>M_t.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}}async getCurrentCommitSha(){let{stdout:e}=await this.run(["rev-parse","HEAD"]);return String(e??"").trim()}async reset(){await this.run(["reset","--hard","HEAD"]),await di.rm(await this.getSetupMetadataPath(),{force:!0})}async discardSetupOnlyChanges(e){let r=e.filter(n=>n.stage&&!n.change).map(n=>n.filePath);r.length!==0&&await this.run(["restore","--staged","--worktree","--pathspec-from-file=-"],{input:r.join(`
|
|
388
388
|
`)})}async stageBuildSetup(){await di.rm(await this.getSetupMetadataPath(),{force:!0});let e=await this.getIgnoredPathspecs();await this.stageFiles(e)}getSetupMetadataPath(){return this.setupMetadataPath??=this.getRoot().then(async e=>{let{stdout:r}=await this.run(["rev-parse","--git-path","netlify-agent-runner-setup.json"],{cwd:e,stdout:"pipe"});return Jo.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=zM){let o=e.slice(i,i+zM).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...GIe,...r});for(let a of String(s??"").split("\0").filter(Boolean))n.push({filePath:a.slice(a.indexOf(" ")+1),entry:a})}return n}async excludeUnchangedSetupDescendants(e){let r;try{r=JSON.parse(await di.readFile(await this.getSetupMetadataPath(),"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}let i={cwd:await this.getRoot(),env:e},o=new Map((await this.listIndexEntries(r.map(({filePath:a})=>a),i)).map(({filePath:a,entry:c})=>[a,c])),s=r.filter(({filePath:a,entry:c})=>o.get(a)===c);s.length!==0&&await this.run(["update-index","--force-remove","-z","--stdin"],{...i,input:s.map(({filePath:a})=>a).join("\0")})}async getIgnoredPathspecs(e){e||=await this.getStatus();let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return e.split(`
|
package/package.json
CHANGED