@netlify/agent-runner-cli 2.10.0-setup-request-skip.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -383,7 +383,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
383
383
|
`,LF:`
|
|
384
384
|
`,concatBytes:U5},omt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},smt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:omt};import{Buffer as amt}from"buffer";var mxe=(t,e)=>t?void 0:cmt.bind(void 0,e),cmt=function*(t,e){if(typeof e!="string"&&!Kr(e)&&!amt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},gxe=(t,e)=>t?umt.bind(void 0,e):lmt.bind(void 0,e),umt=function*(t,e){_xe(t,e),yield e},lmt=function*(t,e){if(_xe(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},_xe=(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 dmt}from"buffer";import{StringDecoder as fmt}from"string_decoder";var kM=(t,e,r)=>{if(r)return;if(t)return{transform:pmt.bind(void 0,new TextEncoder)};let n=new fmt(e);return{transform:hmt.bind(void 0,n),final:mmt.bind(void 0,n)}},pmt=function*(t,e){dmt.isBuffer(e)?yield Eu(e):typeof e=="string"?yield t.encode(e):yield e},hmt=function*(t,e){yield Kr(e)?t.write(e):e},mmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as yxe}from"util";var z5=yxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),NM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_mt}=e[r];for await(let i of n(t))yield*NM(i,e,r+1)},Sxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*gmt(r,Number(e),t)},gmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*NM(n,r,e+1)},vxe=yxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),_mt=function*(t){yield t};var j5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Exe=(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=Smt}=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*ymt(r,Number(e),t)},ymt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*rh(n,r,e+1)},Smt=function*(t){yield t};var B5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=wxe(t,s,o),u=th(e),l=th(r),d=u?z5.bind(void 0,NM,a):j5.bind(void 0,rh),f=u||l?z5.bind(void 0,Sxe,a):j5.bind(void 0,cR),p=u||l?vxe.bind(void 0,a):void 0;return{stream:new vmt({writableObjectMode:n,writableHighWaterMark:bxe(n),readableObjectMode:i,readableHighWaterMark:bxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},$M=(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=wxe(s,r,a);t=Exe(c,t)}return t},wxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:mxe(n,a)},kM(r,s,n),CM(r,o,n,c),{transform:t,final:e},{transform:gxe(i,a)},hxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Txe=(t,e)=>{for(let r of Emt(t))bmt(t,r,e)},Emt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),bmt=(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=>wmt(a,n));r.input=XA(s)},wmt=(t,e)=>{let r=$M(t,e,"utf8",!0);return Tmt(r),XA(r)},Tmt=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 Imt,appendFileSync as Omt}from"fs";var DM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sy(r,n)&&!go.has(e)&&Amt(n)&&(t.some(({type:i,value:o})=>i==="native"&&Rmt.has(o))||t.every(({type:i})=>Qo.has(i))),Amt=t=>t===1||t===2,Rmt=new Set(["pipe","overlapped"]),Axe=async(t,e,r,n)=>{for await(let i of t)xmt(e)||xxe(i,r,n)},Rxe=(t,e,r)=>{for(let n of t)xxe(n,e,r)},xmt=t=>t._readableState.pipes.length>0,xxe=(t,e,r)=>{let n=YD(t);oc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Ixe=({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)=>Pmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Pmt=({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=ORe(t,o,d),p=Eu(f),{stdioItems:h,objectMode:m}=e[r],_=Cmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=kmt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Nmt({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&&$mt(y,h,i),A}catch(S){return n.error=S,A}},Cmt=(t,e,r,n)=>{try{return $M(t,e,r,!1)}catch(i){return n.error=i,t}},kmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:XA(t)};let s=qwe(t,r);return n[o]?{serializedResult:s,finalResult:F5(s,!i[o],e)}:{serializedResult:s}},Nmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!DM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=F5(t,!1,s);try{Rxe(a,e,n)}catch(c){r.error??=c}},$mt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>OM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?Omt(n,t):(r.add(o),Imt(n,t))}};var Oxe=([,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)?K9([t,e]):`${t}${e}`};import{once as q5}from"events";var Pxe=async(t,e)=>{let[r,n]=await Dmt(t);return e.isForcefullyTerminated??=!1,[r,n]},Dmt=async t=>{let[e,r]=await Promise.allSettled([q5(t,"spawn"),q5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Cxe(t):r.value},Cxe=async t=>{try{return await q5(t,"exit")}catch{return Cxe(t)}},kxe=async t=>{let[e,r]=await t;if(!Mmt(e,r)&&V5(e,r))throw new ua;return[e,r]},Mmt=(t,e)=>t===void 0&&e===void 0,V5=(t,e)=>t!==0||e!==null;var Nxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=Lmt(t,e,r),s=o?.code==="ETIMEDOUT",a=IRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},Lmt=(t,e,r)=>t!==void 0?t:V5(e,r)?new ua:void 0;var $xe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Fmt(t,e,r),d=Bmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Oy(d,c,u)},Fmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),a=zmt(r),{file:c,commandArguments:u,options:l}=_M(t,e,a);jmt(l);let d=lxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},zmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,jmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&MM("ipcInput"),t&&MM("ipc: true"),r&&MM("detached: true"),n&&MM("cancelSignal")},MM=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=qmt({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}=Nxe(c,r),{output:h,error:m=u}=Ixe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Tu(v,r,A)),y=Tu(Oxe(h,r),r,"all");return Gmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},qmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Txe(o,r);let a=Vmt(r);return Umt(...yM(t,e,a))}catch(a){return Iy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Vmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:AM(e)}),Gmt=({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?RM({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 k_t}from"events";import{spawn as N_t}from"child_process";import Fxe from"process";import{once as G5,on as Hmt}from"events";var Dxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(by({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:dM(t)}),Wmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Wmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{aM(e,i);let o=fd(t,e,r),s=new AbortController;try{return await Promise.race([Kmt(o,n,s),Ymt(o,r,s),Zmt(o,r,s)])}catch(a){throw wy(t),a}finally{s.abort(),cM(e,i)}},Kmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await G5(t,"message",{signal:r});return n}for await(let[n]of Hmt(t,"message",{signal:r}))if(e(n))return n},Ymt=async(t,e,{signal:r})=>{await G5(t,"disconnect",{signal:r}),EAe(e)},Zmt=async(t,e,{signal:r})=>{let[n]=await G5(t,"strict:error",{signal:r});throw iM(n,e)};import{once as Lxe,on as Jmt}from"events";var Uxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>H5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),H5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{by({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:dM(t)}),aM(e,o);let s=fd(t,e,r),a=new AbortController,c={};return Xmt(t,s,a),Qmt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),egt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Xmt=async(t,e,r)=>{try{await Lxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Qmt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Lxe(t,"strict:error",{signal:r.signal});n.error=iM(i,e),r.abort()}catch{}},egt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Jmt(r,"message",{signal:o.signal}))Mxe(s),yield c}catch{Mxe(s)}finally{o.abort(),cM(e,a),n||wy(t),i&&await t}},Mxe=({error:t})=>{if(t)throw t};var zxe=(t,{ipc:e})=>{Object.assign(t,Bxe(t,!1,e))},jxe=()=>{let t=Fxe,e=!0,r=Fxe.channel!==void 0;return{...Bxe(t,e,r),getCancelSignal:KAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Bxe=(t,e,r)=>({sendMessage:mM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Dxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Uxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as tgt}from"child_process";import{PassThrough as rgt,Readable as ngt,Writable as igt,Duplex as ogt}from"stream";var qxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{M5(n);let a=new tgt;sgt(a,n),Object.assign(a,{readable:agt,writable:cgt,duplex:ugt});let c=Iy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=lgt(c,s,i);return{subprocess:a,promise:u}},sgt=(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 rgt;return t.end(),t},agt=()=>new ngt({read(){}}),cgt=()=>new igt({write(){}}),ugt=()=>new ogt({read(){},write(){}}),lgt=async(t,e,r)=>Oy(t,e,r);import{createReadStream as Vxe,createWriteStream as Gxe}from"fs";import{Buffer as dgt}from"buffer";import{Readable as lR,Writable as fgt,Duplex as pgt}from"stream";var Wxe=(t,e)=>PM(hgt,t,e,!1),dR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Hxe={fileNumber:dR,generator:B5,asyncGenerator:B5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:pgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},hgt={input:{...Hxe,fileUrl:({value:t})=>({stream:Vxe(t)}),filePath:({value:{file:t}})=>({stream:Vxe(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(dgt.from(t))})},output:{...Hxe,fileUrl:({value:t})=>({stream:Gxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Gxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:fgt.fromWeb(t)}),iterable:dR,asyncIterable:dR,string:dR,uint8Array:dR}};import{on as mgt,once as Kxe}from"events";import{PassThrough as ggt,getDefaultHighWaterMark as _gt}from"stream";import{finished as Jxe}from"stream/promises";function nh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)K5(i);let e=t.some(({readableObjectMode:i})=>i),r=ygt(t,e),n=new W5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var ygt=(t,e)=>{if(t.length===0)return _gt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},W5=class extends ggt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(K5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Sgt(this,this.#e,this.#o);let r=bgt({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(K5(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)}},Sgt=async(t,e,r)=>{LM(t,Yxe);let n=new AbortController;try{await Promise.race([vgt(t,n),Egt(t,e,r,n)])}finally{n.abort(),LM(t,-Yxe)}},vgt=async(t,{signal:e})=>{try{await Jxe(t,{signal:e,cleanup:!0})}catch(r){throw Xxe(t,r),r}},Egt=async(t,e,r,{signal:n})=>{for await(let[i]of mgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},K5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},bgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{LM(t,Zxe);let a=new AbortController;try{await Promise.race([wgt(o,e,a),Tgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Agt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),LM(t,-Zxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?Y5(t):Rgt(t))},wgt=async(t,e,{signal:r})=>{try{await t,r.aborted||Y5(e)}catch(n){r.aborted||Xxe(e,n)}},Tgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Jxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Qxe(s)?i.add(e):eIe(t,s)}},Agt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Kxe(t,i,{signal:o}),!t.readable)return Kxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Rgt=t=>{t.writable&&t.end()},Xxe=(t,e)=>{Qxe(e)?Y5(t):eIe(t,e)},Qxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y5=t=>{(t.readable||t.writable)&&t.destroy()},eIe=(t,e)=>{t.destroyed||(t.once("error",xgt),t.destroy(e))},xgt=()=>{},LM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Yxe=2,Zxe=1;import{finished as tIe}from"stream/promises";var Cy=(t,e)=>{t.pipe(e),Igt(t,e),Ogt(t,e)},Igt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await tIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}Z5(e)}},Z5=t=>{t.writable&&t.end()},Ogt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await tIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}J5(t)}},J5=t=>{t.readable&&t.destroy()};var rIe=(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)))Pgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qo.has(c)))kgt({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)}},Pgt=(t,e,r,n)=>{r==="output"?Cy(t.stdio[n],e):Cy(e,t.stdio[n]);let i=Cgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Cgt=["stdin","stdout","stderr"],kgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Ngt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Ngt=(t,{signal:e})=>{ca(t)&&Qp(t,$gt,e)},$gt=2;import{addAbortListener as Lgt}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 UM=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",X5=Symbol.for("signal-exit emitter"),Q5=globalThis,Dgt=Object.defineProperty.bind(Object),e8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Q5[X5])return Q5[X5];Dgt(Q5,X5,{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}},FM=class{},Mgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),t8=class extends FM{onExit(){return()=>{}}load(){}unload(){}},r8=class extends FM{#e=n8.platform==="win32"?"SIGINT":"SIGHUP";#r=new e8;#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(!UM(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 UM(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"&&UM(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)}},n8=globalThis.process,{onExit:nIe,load:Lfr,unload:Ufr}=Mgt(UM(n8)?new r8(n8):new t8);var iIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=nIe(()=>{t.kill()});Lgt(n,()=>{i()})};var sIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=ZD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=Ugt(r,n,i),{sourceStream:d,sourceError:f}=zgt(t,u),{options:p,fileDescriptors:h}=ac.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},Ugt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Fgt(t,e,...r),a=sM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Fgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(oIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||H9(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]=zD(r,...n);return{destination:e(oIe)(i,o,s),pipeOptions:s}}if(ac.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}`)},oIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),zgt=(t,e)=>{try{return{sourceStream:Ty(t,e)}}catch(r){return{sourceError:r}}};var cIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=jgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw i8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},jgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return J5(t),n;if(e!==void 0)return Z5(r),e},i8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Iy({error:t,command:aIe,escapedCommand:aIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),aIe="source.pipe(destination)";var uIe=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 lIe=(t,e,r)=>{let n=zM.has(e)?Vgt(t,e):qgt(t,e);return Qp(t,Hgt,r.signal),Qp(e,Wgt,r.signal),Ggt(e),n},qgt=(t,e)=>{let r=nh([t]);return Cy(r,e),zM.set(e,r),r},Vgt=(t,e)=>{let r=zM.get(e);return r.add(t),r},Ggt=async t=>{try{await Bgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zM.delete(t)},zM=new WeakMap,Hgt=2,Wgt=1;import{aborted as Kgt}from"util";var dIe=(t,e)=>t===void 0?[]:[Ygt(t,e)],Ygt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Kgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw i8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var jM=(t,...e)=>{if(Tr(e[0]))return jM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=sIe(t,...e),i=Zgt({...n,destination:r});return i.pipe=jM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Zgt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Jgt(t,i);cIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=lIe(e,o,d);return await Promise.race([uIe(l),...dIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Jgt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as i_t}from"timers/promises";import{on as Xgt}from"events";import{getDefaultHighWaterMark as Qgt}from"stream";var BM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return e_t(e,s),pIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},e_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},o8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;t_t(e,s,t);let a=t.readableObjectMode&&!o;return pIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},t_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},pIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Xgt(t,"data",{signal:e.signal,highWaterMark:fIe,highWatermark:fIe});return r_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},s8=Qgt(!0),fIe=s8,r_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=n_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)}},n_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[kM(t,r,!e),CM(t,i,!n,{})].filter(Boolean);var hIe=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=o_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([s_t(t),d]);return}let f=L5(c,r),p=o8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([a_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},o_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!DM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=o8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Axe(a,t,r,o)},s_t=async t=>{await i_t(),t.readableFlowing===null&&t.resume()},a_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await bM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await wM(r,{maxBuffer:o})):await xy(r,{maxBuffer:o})}catch(a){return mIe(ARe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},a8=async t=>{try{return await t}catch(e){return mIe(e)}},mIe=({bufferedData:t})=>jwe(t)?new Uint8Array(t):t;import{finished as c_t}from"stream/promises";var fR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=u_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],c_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||f_t(a,e,r,n)}finally{s.abort()}},u_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&l_t(t,r,n),n},l_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{d_t(e,r),n.call(t,...i)}},d_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},f_t=(t,e,r,n)=>{if(!p_t(t,e,r,n))throw t},p_t=(t,e,r,n=!0)=>r.propagating?gIe(t)||qM(t):(r.propagating=!0,c8(r,e)===n?gIe(t):qM(t)),c8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",qM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",gIe=t=>t?.code==="EPIPE";var _Ie=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>u8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),u8=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(c8(u,e)){await l;return}let[d]=await Promise.all([hIe({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 yIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?nh([t,e].filter(Boolean)):void 0,SIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>u8({...h_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:m_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),h_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}},m_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as g_t}from"events";var vIe=t=>Sy(t,"ipc"),EIe=(t,e)=>{let r=YD(t);oc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var bIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=vIe(o),a=bu(e,"ipc"),c=bu(r,"ipc");for await(let u of H5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(RRe(t,i,c),i.push(u)),s&&EIe(u,o);return i},wIe=async(t,e)=>(await Promise.allSettled([t]),e);var TIe=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=Pxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=_Ie({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=SIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=[],R=bIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=__t(m,t,A),O=y_t(h,A);try{return await Promise.race([Promise.all([{},kxe(v),Promise.all(S),b,R,iRe(t,d),...C,...O]),_,S_t(t,y),...QAe(t,o,f,y),...vAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...JAe({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=>a8(T))),a8(b),wIe(R,E),Promise.allSettled(C),Promise.allSettled(O)])}},__t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:fR(n,i,r)),y_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"}))),S_t=async(t,{signal:e})=>{let[r]=await g_t(t,"error",{signal:e});throw r};var AIe=()=>({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=sc();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 v_t}from"stream";import{callbackify as E_t}from"util";import{finished as RIe}from"stream/promises";var l8=async t=>{if(t!==void 0)try{await d8(t)}catch{}},xIe=async t=>{if(t!==void 0)try{await f8(t)}catch{}},d8=async t=>{await RIe(t,{cleanup:!0,readable:!1,writable:!0})},f8=async t=>{await RIe(t,{cleanup:!0,readable:!0,writable:!1})},VM=async(t,e)=>{if(await t,e)throw e},GM=(t,e,r)=>{r&&!qM(r)?t.destroy(r):e&&t.destroy()};var IIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||go.has(r),{subprocessStdout:a,waitReadableDestroy:c}=p8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=h8(a,s),{read:f,onStdoutDataDone:p}=m8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new v_t({read:f,destroy:E_t(_8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return g8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},p8=(t,e,r)=>{let n=Ty(t,e),i=pR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},h8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:s8},m8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=sc(),s=BM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){b_t(this,s,o)},onStdoutDataDone:o}},b_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},g8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await f8(t),await n,await l8(i),await e,r.readable&&r.push(null)}catch(o){await l8(i),OIe(r,o)}},_8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ky(r,e)&&(OIe(t,n),await VM(e,n))},OIe=(t,e)=>{GM(t,t.readable,e)};import{Writable as w_t}from"stream";import{callbackify as PIe}from"util";var CIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=y8(t,r,e),s=new w_t({...S8(n,t,i),destroy:PIe(E8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return v8(n,s),s},y8=(t,e,r)=>{let n=sM(t,e),i=pR(r,n,"writableFinal"),o=pR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},S8=(t,e,r)=>({write:T_t.bind(void 0,t),final:PIe(A_t.bind(void 0,t,e,r))}),T_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},A_t=async(t,e,r)=>{await ky(r,e)&&(t.writable&&t.end(),await e)},v8=async(t,e,r)=>{try{await d8(t),e.writable&&e.end()}catch(n){await xIe(r),kIe(e,n)}},E8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ky(r,e),await ky(n,e)&&(kIe(t,i),await VM(e,i))},kIe=(t,e)=>{GM(t,t.writable,e)};import{Duplex as R_t}from"stream";import{callbackify as x_t}from"util";var NIe=({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}=p8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=y8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=h8(c,a),{read:_,onStdoutDataDone:y}=m8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new R_t({read:_,...S8(l,t,d),destroy:x_t(I_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 g8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),v8(l,v,c),v},I_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([_8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),E8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var b8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||go.has(e),s=Ty(t,r),a=BM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return O_t(a,s,t)},O_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var $Ie=(t,{encoding:e})=>{let r=AIe();t.readable=IIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=CIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=NIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=b8.bind(void 0,t,e),t[Symbol.asyncIterator]=b8.bind(void 0,t,e,{})};var DIe=(t,e)=>{for(let[r,n]of C_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},P_t=(async()=>{})().constructor.prototype,C_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(P_t,t)]);var MIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=$_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=jM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),DIe(f,p),ac.set(f,{options:l,fileDescriptors:d}),f},$_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),{file:a,commandArguments:c,options:u}=_M(t,e,r),l=D_t(u),d=Wxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},D_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=N_t(...yM(t,e,r))}catch(h){return qxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;k_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];rIe(c,a,u),iIe(c,r,u);let d={},f=sc();c.kill=yAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=yIe(c,r),$Ie(c,r),zxe(c,r);let p=L_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}},L_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 TIe({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=U_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)},U_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 cc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):RM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var HM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,F_t(n,t[n],i)]));return{...t,...r}},F_t=(t,e,r)=>z_t.has(t)&&Tr(e)&&Tr(r)?{...e,...r}:r,z_t=new Set(["env",...X9]);var hd=(t,e,r,n)=>{let i=(s,a,c)=>hd(s,a,r,c),o=(...s)=>j_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},j_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Tr(o))return i(t,HM(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?$xe(a,c,u):MIe(a,c,u,i)},B_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Wwe(e)?Kwe(e,r):[e,...r],[s,a,c]=zD(...o),u=HM(HM(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 LIe=({file:t,commandArguments:e})=>FIe(t,e),UIe=({file:t,commandArguments:e})=>({...FIe(t,e),isSync:!0}),FIe=(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]=q_t(t);return{file:r,commandArguments:n}},q_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(V_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},V_t=/ +/g;var zIe=(t,e,r)=>{t.sync=e(G_t,r),t.s=t.sync},jIe=({options:t})=>BIe(t),G_t=({options:t})=>({...BIe(t),isSync:!0}),BIe=t=>({options:{...H_t(t),...t}}),H_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},qIe={preferLocal:!0};var VIe=hd(()=>({})),xmr=hd(()=>({isSync:!0})),GIe=hd(LIe),Imr=hd(UIe),Omr=hd(tRe),Pmr=hd(jIe,{},qIe,zIe),{sendMessage:Cmr,getOneMessage:kmr,getEachMessage:Nmr,getCancelSignal:$mr}=jxe();var HIe=!1,WIe,W_t=t=>{WIe??=t},KIe=t=>{HIe=!0,W_t(t)},Gn=()=>HIe,Au=()=>WIe,YIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var hR=null,ZIe=t=>(hR&&hR.destroy(),hR=new es({totalAllowedTime:t}),hR),JIe=()=>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 XIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.10.0-setup-request-skip.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!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 J_t=Y_t(import.meta.url),X_t=Ru.dirname(J_t),Q_t=Z_t(import.meta.url),Ny=oe("shell"),w8=new Set,QIe={preferLocal:!0},vt=(t,e,r)=>{let[n,i]=eyt(e,r),o={...QIe,...i},s=VIe(t,n,o);tOe(s,o),iOe(s);let a=r?.idleTimeout;return a&&a>0&&nOe(s,a),s},eOe=(t,e)=>{let r={...QIe,...e},n=GIe(t,r);return tOe(n,r),iOe(n),e?.idleTimeout&&e.idleTimeout>0&&nOe(n,e.idleTimeout),n},eyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},tOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||lc.env.NETLIFY_LOCAL_QUIET==="true")return;if(lc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Lw).pipe(lc.stdout),t.stderr?.pipe(new Lw).pipe(lc.stderr);return}t.stdout?.pipe(lc.stdout),t.stderr?.pipe(lc.stderr)},T8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(lc.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}},rOe=t=>T8(t,"SIGKILL"),nOe=(t,e)=>{let r=null,n=()=>{Ny.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),T8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing idle process ${t.pid}`),rOe(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)},iOe=t=>{w8.add(t);let e=JIe();if(e){let r=e.onTimesUp(()=>{Ny.log(`Global timer expired, killing process ${t.pid}`),T8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing process ${t.pid} after timeout`),rOe(t))},5e3)});t.on("exit",()=>{w8.delete(t),r()}),t.on("error",()=>{w8.delete(t),r()})}};function KM(t,e){return!!fa(t,e)}function fa(t,e){if(!lc.env.NETLIFY_LOCAL_MODE)try{let i=Q_t.resolve(XIe.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(WM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(lc.env.NODE_PATH){let i=Ru.join(lc.env.NODE_PATH,".bin",e);if(WM.existsSync(i))return i}let r=Ru.join(t,"node_modules",".bin",e);if(WM.existsSync(r))return r;let n=Ru.join(X_t,"..","node_modules",".bin",e);if(WM.existsSync(n))return n}var $y=oe("repo"),dOe="runner-diffs-",A8=t=>`${dOe}${t}-`,fOe=async t=>{let e=ZM.tmpdir(),r;try{r=await mi.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(dOe)&&!n.startsWith(A8(t))).map(n=>mi.rm(ts.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},oOe=async t=>{let e=tyt("sha256");for await(let r of ryt(t))e.update(r);return e.digest("hex")},sOe=async(t,e)=>t.size===e.size&&await oOe(t.path)===await oOe(e.path),pOe=/.. (.+)?\.log$/,nyt=[pOe],iyt=1,aOe=t=>{let e=t.split(`
|
|
386
|
+
if (condition) { yield value; }`)};import{Buffer as dmt}from"buffer";import{StringDecoder as fmt}from"string_decoder";var kM=(t,e,r)=>{if(r)return;if(t)return{transform:pmt.bind(void 0,new TextEncoder)};let n=new fmt(e);return{transform:hmt.bind(void 0,n),final:mmt.bind(void 0,n)}},pmt=function*(t,e){dmt.isBuffer(e)?yield Eu(e):typeof e=="string"?yield t.encode(e):yield e},hmt=function*(t,e){yield Kr(e)?t.write(e):e},mmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as yxe}from"util";var z5=yxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),NM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_mt}=e[r];for await(let i of n(t))yield*NM(i,e,r+1)},Sxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*gmt(r,Number(e),t)},gmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*NM(n,r,e+1)},vxe=yxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),_mt=function*(t){yield t};var j5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Exe=(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=Smt}=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*ymt(r,Number(e),t)},ymt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*rh(n,r,e+1)},Smt=function*(t){yield t};var B5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=wxe(t,s,o),u=th(e),l=th(r),d=u?z5.bind(void 0,NM,a):j5.bind(void 0,rh),f=u||l?z5.bind(void 0,Sxe,a):j5.bind(void 0,cR),p=u||l?vxe.bind(void 0,a):void 0;return{stream:new vmt({writableObjectMode:n,writableHighWaterMark:bxe(n),readableObjectMode:i,readableHighWaterMark:bxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},$M=(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=wxe(s,r,a);t=Exe(c,t)}return t},wxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:mxe(n,a)},kM(r,s,n),CM(r,o,n,c),{transform:t,final:e},{transform:gxe(i,a)},hxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Txe=(t,e)=>{for(let r of Emt(t))bmt(t,r,e)},Emt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),bmt=(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=>wmt(a,n));r.input=XA(s)},wmt=(t,e)=>{let r=$M(t,e,"utf8",!0);return Tmt(r),XA(r)},Tmt=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 Imt,appendFileSync as Omt}from"fs";var DM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sy(r,n)&&!go.has(e)&&Amt(n)&&(t.some(({type:i,value:o})=>i==="native"&&Rmt.has(o))||t.every(({type:i})=>Qo.has(i))),Amt=t=>t===1||t===2,Rmt=new Set(["pipe","overlapped"]),Axe=async(t,e,r,n)=>{for await(let i of t)xmt(e)||xxe(i,r,n)},Rxe=(t,e,r)=>{for(let n of t)xxe(n,e,r)},xmt=t=>t._readableState.pipes.length>0,xxe=(t,e,r)=>{let n=YD(t);oc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Ixe=({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)=>Pmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Pmt=({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=ORe(t,o,d),p=Eu(f),{stdioItems:h,objectMode:m}=e[r],_=Cmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=kmt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Nmt({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&&$mt(y,h,i),A}catch(S){return n.error=S,A}},Cmt=(t,e,r,n)=>{try{return $M(t,e,r,!1)}catch(i){return n.error=i,t}},kmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:XA(t)};let s=qwe(t,r);return n[o]?{serializedResult:s,finalResult:F5(s,!i[o],e)}:{serializedResult:s}},Nmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!DM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=F5(t,!1,s);try{Rxe(a,e,n)}catch(c){r.error??=c}},$mt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>OM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?Omt(n,t):(r.add(o),Imt(n,t))}};var Oxe=([,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)?K9([t,e]):`${t}${e}`};import{once as q5}from"events";var Pxe=async(t,e)=>{let[r,n]=await Dmt(t);return e.isForcefullyTerminated??=!1,[r,n]},Dmt=async t=>{let[e,r]=await Promise.allSettled([q5(t,"spawn"),q5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Cxe(t):r.value},Cxe=async t=>{try{return await q5(t,"exit")}catch{return Cxe(t)}},kxe=async t=>{let[e,r]=await t;if(!Mmt(e,r)&&V5(e,r))throw new ua;return[e,r]},Mmt=(t,e)=>t===void 0&&e===void 0,V5=(t,e)=>t!==0||e!==null;var Nxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=Lmt(t,e,r),s=o?.code==="ETIMEDOUT",a=IRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},Lmt=(t,e,r)=>t!==void 0?t:V5(e,r)?new ua:void 0;var $xe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Fmt(t,e,r),d=Bmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Oy(d,c,u)},Fmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),a=zmt(r),{file:c,commandArguments:u,options:l}=_M(t,e,a);jmt(l);let d=lxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},zmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,jmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&MM("ipcInput"),t&&MM("ipc: true"),r&&MM("detached: true"),n&&MM("cancelSignal")},MM=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=qmt({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}=Nxe(c,r),{output:h,error:m=u}=Ixe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Tu(v,r,A)),y=Tu(Oxe(h,r),r,"all");return Gmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},qmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Txe(o,r);let a=Vmt(r);return Umt(...yM(t,e,a))}catch(a){return Iy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Vmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:AM(e)}),Gmt=({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?RM({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 k_t}from"events";import{spawn as N_t}from"child_process";import Fxe from"process";import{once as G5,on as Hmt}from"events";var Dxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(by({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:dM(t)}),Wmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Wmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{aM(e,i);let o=fd(t,e,r),s=new AbortController;try{return await Promise.race([Kmt(o,n,s),Ymt(o,r,s),Zmt(o,r,s)])}catch(a){throw wy(t),a}finally{s.abort(),cM(e,i)}},Kmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await G5(t,"message",{signal:r});return n}for await(let[n]of Hmt(t,"message",{signal:r}))if(e(n))return n},Ymt=async(t,e,{signal:r})=>{await G5(t,"disconnect",{signal:r}),EAe(e)},Zmt=async(t,e,{signal:r})=>{let[n]=await G5(t,"strict:error",{signal:r});throw iM(n,e)};import{once as Lxe,on as Jmt}from"events";var Uxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>H5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),H5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{by({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:dM(t)}),aM(e,o);let s=fd(t,e,r),a=new AbortController,c={};return Xmt(t,s,a),Qmt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),egt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Xmt=async(t,e,r)=>{try{await Lxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Qmt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Lxe(t,"strict:error",{signal:r.signal});n.error=iM(i,e),r.abort()}catch{}},egt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Jmt(r,"message",{signal:o.signal}))Mxe(s),yield c}catch{Mxe(s)}finally{o.abort(),cM(e,a),n||wy(t),i&&await t}},Mxe=({error:t})=>{if(t)throw t};var zxe=(t,{ipc:e})=>{Object.assign(t,Bxe(t,!1,e))},jxe=()=>{let t=Fxe,e=!0,r=Fxe.channel!==void 0;return{...Bxe(t,e,r),getCancelSignal:KAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Bxe=(t,e,r)=>({sendMessage:mM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Dxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Uxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as tgt}from"child_process";import{PassThrough as rgt,Readable as ngt,Writable as igt,Duplex as ogt}from"stream";var qxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{M5(n);let a=new tgt;sgt(a,n),Object.assign(a,{readable:agt,writable:cgt,duplex:ugt});let c=Iy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=lgt(c,s,i);return{subprocess:a,promise:u}},sgt=(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 rgt;return t.end(),t},agt=()=>new ngt({read(){}}),cgt=()=>new igt({write(){}}),ugt=()=>new ogt({read(){},write(){}}),lgt=async(t,e,r)=>Oy(t,e,r);import{createReadStream as Vxe,createWriteStream as Gxe}from"fs";import{Buffer as dgt}from"buffer";import{Readable as lR,Writable as fgt,Duplex as pgt}from"stream";var Wxe=(t,e)=>PM(hgt,t,e,!1),dR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Hxe={fileNumber:dR,generator:B5,asyncGenerator:B5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:pgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},hgt={input:{...Hxe,fileUrl:({value:t})=>({stream:Vxe(t)}),filePath:({value:{file:t}})=>({stream:Vxe(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(dgt.from(t))})},output:{...Hxe,fileUrl:({value:t})=>({stream:Gxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Gxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:fgt.fromWeb(t)}),iterable:dR,asyncIterable:dR,string:dR,uint8Array:dR}};import{on as mgt,once as Kxe}from"events";import{PassThrough as ggt,getDefaultHighWaterMark as _gt}from"stream";import{finished as Jxe}from"stream/promises";function nh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)K5(i);let e=t.some(({readableObjectMode:i})=>i),r=ygt(t,e),n=new W5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var ygt=(t,e)=>{if(t.length===0)return _gt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},W5=class extends ggt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(K5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Sgt(this,this.#e,this.#o);let r=bgt({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(K5(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)}},Sgt=async(t,e,r)=>{LM(t,Yxe);let n=new AbortController;try{await Promise.race([vgt(t,n),Egt(t,e,r,n)])}finally{n.abort(),LM(t,-Yxe)}},vgt=async(t,{signal:e})=>{try{await Jxe(t,{signal:e,cleanup:!0})}catch(r){throw Xxe(t,r),r}},Egt=async(t,e,r,{signal:n})=>{for await(let[i]of mgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},K5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},bgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{LM(t,Zxe);let a=new AbortController;try{await Promise.race([wgt(o,e,a),Tgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Agt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),LM(t,-Zxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?Y5(t):Rgt(t))},wgt=async(t,e,{signal:r})=>{try{await t,r.aborted||Y5(e)}catch(n){r.aborted||Xxe(e,n)}},Tgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Jxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Qxe(s)?i.add(e):eIe(t,s)}},Agt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Kxe(t,i,{signal:o}),!t.readable)return Kxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Rgt=t=>{t.writable&&t.end()},Xxe=(t,e)=>{Qxe(e)?Y5(t):eIe(t,e)},Qxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y5=t=>{(t.readable||t.writable)&&t.destroy()},eIe=(t,e)=>{t.destroyed||(t.once("error",xgt),t.destroy(e))},xgt=()=>{},LM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Yxe=2,Zxe=1;import{finished as tIe}from"stream/promises";var Cy=(t,e)=>{t.pipe(e),Igt(t,e),Ogt(t,e)},Igt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await tIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}Z5(e)}},Z5=t=>{t.writable&&t.end()},Ogt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await tIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}J5(t)}},J5=t=>{t.readable&&t.destroy()};var rIe=(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)))Pgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qo.has(c)))kgt({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)}},Pgt=(t,e,r,n)=>{r==="output"?Cy(t.stdio[n],e):Cy(e,t.stdio[n]);let i=Cgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Cgt=["stdin","stdout","stderr"],kgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Ngt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Ngt=(t,{signal:e})=>{ca(t)&&Qp(t,$gt,e)},$gt=2;import{addAbortListener as Lgt}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 UM=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",X5=Symbol.for("signal-exit emitter"),Q5=globalThis,Dgt=Object.defineProperty.bind(Object),e8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Q5[X5])return Q5[X5];Dgt(Q5,X5,{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}},FM=class{},Mgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),t8=class extends FM{onExit(){return()=>{}}load(){}unload(){}},r8=class extends FM{#e=n8.platform==="win32"?"SIGINT":"SIGHUP";#r=new e8;#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(!UM(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 UM(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"&&UM(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)}},n8=globalThis.process,{onExit:nIe,load:Lfr,unload:Ufr}=Mgt(UM(n8)?new r8(n8):new t8);var iIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=nIe(()=>{t.kill()});Lgt(n,()=>{i()})};var sIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=ZD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=Ugt(r,n,i),{sourceStream:d,sourceError:f}=zgt(t,u),{options:p,fileDescriptors:h}=ac.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},Ugt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Fgt(t,e,...r),a=sM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Fgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(oIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||H9(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]=zD(r,...n);return{destination:e(oIe)(i,o,s),pipeOptions:s}}if(ac.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}`)},oIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),zgt=(t,e)=>{try{return{sourceStream:Ty(t,e)}}catch(r){return{sourceError:r}}};var cIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=jgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw i8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},jgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return J5(t),n;if(e!==void 0)return Z5(r),e},i8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Iy({error:t,command:aIe,escapedCommand:aIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),aIe="source.pipe(destination)";var uIe=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 lIe=(t,e,r)=>{let n=zM.has(e)?Vgt(t,e):qgt(t,e);return Qp(t,Hgt,r.signal),Qp(e,Wgt,r.signal),Ggt(e),n},qgt=(t,e)=>{let r=nh([t]);return Cy(r,e),zM.set(e,r),r},Vgt=(t,e)=>{let r=zM.get(e);return r.add(t),r},Ggt=async t=>{try{await Bgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zM.delete(t)},zM=new WeakMap,Hgt=2,Wgt=1;import{aborted as Kgt}from"util";var dIe=(t,e)=>t===void 0?[]:[Ygt(t,e)],Ygt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Kgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw i8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var jM=(t,...e)=>{if(Tr(e[0]))return jM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=sIe(t,...e),i=Zgt({...n,destination:r});return i.pipe=jM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Zgt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Jgt(t,i);cIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=lIe(e,o,d);return await Promise.race([uIe(l),...dIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Jgt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as i_t}from"timers/promises";import{on as Xgt}from"events";import{getDefaultHighWaterMark as Qgt}from"stream";var BM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return e_t(e,s),pIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},e_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},o8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;t_t(e,s,t);let a=t.readableObjectMode&&!o;return pIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},t_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},pIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Xgt(t,"data",{signal:e.signal,highWaterMark:fIe,highWatermark:fIe});return r_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},s8=Qgt(!0),fIe=s8,r_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=n_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)}},n_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[kM(t,r,!e),CM(t,i,!n,{})].filter(Boolean);var hIe=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=o_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([s_t(t),d]);return}let f=L5(c,r),p=o8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([a_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},o_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!DM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=o8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Axe(a,t,r,o)},s_t=async t=>{await i_t(),t.readableFlowing===null&&t.resume()},a_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await bM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await wM(r,{maxBuffer:o})):await xy(r,{maxBuffer:o})}catch(a){return mIe(ARe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},a8=async t=>{try{return await t}catch(e){return mIe(e)}},mIe=({bufferedData:t})=>jwe(t)?new Uint8Array(t):t;import{finished as c_t}from"stream/promises";var fR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=u_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],c_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||f_t(a,e,r,n)}finally{s.abort()}},u_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&l_t(t,r,n),n},l_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{d_t(e,r),n.call(t,...i)}},d_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},f_t=(t,e,r,n)=>{if(!p_t(t,e,r,n))throw t},p_t=(t,e,r,n=!0)=>r.propagating?gIe(t)||qM(t):(r.propagating=!0,c8(r,e)===n?gIe(t):qM(t)),c8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",qM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",gIe=t=>t?.code==="EPIPE";var _Ie=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>u8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),u8=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(c8(u,e)){await l;return}let[d]=await Promise.all([hIe({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 yIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?nh([t,e].filter(Boolean)):void 0,SIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>u8({...h_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:m_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),h_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}},m_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as g_t}from"events";var vIe=t=>Sy(t,"ipc"),EIe=(t,e)=>{let r=YD(t);oc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var bIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=vIe(o),a=bu(e,"ipc"),c=bu(r,"ipc");for await(let u of H5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(RRe(t,i,c),i.push(u)),s&&EIe(u,o);return i},wIe=async(t,e)=>(await Promise.allSettled([t]),e);var TIe=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=Pxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=_Ie({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=SIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=[],R=bIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=__t(m,t,A),O=y_t(h,A);try{return await Promise.race([Promise.all([{},kxe(v),Promise.all(S),b,R,iRe(t,d),...C,...O]),_,S_t(t,y),...QAe(t,o,f,y),...vAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...JAe({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=>a8(T))),a8(b),wIe(R,E),Promise.allSettled(C),Promise.allSettled(O)])}},__t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:fR(n,i,r)),y_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"}))),S_t=async(t,{signal:e})=>{let[r]=await g_t(t,"error",{signal:e});throw r};var AIe=()=>({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=sc();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 v_t}from"stream";import{callbackify as E_t}from"util";import{finished as RIe}from"stream/promises";var l8=async t=>{if(t!==void 0)try{await d8(t)}catch{}},xIe=async t=>{if(t!==void 0)try{await f8(t)}catch{}},d8=async t=>{await RIe(t,{cleanup:!0,readable:!1,writable:!0})},f8=async t=>{await RIe(t,{cleanup:!0,readable:!0,writable:!1})},VM=async(t,e)=>{if(await t,e)throw e},GM=(t,e,r)=>{r&&!qM(r)?t.destroy(r):e&&t.destroy()};var IIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||go.has(r),{subprocessStdout:a,waitReadableDestroy:c}=p8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=h8(a,s),{read:f,onStdoutDataDone:p}=m8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new v_t({read:f,destroy:E_t(_8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return g8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},p8=(t,e,r)=>{let n=Ty(t,e),i=pR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},h8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:s8},m8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=sc(),s=BM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){b_t(this,s,o)},onStdoutDataDone:o}},b_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},g8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await f8(t),await n,await l8(i),await e,r.readable&&r.push(null)}catch(o){await l8(i),OIe(r,o)}},_8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ky(r,e)&&(OIe(t,n),await VM(e,n))},OIe=(t,e)=>{GM(t,t.readable,e)};import{Writable as w_t}from"stream";import{callbackify as PIe}from"util";var CIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=y8(t,r,e),s=new w_t({...S8(n,t,i),destroy:PIe(E8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return v8(n,s),s},y8=(t,e,r)=>{let n=sM(t,e),i=pR(r,n,"writableFinal"),o=pR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},S8=(t,e,r)=>({write:T_t.bind(void 0,t),final:PIe(A_t.bind(void 0,t,e,r))}),T_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},A_t=async(t,e,r)=>{await ky(r,e)&&(t.writable&&t.end(),await e)},v8=async(t,e,r)=>{try{await d8(t),e.writable&&e.end()}catch(n){await xIe(r),kIe(e,n)}},E8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ky(r,e),await ky(n,e)&&(kIe(t,i),await VM(e,i))},kIe=(t,e)=>{GM(t,t.writable,e)};import{Duplex as R_t}from"stream";import{callbackify as x_t}from"util";var NIe=({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}=p8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=y8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=h8(c,a),{read:_,onStdoutDataDone:y}=m8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new R_t({read:_,...S8(l,t,d),destroy:x_t(I_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 g8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),v8(l,v,c),v},I_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([_8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),E8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var b8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||go.has(e),s=Ty(t,r),a=BM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return O_t(a,s,t)},O_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var $Ie=(t,{encoding:e})=>{let r=AIe();t.readable=IIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=CIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=NIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=b8.bind(void 0,t,e),t[Symbol.asyncIterator]=b8.bind(void 0,t,e,{})};var DIe=(t,e)=>{for(let[r,n]of C_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},P_t=(async()=>{})().constructor.prototype,C_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(P_t,t)]);var MIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=$_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=jM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),DIe(f,p),ac.set(f,{options:l,fileDescriptors:d}),f},$_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),{file:a,commandArguments:c,options:u}=_M(t,e,r),l=D_t(u),d=Wxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},D_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=N_t(...yM(t,e,r))}catch(h){return qxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;k_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];rIe(c,a,u),iIe(c,r,u);let d={},f=sc();c.kill=yAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=yIe(c,r),$Ie(c,r),zxe(c,r);let p=L_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}},L_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 TIe({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=U_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)},U_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 cc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):RM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var HM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,F_t(n,t[n],i)]));return{...t,...r}},F_t=(t,e,r)=>z_t.has(t)&&Tr(e)&&Tr(r)?{...e,...r}:r,z_t=new Set(["env",...X9]);var hd=(t,e,r,n)=>{let i=(s,a,c)=>hd(s,a,r,c),o=(...s)=>j_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},j_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Tr(o))return i(t,HM(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?$xe(a,c,u):MIe(a,c,u,i)},B_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Wwe(e)?Kwe(e,r):[e,...r],[s,a,c]=zD(...o),u=HM(HM(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 LIe=({file:t,commandArguments:e})=>FIe(t,e),UIe=({file:t,commandArguments:e})=>({...FIe(t,e),isSync:!0}),FIe=(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]=q_t(t);return{file:r,commandArguments:n}},q_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(V_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},V_t=/ +/g;var zIe=(t,e,r)=>{t.sync=e(G_t,r),t.s=t.sync},jIe=({options:t})=>BIe(t),G_t=({options:t})=>({...BIe(t),isSync:!0}),BIe=t=>({options:{...H_t(t),...t}}),H_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},qIe={preferLocal:!0};var VIe=hd(()=>({})),xmr=hd(()=>({isSync:!0})),GIe=hd(LIe),Imr=hd(UIe),Omr=hd(tRe),Pmr=hd(jIe,{},qIe,zIe),{sendMessage:Cmr,getOneMessage:kmr,getEachMessage:Nmr,getCancelSignal:$mr}=jxe();var HIe=!1,WIe,W_t=t=>{WIe??=t},KIe=t=>{HIe=!0,W_t(t)},Gn=()=>HIe,Au=()=>WIe,YIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var hR=null,ZIe=t=>(hR&&hR.destroy(),hR=new es({totalAllowedTime:t}),hR),JIe=()=>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 XIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.11.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!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 J_t=Y_t(import.meta.url),X_t=Ru.dirname(J_t),Q_t=Z_t(import.meta.url),Ny=oe("shell"),w8=new Set,QIe={preferLocal:!0},vt=(t,e,r)=>{let[n,i]=eyt(e,r),o={...QIe,...i},s=VIe(t,n,o);tOe(s,o),iOe(s);let a=r?.idleTimeout;return a&&a>0&&nOe(s,a),s},eOe=(t,e)=>{let r={...QIe,...e},n=GIe(t,r);return tOe(n,r),iOe(n),e?.idleTimeout&&e.idleTimeout>0&&nOe(n,e.idleTimeout),n},eyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},tOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||lc.env.NETLIFY_LOCAL_QUIET==="true")return;if(lc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Lw).pipe(lc.stdout),t.stderr?.pipe(new Lw).pipe(lc.stderr);return}t.stdout?.pipe(lc.stdout),t.stderr?.pipe(lc.stderr)},T8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(lc.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}},rOe=t=>T8(t,"SIGKILL"),nOe=(t,e)=>{let r=null,n=()=>{Ny.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),T8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing idle process ${t.pid}`),rOe(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)},iOe=t=>{w8.add(t);let e=JIe();if(e){let r=e.onTimesUp(()=>{Ny.log(`Global timer expired, killing process ${t.pid}`),T8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing process ${t.pid} after timeout`),rOe(t))},5e3)});t.on("exit",()=>{w8.delete(t),r()}),t.on("error",()=>{w8.delete(t),r()})}};function KM(t,e){return!!fa(t,e)}function fa(t,e){if(!lc.env.NETLIFY_LOCAL_MODE)try{let i=Q_t.resolve(XIe.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(WM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(lc.env.NODE_PATH){let i=Ru.join(lc.env.NODE_PATH,".bin",e);if(WM.existsSync(i))return i}let r=Ru.join(t,"node_modules",".bin",e);if(WM.existsSync(r))return r;let n=Ru.join(X_t,"..","node_modules",".bin",e);if(WM.existsSync(n))return n}var $y=oe("repo"),dOe="runner-diffs-",A8=t=>`${dOe}${t}-`,fOe=async t=>{let e=ZM.tmpdir(),r;try{r=await mi.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(dOe)&&!n.startsWith(A8(t))).map(n=>mi.rm(ts.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},oOe=async t=>{let e=tyt("sha256");for await(let r of ryt(t))e.update(r);return e.digest("hex")},sOe=async(t,e)=>t.size===e.size&&await oOe(t.path)===await oOe(e.path),pOe=/.. (.+)?\.log$/,nyt=[pOe],iyt=1,aOe=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)},oyt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),cOe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return Rn(r?`${e}: ${r}`:e)},syt=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),uOe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),ayt=(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&&uOe(n)===uOe(r)&&n.password!==""}catch{return!1}},lOe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},YM=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=aOe(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(ZM.tmpdir(),A8(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=>nyt.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+=YM){let o=e.slice(i,i+YM).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...lOe,...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:KQ},zzt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},qzt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:zzt};import{Buffer as Bzt}from"buffer";var BLe=(t,e)=>t?void 0:Vzt.bind(void 0,e),Vzt=function*(t,e){if(typeof e!="string"&&!xn(e)&&!Bzt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},VLe=(t,e)=>t?Hzt.bind(void 0,e):Gzt.bind(void 0,e),Hzt=function*(t,e){HLe(t,e),yield e},Gzt=function*(t,e){if(HLe(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},HLe=(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 Wzt}from"buffer";import{StringDecoder as Kzt}from"string_decoder";var lU=(t,e,r)=>{if(r)return;if(t)return{transform:Yzt.bind(void 0,new TextEncoder)};let n=new Kzt(e);return{transform:Jzt.bind(void 0,n),final:Zzt.bind(void 0,n)}},Yzt=function*(t,e){Wzt.isBuffer(e)?yield Al(e):typeof e=="string"?yield t.encode(e):yield e},Jzt=function*(t,e){yield xn(e)?t.write(e):e},Zzt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as GLe}from"util";var JQ=GLe(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=Qzt}=e[r];for await(let i of n(t))yield*dU(i,e,r+1)},WLe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Xzt(r,Number(e),t)},Xzt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*dU(n,r,e+1)},KLe=GLe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Qzt=function*(t){yield t};var ZQ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},YLe=(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=tqt}=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*eqt(r,Number(e),t)},eqt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Dm(n,r,e+1)},tqt=function*(t){yield t};var XQ=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=ZLe(t,o,s),u=$m(e),l=$m(r),d=u?JQ.bind(void 0,dU,a):ZQ.bind(void 0,Dm),f=u||l?JQ.bind(void 0,WLe,a):ZQ.bind(void 0,yx),p=u||l?KLe.bind(void 0,a):void 0;return{stream:new rqt({writableObjectMode:n,writableHighWaterMark:JLe(n),readableObjectMode:i,readableHighWaterMark:JLe(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=ZLe(o,r,a);t=YLe(c,t)}return t},ZLe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:BLe(n,a)},lU(r,o,n),uU(r,s,n,c),{transform:t,final:e},{transform:VLe(i,a)},qLe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var XLe=(t,e)=>{for(let r of nqt(t))iqt(t,r,e)},nqt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),iqt=(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=>sqt(a,n));r.input=cx(o)},sqt=(t,e)=>{let r=fU(t,e,"utf8",!0);return oqt(r),cx(r)},oqt=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 lqt,appendFileSync as dqt}from"fs";var pU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&oE(r,n)&&!ro.has(e)&&aqt(n)&&(t.some(({type:i,value:s})=>i==="native"&&cqt.has(s))||t.every(({type:i})=>Zo.has(i))),aqt=t=>t===1||t===2,cqt=new Set(["pipe","overlapped"]),QLe=async(t,e,r,n)=>{for await(let i of t)uqt(e)||tMe(i,r,n)},eMe=(t,e,r)=>{for(let n of t)tMe(n,e,r)},uqt=t=>t._readableState.pipes.length>0,tMe=(t,e,r)=>{let n=x1(t);iu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var rMe=({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)=>fqt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},fqt=({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=nLe(t,s,d),p=Al(f),{stdioItems:h,objectMode:m}=e[r],g=pqt([p],h,c,n),{serializedResult:y,finalResult:E=y}=hqt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});mqt({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&&gqt(y,h,i),S}catch(_){return n.error=_,S}},pqt=(t,e,r,n)=>{try{return fU(t,e,r,!1)}catch(i){return n.error=i,t}},hqt=({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=_Ne(t,r);return n[s]?{serializedResult:o,finalResult:YQ(o,!i[s],e)}:{serializedResult:o}},mqt=({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=YQ(t,!1,o);try{eMe(a,e,n)}catch(c){r.error??=c}},gqt=(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)?dqt(n,t):(r.add(s),lqt(n,t))}};var nMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ol(e,r,"all")]:Array.isArray(e)?[Ol(t,r,"all"),...e]:xn(t)&&xn(e)?iQ([t,e]):`${t}${e}`};import{once as QQ}from"events";var iMe=async(t,e)=>{let[r,n]=await _qt(t);return e.isForcefullyTerminated??=!1,[r,n]},_qt=async t=>{let[e,r]=await Promise.allSettled([QQ(t,"spawn"),QQ(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?sMe(t):r.value},sMe=async t=>{try{return await QQ(t,"exit")}catch{return sMe(t)}},oMe=async t=>{let[e,r]=await t;if(!yqt(e,r)&&e7(e,r))throw new Ka;return[e,r]},yqt=(t,e)=>t===void 0&&e===void 0,e7=(t,e)=>t!==0||e!==null;var aMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Sqt(t,e,r),o=s?.code==="ETIMEDOUT",a=rLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Sqt=(t,e,r)=>t!==void 0?t:e7(e,r)?new Ka:void 0;var cMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=vqt(t,e,r),d=Tqt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return gE(d,c,u)},vqt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),a=bqt(r),{file:c,commandArguments:u,options:l}=Y1(t,e,a);wqt(l);let d=ULe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},bqt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,wqt=({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.`)},Tqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Aqt({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}=aMe(c,r),{output:h,error:m=u}=rMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,S)=>Ol(E,r,S)),y=Ol(nMe(h,r),r,"all");return xqt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Aqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{XLe(s,r);let a=Rqt(r);return Eqt(...J1(t,e,a))}catch(a){return mE({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Rqt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:nU(e)}),xqt=({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 h2t}from"events";import{spawn as m2t}from"child_process";import pMe from"process";import{once as t7,on as Oqt}from"events";var uMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(uE({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),Iqt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Iqt=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([Pqt(s,n,o),Cqt(s,r,o),kqt(s,r,o)])}catch(a){throw lE(t),a}finally{o.abort(),j1(e,i)}},Pqt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await t7(t,"message",{signal:r});return n}for await(let[n]of Oqt(t,"message",{signal:r}))if(e(n))return n},Cqt=async(t,e,{signal:r})=>{await t7(t,"disconnect",{signal:r}),Y$e(e)},kqt=async(t,e,{signal:r})=>{let[n]=await t7(t,"strict:error",{signal:r});throw L1(n,e)};import{once as dMe,on as Nqt}from"events";var fMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>r7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),r7=({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 $qt(t,o,a),Dqt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Lqt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},$qt=async(t,e,r)=>{try{await dMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Dqt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await dMe(t,"strict:error",{signal:r.signal});n.error=L1(i,e),r.abort()}catch{}},Lqt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Nqt(r,"message",{signal:s.signal}))lMe(o),yield c}catch{lMe(o)}finally{s.abort(),j1(e,a),n||lE(t),i&&await t}},lMe=({error:t})=>{if(t)throw t};var hMe=(t,{ipc:e})=>{Object.assign(t,gMe(t,!1,e))},mMe=()=>{let t=pMe,e=!0,r=pMe.channel!==void 0;return{...gMe(t,e,r),getCancelSignal:bDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},gMe=(t,e,r)=>({sendMessage:W1.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:uMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:fMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Mqt}from"child_process";import{PassThrough as Uqt,Readable as Fqt,Writable as jqt,Duplex as zqt}from"stream";var _Me=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{GQ(n);let a=new Mqt;qqt(a,n),Object.assign(a,{readable:Bqt,writable:Vqt,duplex:Hqt});let c=mE({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Gqt(c,o,i);return{subprocess:a,promise:u}},qqt=(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 Uqt;return t.end(),t},Bqt=()=>new Fqt({read(){}}),Vqt=()=>new jqt({write(){}}),Hqt=()=>new zqt({read(){},write(){}}),Gqt=async(t,e,r)=>gE(t,e,r);import{createReadStream as yMe,createWriteStream as SMe}from"fs";import{Buffer as Wqt}from"buffer";import{Readable as Ex,Writable as Kqt,Duplex as Yqt}from"stream";var vMe=(t,e)=>cU(Jqt,t,e,!1),vx=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$f[t]}.`)},EMe={fileNumber:vx,generator:XQ,asyncGenerator:XQ,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Yqt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Jqt={input:{...EMe,fileUrl:({value:t})=>({stream:yMe(t)}),filePath:({value:{file:t}})=>({stream:yMe(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(Wqt.from(t))})},output:{...EMe,fileUrl:({value:t})=>({stream:SMe(t)}),filePath:({value:{file:t,append:e}})=>({stream:SMe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Kqt.fromWeb(t)}),iterable:vx,asyncIterable:vx,string:vx,uint8Array:vx}};import{on as Zqt,once as bMe}from"events";import{PassThrough as Xqt,getDefaultHighWaterMark as Qqt}from"stream";import{finished as AMe}from"stream/promises";function Lm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)i7(i);let e=t.some(({readableObjectMode:i})=>i),r=eBt(t,e),n=new n7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var eBt=(t,e)=>{if(t.length===0)return Qqt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},n7=class extends Xqt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(i7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=tBt(this,this.#e,this.#s);let r=iBt({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(i7(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)}},tBt=async(t,e,r)=>{mU(t,wMe);let n=new AbortController;try{await Promise.race([rBt(t,n),nBt(t,e,r,n)])}finally{n.abort(),mU(t,-wMe)}},rBt=async(t,{signal:e})=>{try{await AMe(t,{signal:e,cleanup:!0})}catch(r){throw RMe(t,r),r}},nBt=async(t,e,r,{signal:n})=>{for await(let[i]of Zqt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},i7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},iBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{mU(t,TMe);let a=new AbortController;try{await Promise.race([sBt(s,e,a),oBt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),aBt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),mU(t,-TMe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?s7(t):cBt(t))},sBt=async(t,e,{signal:r})=>{try{await t,r.aborted||s7(e)}catch(n){r.aborted||RMe(e,n)}},oBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await AMe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;xMe(o)?i.add(e):OMe(t,o)}},aBt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await bMe(t,i,{signal:s}),!t.readable)return bMe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},cBt=t=>{t.writable&&t.end()},RMe=(t,e)=>{xMe(e)?s7(t):OMe(t,e)},xMe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",s7=t=>{(t.readable||t.writable)&&t.destroy()},OMe=(t,e)=>{t.destroyed||(t.once("error",uBt),t.destroy(e))},uBt=()=>{},mU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},wMe=2,TMe=1;import{finished as IMe}from"stream/promises";var yE=(t,e)=>{t.pipe(e),lBt(t,e),dBt(t,e)},lBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await IMe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}o7(e)}},o7=t=>{t.writable&&t.end()},dBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await IMe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}a7(t)}},a7=t=>{t.readable&&t.destroy()};var PMe=(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)))fBt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Zo.has(c)))hBt({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)}},fBt=(t,e,r,n)=>{r==="output"?yE(t.stdio[n],e):yE(e,t.stdio[n]);let i=pBt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},pBt=["stdin","stdout","stderr"],hBt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;mBt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},mBt=(t,{signal:e})=>{Wa(t)&&km(t,gBt,e)},gBt=2;import{addAbortListener as SBt}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",c7=Symbol.for("signal-exit emitter"),u7=globalThis,_Bt=Object.defineProperty.bind(Object),l7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(u7[c7])return u7[c7];_Bt(u7,c7,{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{},yBt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),d7=class extends _U{onExit(){return()=>{}}load(){}unload(){}},f7=class extends _U{#e=p7.platform==="win32"?"SIGINT":"SIGHUP";#r=new l7;#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)}},p7=globalThis.process,{onExit:CMe,load:d2r,unload:f2r}=yBt(gU(p7)?new f7(p7):new d7);var kMe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=CMe(()=>{t.kill()});SBt(n,()=>{i()})};var $Me=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=O1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=EBt(r,n,i),{sourceStream:d,sourceError:f}=bBt(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}},EBt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=vBt(t,e,...r),a=U1(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},vBt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(NMe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||rQ(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(NMe)(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}`)},NMe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),bBt=(t,e)=>{try{return{sourceStream:dE(t,e)}}catch(r){return{sourceError:r}}};var LMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=wBt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw h7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},wBt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return a7(t),n;if(e!==void 0)return o7(r),e},h7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>mE({error:t,command:DMe,escapedCommand:DMe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),DMe="source.pipe(destination)";var MMe=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 TBt}from"stream/promises";var UMe=(t,e,r)=>{let n=yU.has(e)?RBt(t,e):ABt(t,e);return km(t,OBt,r.signal),km(e,IBt,r.signal),xBt(e),n},ABt=(t,e)=>{let r=Lm([t]);return yE(r,e),yU.set(e,r),r},RBt=(t,e)=>{let r=yU.get(e);return r.add(t),r},xBt=async t=>{try{await TBt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}yU.delete(t)},yU=new WeakMap,OBt=2,IBt=1;import{aborted as PBt}from"util";var FMe=(t,e)=>t===void 0?[]:[CBt(t,e)],CBt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await PBt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw h7({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}=$Me(t,...e),i=kBt({...n,destination:r});return i.pipe=SU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},kBt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=NBt(t,i);LMe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=UMe(e,s,d);return await Promise.race([MMe(l),...FMe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},NBt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as jBt}from"timers/promises";import{on as $Bt}from"events";import{getDefaultHighWaterMark as DBt}from"stream";var EU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return LBt(e,o),zMe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},LBt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},m7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;MBt(e,o,t);let a=t.readableObjectMode&&!s;return zMe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},MBt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},zMe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=$Bt(t,"data",{signal:e.signal,highWaterMark:jMe,highWatermark:jMe});return UBt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},g7=DBt(!0),jMe=g7,UBt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=FBt({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)}},FBt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[lU(t,r,!e),uU(t,i,!n,{})].filter(Boolean);var qMe=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=zBt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([qBt(t),d]);return}let f=WQ(c,r),p=m7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([BBt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},zBt=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=m7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await QLe(a,t,r,s)},qBt=async t=>{await jBt(),t.readableFlowing===null&&t.resume()},BBt=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 BMe(QDe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},_7=async t=>{try{return await t}catch(e){return BMe(e)}},BMe=({bufferedData:t})=>mNe(t)?new Uint8Array(t):t;import{finished as VBt}from"stream/promises";var bx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=HBt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],VBt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||KBt(a,e,r,n)}finally{o.abort()}},HBt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&GBt(t,r,n),n},GBt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{WBt(e,r),n.call(t,...i)}},WBt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},KBt=(t,e,r,n)=>{if(!YBt(t,e,r,n))throw t},YBt=(t,e,r,n=!0)=>r.propagating?VMe(t)||vU(t):(r.propagating=!0,y7(r,e)===n?VMe(t):vU(t)),y7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",vU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",VMe=t=>t?.code==="EPIPE";var HMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>S7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),S7=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(y7(u,e)){await l;return}let[d]=await Promise.all([qMe({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 GMe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Lm([t,e].filter(Boolean)):void 0,WMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>S7({...JBt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:ZBt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),JBt=({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}},ZBt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as XBt}from"events";var KMe=t=>oE(t,"ipc"),YMe=(t,e)=>{let r=x1(t);iu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var JMe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=KMe(s),a=Rl(e,"ipc"),c=Rl(r,"ipc");for await(let u of r7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(eLe(t,i,c),i.push(u)),o&&YMe(u,s);return i},ZMe=async(t,e)=>(await Promise.allSettled([t]),e);var XMe=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=iMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=HMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=WMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=JMe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=QBt(m,t,S),I=e2t(h,S);try{return await Promise.race([Promise.all([{},oMe(E),Promise.all(_),w,R,kDe(t,d),...T,...I]),g,t2t(t,y),...xDe(t,s,f,y),...K$e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...ADe({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=>_7(O))),_7(w),ZMe(R,b),Promise.allSettled(T),Promise.allSettled(I)])}},QBt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:bx(n,i,r)),e2t=(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"}))),t2t=async(t,{signal:e})=>{let[r]=await XBt(t,"error",{signal:e});throw r};var QMe=()=>({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 r2t}from"stream";import{callbackify as n2t}from"util";import{finished as e1e}from"stream/promises";var E7=async t=>{if(t!==void 0)try{await v7(t)}catch{}},t1e=async t=>{if(t!==void 0)try{await b7(t)}catch{}},v7=async t=>{await e1e(t,{cleanup:!0,readable:!1,writable:!0})},b7=async t=>{await e1e(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 r1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ro.has(r),{subprocessStdout:a,waitReadableDestroy:c}=w7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=T7(a,o),{read:f,onStdoutDataDone:p}=A7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new r2t({read:f,destroy:n2t(x7.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return R7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},w7=(t,e,r)=>{let n=dE(t,e),i=wx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},T7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:g7},A7=({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(){i2t(this,o,s)},onStdoutDataDone:s}},i2t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},R7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await b7(t),await n,await E7(i),await e,r.readable&&r.push(null)}catch(s){await E7(i),n1e(r,s)}},x7=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await SE(r,e)&&(n1e(t,n),await bU(e,n))},n1e=(t,e)=>{wU(t,t.readable,e)};import{Writable as s2t}from"stream";import{callbackify as i1e}from"util";var s1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=O7(t,r,e),o=new s2t({...I7(n,t,i),destroy:i1e(C7.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return P7(n,o),o},O7=(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}},I7=(t,e,r)=>({write:o2t.bind(void 0,t),final:i1e(a2t.bind(void 0,t,e,r))}),o2t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},a2t=async(t,e,r)=>{await SE(r,e)&&(t.writable&&t.end(),await e)},P7=async(t,e,r)=>{try{await v7(t),e.writable&&e.end()}catch(n){await t1e(r),o1e(e,n)}},C7=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await SE(r,e),await SE(n,e)&&(o1e(t,i),await bU(e,i))},o1e=(t,e)=>{wU(t,t.writable,e)};import{Duplex as c2t}from"stream";import{callbackify as u2t}from"util";var a1e=({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}=w7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=O7(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=T7(c,a),{read:g,onStdoutDataDone:y}=A7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new c2t({read:g,...I7(l,t,d),destroy:u2t(l2t.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 R7({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:l}),P7(l,E,c),E},l2t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([x7({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),C7({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var k7=(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 d2t(a,o,t)},d2t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var c1e=(t,{encoding:e})=>{let r=QMe();t.readable=r1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=s1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=a1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=k7.bind(void 0,t,e),t[Symbol.asyncIterator]=k7.bind(void 0,t,e,{})};var u1e=(t,e)=>{for(let[r,n]of p2t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},f2t=(async()=>{})().constructor.prototype,p2t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(f2t,t)]);var l1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=g2t(t,e,r),{subprocess:f,promise:p}=y2t({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}),u1e(f,p),ou.set(f,{options:l,fileDescriptors:d}),f},g2t=(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=_2t(u),d=vMe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},_2t=({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}},y2t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=m2t(...J1(t,e,r))}catch(h){return _Me({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;h2t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];PMe(c,a,u),kMe(c,r,u);let d={},f=su();c.kill=G$e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=GMe(c,r),c1e(c,r),hMe(c,r);let p=S2t({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}},S2t=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 XMe({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)=>Ol(_,e,w)),E=Ol(m,e,"all"),S=E2t({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)},E2t=({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,v2t(n,t[n],i)]));return{...t,...r}},v2t=(t,e,r)=>b2t.has(t)&&Qr(e)&&Qr(r)?{...e,...r}:r,b2t=new Set(["env",...cQ]);var Df=(t,e,r,n)=>{let i=(o,a,c)=>Df(o,a,r,c),s=(...o)=>w2t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},w2t=({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}=T2t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?cMe(a,c,u):l1e(a,c,u,i)},T2t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=vNe(e)?bNe(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 d1e=({file:t,commandArguments:e})=>p1e(t,e),f1e=({file:t,commandArguments:e})=>({...p1e(t,e),isSync:!0}),p1e=(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]=A2t(t);return{file:r,commandArguments:n}},A2t=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(R2t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},R2t=/ +/g;var h1e=(t,e,r)=>{t.sync=e(x2t,r),t.s=t.sync},m1e=({options:t})=>g1e(t),x2t=({options:t})=>({...g1e(t),isSync:!0}),g1e=t=>({options:{...O2t(t),...t}}),O2t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},_1e={preferLocal:!0};var y1e=Df(()=>({})),t4r=Df(()=>({isSync:!0})),S1e=Df(d1e),r4r=Df(f1e),n4r=Df(IDe),i4r=Df(m1e,{},_1e,h1e),{sendMessage:s4r,getOneMessage:o4r,getEachMessage:a4r,getCancelSignal:c4r}=mMe();import{Transform as I2t}from"stream";var P2t=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function C2t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...P2t])]}function k2t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function N2t(){let e=C2t().map(r=>process.env[r]).filter(r=>!(!r||k2t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ei(t){if(typeof t!="string")return t;let e=N2t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp($2t(n),"g");r=r.replace(i,"******")}),r}function $2t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Tx=class extends I2t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ei(i);n(null,s)}},AU=Symbol("maskedWrite");function E1e(){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 v1e=!1,b1e,N7=t=>{b1e??=t},w1e=t=>{v1e=!0,N7(t)},en=()=>v1e,Xo=()=>b1e,T1e=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Ax=null,A1e=t=>(Ax&&Ax.destroy(),Ax=new Qo({totalAllowedTime:t}),Ax),R1e=()=>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 x1e={name:"@netlify/agent-runner-cli",type:"module",version:"2.10.0-setup-request-skip.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!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 U2t=L2t(import.meta.url),F2t=Il.dirname(U2t),j2t=M2t(import.meta.url),EE=he("shell"),$7=new Set,O1e={preferLocal:!0},Ut=(t,e,r)=>{let[n,i]=z2t(e,r),s={...O1e,...i},o=y1e(t,n,s);P1e(o,s),N1e(o);let a=r?.idleTimeout;return a&&a>0&&k1e(o,a),o},I1e=(t,e)=>{let r={...O1e,...e},n=S1e(t,r);return P1e(n,r),N1e(n),e?.idleTimeout&&e.idleTimeout>0&&k1e(n,e.idleTimeout),n},z2t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},P1e=(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)},D7=(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}},C1e=t=>D7(t,"SIGKILL"),k1e=(t,e)=>{let r=null,n=()=>{EE.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),D7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing idle process ${t.pid}`),C1e(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)},N1e=t=>{$7.add(t);let e=R1e();if(e){let r=e.onTimesUp(()=>{EE.log(`Global timer expired, killing process ${t.pid}`),D7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing process ${t.pid} after timeout`),C1e(t))},5e3)});t.on("exit",()=>{$7.delete(t),r()}),t.on("error",()=>{$7.delete(t),r()})}};function lu(t,e){if(!uu.env.NETLIFY_LOCAL_MODE)try{let i=j2t.resolve(x1e.name),s=Il.dirname(i);for(;s!==Il.dirname(s);){let o=Il.dirname(s);if(Il.basename(o)==="node_modules"){let a=Il.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=Il.join(uu.env.NODE_PATH,".bin",e);if(RU.existsSync(i))return i}let r=Il.join(t,"node_modules",".bin",e);if(RU.existsSync(r))return r;let n=Il.join(F2t,"..","node_modules",".bin",e);if(RU.existsSync(n))return n}import Oq from"process";import{fileURLToPath as nXt}from"url";import{createRequire as iXt}from"module";import AI from"path";import{readFileSync as sXt}from"fs";var q2t="__netlify__getTracer",B2t="__netlify__shutdownTracers",$t=(t,e)=>globalThis[q2t]?.(t,e),$1e=async()=>globalThis[B2t]?.();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 KZt}from"timers/promises";Ue();import MHt from"process";Ue();var V2t=(t,e)=>{e.recordException(t),e.setStatus({code:qn.ERROR})};var Pl=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}=D1e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>L1e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=D1e(r,n,i),c=this._tracer.startSpan(e,s,o);return L1e(c,s,a)}};function D1e(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 L1e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:V2t,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 M7=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=G1e(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=G1e(this._rawAttributes),this._schemaUrl=H2t(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=G2t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function U7(t,e){return M7.FromAttributeList(Object.entries(t),e)}function G1e(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 H2t(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 G2t(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}},W1e=new xx;var Ox=Symbol.for("io.opentelemetry.js.api.logs"),wE=globalThis;function K1e(t,e,r){return n=>n===t?e:r}var F7=1;var j7=class{getLogger(e,r,n){return new xx}},IU=new j7;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):W1e}};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]=K1e(F7,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,F7))!==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 Y1e=CU.getInstance();function J1e(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 Z1e(t){t.forEach(e=>e.disable())}function z7(t){let e=t.tracerProvider||Wt.getTracerProvider(),r=t.meterProvider||xR.getMeterProvider(),n=t.loggerProvider||Y1e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return J1e(i,e,r,n),()=>{Z1e(i)}}Ue();var W2t=zn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function X1e(t){return t.getValue(W2t)===!0}var TE;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(TE||(TE={}));Ue();var q7="[_0-9a-z-*/]",K2t=`[a-z]${q7}{0,255}`,Y2t=`[a-z0-9]${q7}{0,240}@[a-z]${q7}{0,13}`,J2t=new RegExp(`^(?:${K2t}|${Y2t})$`),Z2t=/^[ -~]{0,255}[!-~]$/,X2t=/,|=/;function B7(t){return J2t.test(t)}function V7(t){return Z2t.test(t)&&!X2t.test(t)}var Q2t=32,Q1e=512,eUe=",",tUe="=",kU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!B7(e)||!V7(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>Q1e)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=eUe+e),e=`${n[0]}${tUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(eUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(tUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!B7(a)||!V7(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>Q1e)&&(r.set(a,c),n=u,r.size>=Q2t))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",eVt="00",tVt="(?!ff)[\\da-f]{2}",rVt="(?![0]{32})[\\da-f]{32}",nVt="(?![0]{16})[\\da-f]{16}",iVt="[\\da-f]{2}",sVt=new RegExp(`^\\s?(${tVt})-(${rVt})-(${nVt})-(${iVt})(-.*)?\\s?$`);function rUe(t){let e=sVt.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||X1e(e)||!ws(i))return;let s=`${eVt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||zr.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=rUe(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(kee(),1);Ue();var eze=t=>{throw TypeError(t)},Lee=(t,e,r)=>e.has(t)||eze("Cannot "+r),xF=(t,e,r)=>(Lee(t,e,"read from private field"),r?r.call(t):e.get(t)),Nee=(t,e,r)=>e.has(t)?eze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Zje=(t,e,r,n)=>(Lee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),LHt=(t,e,r)=>(Lee(t,e,"access private method"),r),Xje="__netlify__getTracer",UHt="__netlify__shutdownTracers",FHt="__nfOTLPTrace",Yx,Jx,Dee,tze,jHt=class{constructor(){Nee(this,Dee),Nee(this,Yx),Nee(this,Jx),Zje(this,Yx,new Px(LHt(this,Dee,tze),this)),Zje(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(FHt,JSON.stringify(zHt(t))),e({code:TE.SUCCESS})}shutdown(){return xF(this,Yx).call()}};Yx=new WeakMap;Jx=new WeakMap;Dee=new WeakSet;tze=function(){return xF(this,Jx).debug("Shutting down"),Promise.resolve()};function zHt(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:$ee(e.startTime),endTimeUnixNano:$ee(e.endTime),attributes:RF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:$ee(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=>rze(e,t[e]))}function rze(t,e){return{key:t,value:nze(e)}}function nze(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(nze)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>rze(r,n))}}:{}}function $ee(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var Qje={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"}},ize=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Xje))return;let e=MHt.version.slice(1),r=U7({"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??[qHt()],i=new OF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Lf});let s=t.instrumentations??[];z7({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,Xje,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Pl(Wt.getTracer(a,c)):new Pl(Wt.getTracer(Qje.name,Qje.version))}}),Object.defineProperty(globalThis,UHt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},qHt=()=>new OF.SimpleSpanProcessor(new jHt);Ue();var LE=En(kee(),1);Ue();import*as IF from"diagnostics_channel";var sze=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 Pl?t:new Pl(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 W6e=En(B6e(),1);Cse();var V6e=0;var GZt=3*1024*1024,WZt=t=>SI.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Rq=class{constructor(e,r=GZt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=WZt(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:V6e});return}this.inner.export(n[c],u=>{u.code!==V6e&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var Lv=he("tracing"),H6e=8e3,YZt=5e3,G6e=t=>t.length>H6e?`${t.slice(0,H6e)}\u2026`:t,bI={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},JZt=Math.ceil(bI.maxQueueSize/bI.maxExportBatchSize)+1,ZZt=t=>new LE.BatchSpanProcessor(new Rq(new W6e.OTLPTraceExporter({url:t,concurrencyLimit:JZt})),bI),yg=async(t=YZt)=>{try{let e=Symbol("timed out");await Promise.race([$1e(),KZt(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)}},K6e=async(t,e,r)=>{if(!$t()){let n=[new LE.SimpleSpanProcessor(new Nse),ZZt(r.exporterUrl)];await ize({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new sze({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 Nse=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 $se(){return We().captureLlmContentEnabled}function Y6e(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 XZt=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 J6e(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=$se(),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&&XZt.has(a.category)||a.category===ee.AgentMessage&&a.toolCallId!==void 0,f=d?"execute_tool":"chat",p=G6e(a.title||a.type||`step-${a.id??c}`),h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?G6e(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 QZt,rm as eXt}from"fs/promises";import{join as tXt}from"path";async function Z6e(t,e=[]){let n=(await QZt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>eXt(tXt(t,i),{recursive:!0,force:!0})))}var rXt=300,wI=t=>We().budgetCreditThresholds[t.mode]?.[t.runner]??rXt,TI=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Dse=t=>{let e=wI(t);if(!TI(t,e))return"default";let r=We();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},X6e=t=>{let e=Dse(t),r=wI(t);return{budget_eligible:TI(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var oXt=AI.dirname(nXt(import.meta.url)),Q6e=iXt(import.meta.url),aXt=AI.resolve(oXt,"scripts/scaffold.js"),cXt="scripts/scaffold.js",uXt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,Lse=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},lXt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),dXt=t=>{let e=Lse(t);return e==="node"||e.endsWith("/node")},lo=t=>{if(typeof t!="string")return!1;let e=t.match(uXt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&lXt(Lse(e[r]));)r+=1;if(r>=e.length||!dXt(e[r]))return!1;let n=e[r+1];return n?Lse(n).includes(cXt):!1},Sg=he("create_stage"),Mse="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.",fXt=`${Mse}
|
|
597
|
+
if (condition) { yield value; }`)};import{Buffer as Wzt}from"buffer";import{StringDecoder as Kzt}from"string_decoder";var lU=(t,e,r)=>{if(r)return;if(t)return{transform:Yzt.bind(void 0,new TextEncoder)};let n=new Kzt(e);return{transform:Jzt.bind(void 0,n),final:Zzt.bind(void 0,n)}},Yzt=function*(t,e){Wzt.isBuffer(e)?yield Al(e):typeof e=="string"?yield t.encode(e):yield e},Jzt=function*(t,e){yield xn(e)?t.write(e):e},Zzt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as GLe}from"util";var JQ=GLe(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=Qzt}=e[r];for await(let i of n(t))yield*dU(i,e,r+1)},WLe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Xzt(r,Number(e),t)},Xzt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*dU(n,r,e+1)},KLe=GLe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Qzt=function*(t){yield t};var ZQ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},YLe=(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=tqt}=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*eqt(r,Number(e),t)},eqt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Dm(n,r,e+1)},tqt=function*(t){yield t};var XQ=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=ZLe(t,o,s),u=$m(e),l=$m(r),d=u?JQ.bind(void 0,dU,a):ZQ.bind(void 0,Dm),f=u||l?JQ.bind(void 0,WLe,a):ZQ.bind(void 0,yx),p=u||l?KLe.bind(void 0,a):void 0;return{stream:new rqt({writableObjectMode:n,writableHighWaterMark:JLe(n),readableObjectMode:i,readableHighWaterMark:JLe(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=ZLe(o,r,a);t=YLe(c,t)}return t},ZLe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:BLe(n,a)},lU(r,o,n),uU(r,s,n,c),{transform:t,final:e},{transform:VLe(i,a)},qLe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var XLe=(t,e)=>{for(let r of nqt(t))iqt(t,r,e)},nqt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),iqt=(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=>sqt(a,n));r.input=cx(o)},sqt=(t,e)=>{let r=fU(t,e,"utf8",!0);return oqt(r),cx(r)},oqt=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 lqt,appendFileSync as dqt}from"fs";var pU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&oE(r,n)&&!ro.has(e)&&aqt(n)&&(t.some(({type:i,value:s})=>i==="native"&&cqt.has(s))||t.every(({type:i})=>Zo.has(i))),aqt=t=>t===1||t===2,cqt=new Set(["pipe","overlapped"]),QLe=async(t,e,r,n)=>{for await(let i of t)uqt(e)||tMe(i,r,n)},eMe=(t,e,r)=>{for(let n of t)tMe(n,e,r)},uqt=t=>t._readableState.pipes.length>0,tMe=(t,e,r)=>{let n=x1(t);iu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var rMe=({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)=>fqt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},fqt=({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=nLe(t,s,d),p=Al(f),{stdioItems:h,objectMode:m}=e[r],g=pqt([p],h,c,n),{serializedResult:y,finalResult:E=y}=hqt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});mqt({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&&gqt(y,h,i),S}catch(_){return n.error=_,S}},pqt=(t,e,r,n)=>{try{return fU(t,e,r,!1)}catch(i){return n.error=i,t}},hqt=({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=_Ne(t,r);return n[s]?{serializedResult:o,finalResult:YQ(o,!i[s],e)}:{serializedResult:o}},mqt=({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=YQ(t,!1,o);try{eMe(a,e,n)}catch(c){r.error??=c}},gqt=(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)?dqt(n,t):(r.add(s),lqt(n,t))}};var nMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ol(e,r,"all")]:Array.isArray(e)?[Ol(t,r,"all"),...e]:xn(t)&&xn(e)?iQ([t,e]):`${t}${e}`};import{once as QQ}from"events";var iMe=async(t,e)=>{let[r,n]=await _qt(t);return e.isForcefullyTerminated??=!1,[r,n]},_qt=async t=>{let[e,r]=await Promise.allSettled([QQ(t,"spawn"),QQ(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?sMe(t):r.value},sMe=async t=>{try{return await QQ(t,"exit")}catch{return sMe(t)}},oMe=async t=>{let[e,r]=await t;if(!yqt(e,r)&&e7(e,r))throw new Ka;return[e,r]},yqt=(t,e)=>t===void 0&&e===void 0,e7=(t,e)=>t!==0||e!==null;var aMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Sqt(t,e,r),o=s?.code==="ETIMEDOUT",a=rLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Sqt=(t,e,r)=>t!==void 0?t:e7(e,r)?new Ka:void 0;var cMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=vqt(t,e,r),d=Tqt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return gE(d,c,u)},vqt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),a=bqt(r),{file:c,commandArguments:u,options:l}=Y1(t,e,a);wqt(l);let d=ULe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},bqt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,wqt=({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.`)},Tqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Aqt({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}=aMe(c,r),{output:h,error:m=u}=rMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,S)=>Ol(E,r,S)),y=Ol(nMe(h,r),r,"all");return xqt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Aqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{XLe(s,r);let a=Rqt(r);return Eqt(...J1(t,e,a))}catch(a){return mE({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Rqt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:nU(e)}),xqt=({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 h2t}from"events";import{spawn as m2t}from"child_process";import pMe from"process";import{once as t7,on as Oqt}from"events";var uMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(uE({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),Iqt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Iqt=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([Pqt(s,n,o),Cqt(s,r,o),kqt(s,r,o)])}catch(a){throw lE(t),a}finally{o.abort(),j1(e,i)}},Pqt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await t7(t,"message",{signal:r});return n}for await(let[n]of Oqt(t,"message",{signal:r}))if(e(n))return n},Cqt=async(t,e,{signal:r})=>{await t7(t,"disconnect",{signal:r}),Y$e(e)},kqt=async(t,e,{signal:r})=>{let[n]=await t7(t,"strict:error",{signal:r});throw L1(n,e)};import{once as dMe,on as Nqt}from"events";var fMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>r7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),r7=({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 $qt(t,o,a),Dqt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Lqt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},$qt=async(t,e,r)=>{try{await dMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Dqt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await dMe(t,"strict:error",{signal:r.signal});n.error=L1(i,e),r.abort()}catch{}},Lqt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Nqt(r,"message",{signal:s.signal}))lMe(o),yield c}catch{lMe(o)}finally{s.abort(),j1(e,a),n||lE(t),i&&await t}},lMe=({error:t})=>{if(t)throw t};var hMe=(t,{ipc:e})=>{Object.assign(t,gMe(t,!1,e))},mMe=()=>{let t=pMe,e=!0,r=pMe.channel!==void 0;return{...gMe(t,e,r),getCancelSignal:bDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},gMe=(t,e,r)=>({sendMessage:W1.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:uMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:fMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Mqt}from"child_process";import{PassThrough as Uqt,Readable as Fqt,Writable as jqt,Duplex as zqt}from"stream";var _Me=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{GQ(n);let a=new Mqt;qqt(a,n),Object.assign(a,{readable:Bqt,writable:Vqt,duplex:Hqt});let c=mE({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Gqt(c,o,i);return{subprocess:a,promise:u}},qqt=(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 Uqt;return t.end(),t},Bqt=()=>new Fqt({read(){}}),Vqt=()=>new jqt({write(){}}),Hqt=()=>new zqt({read(){},write(){}}),Gqt=async(t,e,r)=>gE(t,e,r);import{createReadStream as yMe,createWriteStream as SMe}from"fs";import{Buffer as Wqt}from"buffer";import{Readable as Ex,Writable as Kqt,Duplex as Yqt}from"stream";var vMe=(t,e)=>cU(Jqt,t,e,!1),vx=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$f[t]}.`)},EMe={fileNumber:vx,generator:XQ,asyncGenerator:XQ,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Yqt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Jqt={input:{...EMe,fileUrl:({value:t})=>({stream:yMe(t)}),filePath:({value:{file:t}})=>({stream:yMe(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(Wqt.from(t))})},output:{...EMe,fileUrl:({value:t})=>({stream:SMe(t)}),filePath:({value:{file:t,append:e}})=>({stream:SMe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Kqt.fromWeb(t)}),iterable:vx,asyncIterable:vx,string:vx,uint8Array:vx}};import{on as Zqt,once as bMe}from"events";import{PassThrough as Xqt,getDefaultHighWaterMark as Qqt}from"stream";import{finished as AMe}from"stream/promises";function Lm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)i7(i);let e=t.some(({readableObjectMode:i})=>i),r=eBt(t,e),n=new n7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var eBt=(t,e)=>{if(t.length===0)return Qqt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},n7=class extends Xqt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(i7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=tBt(this,this.#e,this.#s);let r=iBt({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(i7(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)}},tBt=async(t,e,r)=>{mU(t,wMe);let n=new AbortController;try{await Promise.race([rBt(t,n),nBt(t,e,r,n)])}finally{n.abort(),mU(t,-wMe)}},rBt=async(t,{signal:e})=>{try{await AMe(t,{signal:e,cleanup:!0})}catch(r){throw RMe(t,r),r}},nBt=async(t,e,r,{signal:n})=>{for await(let[i]of Zqt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},i7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},iBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{mU(t,TMe);let a=new AbortController;try{await Promise.race([sBt(s,e,a),oBt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),aBt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),mU(t,-TMe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?s7(t):cBt(t))},sBt=async(t,e,{signal:r})=>{try{await t,r.aborted||s7(e)}catch(n){r.aborted||RMe(e,n)}},oBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await AMe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;xMe(o)?i.add(e):OMe(t,o)}},aBt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await bMe(t,i,{signal:s}),!t.readable)return bMe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},cBt=t=>{t.writable&&t.end()},RMe=(t,e)=>{xMe(e)?s7(t):OMe(t,e)},xMe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",s7=t=>{(t.readable||t.writable)&&t.destroy()},OMe=(t,e)=>{t.destroyed||(t.once("error",uBt),t.destroy(e))},uBt=()=>{},mU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},wMe=2,TMe=1;import{finished as IMe}from"stream/promises";var yE=(t,e)=>{t.pipe(e),lBt(t,e),dBt(t,e)},lBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await IMe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}o7(e)}},o7=t=>{t.writable&&t.end()},dBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await IMe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}a7(t)}},a7=t=>{t.readable&&t.destroy()};var PMe=(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)))fBt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Zo.has(c)))hBt({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)}},fBt=(t,e,r,n)=>{r==="output"?yE(t.stdio[n],e):yE(e,t.stdio[n]);let i=pBt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},pBt=["stdin","stdout","stderr"],hBt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;mBt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},mBt=(t,{signal:e})=>{Wa(t)&&km(t,gBt,e)},gBt=2;import{addAbortListener as SBt}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",c7=Symbol.for("signal-exit emitter"),u7=globalThis,_Bt=Object.defineProperty.bind(Object),l7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(u7[c7])return u7[c7];_Bt(u7,c7,{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{},yBt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),d7=class extends _U{onExit(){return()=>{}}load(){}unload(){}},f7=class extends _U{#e=p7.platform==="win32"?"SIGINT":"SIGHUP";#r=new l7;#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)}},p7=globalThis.process,{onExit:CMe,load:d2r,unload:f2r}=yBt(gU(p7)?new f7(p7):new d7);var kMe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=CMe(()=>{t.kill()});SBt(n,()=>{i()})};var $Me=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=O1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=EBt(r,n,i),{sourceStream:d,sourceError:f}=bBt(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}},EBt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=vBt(t,e,...r),a=U1(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},vBt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(NMe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||rQ(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(NMe)(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}`)},NMe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),bBt=(t,e)=>{try{return{sourceStream:dE(t,e)}}catch(r){return{sourceError:r}}};var LMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=wBt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw h7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},wBt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return a7(t),n;if(e!==void 0)return o7(r),e},h7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>mE({error:t,command:DMe,escapedCommand:DMe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),DMe="source.pipe(destination)";var MMe=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 TBt}from"stream/promises";var UMe=(t,e,r)=>{let n=yU.has(e)?RBt(t,e):ABt(t,e);return km(t,OBt,r.signal),km(e,IBt,r.signal),xBt(e),n},ABt=(t,e)=>{let r=Lm([t]);return yE(r,e),yU.set(e,r),r},RBt=(t,e)=>{let r=yU.get(e);return r.add(t),r},xBt=async t=>{try{await TBt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}yU.delete(t)},yU=new WeakMap,OBt=2,IBt=1;import{aborted as PBt}from"util";var FMe=(t,e)=>t===void 0?[]:[CBt(t,e)],CBt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await PBt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw h7({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}=$Me(t,...e),i=kBt({...n,destination:r});return i.pipe=SU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},kBt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=NBt(t,i);LMe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=UMe(e,s,d);return await Promise.race([MMe(l),...FMe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},NBt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as jBt}from"timers/promises";import{on as $Bt}from"events";import{getDefaultHighWaterMark as DBt}from"stream";var EU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return LBt(e,o),zMe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},LBt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},m7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;MBt(e,o,t);let a=t.readableObjectMode&&!s;return zMe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},MBt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},zMe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=$Bt(t,"data",{signal:e.signal,highWaterMark:jMe,highWatermark:jMe});return UBt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},g7=DBt(!0),jMe=g7,UBt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=FBt({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)}},FBt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[lU(t,r,!e),uU(t,i,!n,{})].filter(Boolean);var qMe=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=zBt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([qBt(t),d]);return}let f=WQ(c,r),p=m7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([BBt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},zBt=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=m7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await QLe(a,t,r,s)},qBt=async t=>{await jBt(),t.readableFlowing===null&&t.resume()},BBt=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 BMe(QDe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},_7=async t=>{try{return await t}catch(e){return BMe(e)}},BMe=({bufferedData:t})=>mNe(t)?new Uint8Array(t):t;import{finished as VBt}from"stream/promises";var bx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=HBt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],VBt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||KBt(a,e,r,n)}finally{o.abort()}},HBt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&GBt(t,r,n),n},GBt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{WBt(e,r),n.call(t,...i)}},WBt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},KBt=(t,e,r,n)=>{if(!YBt(t,e,r,n))throw t},YBt=(t,e,r,n=!0)=>r.propagating?VMe(t)||vU(t):(r.propagating=!0,y7(r,e)===n?VMe(t):vU(t)),y7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",vU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",VMe=t=>t?.code==="EPIPE";var HMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>S7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),S7=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(y7(u,e)){await l;return}let[d]=await Promise.all([qMe({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 GMe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Lm([t,e].filter(Boolean)):void 0,WMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>S7({...JBt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:ZBt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),JBt=({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}},ZBt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as XBt}from"events";var KMe=t=>oE(t,"ipc"),YMe=(t,e)=>{let r=x1(t);iu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var JMe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=KMe(s),a=Rl(e,"ipc"),c=Rl(r,"ipc");for await(let u of r7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(eLe(t,i,c),i.push(u)),o&&YMe(u,s);return i},ZMe=async(t,e)=>(await Promise.allSettled([t]),e);var XMe=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=iMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=HMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=WMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=JMe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=QBt(m,t,S),I=e2t(h,S);try{return await Promise.race([Promise.all([{},oMe(E),Promise.all(_),w,R,kDe(t,d),...T,...I]),g,t2t(t,y),...xDe(t,s,f,y),...K$e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...ADe({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=>_7(O))),_7(w),ZMe(R,b),Promise.allSettled(T),Promise.allSettled(I)])}},QBt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:bx(n,i,r)),e2t=(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"}))),t2t=async(t,{signal:e})=>{let[r]=await XBt(t,"error",{signal:e});throw r};var QMe=()=>({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 r2t}from"stream";import{callbackify as n2t}from"util";import{finished as e1e}from"stream/promises";var E7=async t=>{if(t!==void 0)try{await v7(t)}catch{}},t1e=async t=>{if(t!==void 0)try{await b7(t)}catch{}},v7=async t=>{await e1e(t,{cleanup:!0,readable:!1,writable:!0})},b7=async t=>{await e1e(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 r1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ro.has(r),{subprocessStdout:a,waitReadableDestroy:c}=w7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=T7(a,o),{read:f,onStdoutDataDone:p}=A7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new r2t({read:f,destroy:n2t(x7.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return R7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},w7=(t,e,r)=>{let n=dE(t,e),i=wx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},T7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:g7},A7=({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(){i2t(this,o,s)},onStdoutDataDone:s}},i2t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},R7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await b7(t),await n,await E7(i),await e,r.readable&&r.push(null)}catch(s){await E7(i),n1e(r,s)}},x7=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await SE(r,e)&&(n1e(t,n),await bU(e,n))},n1e=(t,e)=>{wU(t,t.readable,e)};import{Writable as s2t}from"stream";import{callbackify as i1e}from"util";var s1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=O7(t,r,e),o=new s2t({...I7(n,t,i),destroy:i1e(C7.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return P7(n,o),o},O7=(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}},I7=(t,e,r)=>({write:o2t.bind(void 0,t),final:i1e(a2t.bind(void 0,t,e,r))}),o2t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},a2t=async(t,e,r)=>{await SE(r,e)&&(t.writable&&t.end(),await e)},P7=async(t,e,r)=>{try{await v7(t),e.writable&&e.end()}catch(n){await t1e(r),o1e(e,n)}},C7=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await SE(r,e),await SE(n,e)&&(o1e(t,i),await bU(e,i))},o1e=(t,e)=>{wU(t,t.writable,e)};import{Duplex as c2t}from"stream";import{callbackify as u2t}from"util";var a1e=({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}=w7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=O7(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=T7(c,a),{read:g,onStdoutDataDone:y}=A7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new c2t({read:g,...I7(l,t,d),destroy:u2t(l2t.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 R7({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:l}),P7(l,E,c),E},l2t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([x7({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),C7({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var k7=(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 d2t(a,o,t)},d2t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var c1e=(t,{encoding:e})=>{let r=QMe();t.readable=r1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=s1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=a1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=k7.bind(void 0,t,e),t[Symbol.asyncIterator]=k7.bind(void 0,t,e,{})};var u1e=(t,e)=>{for(let[r,n]of p2t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},f2t=(async()=>{})().constructor.prototype,p2t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(f2t,t)]);var l1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=g2t(t,e,r),{subprocess:f,promise:p}=y2t({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}),u1e(f,p),ou.set(f,{options:l,fileDescriptors:d}),f},g2t=(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=_2t(u),d=vMe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},_2t=({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}},y2t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=m2t(...J1(t,e,r))}catch(h){return _Me({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;h2t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];PMe(c,a,u),kMe(c,r,u);let d={},f=su();c.kill=G$e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=GMe(c,r),c1e(c,r),hMe(c,r);let p=S2t({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}},S2t=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 XMe({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)=>Ol(_,e,w)),E=Ol(m,e,"all"),S=E2t({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)},E2t=({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,v2t(n,t[n],i)]));return{...t,...r}},v2t=(t,e,r)=>b2t.has(t)&&Qr(e)&&Qr(r)?{...e,...r}:r,b2t=new Set(["env",...cQ]);var Df=(t,e,r,n)=>{let i=(o,a,c)=>Df(o,a,r,c),s=(...o)=>w2t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},w2t=({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}=T2t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?cMe(a,c,u):l1e(a,c,u,i)},T2t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=vNe(e)?bNe(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 d1e=({file:t,commandArguments:e})=>p1e(t,e),f1e=({file:t,commandArguments:e})=>({...p1e(t,e),isSync:!0}),p1e=(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]=A2t(t);return{file:r,commandArguments:n}},A2t=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(R2t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},R2t=/ +/g;var h1e=(t,e,r)=>{t.sync=e(x2t,r),t.s=t.sync},m1e=({options:t})=>g1e(t),x2t=({options:t})=>({...g1e(t),isSync:!0}),g1e=t=>({options:{...O2t(t),...t}}),O2t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},_1e={preferLocal:!0};var y1e=Df(()=>({})),t4r=Df(()=>({isSync:!0})),S1e=Df(d1e),r4r=Df(f1e),n4r=Df(IDe),i4r=Df(m1e,{},_1e,h1e),{sendMessage:s4r,getOneMessage:o4r,getEachMessage:a4r,getCancelSignal:c4r}=mMe();import{Transform as I2t}from"stream";var P2t=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function C2t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...P2t])]}function k2t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function N2t(){let e=C2t().map(r=>process.env[r]).filter(r=>!(!r||k2t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ei(t){if(typeof t!="string")return t;let e=N2t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp($2t(n),"g");r=r.replace(i,"******")}),r}function $2t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Tx=class extends I2t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ei(i);n(null,s)}},AU=Symbol("maskedWrite");function E1e(){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 v1e=!1,b1e,N7=t=>{b1e??=t},w1e=t=>{v1e=!0,N7(t)},en=()=>v1e,Xo=()=>b1e,T1e=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Ax=null,A1e=t=>(Ax&&Ax.destroy(),Ax=new Qo({totalAllowedTime:t}),Ax),R1e=()=>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 x1e={name:"@netlify/agent-runner-cli",type:"module",version:"2.11.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!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 U2t=L2t(import.meta.url),F2t=Il.dirname(U2t),j2t=M2t(import.meta.url),EE=he("shell"),$7=new Set,O1e={preferLocal:!0},Ut=(t,e,r)=>{let[n,i]=z2t(e,r),s={...O1e,...i},o=y1e(t,n,s);P1e(o,s),N1e(o);let a=r?.idleTimeout;return a&&a>0&&k1e(o,a),o},I1e=(t,e)=>{let r={...O1e,...e},n=S1e(t,r);return P1e(n,r),N1e(n),e?.idleTimeout&&e.idleTimeout>0&&k1e(n,e.idleTimeout),n},z2t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},P1e=(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)},D7=(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}},C1e=t=>D7(t,"SIGKILL"),k1e=(t,e)=>{let r=null,n=()=>{EE.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),D7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing idle process ${t.pid}`),C1e(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)},N1e=t=>{$7.add(t);let e=R1e();if(e){let r=e.onTimesUp(()=>{EE.log(`Global timer expired, killing process ${t.pid}`),D7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing process ${t.pid} after timeout`),C1e(t))},5e3)});t.on("exit",()=>{$7.delete(t),r()}),t.on("error",()=>{$7.delete(t),r()})}};function lu(t,e){if(!uu.env.NETLIFY_LOCAL_MODE)try{let i=j2t.resolve(x1e.name),s=Il.dirname(i);for(;s!==Il.dirname(s);){let o=Il.dirname(s);if(Il.basename(o)==="node_modules"){let a=Il.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=Il.join(uu.env.NODE_PATH,".bin",e);if(RU.existsSync(i))return i}let r=Il.join(t,"node_modules",".bin",e);if(RU.existsSync(r))return r;let n=Il.join(F2t,"..","node_modules",".bin",e);if(RU.existsSync(n))return n}import Oq from"process";import{fileURLToPath as nXt}from"url";import{createRequire as iXt}from"module";import AI from"path";import{readFileSync as sXt}from"fs";var q2t="__netlify__getTracer",B2t="__netlify__shutdownTracers",$t=(t,e)=>globalThis[q2t]?.(t,e),$1e=async()=>globalThis[B2t]?.();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 KZt}from"timers/promises";Ue();import MHt from"process";Ue();var V2t=(t,e)=>{e.recordException(t),e.setStatus({code:qn.ERROR})};var Pl=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}=D1e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>L1e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=D1e(r,n,i),c=this._tracer.startSpan(e,s,o);return L1e(c,s,a)}};function D1e(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 L1e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:V2t,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 M7=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=G1e(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=G1e(this._rawAttributes),this._schemaUrl=H2t(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=G2t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function U7(t,e){return M7.FromAttributeList(Object.entries(t),e)}function G1e(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 H2t(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 G2t(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}},W1e=new xx;var Ox=Symbol.for("io.opentelemetry.js.api.logs"),wE=globalThis;function K1e(t,e,r){return n=>n===t?e:r}var F7=1;var j7=class{getLogger(e,r,n){return new xx}},IU=new j7;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):W1e}};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]=K1e(F7,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,F7))!==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 Y1e=CU.getInstance();function J1e(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 Z1e(t){t.forEach(e=>e.disable())}function z7(t){let e=t.tracerProvider||Wt.getTracerProvider(),r=t.meterProvider||xR.getMeterProvider(),n=t.loggerProvider||Y1e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return J1e(i,e,r,n),()=>{Z1e(i)}}Ue();var W2t=zn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function X1e(t){return t.getValue(W2t)===!0}var TE;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(TE||(TE={}));Ue();var q7="[_0-9a-z-*/]",K2t=`[a-z]${q7}{0,255}`,Y2t=`[a-z0-9]${q7}{0,240}@[a-z]${q7}{0,13}`,J2t=new RegExp(`^(?:${K2t}|${Y2t})$`),Z2t=/^[ -~]{0,255}[!-~]$/,X2t=/,|=/;function B7(t){return J2t.test(t)}function V7(t){return Z2t.test(t)&&!X2t.test(t)}var Q2t=32,Q1e=512,eUe=",",tUe="=",kU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!B7(e)||!V7(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>Q1e)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=eUe+e),e=`${n[0]}${tUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(eUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(tUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!B7(a)||!V7(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>Q1e)&&(r.set(a,c),n=u,r.size>=Q2t))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",eVt="00",tVt="(?!ff)[\\da-f]{2}",rVt="(?![0]{32})[\\da-f]{32}",nVt="(?![0]{16})[\\da-f]{16}",iVt="[\\da-f]{2}",sVt=new RegExp(`^\\s?(${tVt})-(${rVt})-(${nVt})-(${iVt})(-.*)?\\s?$`);function rUe(t){let e=sVt.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||X1e(e)||!ws(i))return;let s=`${eVt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||zr.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=rUe(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(kee(),1);Ue();var eze=t=>{throw TypeError(t)},Lee=(t,e,r)=>e.has(t)||eze("Cannot "+r),xF=(t,e,r)=>(Lee(t,e,"read from private field"),r?r.call(t):e.get(t)),Nee=(t,e,r)=>e.has(t)?eze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Zje=(t,e,r,n)=>(Lee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),LHt=(t,e,r)=>(Lee(t,e,"access private method"),r),Xje="__netlify__getTracer",UHt="__netlify__shutdownTracers",FHt="__nfOTLPTrace",Yx,Jx,Dee,tze,jHt=class{constructor(){Nee(this,Dee),Nee(this,Yx),Nee(this,Jx),Zje(this,Yx,new Px(LHt(this,Dee,tze),this)),Zje(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(FHt,JSON.stringify(zHt(t))),e({code:TE.SUCCESS})}shutdown(){return xF(this,Yx).call()}};Yx=new WeakMap;Jx=new WeakMap;Dee=new WeakSet;tze=function(){return xF(this,Jx).debug("Shutting down"),Promise.resolve()};function zHt(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:$ee(e.startTime),endTimeUnixNano:$ee(e.endTime),attributes:RF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:$ee(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=>rze(e,t[e]))}function rze(t,e){return{key:t,value:nze(e)}}function nze(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(nze)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>rze(r,n))}}:{}}function $ee(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var Qje={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"}},ize=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Xje))return;let e=MHt.version.slice(1),r=U7({"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??[qHt()],i=new OF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Lf});let s=t.instrumentations??[];z7({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,Xje,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Pl(Wt.getTracer(a,c)):new Pl(Wt.getTracer(Qje.name,Qje.version))}}),Object.defineProperty(globalThis,UHt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},qHt=()=>new OF.SimpleSpanProcessor(new jHt);Ue();var LE=En(kee(),1);Ue();import*as IF from"diagnostics_channel";var sze=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 Pl?t:new Pl(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 W6e=En(B6e(),1);Cse();var V6e=0;var GZt=3*1024*1024,WZt=t=>SI.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Rq=class{constructor(e,r=GZt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=WZt(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:V6e});return}this.inner.export(n[c],u=>{u.code!==V6e&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var Lv=he("tracing"),H6e=8e3,YZt=5e3,G6e=t=>t.length>H6e?`${t.slice(0,H6e)}\u2026`:t,bI={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},JZt=Math.ceil(bI.maxQueueSize/bI.maxExportBatchSize)+1,ZZt=t=>new LE.BatchSpanProcessor(new Rq(new W6e.OTLPTraceExporter({url:t,concurrencyLimit:JZt})),bI),yg=async(t=YZt)=>{try{let e=Symbol("timed out");await Promise.race([$1e(),KZt(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)}},K6e=async(t,e,r)=>{if(!$t()){let n=[new LE.SimpleSpanProcessor(new Nse),ZZt(r.exporterUrl)];await ize({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new sze({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 Nse=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 $se(){return We().captureLlmContentEnabled}function Y6e(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 XZt=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 J6e(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=$se(),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&&XZt.has(a.category)||a.category===ee.AgentMessage&&a.toolCallId!==void 0,f=d?"execute_tool":"chat",p=G6e(a.title||a.type||`step-${a.id??c}`),h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?G6e(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 QZt,rm as eXt}from"fs/promises";import{join as tXt}from"path";async function Z6e(t,e=[]){let n=(await QZt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>eXt(tXt(t,i),{recursive:!0,force:!0})))}var rXt=300,wI=t=>We().budgetCreditThresholds[t.mode]?.[t.runner]??rXt,TI=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Dse=t=>{let e=wI(t);if(!TI(t,e))return"default";let r=We();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},X6e=t=>{let e=Dse(t),r=wI(t);return{budget_eligible:TI(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var oXt=AI.dirname(nXt(import.meta.url)),Q6e=iXt(import.meta.url),aXt=AI.resolve(oXt,"scripts/scaffold.js"),cXt="scripts/scaffold.js",uXt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,Lse=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},lXt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),dXt=t=>{let e=Lse(t);return e==="node"||e.endsWith("/node")},lo=t=>{if(typeof t!="string")return!1;let e=t.match(uXt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&lXt(Lse(e[r]));)r+=1;if(r>=e.length||!dXt(e[r]))return!1;let n=e[r+1];return n?Lse(n).includes(cXt):!1},Sg=he("create_stage"),Mse="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.",fXt=`${Mse}
|
|
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.`,pXt=`${Mse}
|
|
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:T5},kht=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Nht={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:kht};import{Buffer as $ht}from"buffer";var KRe=(t,e)=>t?void 0:Dht.bind(void 0,e),Dht=function*(t,e){if(typeof e!="string"&&!Wr(e)&&!$ht.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},YRe=(t,e)=>t?Mht.bind(void 0,e):Lht.bind(void 0,e),Mht=function*(t,e){ZRe(t,e),yield e},Lht=function*(t,e){if(ZRe(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},ZRe=(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 Uht}from"buffer";import{StringDecoder as Fht}from"string_decoder";var wM=(t,e,r)=>{if(r)return;if(t)return{transform:zht.bind(void 0,new TextEncoder)};let n=new Fht(e);return{transform:jht.bind(void 0,n),final:Bht.bind(void 0,n)}},zht=function*(t,e){Uht.isBuffer(e)?yield gu(e):typeof e=="string"?yield t.encode(e):yield e},jht=function*(t,e){yield Wr(e)?t.write(e):e},Bht=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as XRe}from"util";var R5=XRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),TM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Vht}=e[r];for await(let i of n(t))yield*TM(i,e,r+1)},JRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*qht(r,Number(e),t)},qht=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*TM(n,r,e+1)},QRe=XRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Vht=function*(t){yield t};var x5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},exe=(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=Hht}=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*Ght(r,Number(e),t)},Ght=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Xp(n,r,e+1)},Hht=function*(t){yield t};var I5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=rxe(t,s,o),u=Zp(e),l=Zp(r),d=u?R5.bind(void 0,TM,a):x5.bind(void 0,Xp),f=u||l?R5.bind(void 0,JRe,a):x5.bind(void 0,eR),p=u||l?QRe.bind(void 0,a):void 0;return{stream:new Wht({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})}},AM=(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=rxe(s,r,a);t=exe(c,t)}return t},rxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:KRe(n,a)},wM(r,s,n),EM(r,o,n,c),{transform:t,final:e},{transform:YRe(i,a)},WRe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var nxe=(t,e)=>{for(let r of Kht(t))Yht(t,r,e)},Kht=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Yht=(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=>Zht(a,n));r.input=VA(s)},Zht=(t,e)=>{let r=AM(t,e,"utf8",!0);return Xht(r),VA(r)},Xht=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 tmt,appendFileSync as rmt}from"fs";var RM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&fy(r,n)&&!po.has(e)&&Jht(n)&&(t.some(({type:i,value:o})=>i==="native"&&Qht.has(o))||t.every(({type:i})=>Zo.has(i))),Jht=t=>t===1||t===2,Qht=new Set(["pipe","overlapped"]),ixe=async(t,e,r,n)=>{for await(let i of t)emt(e)||sxe(i,r,n)},oxe=(t,e,r)=>{for(let n of t)sxe(n,e,r)},emt=t=>t._readableState.pipes.length>0,sxe=(t,e,r)=>{let n=zD(t);ec({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var axe=({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)=>nmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},nmt=({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=gu(f),{stdioItems:h,objectMode:m}=e[r],_=imt([p],h,c,n),{serializedResult:y,finalResult:v=y}=omt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});smt({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&&amt(y,h,i),A}catch(S){return n.error=S,A}},imt=(t,e,r,n)=>{try{return AM(t,e,r,!1)}catch(i){return n.error=i,t}},omt=({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=Ewe(t,r);return n[o]?{serializedResult:s,finalResult:A5(s,!i[o],e)}:{serializedResult:s}},smt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!RM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=A5(t,!1,s);try{oxe(a,e,n)}catch(c){r.error??=c}},amt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>vM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?rmt(n,t):(r.add(o),tmt(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,Su(e,r,"all")]:Array.isArray(e)?[Su(t,r,"all"),...e]:Wr(t)&&Wr(e)?$9([t,e]):`${t}${e}`};import{once as O5}from"events";var uxe=async(t,e)=>{let[r,n]=await cmt(t);return e.isForcefullyTerminated??=!1,[r,n]},cmt=async t=>{let[e,r]=await Promise.allSettled([O5(t,"spawn"),O5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?lxe(t):r.value},lxe=async t=>{try{return await O5(t,"exit")}catch{return lxe(t)}},dxe=async t=>{let[e,r]=await t;if(!umt(e,r)&&P5(e,r))throw new oa;return[e,r]},umt=(t,e)=>t===void 0&&e===void 0,P5=(t,e)=>t!==0||e!==null;var fxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=lmt(t,e,r),s=o?.code==="ETIMEDOUT",a=aRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},lmt=(t,e,r)=>t!==void 0?t:P5(e,r)?new oa:void 0;var pxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=fmt(t,e,r),d=mmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Ey(d,c,u)},fmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BD(t,e,r),a=pmt(r),{file:c,commandArguments:u,options:l}=cM(t,e,a);hmt(l);let d=qRe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},pmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,hmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&xM("ipcInput"),t&&xM("ipc: true"),r&&xM("detached: true"),n&&xM("cancelSignal")},xM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},mmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=gmt({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}=fxe(c,r),{output:h,error:m=u}=axe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Su(v,r,A)),y=Su(cxe(h,r),r,"all");return ymt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},gmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{nxe(o,r);let a=_mt(r);return dmt(...uM(t,e,a))}catch(a){return by({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},_mt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:gM(e)}),ymt=({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?_M({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 o_t}from"events";import{spawn as s_t}from"child_process";import yxe from"process";import{once as C5,on as Smt}from"events";var hxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(my({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:rM(t)}),vmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),vmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{JD(e,i);let o=ad(t,e,r),s=new AbortController;try{return await Promise.race([bmt(o,n,s),Emt(o,r,s),wmt(o,r,s)])}catch(a){throw gy(t),a}finally{s.abort(),QD(e,i)}},bmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await C5(t,"message",{signal:r});return n}for await(let[n]of Smt(t,"message",{signal:r}))if(e(n))return n},Emt=async(t,e,{signal:r})=>{await C5(t,"disconnect",{signal:r}),eAe(e)},wmt=async(t,e,{signal:r})=>{let[n]=await C5(t,"strict:error",{signal:r});throw YD(n,e)};import{once as gxe,on as Tmt}from"events";var _xe=({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})=>{my({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:rM(t)}),JD(e,o);let s=ad(t,e,r),a=new AbortController,c={};return Amt(t,s,a),Rmt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),xmt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Amt=async(t,e,r)=>{try{await gxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Rmt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await gxe(t,"strict:error",{signal:r.signal});n.error=YD(i,e),r.abort()}catch{}},xmt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Tmt(r,"message",{signal:o.signal}))mxe(s),yield c}catch{mxe(s)}finally{o.abort(),QD(e,a),n||gy(t),i&&await t}},mxe=({error:t})=>{if(t)throw t};var Sxe=(t,{ipc:e})=>{Object.assign(t,bxe(t,!1,e))},vxe=()=>{let t=yxe,e=!0,r=yxe.channel!==void 0;return{...bxe(t,e,r),getCancelSignal:xAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},bxe=(t,e,r)=>({sendMessage:sM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:hxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:_xe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Imt}from"child_process";import{PassThrough as Omt,Readable as Pmt,Writable as Cmt,Duplex as kmt}from"stream";var Exe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{E5(n);let a=new Imt;Nmt(a,n),Object.assign(a,{readable:$mt,writable:Dmt,duplex:Mmt});let c=by({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=Lmt(c,s,i);return{subprocess:a,promise:u}},Nmt=(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 Omt;return t.end(),t},$mt=()=>new Pmt({read(){}}),Dmt=()=>new Cmt({write(){}}),Mmt=()=>new kmt({read(){},write(){}}),Lmt=async(t,e,r)=>Ey(t,e,r);import{createReadStream as wxe,createWriteStream as Txe}from"fs";import{Buffer as Umt}from"buffer";import{Readable as rR,Writable as Fmt,Duplex as zmt}from"stream";var Rxe=(t,e)=>bM(jmt,t,e,!1),nR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${cd[t]}.`)},Axe={fileNumber:nR,generator:I5,asyncGenerator:I5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:zmt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},jmt={input:{...Axe,fileUrl:({value:t})=>({stream:wxe(t)}),filePath:({value:{file:t}})=>({stream:wxe(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(Umt.from(t))})},output:{...Axe,fileUrl:({value:t})=>({stream:Txe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Txe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Fmt.fromWeb(t)}),iterable:nR,asyncIterable:nR,string:nR,uint8Array:nR}};import{on as Bmt,once as xxe}from"events";import{PassThrough as qmt,getDefaultHighWaterMark as Vmt}from"stream";import{finished as Pxe}from"stream/promises";function Jp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)$5(i);let e=t.some(({readableObjectMode:i})=>i),r=Gmt(t,e),n=new N5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Gmt=(t,e)=>{if(t.length===0)return Vmt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},N5=class extends qmt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if($5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Hmt(this,this.#e,this.#o);let r=Ymt({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($5(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)}},Hmt=async(t,e,r)=>{IM(t,Ixe);let n=new AbortController;try{await Promise.race([Wmt(t,n),Kmt(t,e,r,n)])}finally{n.abort(),IM(t,-Ixe)}},Wmt=async(t,{signal:e})=>{try{await Pxe(t,{signal:e,cleanup:!0})}catch(r){throw Cxe(t,r),r}},Kmt=async(t,e,r,{signal:n})=>{for await(let[i]of Bmt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},$5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Ymt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{IM(t,Oxe);let a=new AbortController;try{await Promise.race([Zmt(o,e,a),Xmt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Jmt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),IM(t,-Oxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?D5(t):Qmt(t))},Zmt=async(t,e,{signal:r})=>{try{await t,r.aborted||D5(e)}catch(n){r.aborted||Cxe(e,n)}},Xmt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Pxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;kxe(s)?i.add(e):Nxe(t,s)}},Jmt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await xxe(t,i,{signal:o}),!t.readable)return xxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Qmt=t=>{t.writable&&t.end()},Cxe=(t,e)=>{kxe(e)?D5(t):Nxe(t,e)},kxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",D5=t=>{(t.readable||t.writable)&&t.destroy()},Nxe=(t,e)=>{t.destroyed||(t.once("error",egt),t.destroy(e))},egt=()=>{},IM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Ixe=2,Oxe=1;import{finished as $xe}from"stream/promises";var Ty=(t,e)=>{t.pipe(e),tgt(t,e),rgt(t,e)},tgt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await $xe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}M5(e)}},M5=t=>{t.writable&&t.end()},rgt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await $xe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}L5(t)}},L5=t=>{t.readable&&t.destroy()};var Dxe=(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)))ngt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zo.has(c)))ogt({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)}},ngt=(t,e,r,n)=>{r==="output"?Ty(t.stdio[n],e):Ty(e,t.stdio[n]);let i=igt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},igt=["stdin","stdout","stderr"],ogt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;sgt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},sgt=(t,{signal:e})=>{ia(t)&&Kp(t,agt,e)},agt=2;import{addAbortListener as lgt}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 OM=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",U5=Symbol.for("signal-exit emitter"),F5=globalThis,cgt=Object.defineProperty.bind(Object),z5=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(F5[U5])return F5[U5];cgt(F5,U5,{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}},PM=class{},ugt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),j5=class extends PM{onExit(){return()=>{}}load(){}unload(){}},B5=class extends PM{#e=q5.platform==="win32"?"SIGINT":"SIGHUP";#r=new z5;#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(!OM(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 OM(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"&&OM(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)}},q5=globalThis.process,{onExit:Mxe,load:hfr,unload:mfr}=ugt(OM(q5)?new B5(q5):new j5);var Lxe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Mxe(()=>{t.kill()});lgt(n,()=>{i()})};var Fxe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=jD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=dgt(r,n,i),{sourceStream:d,sourceError:f}=pgt(t,u),{options:p,fileDescriptors:h}=rc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},dgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=fgt(t,e,...r),a=XD(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},fgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Uxe,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]=CD(r,...n);return{destination:e(Uxe)(i,o,s),pipeOptions:s}}if(rc.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}`)},Uxe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),pgt=(t,e)=>{try{return{sourceStream:_y(t,e)}}catch(r){return{sourceError:r}}};var jxe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=hgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw V5({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},hgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return L5(t),n;if(e!==void 0)return M5(r),e},V5=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>by({error:t,command:zxe,escapedCommand:zxe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),zxe="source.pipe(destination)";var Bxe=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 mgt}from"stream/promises";var qxe=(t,e,r)=>{let n=CM.has(e)?_gt(t,e):ggt(t,e);return Kp(t,Sgt,r.signal),Kp(e,vgt,r.signal),ygt(e),n},ggt=(t,e)=>{let r=Jp([t]);return Ty(r,e),CM.set(e,r),r},_gt=(t,e)=>{let r=CM.get(e);return r.add(t),r},ygt=async t=>{try{await mgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}CM.delete(t)},CM=new WeakMap,Sgt=2,vgt=1;import{aborted as bgt}from"util";var Vxe=(t,e)=>t===void 0?[]:[Egt(t,e)],Egt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await bgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw V5({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var kM=(t,...e)=>{if(wr(e[0]))return kM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Fxe(t,...e),i=wgt({...n,destination:r});return i.pipe=kM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},wgt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Tgt(t,i);jxe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=qxe(e,o,d);return await Promise.race([Bxe(l),...Vxe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Tgt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Cgt}from"timers/promises";import{on as Agt}from"events";import{getDefaultHighWaterMark as Rgt}from"stream";var NM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return xgt(e,s),Hxe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},xgt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},G5=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;Igt(e,s,t);let a=t.readableObjectMode&&!o;return Hxe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Igt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Hxe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Agt(t,"data",{signal:e.signal,highWaterMark:Gxe,highWatermark:Gxe});return Ogt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},H5=Rgt(!0),Gxe=H5,Ogt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=Pgt({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)}},Pgt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[wM(t,r,!e),EM(t,i,!n,{})].filter(Boolean);var Wxe=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=kgt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([Ngt(t),d]);return}let f=w5(c,r),p=G5({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([$gt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},kgt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!RM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=G5({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await ixe(a,t,r,o)},Ngt=async t=>{await Cgt(),t.readableFlowing===null&&t.resume()},$gt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await pM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await hM(r,{maxBuffer:o})):await vy(r,{maxBuffer:o})}catch(a){return Kxe(iRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},W5=async t=>{try{return await t}catch(e){return Kxe(e)}},Kxe=({bufferedData:t})=>vwe(t)?new Uint8Array(t):t;import{finished as Dgt}from"stream/promises";var iR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=Mgt(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Dgt(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Fgt(a,e,r,n)}finally{s.abort()}},Mgt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Lgt(t,r,n),n},Lgt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Ugt(e,r),n.call(t,...i)}},Ugt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Fgt=(t,e,r,n)=>{if(!zgt(t,e,r,n))throw t},zgt=(t,e,r,n=!0)=>r.propagating?Yxe(t)||$M(t):(r.propagating=!0,K5(r,e)===n?Yxe(t):$M(t)),K5=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",$M=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Yxe=t=>t?.code==="EPIPE";var Zxe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>Y5({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Y5=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(K5(u,e)){await l;return}let[d]=await Promise.all([Wxe({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 Xxe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Jp([t,e].filter(Boolean)):void 0,Jxe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Y5({...jgt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Bgt(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),jgt=({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}},Bgt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as qgt}from"events";var Qxe=t=>fy(t,"ipc"),eIe=(t,e)=>{let r=zD(t);ec({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=Qxe(o),a=_u(e,"ipc"),c=_u(r,"ipc");for await(let u of k5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(oRe(t,i,c),i.push(u)),s&&eIe(u,o);return i},rIe=async(t,e)=>(await Promise.allSettled([t]),e);var nIe=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=uxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=Zxe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=Jxe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=[],I=tIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),C=Vgt(m,t,A),P=Ggt(h,A);try{return await Promise.race([Promise.all([{},dxe(v),Promise.all(S),E,I,LAe(t,d),...C,...P]),_,Hgt(t,y),...kAe(t,o,f,y),...QTe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...PAe({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=>W5(T))),W5(E),rIe(I,b),Promise.allSettled(C),Promise.allSettled(P)])}},Vgt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:iR(n,i,r)),Ggt=(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"}))),Hgt=async(t,{signal:e})=>{let[r]=await qgt(t,"error",{signal:e});throw r};var iIe=()=>({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=tc();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 Wgt}from"stream";import{callbackify as Kgt}from"util";import{finished as oIe}from"stream/promises";var Z5=async t=>{if(t!==void 0)try{await X5(t)}catch{}},sIe=async t=>{if(t!==void 0)try{await J5(t)}catch{}},X5=async t=>{await oIe(t,{cleanup:!0,readable:!1,writable:!0})},J5=async t=>{await oIe(t,{cleanup:!0,readable:!0,writable:!1})},DM=async(t,e)=>{if(await t,e)throw e},MM=(t,e,r)=>{r&&!$M(r)?t.destroy(r):e&&t.destroy()};var aIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||po.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Q5(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=e8(a,s),{read:f,onStdoutDataDone:p}=t8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new Wgt({read:f,destroy:Kgt(n8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return r8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Q5=(t,e,r)=>{let n=_y(t,e),i=oR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},e8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:H5},t8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=tc(),s=NM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Ygt(this,s,o)},onStdoutDataDone:o}},Ygt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},r8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await J5(t),await n,await Z5(i),await e,r.readable&&r.push(null)}catch(o){await Z5(i),cIe(r,o)}},n8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Ay(r,e)&&(cIe(t,n),await DM(e,n))},cIe=(t,e)=>{MM(t,t.readable,e)};import{Writable as Zgt}from"stream";import{callbackify as uIe}from"util";var lIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=i8(t,r,e),s=new Zgt({...o8(n,t,i),destroy:uIe(a8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return s8(n,s),s},i8=(t,e,r)=>{let n=XD(t,e),i=oR(r,n,"writableFinal"),o=oR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},o8=(t,e,r)=>({write:Xgt.bind(void 0,t),final:uIe(Jgt.bind(void 0,t,e,r))}),Xgt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Jgt=async(t,e,r)=>{await Ay(r,e)&&(t.writable&&t.end(),await e)},s8=async(t,e,r)=>{try{await X5(t),e.writable&&e.end()}catch(n){await sIe(r),dIe(e,n)}},a8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Ay(r,e),await Ay(n,e)&&(dIe(t,i),await DM(e,i))},dIe=(t,e)=>{MM(t,t.writable,e)};import{Duplex as Qgt}from"stream";import{callbackify as e_t}from"util";var fIe=({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}=Q5(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=i8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=e8(c,a),{read:_,onStdoutDataDone:y}=t8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new Qgt({read:_,...o8(l,t,d),destroy:e_t(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 r8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),s8(l,v,c),v},t_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([n8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),a8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var c8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||po.has(e),s=_y(t,r),a=NM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return r_t(a,s,t)},r_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var pIe=(t,{encoding:e})=>{let r=iIe();t.readable=aIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=lIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=fIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=c8.bind(void 0,t,e),t[Symbol.asyncIterator]=c8.bind(void 0,t,e,{})};var hIe=(t,e)=>{for(let[r,n]of i_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},n_t=(async()=>{})().constructor.prototype,i_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(n_t,t)]);var mIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=a_t(t,e,r),{subprocess:f,promise:p}=u_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=kM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),hIe(f,p),rc.set(f,{options:l,fileDescriptors:d}),f},a_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BD(t,e,r),{file:a,commandArguments:c,options:u}=cM(t,e,r),l=c_t(u),d=Rxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},c_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}},u_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=s_t(...uM(t,e,r))}catch(h){return Exe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;o_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Dxe(c,a,u),Lxe(c,r,u);let d={},f=tc();c.kill=XTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Xxe(c,r),pIe(c,r),Sxe(c,r);let p=l_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}},l_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 nIe({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=d_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)},d_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 nc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):_M({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var LM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,f_t(n,t[n],i)]));return{...t,...r}},f_t=(t,e,r)=>p_t.has(t)&&wr(e)&&wr(r)?{...e,...r}:r,p_t=new Set(["env",...U9]);var ud=(t,e,r,n)=>{let i=(s,a,c)=>ud(s,a,r,c),o=(...s)=>h_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},h_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(wr(o))return i(t,LM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=m_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?pxe(a,c,u):mIe(a,c,u,i)},m_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Rwe(e)?xwe(e,r):[e,...r],[s,a,c]=CD(...o),u=LM(LM(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 gIe=({file:t,commandArguments:e})=>yIe(t,e),_Ie=({file:t,commandArguments:e})=>({...yIe(t,e),isSync:!0}),yIe=(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]=g_t(t);return{file:r,commandArguments:n}},g_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(__t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},__t=/ +/g;var SIe=(t,e,r)=>{t.sync=e(y_t,r),t.s=t.sync},vIe=({options:t})=>bIe(t),y_t=({options:t})=>({...bIe(t),isSync:!0}),bIe=t=>({options:{...S_t(t),...t}}),S_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},EIe={preferLocal:!0};var wIe=ud(()=>({})),imr=ud(()=>({isSync:!0})),TIe=ud(gIe),omr=ud(_Ie),smr=ud($Ae),amr=ud(vIe,{},EIe,SIe),{sendMessage:cmr,getOneMessage:umr,getEachMessage:lmr,getCancelSignal:dmr}=vxe();var AIe=!1,RIe,v_t=t=>{RIe??=t},xIe=t=>{AIe=!0,v_t(t)},Bn=()=>AIe,vu=()=>RIe,IIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var sR=null,OIe=t=>(sR&&sR.destroy(),sR=new Xo({totalAllowedTime:t}),sR),PIe=()=>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 CIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.10.0-setup-request-skip.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!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 T_t=E_t(import.meta.url),A_t=bu.dirname(T_t),R_t=w_t(import.meta.url),Ry=oe("shell"),u8=new Set,kIe={preferLocal:!0},bt=(t,e,r)=>{let[n,i]=x_t(e,r),o={...kIe,...i},s=wIe(t,n,o);$Ie(s,o),LIe(s);let a=r?.idleTimeout;return a&&a>0&&MIe(s,a),s},NIe=(t,e)=>{let r={...kIe,...e},n=TIe(t,r);return $Ie(n,r),LIe(n),e?.idleTimeout&&e.idleTimeout>0&&MIe(n,e.idleTimeout),n},x_t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},$Ie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||oc.env.NETLIFY_LOCAL_QUIET==="true")return;if(oc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Ow).pipe(oc.stdout),t.stderr?.pipe(new Ow).pipe(oc.stderr);return}t.stdout?.pipe(oc.stdout),t.stderr?.pipe(oc.stderr)},l8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(oc.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}},DIe=t=>l8(t,"SIGKILL"),MIe=(t,e)=>{let r=null,n=()=>{Ry.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),l8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing idle process ${t.pid}`),DIe(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)},LIe=t=>{u8.add(t);let e=PIe();if(e){let r=e.onTimesUp(()=>{Ry.log(`Global timer expired, killing process ${t.pid}`),l8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing process ${t.pid} after timeout`),DIe(t))},5e3)});t.on("exit",()=>{u8.delete(t),r()}),t.on("error",()=>{u8.delete(t),r()})}};function sc(t,e){if(!oc.env.NETLIFY_LOCAL_MODE)try{let i=R_t.resolve(CIe.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(UM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(oc.env.NODE_PATH){let i=bu.join(oc.env.NODE_PATH,".bin",e);if(UM.existsSync(i))return i}let r=bu.join(t,"node_modules",".bin",e);if(UM.existsSync(r))return r;let n=bu.join(A_t,"..","node_modules",".bin",e);if(UM.existsSync(n))return n}var xy=oe("repo"),VIe="runner-diffs-",d8=t=>`${VIe}${t}-`,GIe=async t=>{let e=zM.tmpdir(),r;try{r=await di.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(VIe)&&!n.startsWith(d8(t))).map(n=>di.rm(Jo.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},UIe=async t=>{let e=I_t("sha256");for await(let r of O_t(t))e.update(r);return e.digest("hex")},FIe=async(t,e)=>t.size===e.size&&await UIe(t.path)===await UIe(e.path),HIe=/.. (.+)?\.log$/,P_t=[HIe],C_t=1,zIe=t=>{let e=t.split(`
|
|
385
|
+
if (condition) { yield value; }`)};import{Buffer as Uht}from"buffer";import{StringDecoder as Fht}from"string_decoder";var wM=(t,e,r)=>{if(r)return;if(t)return{transform:zht.bind(void 0,new TextEncoder)};let n=new Fht(e);return{transform:jht.bind(void 0,n),final:Bht.bind(void 0,n)}},zht=function*(t,e){Uht.isBuffer(e)?yield gu(e):typeof e=="string"?yield t.encode(e):yield e},jht=function*(t,e){yield Wr(e)?t.write(e):e},Bht=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as XRe}from"util";var R5=XRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),TM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Vht}=e[r];for await(let i of n(t))yield*TM(i,e,r+1)},JRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*qht(r,Number(e),t)},qht=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*TM(n,r,e+1)},QRe=XRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Vht=function*(t){yield t};var x5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},exe=(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=Hht}=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*Ght(r,Number(e),t)},Ght=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Xp(n,r,e+1)},Hht=function*(t){yield t};var I5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=rxe(t,s,o),u=Zp(e),l=Zp(r),d=u?R5.bind(void 0,TM,a):x5.bind(void 0,Xp),f=u||l?R5.bind(void 0,JRe,a):x5.bind(void 0,eR),p=u||l?QRe.bind(void 0,a):void 0;return{stream:new Wht({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})}},AM=(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=rxe(s,r,a);t=exe(c,t)}return t},rxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:KRe(n,a)},wM(r,s,n),EM(r,o,n,c),{transform:t,final:e},{transform:YRe(i,a)},WRe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var nxe=(t,e)=>{for(let r of Kht(t))Yht(t,r,e)},Kht=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Yht=(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=>Zht(a,n));r.input=VA(s)},Zht=(t,e)=>{let r=AM(t,e,"utf8",!0);return Xht(r),VA(r)},Xht=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 tmt,appendFileSync as rmt}from"fs";var RM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&fy(r,n)&&!po.has(e)&&Jht(n)&&(t.some(({type:i,value:o})=>i==="native"&&Qht.has(o))||t.every(({type:i})=>Zo.has(i))),Jht=t=>t===1||t===2,Qht=new Set(["pipe","overlapped"]),ixe=async(t,e,r,n)=>{for await(let i of t)emt(e)||sxe(i,r,n)},oxe=(t,e,r)=>{for(let n of t)sxe(n,e,r)},emt=t=>t._readableState.pipes.length>0,sxe=(t,e,r)=>{let n=zD(t);ec({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var axe=({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)=>nmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},nmt=({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=gu(f),{stdioItems:h,objectMode:m}=e[r],_=imt([p],h,c,n),{serializedResult:y,finalResult:v=y}=omt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});smt({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&&amt(y,h,i),A}catch(S){return n.error=S,A}},imt=(t,e,r,n)=>{try{return AM(t,e,r,!1)}catch(i){return n.error=i,t}},omt=({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=Ewe(t,r);return n[o]?{serializedResult:s,finalResult:A5(s,!i[o],e)}:{serializedResult:s}},smt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!RM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=A5(t,!1,s);try{oxe(a,e,n)}catch(c){r.error??=c}},amt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>vM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?rmt(n,t):(r.add(o),tmt(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,Su(e,r,"all")]:Array.isArray(e)?[Su(t,r,"all"),...e]:Wr(t)&&Wr(e)?$9([t,e]):`${t}${e}`};import{once as O5}from"events";var uxe=async(t,e)=>{let[r,n]=await cmt(t);return e.isForcefullyTerminated??=!1,[r,n]},cmt=async t=>{let[e,r]=await Promise.allSettled([O5(t,"spawn"),O5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?lxe(t):r.value},lxe=async t=>{try{return await O5(t,"exit")}catch{return lxe(t)}},dxe=async t=>{let[e,r]=await t;if(!umt(e,r)&&P5(e,r))throw new oa;return[e,r]},umt=(t,e)=>t===void 0&&e===void 0,P5=(t,e)=>t!==0||e!==null;var fxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=lmt(t,e,r),s=o?.code==="ETIMEDOUT",a=aRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},lmt=(t,e,r)=>t!==void 0?t:P5(e,r)?new oa:void 0;var pxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=fmt(t,e,r),d=mmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Ey(d,c,u)},fmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BD(t,e,r),a=pmt(r),{file:c,commandArguments:u,options:l}=cM(t,e,a);hmt(l);let d=qRe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},pmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,hmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&xM("ipcInput"),t&&xM("ipc: true"),r&&xM("detached: true"),n&&xM("cancelSignal")},xM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},mmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=gmt({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}=fxe(c,r),{output:h,error:m=u}=axe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Su(v,r,A)),y=Su(cxe(h,r),r,"all");return ymt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},gmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{nxe(o,r);let a=_mt(r);return dmt(...uM(t,e,a))}catch(a){return by({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},_mt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:gM(e)}),ymt=({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?_M({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 o_t}from"events";import{spawn as s_t}from"child_process";import yxe from"process";import{once as C5,on as Smt}from"events";var hxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(my({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:rM(t)}),vmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),vmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{JD(e,i);let o=ad(t,e,r),s=new AbortController;try{return await Promise.race([bmt(o,n,s),Emt(o,r,s),wmt(o,r,s)])}catch(a){throw gy(t),a}finally{s.abort(),QD(e,i)}},bmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await C5(t,"message",{signal:r});return n}for await(let[n]of Smt(t,"message",{signal:r}))if(e(n))return n},Emt=async(t,e,{signal:r})=>{await C5(t,"disconnect",{signal:r}),eAe(e)},wmt=async(t,e,{signal:r})=>{let[n]=await C5(t,"strict:error",{signal:r});throw YD(n,e)};import{once as gxe,on as Tmt}from"events";var _xe=({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})=>{my({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:rM(t)}),JD(e,o);let s=ad(t,e,r),a=new AbortController,c={};return Amt(t,s,a),Rmt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),xmt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Amt=async(t,e,r)=>{try{await gxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Rmt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await gxe(t,"strict:error",{signal:r.signal});n.error=YD(i,e),r.abort()}catch{}},xmt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Tmt(r,"message",{signal:o.signal}))mxe(s),yield c}catch{mxe(s)}finally{o.abort(),QD(e,a),n||gy(t),i&&await t}},mxe=({error:t})=>{if(t)throw t};var Sxe=(t,{ipc:e})=>{Object.assign(t,bxe(t,!1,e))},vxe=()=>{let t=yxe,e=!0,r=yxe.channel!==void 0;return{...bxe(t,e,r),getCancelSignal:xAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},bxe=(t,e,r)=>({sendMessage:sM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:hxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:_xe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Imt}from"child_process";import{PassThrough as Omt,Readable as Pmt,Writable as Cmt,Duplex as kmt}from"stream";var Exe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{E5(n);let a=new Imt;Nmt(a,n),Object.assign(a,{readable:$mt,writable:Dmt,duplex:Mmt});let c=by({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=Lmt(c,s,i);return{subprocess:a,promise:u}},Nmt=(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 Omt;return t.end(),t},$mt=()=>new Pmt({read(){}}),Dmt=()=>new Cmt({write(){}}),Mmt=()=>new kmt({read(){},write(){}}),Lmt=async(t,e,r)=>Ey(t,e,r);import{createReadStream as wxe,createWriteStream as Txe}from"fs";import{Buffer as Umt}from"buffer";import{Readable as rR,Writable as Fmt,Duplex as zmt}from"stream";var Rxe=(t,e)=>bM(jmt,t,e,!1),nR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${cd[t]}.`)},Axe={fileNumber:nR,generator:I5,asyncGenerator:I5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:zmt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},jmt={input:{...Axe,fileUrl:({value:t})=>({stream:wxe(t)}),filePath:({value:{file:t}})=>({stream:wxe(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(Umt.from(t))})},output:{...Axe,fileUrl:({value:t})=>({stream:Txe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Txe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Fmt.fromWeb(t)}),iterable:nR,asyncIterable:nR,string:nR,uint8Array:nR}};import{on as Bmt,once as xxe}from"events";import{PassThrough as qmt,getDefaultHighWaterMark as Vmt}from"stream";import{finished as Pxe}from"stream/promises";function Jp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)$5(i);let e=t.some(({readableObjectMode:i})=>i),r=Gmt(t,e),n=new N5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Gmt=(t,e)=>{if(t.length===0)return Vmt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},N5=class extends qmt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if($5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Hmt(this,this.#e,this.#o);let r=Ymt({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($5(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)}},Hmt=async(t,e,r)=>{IM(t,Ixe);let n=new AbortController;try{await Promise.race([Wmt(t,n),Kmt(t,e,r,n)])}finally{n.abort(),IM(t,-Ixe)}},Wmt=async(t,{signal:e})=>{try{await Pxe(t,{signal:e,cleanup:!0})}catch(r){throw Cxe(t,r),r}},Kmt=async(t,e,r,{signal:n})=>{for await(let[i]of Bmt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},$5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Ymt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{IM(t,Oxe);let a=new AbortController;try{await Promise.race([Zmt(o,e,a),Xmt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Jmt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),IM(t,-Oxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?D5(t):Qmt(t))},Zmt=async(t,e,{signal:r})=>{try{await t,r.aborted||D5(e)}catch(n){r.aborted||Cxe(e,n)}},Xmt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Pxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;kxe(s)?i.add(e):Nxe(t,s)}},Jmt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await xxe(t,i,{signal:o}),!t.readable)return xxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Qmt=t=>{t.writable&&t.end()},Cxe=(t,e)=>{kxe(e)?D5(t):Nxe(t,e)},kxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",D5=t=>{(t.readable||t.writable)&&t.destroy()},Nxe=(t,e)=>{t.destroyed||(t.once("error",egt),t.destroy(e))},egt=()=>{},IM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Ixe=2,Oxe=1;import{finished as $xe}from"stream/promises";var Ty=(t,e)=>{t.pipe(e),tgt(t,e),rgt(t,e)},tgt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await $xe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}M5(e)}},M5=t=>{t.writable&&t.end()},rgt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await $xe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}L5(t)}},L5=t=>{t.readable&&t.destroy()};var Dxe=(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)))ngt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zo.has(c)))ogt({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)}},ngt=(t,e,r,n)=>{r==="output"?Ty(t.stdio[n],e):Ty(e,t.stdio[n]);let i=igt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},igt=["stdin","stdout","stderr"],ogt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;sgt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},sgt=(t,{signal:e})=>{ia(t)&&Kp(t,agt,e)},agt=2;import{addAbortListener as lgt}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 OM=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",U5=Symbol.for("signal-exit emitter"),F5=globalThis,cgt=Object.defineProperty.bind(Object),z5=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(F5[U5])return F5[U5];cgt(F5,U5,{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}},PM=class{},ugt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),j5=class extends PM{onExit(){return()=>{}}load(){}unload(){}},B5=class extends PM{#e=q5.platform==="win32"?"SIGINT":"SIGHUP";#r=new z5;#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(!OM(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 OM(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"&&OM(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)}},q5=globalThis.process,{onExit:Mxe,load:hfr,unload:mfr}=ugt(OM(q5)?new B5(q5):new j5);var Lxe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Mxe(()=>{t.kill()});lgt(n,()=>{i()})};var Fxe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=jD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=dgt(r,n,i),{sourceStream:d,sourceError:f}=pgt(t,u),{options:p,fileDescriptors:h}=rc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},dgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=fgt(t,e,...r),a=XD(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},fgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Uxe,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]=CD(r,...n);return{destination:e(Uxe)(i,o,s),pipeOptions:s}}if(rc.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}`)},Uxe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),pgt=(t,e)=>{try{return{sourceStream:_y(t,e)}}catch(r){return{sourceError:r}}};var jxe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=hgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw V5({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},hgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return L5(t),n;if(e!==void 0)return M5(r),e},V5=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>by({error:t,command:zxe,escapedCommand:zxe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),zxe="source.pipe(destination)";var Bxe=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 mgt}from"stream/promises";var qxe=(t,e,r)=>{let n=CM.has(e)?_gt(t,e):ggt(t,e);return Kp(t,Sgt,r.signal),Kp(e,vgt,r.signal),ygt(e),n},ggt=(t,e)=>{let r=Jp([t]);return Ty(r,e),CM.set(e,r),r},_gt=(t,e)=>{let r=CM.get(e);return r.add(t),r},ygt=async t=>{try{await mgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}CM.delete(t)},CM=new WeakMap,Sgt=2,vgt=1;import{aborted as bgt}from"util";var Vxe=(t,e)=>t===void 0?[]:[Egt(t,e)],Egt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await bgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw V5({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var kM=(t,...e)=>{if(wr(e[0]))return kM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Fxe(t,...e),i=wgt({...n,destination:r});return i.pipe=kM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},wgt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Tgt(t,i);jxe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=qxe(e,o,d);return await Promise.race([Bxe(l),...Vxe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Tgt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Cgt}from"timers/promises";import{on as Agt}from"events";import{getDefaultHighWaterMark as Rgt}from"stream";var NM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return xgt(e,s),Hxe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},xgt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},G5=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;Igt(e,s,t);let a=t.readableObjectMode&&!o;return Hxe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Igt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Hxe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Agt(t,"data",{signal:e.signal,highWaterMark:Gxe,highWatermark:Gxe});return Ogt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},H5=Rgt(!0),Gxe=H5,Ogt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=Pgt({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)}},Pgt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[wM(t,r,!e),EM(t,i,!n,{})].filter(Boolean);var Wxe=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=kgt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([Ngt(t),d]);return}let f=w5(c,r),p=G5({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([$gt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},kgt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!RM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=G5({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await ixe(a,t,r,o)},Ngt=async t=>{await Cgt(),t.readableFlowing===null&&t.resume()},$gt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await pM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await hM(r,{maxBuffer:o})):await vy(r,{maxBuffer:o})}catch(a){return Kxe(iRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},W5=async t=>{try{return await t}catch(e){return Kxe(e)}},Kxe=({bufferedData:t})=>vwe(t)?new Uint8Array(t):t;import{finished as Dgt}from"stream/promises";var iR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=Mgt(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Dgt(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Fgt(a,e,r,n)}finally{s.abort()}},Mgt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Lgt(t,r,n),n},Lgt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Ugt(e,r),n.call(t,...i)}},Ugt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Fgt=(t,e,r,n)=>{if(!zgt(t,e,r,n))throw t},zgt=(t,e,r,n=!0)=>r.propagating?Yxe(t)||$M(t):(r.propagating=!0,K5(r,e)===n?Yxe(t):$M(t)),K5=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",$M=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Yxe=t=>t?.code==="EPIPE";var Zxe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>Y5({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Y5=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(K5(u,e)){await l;return}let[d]=await Promise.all([Wxe({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 Xxe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Jp([t,e].filter(Boolean)):void 0,Jxe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Y5({...jgt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Bgt(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),jgt=({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}},Bgt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as qgt}from"events";var Qxe=t=>fy(t,"ipc"),eIe=(t,e)=>{let r=zD(t);ec({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=Qxe(o),a=_u(e,"ipc"),c=_u(r,"ipc");for await(let u of k5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(oRe(t,i,c),i.push(u)),s&&eIe(u,o);return i},rIe=async(t,e)=>(await Promise.allSettled([t]),e);var nIe=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=uxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=Zxe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=Jxe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=[],I=tIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),C=Vgt(m,t,A),P=Ggt(h,A);try{return await Promise.race([Promise.all([{},dxe(v),Promise.all(S),E,I,LAe(t,d),...C,...P]),_,Hgt(t,y),...kAe(t,o,f,y),...QTe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...PAe({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=>W5(T))),W5(E),rIe(I,b),Promise.allSettled(C),Promise.allSettled(P)])}},Vgt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:iR(n,i,r)),Ggt=(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"}))),Hgt=async(t,{signal:e})=>{let[r]=await qgt(t,"error",{signal:e});throw r};var iIe=()=>({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=tc();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 Wgt}from"stream";import{callbackify as Kgt}from"util";import{finished as oIe}from"stream/promises";var Z5=async t=>{if(t!==void 0)try{await X5(t)}catch{}},sIe=async t=>{if(t!==void 0)try{await J5(t)}catch{}},X5=async t=>{await oIe(t,{cleanup:!0,readable:!1,writable:!0})},J5=async t=>{await oIe(t,{cleanup:!0,readable:!0,writable:!1})},DM=async(t,e)=>{if(await t,e)throw e},MM=(t,e,r)=>{r&&!$M(r)?t.destroy(r):e&&t.destroy()};var aIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||po.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Q5(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=e8(a,s),{read:f,onStdoutDataDone:p}=t8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new Wgt({read:f,destroy:Kgt(n8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return r8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Q5=(t,e,r)=>{let n=_y(t,e),i=oR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},e8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:H5},t8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=tc(),s=NM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Ygt(this,s,o)},onStdoutDataDone:o}},Ygt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},r8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await J5(t),await n,await Z5(i),await e,r.readable&&r.push(null)}catch(o){await Z5(i),cIe(r,o)}},n8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Ay(r,e)&&(cIe(t,n),await DM(e,n))},cIe=(t,e)=>{MM(t,t.readable,e)};import{Writable as Zgt}from"stream";import{callbackify as uIe}from"util";var lIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=i8(t,r,e),s=new Zgt({...o8(n,t,i),destroy:uIe(a8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return s8(n,s),s},i8=(t,e,r)=>{let n=XD(t,e),i=oR(r,n,"writableFinal"),o=oR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},o8=(t,e,r)=>({write:Xgt.bind(void 0,t),final:uIe(Jgt.bind(void 0,t,e,r))}),Xgt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Jgt=async(t,e,r)=>{await Ay(r,e)&&(t.writable&&t.end(),await e)},s8=async(t,e,r)=>{try{await X5(t),e.writable&&e.end()}catch(n){await sIe(r),dIe(e,n)}},a8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Ay(r,e),await Ay(n,e)&&(dIe(t,i),await DM(e,i))},dIe=(t,e)=>{MM(t,t.writable,e)};import{Duplex as Qgt}from"stream";import{callbackify as e_t}from"util";var fIe=({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}=Q5(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=i8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=e8(c,a),{read:_,onStdoutDataDone:y}=t8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new Qgt({read:_,...o8(l,t,d),destroy:e_t(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 r8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),s8(l,v,c),v},t_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([n8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),a8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var c8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||po.has(e),s=_y(t,r),a=NM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return r_t(a,s,t)},r_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var pIe=(t,{encoding:e})=>{let r=iIe();t.readable=aIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=lIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=fIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=c8.bind(void 0,t,e),t[Symbol.asyncIterator]=c8.bind(void 0,t,e,{})};var hIe=(t,e)=>{for(let[r,n]of i_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},n_t=(async()=>{})().constructor.prototype,i_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(n_t,t)]);var mIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=a_t(t,e,r),{subprocess:f,promise:p}=u_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=kM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),hIe(f,p),rc.set(f,{options:l,fileDescriptors:d}),f},a_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BD(t,e,r),{file:a,commandArguments:c,options:u}=cM(t,e,r),l=c_t(u),d=Rxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},c_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}},u_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=s_t(...uM(t,e,r))}catch(h){return Exe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;o_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Dxe(c,a,u),Lxe(c,r,u);let d={},f=tc();c.kill=XTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Xxe(c,r),pIe(c,r),Sxe(c,r);let p=l_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}},l_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 nIe({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=d_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)},d_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 nc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):_M({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var LM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,f_t(n,t[n],i)]));return{...t,...r}},f_t=(t,e,r)=>p_t.has(t)&&wr(e)&&wr(r)?{...e,...r}:r,p_t=new Set(["env",...U9]);var ud=(t,e,r,n)=>{let i=(s,a,c)=>ud(s,a,r,c),o=(...s)=>h_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},h_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(wr(o))return i(t,LM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=m_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?pxe(a,c,u):mIe(a,c,u,i)},m_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Rwe(e)?xwe(e,r):[e,...r],[s,a,c]=CD(...o),u=LM(LM(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 gIe=({file:t,commandArguments:e})=>yIe(t,e),_Ie=({file:t,commandArguments:e})=>({...yIe(t,e),isSync:!0}),yIe=(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]=g_t(t);return{file:r,commandArguments:n}},g_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(__t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},__t=/ +/g;var SIe=(t,e,r)=>{t.sync=e(y_t,r),t.s=t.sync},vIe=({options:t})=>bIe(t),y_t=({options:t})=>({...bIe(t),isSync:!0}),bIe=t=>({options:{...S_t(t),...t}}),S_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},EIe={preferLocal:!0};var wIe=ud(()=>({})),imr=ud(()=>({isSync:!0})),TIe=ud(gIe),omr=ud(_Ie),smr=ud($Ae),amr=ud(vIe,{},EIe,SIe),{sendMessage:cmr,getOneMessage:umr,getEachMessage:lmr,getCancelSignal:dmr}=vxe();var AIe=!1,RIe,v_t=t=>{RIe??=t},xIe=t=>{AIe=!0,v_t(t)},Bn=()=>AIe,vu=()=>RIe,IIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var sR=null,OIe=t=>(sR&&sR.destroy(),sR=new Xo({totalAllowedTime:t}),sR),PIe=()=>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 CIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.11.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!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 T_t=E_t(import.meta.url),A_t=bu.dirname(T_t),R_t=w_t(import.meta.url),Ry=oe("shell"),u8=new Set,kIe={preferLocal:!0},bt=(t,e,r)=>{let[n,i]=x_t(e,r),o={...kIe,...i},s=wIe(t,n,o);$Ie(s,o),LIe(s);let a=r?.idleTimeout;return a&&a>0&&MIe(s,a),s},NIe=(t,e)=>{let r={...kIe,...e},n=TIe(t,r);return $Ie(n,r),LIe(n),e?.idleTimeout&&e.idleTimeout>0&&MIe(n,e.idleTimeout),n},x_t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},$Ie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||oc.env.NETLIFY_LOCAL_QUIET==="true")return;if(oc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Ow).pipe(oc.stdout),t.stderr?.pipe(new Ow).pipe(oc.stderr);return}t.stdout?.pipe(oc.stdout),t.stderr?.pipe(oc.stderr)},l8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(oc.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}},DIe=t=>l8(t,"SIGKILL"),MIe=(t,e)=>{let r=null,n=()=>{Ry.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),l8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing idle process ${t.pid}`),DIe(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)},LIe=t=>{u8.add(t);let e=PIe();if(e){let r=e.onTimesUp(()=>{Ry.log(`Global timer expired, killing process ${t.pid}`),l8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing process ${t.pid} after timeout`),DIe(t))},5e3)});t.on("exit",()=>{u8.delete(t),r()}),t.on("error",()=>{u8.delete(t),r()})}};function sc(t,e){if(!oc.env.NETLIFY_LOCAL_MODE)try{let i=R_t.resolve(CIe.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(UM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(oc.env.NODE_PATH){let i=bu.join(oc.env.NODE_PATH,".bin",e);if(UM.existsSync(i))return i}let r=bu.join(t,"node_modules",".bin",e);if(UM.existsSync(r))return r;let n=bu.join(A_t,"..","node_modules",".bin",e);if(UM.existsSync(n))return n}var xy=oe("repo"),VIe="runner-diffs-",d8=t=>`${VIe}${t}-`,GIe=async t=>{let e=zM.tmpdir(),r;try{r=await di.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(VIe)&&!n.startsWith(d8(t))).map(n=>di.rm(Jo.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},UIe=async t=>{let e=I_t("sha256");for await(let r of O_t(t))e.update(r);return e.digest("hex")},FIe=async(t,e)=>t.size===e.size&&await UIe(t.path)===await UIe(e.path),HIe=/.. (.+)?\.log$/,P_t=[HIe],C_t=1,zIe=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)},k_t=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),jIe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return An(r?`${e}: ${r}`:e)},N_t=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),BIe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),$_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&&BIe(n)===BIe(r)&&n.password!==""}catch{return!1}},qIe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},FM=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=zIe(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(zM.tmpdir(),d8(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=>P_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+=FM){let o=e.slice(i,i+FM).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...qIe,...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