@netlify/agent-runner-cli 1.145.0-test.0 → 1.145.0-test.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.js +1 -1
- package/dist/skills/netlify-database/SKILL.md +1 -1
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -99,7 +99,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
99
99
|
`,LF:`
|
|
100
100
|
`,concatBytes:TD},SNe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},ENe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:SNe};import{Buffer as vNe}from"buffer";var ZQ=(t,e)=>t?void 0:bNe.bind(void 0,e),bNe=function*(t,e){if(typeof e!="string"&&!Ut(e)&&!vNe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},JQ=(t,e)=>t?TNe.bind(void 0,e):xNe.bind(void 0,e),TNe=function*(t,e){XQ(t,e),yield e},xNe=function*(t,e){if(XQ(t,e),typeof e!="string"&&!Ut(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},XQ=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
101
101
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
102
|
-
if (condition) { yield value; }`)};import{Buffer as wNe}from"buffer";import{StringDecoder as ANe}from"string_decoder";var bx=(t,e,r)=>{if(r)return;if(t)return{transform:RNe.bind(void 0,new TextEncoder)};let n=new ANe(e);return{transform:INe.bind(void 0,n),final:CNe.bind(void 0,n)}},RNe=function*(t,e){wNe.isBuffer(e)?yield ds(e):typeof e=="string"?yield t.encode(e):yield e},INe=function*(t,e){yield Ut(e)?t.write(e):e},CNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as QQ}from"util";var wD=QQ(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Tx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=ONe}=e[r];for await(let i of n(t))yield*Tx(i,e,r+1)},e7=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*PNe(r,Number(e),t)},PNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Tx(n,r,e+1)},t7=QQ(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),ONe=function*(t){yield t};var AD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},r7=(t,e)=>[...e.flatMap(r=>[...Tl(r,t,0)]),...t_(t)],Tl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=kNe}=e[r];for(let i of n(t))yield*Tl(i,e,r+1)},t_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*NNe(r,Number(e),t)},NNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Tl(n,r,e+1)},kNe=function*(t){yield t};var RD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=i7(t,s,o),l=bl(e),u=bl(r),d=l?wD.bind(void 0,Tx,a):AD.bind(void 0,Tl),f=l||u?wD.bind(void 0,e7,a):AD.bind(void 0,t_),p=l||u?t7.bind(void 0,a):void 0;return{stream:new MNe({writableObjectMode:n,writableHighWaterMark:n7(n),readableObjectMode:i,readableHighWaterMark:n7(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},xx=(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=i7(s,r,a);t=r7(c,t)}return t},i7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:ZQ(n,a)},bx(r,s,n),vx(r,o,n,c),{transform:t,final:e},{transform:JQ(i,a)},KQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var o7=(t,e)=>{for(let r of DNe(t))LNe(t,r,e)},DNe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),LNe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Ca[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>$Ne(a,n));r.input=qg(s)},$Ne=(t,e)=>{let r=xx(t,e,"utf8",!0);return UNe(r),qg(r)},UNe=t=>{let e=t.find(r=>typeof r!="string"&&!Ut(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 zNe,appendFileSync as GNe}from"fs";var wx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Fd(r,n)&&!hn.has(e)&&FNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&BNe.has(o))||t.every(({type:i})=>qn.has(i))),FNe=t=>t===1||t===2,BNe=new Set(["pipe","overlapped"]),s7=async(t,e,r,n)=>{for await(let i of t)jNe(e)||c7(i,r,n)},a7=(t,e,r)=>{for(let n of t)c7(n,e,r)},jNe=t=>t._readableState.pipes.length>0,c7=(t,e,r)=>{let n=FT(t);lo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var l7=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>VNe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},VNe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=uQ(t,o,d),p=ds(f),{stdioItems:h,objectMode:m}=e[r],S=qNe([p],h,c,n),{serializedResult:E,finalResult:b=E}=HNe({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});WNe({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?b:void 0;try{return n.error===void 0&&YNe(E,h,i),x}catch(y){return n.error=y,x}},qNe=(t,e,r,n)=>{try{return xx(t,e,r,!1)}catch(i){return n.error=i,t}},HNe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qg(t)};let s=x9(t,r);return n[o]?{serializedResult:s,finalResult:xD(s,!i[o],e)}:{serializedResult:s}},WNe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!wx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=xD(t,!1,s);try{a7(a,e,n)}catch(c){r.error??=c}},YNe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Sx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?GNe(n,t):(r.add(o),zNe(n,t))}};var u7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,hs(e,r,"all")]:Array.isArray(e)?[hs(t,r,"all"),...e]:Ut(t)&&Ut(e)?kM([t,e]):`${t}${e}`};import{once as ID}from"events";var d7=async(t,e)=>{let[r,n]=await KNe(t);return e.isForcefullyTerminated??=!1,[r,n]},KNe=async t=>{let[e,r]=await Promise.allSettled([ID(t,"spawn"),ID(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?f7(t):r.value},f7=async t=>{try{return await ID(t,"exit")}catch{return f7(t)}},p7=async t=>{let[e,r]=await t;if(!ZNe(e,r)&&CD(e,r))throw new xi;return[e,r]},ZNe=(t,e)=>t===void 0&&e===void 0,CD=(t,e)=>t!==0||e!==null;var h7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=JNe(t,e,r),s=o?.code==="ETIMEDOUT",a=lQ(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},JNe=(t,e,r)=>t!==void 0?t:CD(e,r)?new xi:void 0;var m7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=QNe(t,e,r),d=rke({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Kd(d,c,l)},QNe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=jT(t,e,r),a=eke(r),{file:c,commandArguments:l,options:u}=ax(t,e,a);tke(u);let d=qQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},eke=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,tke=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Ax("ipcInput"),t&&Ax("ipc: true"),r&&Ax("detached: true"),n&&Ax("cancelSignal")},Ax=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},rke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=nke({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=h7(c,r),{output:h,error:m=l}=l7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,x)=>hs(b,r,x)),E=hs(u7(h,r),r,"all");return oke({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},nke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{o7(o,r);let a=ike(r);return XNe(...cx(t,e,a))}catch(a){return Yd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},ike=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:mx(e)}),oke=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?gx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):e_({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as HMe}from"events";import{spawn as WMe}from"child_process";import E7 from"process";import{once as PD,on as ske}from"events";var g7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(zd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:tx(t)}),ake({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),ake=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{JT(e,i);let o=Ia(t,e,r),s=new AbortController;try{return await Promise.race([cke(o,n,s),lke(o,r,s),uke(o,r,s)])}catch(a){throw Gd(t),a}finally{s.abort(),XT(e,i)}},cke=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await PD(t,"message",{signal:r});return n}for await(let[n]of ske(t,"message",{signal:r}))if(e(n))return n},lke=async(t,e,{signal:r})=>{await PD(t,"disconnect",{signal:r}),rX(e)},uke=async(t,e,{signal:r})=>{let[n]=await PD(t,"strict:error",{signal:r});throw YT(n,e)};import{once as y7,on as dke}from"events";var S7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>OD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),OD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{zd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:tx(t)}),JT(e,o);let s=Ia(t,e,r),a=new AbortController,c={};return fke(t,s,a),pke({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),hke({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},fke=async(t,e,r)=>{try{await y7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},pke=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await y7(t,"strict:error",{signal:r.signal});n.error=YT(i,e),r.abort()}catch{}},hke=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of dke(r,"message",{signal:o.signal}))_7(s),yield c}catch{_7(s)}finally{o.abort(),XT(e,a),n||Gd(t),i&&await t}},_7=({error:t})=>{if(t)throw t};var v7=(t,{ipc:e})=>{Object.assign(t,T7(t,!1,e))},b7=()=>{let t=E7,e=!0,r=E7.channel!==void 0;return{...T7(t,e,r),getCancelSignal:CX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},T7=(t,e,r)=>({sendMessage:ox.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:g7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:S7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as mke}from"child_process";import{PassThrough as gke,Readable as _ke,Writable as yke,Duplex as Ske}from"stream";var x7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{vD(n);let a=new mke;Eke(a,n),Object.assign(a,{readable:vke,writable:bke,duplex:Tke});let c=Yd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=xke(c,s,i);return{subprocess:a,promise:l}},Eke=(t,e)=>{let r=r_(),n=r_(),i=r_(),o=Array.from({length:e.length-3},r_),s=r_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},r_=()=>{let t=new gke;return t.end(),t},vke=()=>new _ke({read(){}}),bke=()=>new yke({write(){}}),Tke=()=>new Ske({read(){},write(){}}),xke=async(t,e,r)=>Kd(t,e,r);import{createReadStream as w7,createWriteStream as A7}from"fs";import{Buffer as wke}from"buffer";import{Readable as n_,Writable as Ake,Duplex as Rke}from"stream";var I7=(t,e)=>Ex(Ike,t,e,!1),i_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ca[t]}.`)},R7={fileNumber:i_,generator:RD,asyncGenerator:RD,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Rke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Ike={input:{...R7,fileUrl:({value:t})=>({stream:w7(t)}),filePath:({value:{file:t}})=>({stream:w7(t)}),webStream:({value:t})=>({stream:n_.fromWeb(t)}),iterable:({value:t})=>({stream:n_.from(t)}),asyncIterable:({value:t})=>({stream:n_.from(t)}),string:({value:t})=>({stream:n_.from(t)}),uint8Array:({value:t})=>({stream:n_.from(wke.from(t))})},output:{...R7,fileUrl:({value:t})=>({stream:A7(t)}),filePath:({value:{file:t,append:e}})=>({stream:A7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Ake.fromWeb(t)}),iterable:i_,asyncIterable:i_,string:i_,uint8Array:i_}};import{on as Cke,once as C7}from"events";import{PassThrough as Pke,getDefaultHighWaterMark as Oke}from"stream";import{finished as N7}from"stream/promises";function xl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)kD(i);let e=t.some(({readableObjectMode:i})=>i),r=Nke(t,e),n=new ND({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Nke=(t,e)=>{if(t.length===0)return Oke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},ND=class extends Pke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(kD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=kke(this,this.#e,this.#o);let r=Lke({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(kD(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)}},kke=async(t,e,r)=>{Rx(t,P7);let n=new AbortController;try{await Promise.race([Mke(t,n),Dke(t,e,r,n)])}finally{n.abort(),Rx(t,-P7)}},Mke=async(t,{signal:e})=>{try{await N7(t,{signal:e,cleanup:!0})}catch(r){throw k7(t,r),r}},Dke=async(t,e,r,{signal:n})=>{for await(let[i]of Cke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},kD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Lke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Rx(t,O7);let a=new AbortController;try{await Promise.race([$ke(o,e,a),Uke({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Fke({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Rx(t,-O7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?MD(t):Bke(t))},$ke=async(t,e,{signal:r})=>{try{await t,r.aborted||MD(e)}catch(n){r.aborted||k7(e,n)}},Uke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await N7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;M7(s)?i.add(e):D7(t,s)}},Fke=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await C7(t,i,{signal:o}),!t.readable)return C7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Bke=t=>{t.writable&&t.end()},k7=(t,e)=>{M7(e)?MD(t):D7(t,e)},M7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",MD=t=>{(t.readable||t.writable)&&t.destroy()},D7=(t,e)=>{t.destroyed||(t.once("error",jke),t.destroy(e))},jke=()=>{},Rx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},P7=2,O7=1;import{finished as L7}from"stream/promises";var Jd=(t,e)=>{t.pipe(e),zke(t,e),Gke(t,e)},zke=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await L7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}DD(e)}},DD=t=>{t.writable&&t.end()},Gke=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await L7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}LD(t)}},LD=t=>{t.readable&&t.destroy()};var $7=(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})=>qn.has(c)))Vke(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!qn.has(c)))Hke({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]:xl(o);Jd(s,i)}},Vke=(t,e,r,n)=>{r==="output"?Jd(t.stdio[n],e):Jd(e,t.stdio[n]);let i=qke[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},qke=["stdin","stdout","stderr"],Hke=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Wke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Wke=(t,{signal:e})=>{Ti(t)&&El(t,Yke,e)},Yke=2;import{addAbortListener as Jke}from"events";var wl=[];wl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&wl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&wl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Ix=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",$D=Symbol.for("signal-exit emitter"),UD=globalThis,Kke=Object.defineProperty.bind(Object),FD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(UD[$D])return UD[$D];Kke(UD,$D,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},Cx=class{},Zke=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),BD=class extends Cx{onExit(){return()=>{}}load(){}unload(){}},jD=class extends Cx{#e=zD.platform==="win32"?"SIGINT":"SIGHUP";#r=new FD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of wl)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(!Ix(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 wl)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,wl.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 Ix(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"&&Ix(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)}},zD=globalThis.process,{onExit:U7,load:Cpt,unload:Ppt}=Zke(Ix(zD)?new jD(zD):new BD);var F7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=U7(()=>{t.kill()});Jke(n,()=>{i()})};var j7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=BT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Xke(r,n,i),{sourceStream:d,sourceError:f}=eMe(t,l),{options:p,fileDescriptors:h}=fo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},Xke=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Qke(t,e,...r),a=ZT(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Qke=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(B7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||OM(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]=PT(r,...n);return{destination:e(B7)(i,o,s),pipeOptions:s}}if(fo.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},B7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),eMe=(t,e)=>{try{return{sourceStream:Vd(t,e)}}catch(r){return{sourceError:r}}};var G7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=tMe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw GD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},tMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return LD(t),n;if(e!==void 0)return DD(r),e},GD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Yd({error:t,command:z7,escapedCommand:z7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),z7="source.pipe(destination)";var V7=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 rMe}from"stream/promises";var q7=(t,e,r)=>{let n=Px.has(e)?iMe(t,e):nMe(t,e);return El(t,sMe,r.signal),El(e,aMe,r.signal),oMe(e),n},nMe=(t,e)=>{let r=xl([t]);return Jd(r,e),Px.set(e,r),r},iMe=(t,e)=>{let r=Px.get(e);return r.add(t),r},oMe=async t=>{try{await rMe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Px.delete(t)},Px=new WeakMap,sMe=2,aMe=1;import{aborted as cMe}from"util";var H7=(t,e)=>t===void 0?[]:[lMe(t,e)],lMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await cMe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw GD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Ox=(t,...e)=>{if(At(e[0]))return Ox.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=j7(t,...e),i=uMe({...n,destination:r});return i.pipe=Ox.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},uMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=dMe(t,i);G7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=q7(e,o,d);return await Promise.race([V7(u),...H7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},dMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as yMe}from"timers/promises";import{on as fMe}from"events";import{getDefaultHighWaterMark as pMe}from"stream";var Nx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return hMe(e,s),Y7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},hMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},VD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;mMe(e,s,t);let a=t.readableObjectMode&&!o;return Y7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},mMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Y7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=fMe(t,"data",{signal:e.signal,highWaterMark:W7,highWatermark:W7});return gMe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},qD=pMe(!0),W7=qD,gMe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=_Me({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Tl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*t_(a)}},_Me=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[bx(t,r,!e),vx(t,i,!n,{})].filter(Boolean);var K7=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=SMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([EMe(t),d]);return}let f=bD(c,r),p=VD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([vMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},SMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!wx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=VD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await s7(a,t,r,o)},EMe=async t=>{await yMe(),t.readableFlowing===null&&t.resume()},vMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await fx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await px(r,{maxBuffer:o})):await Wd(r,{maxBuffer:o})}catch(a){return Z7(sQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},HD=async t=>{try{return await t}catch(e){return Z7(e)}},Z7=({bufferedData:t})=>b9(t)?new Uint8Array(t):t;import{finished as bMe}from"stream/promises";var o_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=TMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],bMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||AMe(a,e,r,n)}finally{s.abort()}},TMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&xMe(t,r,n),n},xMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{wMe(e,r),n.call(t,...i)}},wMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},AMe=(t,e,r,n)=>{if(!RMe(t,e,r,n))throw t},RMe=(t,e,r,n=!0)=>r.propagating?J7(t)||kx(t):(r.propagating=!0,WD(r,e)===n?J7(t):kx(t)),WD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",kx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",J7=t=>t?.code==="EPIPE";var X7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>YD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),YD=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=o_(t,e,l);if(WD(l,e)){await u;return}let[d]=await Promise.all([K7({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Q7=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?xl([t,e].filter(Boolean)):void 0,eee=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>YD({...IMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:CMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),IMe=({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}},CMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as PMe}from"events";var tee=t=>Fd(t,"ipc"),ree=(t,e)=>{let r=FT(t);lo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var nee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=tee(o),a=fs(e,"ipc"),c=fs(r,"ipc");for await(let l of OD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(aQ(t,i,c),i.push(l)),s&&ree(l,o);return i},iee=async(t,e)=>(await Promise.allSettled([t]),e);var oee=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:S,controller:E})=>{let b=d7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=X7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),A=eee({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),I=[],C=nee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),O=OMe(m,t,x),M=NMe(h,x);try{return await Promise.race([Promise.all([{},p7(b),Promise.all(y),A,C,FX(t,d),...O,...M]),S,kMe(t,E),...MX(t,o,f,E),...tX({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...NX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(B){return f.terminationReason??="other",Promise.all([{error:B},b,Promise.all(y.map(_=>HD(_))),HD(A),iee(C,I),Promise.allSettled(O),Promise.allSettled(M)])}},OMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:o_(n,i,r)),NMe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ai(o,{checkOpen:!1})&&!Ti(o)).map(({type:i,value:o,stream:s=o})=>o_(s,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),kMe=async(t,{signal:e})=>{let[r]=await PMe(t,"error",{signal:e});throw r};var see=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),s_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=uo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Xd=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 MMe}from"stream";import{callbackify as DMe}from"util";import{finished as aee}from"stream/promises";var KD=async t=>{if(t!==void 0)try{await ZD(t)}catch{}},cee=async t=>{if(t!==void 0)try{await JD(t)}catch{}},ZD=async t=>{await aee(t,{cleanup:!0,readable:!1,writable:!0})},JD=async t=>{await aee(t,{cleanup:!0,readable:!0,writable:!1})},Mx=async(t,e)=>{if(await t,e)throw e},Dx=(t,e,r)=>{r&&!kx(r)?t.destroy(r):e&&t.destroy()};var lee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||hn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=XD(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=QD(a,s),{read:f,onStdoutDataDone:p}=eL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new MMe({read:f,destroy:DMe(rL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return tL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},XD=(t,e,r)=>{let n=Vd(t,e),i=s_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},QD=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:qD},eL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=uo(),s=Nx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){LMe(this,s,o)},onStdoutDataDone:o}},LMe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},tL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await JD(t),await n,await KD(i),await e,r.readable&&r.push(null)}catch(o){await KD(i),uee(r,o)}},rL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Xd(r,e)&&(uee(t,n),await Mx(e,n))},uee=(t,e)=>{Dx(t,t.readable,e)};import{Writable as $Me}from"stream";import{callbackify as dee}from"util";var fee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=nL(t,r,e),s=new $Me({...iL(n,t,i),destroy:dee(sL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return oL(n,s),s},nL=(t,e,r)=>{let n=ZT(t,e),i=s_(r,n,"writableFinal"),o=s_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},iL=(t,e,r)=>({write:UMe.bind(void 0,t),final:dee(FMe.bind(void 0,t,e,r))}),UMe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},FMe=async(t,e,r)=>{await Xd(r,e)&&(t.writable&&t.end(),await e)},oL=async(t,e,r)=>{try{await ZD(t),e.writable&&e.end()}catch(n){await cee(r),pee(e,n)}},sL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Xd(r,e),await Xd(n,e)&&(pee(t,i),await Mx(e,i))},pee=(t,e)=>{Dx(t,t.writable,e)};import{Duplex as BMe}from"stream";import{callbackify as jMe}from"util";var hee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||hn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=XD(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=nL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=QD(c,a),{read:S,onStdoutDataDone:E}=eL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new BMe({read:S,...iL(u,t,d),destroy:jMe(zMe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return tL({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),oL(u,b,c),b},zMe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([rL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),sL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var aL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||hn.has(e),s=Vd(t,r),a=Nx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return GMe(a,s,t)},GMe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var mee=(t,{encoding:e})=>{let r=see();t.readable=lee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=fee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=hee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=aL.bind(void 0,t,e),t[Symbol.asyncIterator]=aL.bind(void 0,t,e,{})};var gee=(t,e)=>{for(let[r,n]of qMe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},VMe=(async()=>{})().constructor.prototype,qMe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(VMe,t)]);var _ee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=YMe(t,e,r),{subprocess:f,promise:p}=ZMe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Ox.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),gee(f,p),fo.set(f,{options:u,fileDescriptors:d}),f},YMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=jT(t,e,r),{file:a,commandArguments:c,options:l}=ax(t,e,r),u=KMe(l),d=I7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},KMe=({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}},ZMe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=WMe(...cx(t,e,r))}catch(h){return x7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;HMe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];$7(c,a,l),F7(c,r,l);let d={},f=uo();c.kill=QJ.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Q7(c,r),mee(c,r),v7(c,r);let p=JMe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},JMe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,S]=await oee({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((y,A)=>hs(y,e,A)),b=hs(m,e,"all"),x=XMe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Kd(x,n,e)},XMe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?e_({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof po,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):gx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Lx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,QMe(n,t[n],i)]));return{...t,...r}},QMe=(t,e,r)=>eDe.has(t)&&At(e)&&At(r)?{...e,...r}:r,eDe=new Set(["env",...$M]);var Pa=(t,e,r,n)=>{let i=(s,a,c)=>Pa(s,a,r,c),o=(...s)=>tDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},tDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(At(o))return i(t,Lx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=rDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?m7(a,c,l):_ee(a,c,l,i)},rDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=I9(e)?C9(e,r):[e,...r],[s,a,c]=PT(...o),l=Lx(Lx(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var yee=({file:t,commandArguments:e})=>Eee(t,e),See=({file:t,commandArguments:e})=>({...Eee(t,e),isSync:!0}),Eee=(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]=nDe(t);return{file:r,commandArguments:n}},nDe=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(iDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},iDe=/ +/g;var vee=(t,e,r)=>{t.sync=e(oDe,r),t.s=t.sync},bee=({options:t})=>Tee(t),oDe=({options:t})=>({...Tee(t),isSync:!0}),Tee=t=>({options:{...sDe(t),...t}}),sDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},xee={preferLocal:!0};var wee=Pa(()=>({})),Sgt=Pa(()=>({isSync:!0})),Aee=Pa(yee),Egt=Pa(See),vgt=Pa(LX),bgt=Pa(bee,{},xee,vee),{sendMessage:Tgt,getOneMessage:xgt,getEachMessage:wgt,getCancelSignal:Agt}=b7();var Ree=!1,Iee=()=>{Ree=!0},mo=()=>Ree;var a_=null,Cee=t=>(a_&&a_.destroy(),a_=new ms({totalAllowedTime:t}),a_),Pee=()=>a_;var ms=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&mo())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await xT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Se.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Oee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-test.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var uDe=cDe(import.meta.url),dDe=gs.dirname(uDe),fDe=lDe(import.meta.url),Qd=_e("shell"),cL=new Set,Nee={preferLocal:!0},or=(t,e,r)=>{let[n,i]=pDe(e,r),o={...Nee,...i},s=wee(t,n,o);Mee(s,o),$ee(s);let a=r?.idleTimeout;return a&&a>0&&Lee(s,a),s},kee=(t,e)=>{let r={...Nee,...e},n=Aee(t,r);return Mee(n,r),$ee(n),e?.idleTimeout&&e.idleTimeout>0&&Lee(n,e.idleTimeout),n},pDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Mee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(_s.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new $g).pipe(_s.stdout),t.stderr?.pipe(new $g).pipe(_s.stderr);return}t.stdout?.pipe(_s.stdout),t.stderr?.pipe(_s.stderr)},lL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_s.kill(-t.pid,e),Qd.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Qd.error("Error killing process:",r),!1}},Dee=t=>lL(t,"SIGKILL"),Lee=(t,e)=>{let r=null,n=()=>{Qd.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),lL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Qd.log(`Force killing idle process ${t.pid}`),Dee(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)},$ee=t=>{cL.add(t);let e=Pee();if(e){let r=e.onTimesUp(()=>{Qd.log(`Global timer expired, killing process ${t.pid}`),lL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Qd.log(`Force killing process ${t.pid} after timeout`),Dee(t))},5e3)});t.on("exit",()=>{cL.delete(t),r()}),t.on("error",()=>{cL.delete(t),r()})}};function Ux(t,e){return!!Ri(t,e)}function Ri(t,e){if(!_s.env.NETLIFY_LOCAL_MODE)try{let i=fDe.resolve(Oee.name),o=gs.dirname(i);for(;o!==gs.dirname(o);){let s=gs.dirname(o);if(gs.basename(s)==="node_modules"){let a=gs.join(s,".bin",e);if($x.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(_s.env.NODE_PATH){let i=gs.join(_s.env.NODE_PATH,".bin",e);if($x.existsSync(i))return i}let r=gs.join(t,"node_modules",".bin",e);if($x.existsSync(r))return r;let n=gs.join(dDe,"..","node_modules",".bin",e);if($x.existsSync(n))return n}var hDe=_e("utils"),mDe=t=>new Promise(e=>{setTimeout(e,t)});var Fx=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await mDe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Oa=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Uee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):hDe.error("Could not parse JSON",n))}},gDe=t=>t.charAt(0).toUpperCase()+t.slice(1),go=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():gDe(e)).join(" ");function ys(t,e){e&&t.log(`Skill invoked: ${e}`)}var Bx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Fee=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var uL=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},_De=1e4,dL=(t,e=_De)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as Bee}from"buffer";import yDe from"path";var jee=_e("repo"),Wr=(t,e={})=>or("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),jx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{jee.info("Getting runner diffs");let n=await EDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=bDe(o);await TDe(m,r)}jee.info("Changes after processing"),await pL(r);let s=await hL(o,r);if(await fL(s,r),i=await vDe(r),!i)return{hasChanges:!1,ignored:s};await Wr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Wr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await zee(r),{hasChanges:!1,ignored:s};let u=await Wr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Wr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let S=await Wr(["diff",t.sha,"HEAD","--binary"],a),E=String(S.stdout??"");f!==E&&(p=Bee.from(E).toString("base64"))}await zee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Bee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},zee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Wr(["reset","--soft","HEAD~1"],{cwd:t})},fL=async(t=[],e=process.cwd())=>{await Wr(["add",".",...t],{cwd:e})},pL=async(t=process.cwd())=>{let e=await Wr(["status","-s"],{cwd:t});return String(e.stdout??"")},Gee=/.. (.+)?\.log$/,SDe=[Gee],EDe=async(t=process.cwd())=>{let e=await pL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
|
+
if (condition) { yield value; }`)};import{Buffer as wNe}from"buffer";import{StringDecoder as ANe}from"string_decoder";var bx=(t,e,r)=>{if(r)return;if(t)return{transform:RNe.bind(void 0,new TextEncoder)};let n=new ANe(e);return{transform:INe.bind(void 0,n),final:CNe.bind(void 0,n)}},RNe=function*(t,e){wNe.isBuffer(e)?yield ds(e):typeof e=="string"?yield t.encode(e):yield e},INe=function*(t,e){yield Ut(e)?t.write(e):e},CNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as QQ}from"util";var wD=QQ(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Tx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=ONe}=e[r];for await(let i of n(t))yield*Tx(i,e,r+1)},e7=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*PNe(r,Number(e),t)},PNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Tx(n,r,e+1)},t7=QQ(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),ONe=function*(t){yield t};var AD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},r7=(t,e)=>[...e.flatMap(r=>[...Tl(r,t,0)]),...t_(t)],Tl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=kNe}=e[r];for(let i of n(t))yield*Tl(i,e,r+1)},t_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*NNe(r,Number(e),t)},NNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Tl(n,r,e+1)},kNe=function*(t){yield t};var RD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=i7(t,s,o),l=bl(e),u=bl(r),d=l?wD.bind(void 0,Tx,a):AD.bind(void 0,Tl),f=l||u?wD.bind(void 0,e7,a):AD.bind(void 0,t_),p=l||u?t7.bind(void 0,a):void 0;return{stream:new MNe({writableObjectMode:n,writableHighWaterMark:n7(n),readableObjectMode:i,readableHighWaterMark:n7(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},xx=(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=i7(s,r,a);t=r7(c,t)}return t},i7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:ZQ(n,a)},bx(r,s,n),vx(r,o,n,c),{transform:t,final:e},{transform:JQ(i,a)},KQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var o7=(t,e)=>{for(let r of DNe(t))LNe(t,r,e)},DNe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),LNe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Ca[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>$Ne(a,n));r.input=qg(s)},$Ne=(t,e)=>{let r=xx(t,e,"utf8",!0);return UNe(r),qg(r)},UNe=t=>{let e=t.find(r=>typeof r!="string"&&!Ut(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 zNe,appendFileSync as GNe}from"fs";var wx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Fd(r,n)&&!hn.has(e)&&FNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&BNe.has(o))||t.every(({type:i})=>qn.has(i))),FNe=t=>t===1||t===2,BNe=new Set(["pipe","overlapped"]),s7=async(t,e,r,n)=>{for await(let i of t)jNe(e)||c7(i,r,n)},a7=(t,e,r)=>{for(let n of t)c7(n,e,r)},jNe=t=>t._readableState.pipes.length>0,c7=(t,e,r)=>{let n=FT(t);lo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var l7=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>VNe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},VNe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=uQ(t,o,d),p=ds(f),{stdioItems:h,objectMode:m}=e[r],S=qNe([p],h,c,n),{serializedResult:E,finalResult:b=E}=HNe({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});WNe({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?b:void 0;try{return n.error===void 0&&YNe(E,h,i),x}catch(y){return n.error=y,x}},qNe=(t,e,r,n)=>{try{return xx(t,e,r,!1)}catch(i){return n.error=i,t}},HNe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qg(t)};let s=x9(t,r);return n[o]?{serializedResult:s,finalResult:xD(s,!i[o],e)}:{serializedResult:s}},WNe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!wx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=xD(t,!1,s);try{a7(a,e,n)}catch(c){r.error??=c}},YNe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Sx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?GNe(n,t):(r.add(o),zNe(n,t))}};var u7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,hs(e,r,"all")]:Array.isArray(e)?[hs(t,r,"all"),...e]:Ut(t)&&Ut(e)?kM([t,e]):`${t}${e}`};import{once as ID}from"events";var d7=async(t,e)=>{let[r,n]=await KNe(t);return e.isForcefullyTerminated??=!1,[r,n]},KNe=async t=>{let[e,r]=await Promise.allSettled([ID(t,"spawn"),ID(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?f7(t):r.value},f7=async t=>{try{return await ID(t,"exit")}catch{return f7(t)}},p7=async t=>{let[e,r]=await t;if(!ZNe(e,r)&&CD(e,r))throw new xi;return[e,r]},ZNe=(t,e)=>t===void 0&&e===void 0,CD=(t,e)=>t!==0||e!==null;var h7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=JNe(t,e,r),s=o?.code==="ETIMEDOUT",a=lQ(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},JNe=(t,e,r)=>t!==void 0?t:CD(e,r)?new xi:void 0;var m7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=QNe(t,e,r),d=rke({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Kd(d,c,l)},QNe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=jT(t,e,r),a=eke(r),{file:c,commandArguments:l,options:u}=ax(t,e,a);tke(u);let d=qQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},eke=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,tke=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Ax("ipcInput"),t&&Ax("ipc: true"),r&&Ax("detached: true"),n&&Ax("cancelSignal")},Ax=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},rke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=nke({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=h7(c,r),{output:h,error:m=l}=l7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,x)=>hs(b,r,x)),E=hs(u7(h,r),r,"all");return oke({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},nke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{o7(o,r);let a=ike(r);return XNe(...cx(t,e,a))}catch(a){return Yd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},ike=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:mx(e)}),oke=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?gx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):e_({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as HMe}from"events";import{spawn as WMe}from"child_process";import E7 from"process";import{once as PD,on as ske}from"events";var g7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(zd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:tx(t)}),ake({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),ake=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{JT(e,i);let o=Ia(t,e,r),s=new AbortController;try{return await Promise.race([cke(o,n,s),lke(o,r,s),uke(o,r,s)])}catch(a){throw Gd(t),a}finally{s.abort(),XT(e,i)}},cke=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await PD(t,"message",{signal:r});return n}for await(let[n]of ske(t,"message",{signal:r}))if(e(n))return n},lke=async(t,e,{signal:r})=>{await PD(t,"disconnect",{signal:r}),rX(e)},uke=async(t,e,{signal:r})=>{let[n]=await PD(t,"strict:error",{signal:r});throw YT(n,e)};import{once as y7,on as dke}from"events";var S7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>OD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),OD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{zd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:tx(t)}),JT(e,o);let s=Ia(t,e,r),a=new AbortController,c={};return fke(t,s,a),pke({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),hke({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},fke=async(t,e,r)=>{try{await y7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},pke=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await y7(t,"strict:error",{signal:r.signal});n.error=YT(i,e),r.abort()}catch{}},hke=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of dke(r,"message",{signal:o.signal}))_7(s),yield c}catch{_7(s)}finally{o.abort(),XT(e,a),n||Gd(t),i&&await t}},_7=({error:t})=>{if(t)throw t};var v7=(t,{ipc:e})=>{Object.assign(t,T7(t,!1,e))},b7=()=>{let t=E7,e=!0,r=E7.channel!==void 0;return{...T7(t,e,r),getCancelSignal:CX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},T7=(t,e,r)=>({sendMessage:ox.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:g7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:S7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as mke}from"child_process";import{PassThrough as gke,Readable as _ke,Writable as yke,Duplex as Ske}from"stream";var x7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{vD(n);let a=new mke;Eke(a,n),Object.assign(a,{readable:vke,writable:bke,duplex:Tke});let c=Yd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=xke(c,s,i);return{subprocess:a,promise:l}},Eke=(t,e)=>{let r=r_(),n=r_(),i=r_(),o=Array.from({length:e.length-3},r_),s=r_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},r_=()=>{let t=new gke;return t.end(),t},vke=()=>new _ke({read(){}}),bke=()=>new yke({write(){}}),Tke=()=>new Ske({read(){},write(){}}),xke=async(t,e,r)=>Kd(t,e,r);import{createReadStream as w7,createWriteStream as A7}from"fs";import{Buffer as wke}from"buffer";import{Readable as n_,Writable as Ake,Duplex as Rke}from"stream";var I7=(t,e)=>Ex(Ike,t,e,!1),i_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ca[t]}.`)},R7={fileNumber:i_,generator:RD,asyncGenerator:RD,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Rke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Ike={input:{...R7,fileUrl:({value:t})=>({stream:w7(t)}),filePath:({value:{file:t}})=>({stream:w7(t)}),webStream:({value:t})=>({stream:n_.fromWeb(t)}),iterable:({value:t})=>({stream:n_.from(t)}),asyncIterable:({value:t})=>({stream:n_.from(t)}),string:({value:t})=>({stream:n_.from(t)}),uint8Array:({value:t})=>({stream:n_.from(wke.from(t))})},output:{...R7,fileUrl:({value:t})=>({stream:A7(t)}),filePath:({value:{file:t,append:e}})=>({stream:A7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Ake.fromWeb(t)}),iterable:i_,asyncIterable:i_,string:i_,uint8Array:i_}};import{on as Cke,once as C7}from"events";import{PassThrough as Pke,getDefaultHighWaterMark as Oke}from"stream";import{finished as N7}from"stream/promises";function xl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)kD(i);let e=t.some(({readableObjectMode:i})=>i),r=Nke(t,e),n=new ND({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Nke=(t,e)=>{if(t.length===0)return Oke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},ND=class extends Pke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(kD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=kke(this,this.#e,this.#o);let r=Lke({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(kD(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)}},kke=async(t,e,r)=>{Rx(t,P7);let n=new AbortController;try{await Promise.race([Mke(t,n),Dke(t,e,r,n)])}finally{n.abort(),Rx(t,-P7)}},Mke=async(t,{signal:e})=>{try{await N7(t,{signal:e,cleanup:!0})}catch(r){throw k7(t,r),r}},Dke=async(t,e,r,{signal:n})=>{for await(let[i]of Cke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},kD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Lke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Rx(t,O7);let a=new AbortController;try{await Promise.race([$ke(o,e,a),Uke({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Fke({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Rx(t,-O7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?MD(t):Bke(t))},$ke=async(t,e,{signal:r})=>{try{await t,r.aborted||MD(e)}catch(n){r.aborted||k7(e,n)}},Uke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await N7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;M7(s)?i.add(e):D7(t,s)}},Fke=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await C7(t,i,{signal:o}),!t.readable)return C7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Bke=t=>{t.writable&&t.end()},k7=(t,e)=>{M7(e)?MD(t):D7(t,e)},M7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",MD=t=>{(t.readable||t.writable)&&t.destroy()},D7=(t,e)=>{t.destroyed||(t.once("error",jke),t.destroy(e))},jke=()=>{},Rx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},P7=2,O7=1;import{finished as L7}from"stream/promises";var Jd=(t,e)=>{t.pipe(e),zke(t,e),Gke(t,e)},zke=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await L7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}DD(e)}},DD=t=>{t.writable&&t.end()},Gke=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await L7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}LD(t)}},LD=t=>{t.readable&&t.destroy()};var $7=(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})=>qn.has(c)))Vke(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!qn.has(c)))Hke({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]:xl(o);Jd(s,i)}},Vke=(t,e,r,n)=>{r==="output"?Jd(t.stdio[n],e):Jd(e,t.stdio[n]);let i=qke[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},qke=["stdin","stdout","stderr"],Hke=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Wke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Wke=(t,{signal:e})=>{Ti(t)&&El(t,Yke,e)},Yke=2;import{addAbortListener as Jke}from"events";var wl=[];wl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&wl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&wl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Ix=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",$D=Symbol.for("signal-exit emitter"),UD=globalThis,Kke=Object.defineProperty.bind(Object),FD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(UD[$D])return UD[$D];Kke(UD,$D,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},Cx=class{},Zke=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),BD=class extends Cx{onExit(){return()=>{}}load(){}unload(){}},jD=class extends Cx{#e=zD.platform==="win32"?"SIGINT":"SIGHUP";#r=new FD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of wl)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(!Ix(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 wl)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,wl.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 Ix(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"&&Ix(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)}},zD=globalThis.process,{onExit:U7,load:Cpt,unload:Ppt}=Zke(Ix(zD)?new jD(zD):new BD);var F7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=U7(()=>{t.kill()});Jke(n,()=>{i()})};var j7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=BT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Xke(r,n,i),{sourceStream:d,sourceError:f}=eMe(t,l),{options:p,fileDescriptors:h}=fo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},Xke=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Qke(t,e,...r),a=ZT(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Qke=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(B7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||OM(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]=PT(r,...n);return{destination:e(B7)(i,o,s),pipeOptions:s}}if(fo.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},B7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),eMe=(t,e)=>{try{return{sourceStream:Vd(t,e)}}catch(r){return{sourceError:r}}};var G7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=tMe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw GD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},tMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return LD(t),n;if(e!==void 0)return DD(r),e},GD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Yd({error:t,command:z7,escapedCommand:z7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),z7="source.pipe(destination)";var V7=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 rMe}from"stream/promises";var q7=(t,e,r)=>{let n=Px.has(e)?iMe(t,e):nMe(t,e);return El(t,sMe,r.signal),El(e,aMe,r.signal),oMe(e),n},nMe=(t,e)=>{let r=xl([t]);return Jd(r,e),Px.set(e,r),r},iMe=(t,e)=>{let r=Px.get(e);return r.add(t),r},oMe=async t=>{try{await rMe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Px.delete(t)},Px=new WeakMap,sMe=2,aMe=1;import{aborted as cMe}from"util";var H7=(t,e)=>t===void 0?[]:[lMe(t,e)],lMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await cMe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw GD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Ox=(t,...e)=>{if(At(e[0]))return Ox.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=j7(t,...e),i=uMe({...n,destination:r});return i.pipe=Ox.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},uMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=dMe(t,i);G7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=q7(e,o,d);return await Promise.race([V7(u),...H7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},dMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as yMe}from"timers/promises";import{on as fMe}from"events";import{getDefaultHighWaterMark as pMe}from"stream";var Nx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return hMe(e,s),Y7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},hMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},VD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;mMe(e,s,t);let a=t.readableObjectMode&&!o;return Y7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},mMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Y7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=fMe(t,"data",{signal:e.signal,highWaterMark:W7,highWatermark:W7});return gMe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},qD=pMe(!0),W7=qD,gMe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=_Me({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Tl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*t_(a)}},_Me=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[bx(t,r,!e),vx(t,i,!n,{})].filter(Boolean);var K7=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=SMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([EMe(t),d]);return}let f=bD(c,r),p=VD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([vMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},SMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!wx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=VD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await s7(a,t,r,o)},EMe=async t=>{await yMe(),t.readableFlowing===null&&t.resume()},vMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await fx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await px(r,{maxBuffer:o})):await Wd(r,{maxBuffer:o})}catch(a){return Z7(sQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},HD=async t=>{try{return await t}catch(e){return Z7(e)}},Z7=({bufferedData:t})=>b9(t)?new Uint8Array(t):t;import{finished as bMe}from"stream/promises";var o_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=TMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],bMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||AMe(a,e,r,n)}finally{s.abort()}},TMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&xMe(t,r,n),n},xMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{wMe(e,r),n.call(t,...i)}},wMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},AMe=(t,e,r,n)=>{if(!RMe(t,e,r,n))throw t},RMe=(t,e,r,n=!0)=>r.propagating?J7(t)||kx(t):(r.propagating=!0,WD(r,e)===n?J7(t):kx(t)),WD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",kx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",J7=t=>t?.code==="EPIPE";var X7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>YD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),YD=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=o_(t,e,l);if(WD(l,e)){await u;return}let[d]=await Promise.all([K7({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Q7=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?xl([t,e].filter(Boolean)):void 0,eee=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>YD({...IMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:CMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),IMe=({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}},CMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as PMe}from"events";var tee=t=>Fd(t,"ipc"),ree=(t,e)=>{let r=FT(t);lo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var nee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=tee(o),a=fs(e,"ipc"),c=fs(r,"ipc");for await(let l of OD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(aQ(t,i,c),i.push(l)),s&&ree(l,o);return i},iee=async(t,e)=>(await Promise.allSettled([t]),e);var oee=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:S,controller:E})=>{let b=d7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=X7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),A=eee({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),I=[],C=nee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),O=OMe(m,t,x),M=NMe(h,x);try{return await Promise.race([Promise.all([{},p7(b),Promise.all(y),A,C,FX(t,d),...O,...M]),S,kMe(t,E),...MX(t,o,f,E),...tX({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...NX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(B){return f.terminationReason??="other",Promise.all([{error:B},b,Promise.all(y.map(_=>HD(_))),HD(A),iee(C,I),Promise.allSettled(O),Promise.allSettled(M)])}},OMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:o_(n,i,r)),NMe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ai(o,{checkOpen:!1})&&!Ti(o)).map(({type:i,value:o,stream:s=o})=>o_(s,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),kMe=async(t,{signal:e})=>{let[r]=await PMe(t,"error",{signal:e});throw r};var see=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),s_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=uo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Xd=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 MMe}from"stream";import{callbackify as DMe}from"util";import{finished as aee}from"stream/promises";var KD=async t=>{if(t!==void 0)try{await ZD(t)}catch{}},cee=async t=>{if(t!==void 0)try{await JD(t)}catch{}},ZD=async t=>{await aee(t,{cleanup:!0,readable:!1,writable:!0})},JD=async t=>{await aee(t,{cleanup:!0,readable:!0,writable:!1})},Mx=async(t,e)=>{if(await t,e)throw e},Dx=(t,e,r)=>{r&&!kx(r)?t.destroy(r):e&&t.destroy()};var lee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||hn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=XD(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=QD(a,s),{read:f,onStdoutDataDone:p}=eL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new MMe({read:f,destroy:DMe(rL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return tL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},XD=(t,e,r)=>{let n=Vd(t,e),i=s_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},QD=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:qD},eL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=uo(),s=Nx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){LMe(this,s,o)},onStdoutDataDone:o}},LMe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},tL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await JD(t),await n,await KD(i),await e,r.readable&&r.push(null)}catch(o){await KD(i),uee(r,o)}},rL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Xd(r,e)&&(uee(t,n),await Mx(e,n))},uee=(t,e)=>{Dx(t,t.readable,e)};import{Writable as $Me}from"stream";import{callbackify as dee}from"util";var fee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=nL(t,r,e),s=new $Me({...iL(n,t,i),destroy:dee(sL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return oL(n,s),s},nL=(t,e,r)=>{let n=ZT(t,e),i=s_(r,n,"writableFinal"),o=s_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},iL=(t,e,r)=>({write:UMe.bind(void 0,t),final:dee(FMe.bind(void 0,t,e,r))}),UMe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},FMe=async(t,e,r)=>{await Xd(r,e)&&(t.writable&&t.end(),await e)},oL=async(t,e,r)=>{try{await ZD(t),e.writable&&e.end()}catch(n){await cee(r),pee(e,n)}},sL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Xd(r,e),await Xd(n,e)&&(pee(t,i),await Mx(e,i))},pee=(t,e)=>{Dx(t,t.writable,e)};import{Duplex as BMe}from"stream";import{callbackify as jMe}from"util";var hee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||hn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=XD(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=nL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=QD(c,a),{read:S,onStdoutDataDone:E}=eL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new BMe({read:S,...iL(u,t,d),destroy:jMe(zMe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return tL({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),oL(u,b,c),b},zMe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([rL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),sL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var aL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||hn.has(e),s=Vd(t,r),a=Nx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return GMe(a,s,t)},GMe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var mee=(t,{encoding:e})=>{let r=see();t.readable=lee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=fee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=hee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=aL.bind(void 0,t,e),t[Symbol.asyncIterator]=aL.bind(void 0,t,e,{})};var gee=(t,e)=>{for(let[r,n]of qMe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},VMe=(async()=>{})().constructor.prototype,qMe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(VMe,t)]);var _ee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=YMe(t,e,r),{subprocess:f,promise:p}=ZMe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Ox.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),gee(f,p),fo.set(f,{options:u,fileDescriptors:d}),f},YMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=jT(t,e,r),{file:a,commandArguments:c,options:l}=ax(t,e,r),u=KMe(l),d=I7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},KMe=({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}},ZMe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=WMe(...cx(t,e,r))}catch(h){return x7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;HMe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];$7(c,a,l),F7(c,r,l);let d={},f=uo();c.kill=QJ.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Q7(c,r),mee(c,r),v7(c,r);let p=JMe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},JMe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,S]=await oee({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((y,A)=>hs(y,e,A)),b=hs(m,e,"all"),x=XMe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Kd(x,n,e)},XMe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?e_({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof po,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):gx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Lx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,QMe(n,t[n],i)]));return{...t,...r}},QMe=(t,e,r)=>eDe.has(t)&&At(e)&&At(r)?{...e,...r}:r,eDe=new Set(["env",...$M]);var Pa=(t,e,r,n)=>{let i=(s,a,c)=>Pa(s,a,r,c),o=(...s)=>tDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},tDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(At(o))return i(t,Lx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=rDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?m7(a,c,l):_ee(a,c,l,i)},rDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=I9(e)?C9(e,r):[e,...r],[s,a,c]=PT(...o),l=Lx(Lx(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var yee=({file:t,commandArguments:e})=>Eee(t,e),See=({file:t,commandArguments:e})=>({...Eee(t,e),isSync:!0}),Eee=(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]=nDe(t);return{file:r,commandArguments:n}},nDe=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(iDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},iDe=/ +/g;var vee=(t,e,r)=>{t.sync=e(oDe,r),t.s=t.sync},bee=({options:t})=>Tee(t),oDe=({options:t})=>({...Tee(t),isSync:!0}),Tee=t=>({options:{...sDe(t),...t}}),sDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},xee={preferLocal:!0};var wee=Pa(()=>({})),Sgt=Pa(()=>({isSync:!0})),Aee=Pa(yee),Egt=Pa(See),vgt=Pa(LX),bgt=Pa(bee,{},xee,vee),{sendMessage:Tgt,getOneMessage:xgt,getEachMessage:wgt,getCancelSignal:Agt}=b7();var Ree=!1,Iee=()=>{Ree=!0},mo=()=>Ree;var a_=null,Cee=t=>(a_&&a_.destroy(),a_=new ms({totalAllowedTime:t}),a_),Pee=()=>a_;var ms=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&mo())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await xT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Se.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Oee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-test.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var uDe=cDe(import.meta.url),dDe=gs.dirname(uDe),fDe=lDe(import.meta.url),Qd=_e("shell"),cL=new Set,Nee={preferLocal:!0},or=(t,e,r)=>{let[n,i]=pDe(e,r),o={...Nee,...i},s=wee(t,n,o);Mee(s,o),$ee(s);let a=r?.idleTimeout;return a&&a>0&&Lee(s,a),s},kee=(t,e)=>{let r={...Nee,...e},n=Aee(t,r);return Mee(n,r),$ee(n),e?.idleTimeout&&e.idleTimeout>0&&Lee(n,e.idleTimeout),n},pDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Mee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(_s.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new $g).pipe(_s.stdout),t.stderr?.pipe(new $g).pipe(_s.stderr);return}t.stdout?.pipe(_s.stdout),t.stderr?.pipe(_s.stderr)},lL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_s.kill(-t.pid,e),Qd.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Qd.error("Error killing process:",r),!1}},Dee=t=>lL(t,"SIGKILL"),Lee=(t,e)=>{let r=null,n=()=>{Qd.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),lL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Qd.log(`Force killing idle process ${t.pid}`),Dee(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)},$ee=t=>{cL.add(t);let e=Pee();if(e){let r=e.onTimesUp(()=>{Qd.log(`Global timer expired, killing process ${t.pid}`),lL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Qd.log(`Force killing process ${t.pid} after timeout`),Dee(t))},5e3)});t.on("exit",()=>{cL.delete(t),r()}),t.on("error",()=>{cL.delete(t),r()})}};function Ux(t,e){return!!Ri(t,e)}function Ri(t,e){if(!_s.env.NETLIFY_LOCAL_MODE)try{let i=fDe.resolve(Oee.name),o=gs.dirname(i);for(;o!==gs.dirname(o);){let s=gs.dirname(o);if(gs.basename(s)==="node_modules"){let a=gs.join(s,".bin",e);if($x.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(_s.env.NODE_PATH){let i=gs.join(_s.env.NODE_PATH,".bin",e);if($x.existsSync(i))return i}let r=gs.join(t,"node_modules",".bin",e);if($x.existsSync(r))return r;let n=gs.join(dDe,"..","node_modules",".bin",e);if($x.existsSync(n))return n}var hDe=_e("utils"),mDe=t=>new Promise(e=>{setTimeout(e,t)});var Fx=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await mDe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Oa=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Uee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):hDe.error("Could not parse JSON",n))}},gDe=t=>t.charAt(0).toUpperCase()+t.slice(1),go=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():gDe(e)).join(" ");function ys(t,e){e&&t.log(`Skill invoked: ${e}`)}var Bx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Fee=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var uL=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},_De=1e4,dL=(t,e=_De)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as Bee}from"buffer";import yDe from"path";var jee=_e("repo"),Wr=(t,e={})=>or("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),jx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{jee.info("Getting runner diffs");let n=await EDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=bDe(o);await TDe(m,r)}jee.info("Changes after processing"),await pL(r);let s=await hL(o,r);if(await fL(s,r),i=await vDe(r),!i)return{hasChanges:!1,ignored:s};await Wr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Wr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await zee(r),{hasChanges:!1,ignored:s};let u=await Wr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Wr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let S=await Wr(["diff",t.sha,"HEAD","--binary"],a),E=String(S.stdout??"");f!==E&&(p=Bee.from(E).toString("base64"))}await zee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Bee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},zee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Wr(["reset","--soft","HEAD~1"],{cwd:t})},fL=async(t=[],e=process.cwd())=>{await Wr(["add",".",...t],{cwd:e})},pL=async(t=process.cwd())=>{let e=await Wr(["status","-s"],{cwd:t});return String(e.stdout??"")},Gee=/.. (.+)?\.log$/,SDe=[Gee],EDe=async(t=process.cwd())=>{let e=await pL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
103
103
|
`).filter(i=>SDe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},vDe=async(t=process.cwd())=>{try{return await Wr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},c_=async(t=process.cwd())=>{let{stdout:e}=await Wr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Vee=async(t=process.cwd())=>{let{stdout:e}=await Wr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},hL=async(t,e=process.cwd())=>{t||=await pL(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
104
104
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${yDe.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Gee)?.[1];o&&n.push(`:!${o}.log`)}),n},mL=async(t=process.cwd())=>{await Wr(["reset","--hard","HEAD"],{cwd:t})},qee=async(t=process.cwd())=>{let e=await Wr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
105
105
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},bDe=t=>{let e=t.split(`
|
package/dist/bin.js
CHANGED
|
@@ -578,7 +578,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
578
578
|
`,LF:`
|
|
579
579
|
`,concatBytes:p6},hmt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},mmt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:hmt};import{Buffer as gmt}from"buffer";var jve=(t,e)=>t?void 0:_mt.bind(void 0,e),_mt=function*(t,e){if(typeof e!="string"&&!xr(e)&&!gmt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},qve=(t,e)=>t?ymt.bind(void 0,e):Smt.bind(void 0,e),ymt=function*(t,e){Bve(t,e),yield e},Smt=function*(t,e){if(Bve(t,e),typeof e!="string"&&!xr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Bve=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
580
580
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
581
|
-
if (condition) { yield value; }`)};import{Buffer as Emt}from"buffer";import{StringDecoder as vmt}from"string_decoder";var VO=(t,e,r)=>{if(r)return;if(t)return{transform:bmt.bind(void 0,new TextEncoder)};let n=new vmt(e);return{transform:Tmt.bind(void 0,n),final:wmt.bind(void 0,n)}},bmt=function*(t,e){Emt.isBuffer(e)?yield yc(e):typeof e=="string"?yield t.encode(e):yield e},Tmt=function*(t,e){yield xr(e)?t.write(e):e},wmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as zve}from"util";var m6=zve(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),HO=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Amt}=e[r];for await(let i of n(t))yield*HO(i,e,r+1)},Vve=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Rmt(r,Number(e),t)},Rmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*HO(n,r,e+1)},Hve=zve(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Amt=function*(t){yield t};var g6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Gve=(t,e)=>[...e.flatMap(r=>[...Lf(r,t,0)]),...bb(t)],Lf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Imt}=e[r];for(let i of n(t))yield*Lf(i,e,r+1)},bb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*xmt(r,Number(e),t)},xmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Lf(n,r,e+1)},Imt=function*(t){yield t};var _6=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Yve(t,o,s),l=$f(e),u=$f(r),d=l?m6.bind(void 0,HO,a):g6.bind(void 0,Lf),f=l||u?m6.bind(void 0,Vve,a):g6.bind(void 0,bb),p=l||u?Hve.bind(void 0,a):void 0;return{stream:new Pmt({writableObjectMode:n,writableHighWaterMark:Wve(n),readableObjectMode:i,readableHighWaterMark:Wve(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},GO=(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=Yve(o,r,a);t=Gve(c,t)}return t},Yve=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:jve(n,a)},VO(r,o,n),zO(r,s,n,c),{transform:t,final:e},{transform:qve(i,a)},Fve({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Kve=(t,e)=>{for(let r of Omt(t))Cmt(t,r,e)},Omt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Cmt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${yu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Nmt(a,n));r.input=fb(o)},Nmt=(t,e)=>{let r=GO(t,e,"utf8",!0);return kmt(r),fb(r)},kmt=t=>{let e=t.find(r=>typeof r!="string"&&!xr(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 Mmt,appendFileSync as Umt}from"fs";var WO=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&bg(r,n)&&!$i.has(e)&&$mt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Lmt.has(s))||t.every(({type:i})=>Es.has(i))),$mt=t=>t===1||t===2,Lmt=new Set(["pipe","overlapped"]),Jve=async(t,e,r,n)=>{for await(let i of t)Dmt(e)||Xve(i,r,n)},Zve=(t,e,r)=>{for(let n of t)Xve(n,e,r)},Dmt=t=>t._readableState.pipes.length>0,Xve=(t,e,r)=>{let n=aO(t);Xo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Qve=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>Fmt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Fmt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=eve(t,s,d),p=yc(f),{stdioItems:h,objectMode:m}=e[r],_=jmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=qmt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Bmt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&zmt(y,h,i),S}catch(g){return n.error=g,S}},jmt=(t,e,r,n)=>{try{return GO(t,e,r,!1)}catch(i){return n.error=i,t}},qmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:fb(t)};let o=hye(t,r);return n[s]?{serializedResult:o,finalResult:h6(o,!i[s],e)}:{serializedResult:o}},Bmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!WO({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=h6(t,!1,o);try{Zve(a,e,n)}catch(c){r.error??=c}},zmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>qO.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?Umt(n,t):(r.add(s),Mmt(n,t))}};var ebe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,vc(e,r,"all")]:Array.isArray(e)?[vc(t,r,"all"),...e]:xr(t)&&xr(e)?TG([t,e]):`${t}${e}`};import{once as y6}from"events";var tbe=async(t,e)=>{let[r,n]=await Vmt(t);return e.isForcefullyTerminated??=!1,[r,n]},Vmt=async t=>{let[e,r]=await Promise.allSettled([y6(t,"spawn"),y6(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?rbe(t):r.value},rbe=async t=>{try{return await y6(t,"exit")}catch{return rbe(t)}},nbe=async t=>{let[e,r]=await t;if(!Hmt(e,r)&&S6(e,r))throw new Zs;return[e,r]},Hmt=(t,e)=>t===void 0&&e===void 0,S6=(t,e)=>t!==0||e!==null;var ibe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Gmt(t,e,r),o=s?.code==="ETIMEDOUT",a=QEe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Gmt=(t,e,r)=>t!==void 0?t:S6(e,r)?new Zs:void 0;var sbe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Ymt(t,e,r),d=Zmt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ng(d,c,l)},Ymt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=lO(t,e,r),a=Kmt(r),{file:c,commandArguments:l,options:u}=PO(t,e,a);Jmt(u);let d=Lve(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Kmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Jmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&YO("ipcInput"),t&&YO("ipc: true"),r&&YO("detached: true"),n&&YO("cancelSignal")},YO=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Zmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Xmt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=ibe(c,r),{output:h,error:m=l}=Qve({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>vc(v,r,S)),y=vc(ebe(h,r),r,"all");return egt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Xmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Kve(s,r);let a=Qmt(r);return Wmt(...OO(t,e,a))}catch(a){return Cg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Qmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:MO(e)}),egt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?UO({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):vb({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as q_t}from"events";import{spawn as B_t}from"child_process";import ube from"process";import{once as E6,on as tgt}from"events";var obe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Rg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:TO(t)}),rgt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),rgt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{SO(e,i);let s=_u(t,e,r),o=new AbortController;try{return await Promise.race([ngt(s,n,o),igt(s,r,o),sgt(s,r,o)])}catch(a){throw Ag(t),a}finally{o.abort(),EO(e,i)}},ngt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await E6(t,"message",{signal:r});return n}for await(let[n]of tgt(t,"message",{signal:r}))if(e(n))return n},igt=async(t,e,{signal:r})=>{await E6(t,"disconnect",{signal:r}),GSe(e)},sgt=async(t,e,{signal:r})=>{let[n]=await E6(t,"strict:error",{signal:r});throw gO(n,e)};import{once as cbe,on as ogt}from"events";var lbe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>v6({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),v6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Rg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:TO(t)}),SO(e,s);let o=_u(t,e,r),a=new AbortController,c={};return agt(t,o,a),cgt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),lgt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},agt=async(t,e,r)=>{try{await cbe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},cgt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await cbe(t,"strict:error",{signal:r.signal});n.error=gO(i,e),r.abort()}catch{}},lgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of ogt(r,"message",{signal:s.signal}))abe(o),yield c}catch{abe(o)}finally{s.abort(),EO(e,a),n||Ag(t),i&&await t}},abe=({error:t})=>{if(t)throw t};var dbe=(t,{ipc:e})=>{Object.assign(t,pbe(t,!1,e))},fbe=()=>{let t=ube,e=!0,r=ube.channel!==void 0;return{...pbe(t,e,r),getCancelSignal:SEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},pbe=(t,e,r)=>({sendMessage:xO.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:obe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:lbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as ugt}from"child_process";import{PassThrough as dgt,Readable as fgt,Writable as pgt,Duplex as hgt}from"stream";var hbe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{d6(n);let a=new ugt;mgt(a,n),Object.assign(a,{readable:ggt,writable:_gt,duplex:ygt});let c=Cg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Sgt(c,o,i);return{subprocess:a,promise:l}},mgt=(t,e)=>{let r=Tb(),n=Tb(),i=Tb(),s=Array.from({length:e.length-3},Tb),o=Tb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Tb=()=>{let t=new dgt;return t.end(),t},ggt=()=>new fgt({read(){}}),_gt=()=>new pgt({write(){}}),ygt=()=>new hgt({read(){},write(){}}),Sgt=async(t,e,r)=>Ng(t,e,r);import{createReadStream as mbe,createWriteStream as gbe}from"fs";import{Buffer as Egt}from"buffer";import{Readable as wb,Writable as vgt,Duplex as bgt}from"stream";var ybe=(t,e)=>BO(Tgt,t,e,!1),Rb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${yu[t]}.`)},_be={fileNumber:Rb,generator:_6,asyncGenerator:_6,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:bgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Tgt={input:{..._be,fileUrl:({value:t})=>({stream:mbe(t)}),filePath:({value:{file:t}})=>({stream:mbe(t)}),webStream:({value:t})=>({stream:wb.fromWeb(t)}),iterable:({value:t})=>({stream:wb.from(t)}),asyncIterable:({value:t})=>({stream:wb.from(t)}),string:({value:t})=>({stream:wb.from(t)}),uint8Array:({value:t})=>({stream:wb.from(Egt.from(t))})},output:{..._be,fileUrl:({value:t})=>({stream:gbe(t)}),filePath:({value:{file:t,append:e}})=>({stream:gbe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:vgt.fromWeb(t)}),iterable:Rb,asyncIterable:Rb,string:Rb,uint8Array:Rb}};import{on as wgt,once as Sbe}from"events";import{PassThrough as Rgt,getDefaultHighWaterMark as Agt}from"stream";import{finished as bbe}from"stream/promises";function Df(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)T6(i);let e=t.some(({readableObjectMode:i})=>i),r=xgt(t,e),n=new b6({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var xgt=(t,e)=>{if(t.length===0)return Agt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},b6=class extends Rgt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(T6(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Igt(this,this.#e,this.#s);let r=Cgt({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(T6(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)}},Igt=async(t,e,r)=>{KO(t,Ebe);let n=new AbortController;try{await Promise.race([Pgt(t,n),Ogt(t,e,r,n)])}finally{n.abort(),KO(t,-Ebe)}},Pgt=async(t,{signal:e})=>{try{await bbe(t,{signal:e,cleanup:!0})}catch(r){throw Tbe(t,r),r}},Ogt=async(t,e,r,{signal:n})=>{for await(let[i]of wgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},T6=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Cgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{KO(t,vbe);let a=new AbortController;try{await Promise.race([Ngt(s,e,a),kgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),$gt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),KO(t,-vbe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?w6(t):Lgt(t))},Ngt=async(t,e,{signal:r})=>{try{await t,r.aborted||w6(e)}catch(n){r.aborted||Tbe(e,n)}},kgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await bbe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;wbe(o)?i.add(e):Rbe(t,o)}},$gt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Sbe(t,i,{signal:s}),!t.readable)return Sbe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Lgt=t=>{t.writable&&t.end()},Tbe=(t,e)=>{wbe(e)?w6(t):Rbe(t,e)},wbe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",w6=t=>{(t.readable||t.writable)&&t.destroy()},Rbe=(t,e)=>{t.destroyed||(t.once("error",Dgt),t.destroy(e))},Dgt=()=>{},KO=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Ebe=2,vbe=1;import{finished as Abe}from"stream/promises";var $g=(t,e)=>{t.pipe(e),Mgt(t,e),Ugt(t,e)},Mgt=async(t,e)=>{if(!(Js(t)||Js(e))){try{await Abe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}R6(e)}},R6=t=>{t.writable&&t.end()},Ugt=async(t,e)=>{if(!(Js(t)||Js(e))){try{await Abe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}A6(t)}},A6=t=>{t.readable&&t.destroy()};var xbe=(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})=>Es.has(c)))Fgt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Es.has(c)))qgt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Df(s);$g(o,i)}},Fgt=(t,e,r,n)=>{r==="output"?$g(t.stdio[n],e):$g(e,t.stdio[n]);let i=jgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},jgt=["stdin","stdout","stderr"],qgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;Bgt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},Bgt=(t,{signal:e})=>{Js(t)&&Nf(t,zgt,e)},zgt=2;import{addAbortListener as Ggt}from"events";var Mf=[];Mf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Mf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Mf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var JO=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",x6=Symbol.for("signal-exit emitter"),I6=globalThis,Vgt=Object.defineProperty.bind(Object),P6=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(I6[x6])return I6[x6];Vgt(I6,x6,{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}},ZO=class{},Hgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),O6=class extends ZO{onExit(){return()=>{}}load(){}unload(){}},C6=class extends ZO{#e=N6.platform==="win32"?"SIGINT":"SIGHUP";#r=new P6;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Mf)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!JO(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Mf)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Mf.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return JO(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"&&JO(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)}},N6=globalThis.process,{onExit:Ibe,load:cir,unload:lir}=Hgt(JO(N6)?new C6(N6):new O6);var Pbe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Ibe(()=>{t.kill()});Ggt(n,()=>{i()})};var Cbe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=cO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Wgt(r,n,i),{sourceStream:d,sourceError:f}=Kgt(t,l),{options:p,fileDescriptors:h}=ea.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},Wgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Ygt(t,e,...r),a=yO(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Ygt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Obe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||vG(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]=XP(r,...n);return{destination:e(Obe)(i,s,o),pipeOptions:o}}if(ea.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}`)},Obe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Kgt=(t,e)=>{try{return{sourceStream:xg(t,e)}}catch(r){return{sourceError:r}}};var kbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Jgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw k6({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Jgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return A6(t),n;if(e!==void 0)return R6(r),e},k6=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Cg({error:t,command:Nbe,escapedCommand:Nbe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Nbe="source.pipe(destination)";var $be=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 Zgt}from"stream/promises";var Lbe=(t,e,r)=>{let n=XO.has(e)?Qgt(t,e):Xgt(t,e);return Nf(t,t_t,r.signal),Nf(e,r_t,r.signal),e_t(e),n},Xgt=(t,e)=>{let r=Df([t]);return $g(r,e),XO.set(e,r),r},Qgt=(t,e)=>{let r=XO.get(e);return r.add(t),r},e_t=async t=>{try{await Zgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}XO.delete(t)},XO=new WeakMap,t_t=2,r_t=1;import{aborted as n_t}from"util";var Dbe=(t,e)=>t===void 0?[]:[i_t(t,e)],i_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await n_t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw k6({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var QO=(t,...e)=>{if(mr(e[0]))return QO.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Cbe(t,...e),i=s_t({...n,destination:r});return i.pipe=QO.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},s_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=o_t(t,i);kbe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Lbe(e,s,d);return await Promise.race([$be(u),...Dbe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},o_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as p_t}from"timers/promises";import{on as a_t}from"events";import{getDefaultHighWaterMark as c_t}from"stream";var eC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return l_t(e,o),Ube({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},l_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},$6=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;u_t(e,o,t);let a=t.readableObjectMode&&!s;return Ube({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},u_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Ube=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=a_t(t,"data",{signal:e.signal,highWaterMark:Mbe,highWatermark:Mbe});return d_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},L6=c_t(!0),Mbe=L6,d_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=f_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Lf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*bb(a)}},f_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[VO(t,r,!e),zO(t,i,!n,{})].filter(Boolean);var Fbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=h_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([m_t(t),d]);return}let f=f6(c,r),p=$6({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([g_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},h_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!WO({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=$6({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Jve(a,t,r,s)},m_t=async t=>{await p_t(),t.readableFlowing===null&&t.resume()},g_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await $O(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await LO(r,{maxBuffer:s})):await Og(r,{maxBuffer:s})}catch(a){return jbe(JEe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},D6=async t=>{try{return await t}catch(e){return jbe(e)}},jbe=({bufferedData:t})=>fye(t)?new Uint8Array(t):t;import{finished as __t}from"stream/promises";var Ab=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=y_t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],__t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||v_t(a,e,r,n)}finally{o.abort()}},y_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&S_t(t,r,n),n},S_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{E_t(e,r),n.call(t,...i)}},E_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},v_t=(t,e,r,n)=>{if(!b_t(t,e,r,n))throw t},b_t=(t,e,r,n=!0)=>r.propagating?qbe(t)||tC(t):(r.propagating=!0,M6(r,e)===n?qbe(t):tC(t)),M6=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",tC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",qbe=t=>t?.code==="EPIPE";var Bbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>U6({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),U6=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Ab(t,e,l);if(M6(l,e)){await u;return}let[d]=await Promise.all([Fbe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var zbe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Df([t,e].filter(Boolean)):void 0,Vbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>U6({...T_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:w_t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),T_t=({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}},w_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as R_t}from"events";var Hbe=t=>bg(t,"ipc"),Gbe=(t,e)=>{let r=aO(t);Xo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Wbe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Hbe(s),a=Sc(e,"ipc"),c=Sc(r,"ipc");for await(let l of v6({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ZEe(t,i,c),i.push(l)),o&&Gbe(l,s);return i},Ybe=async(t,e)=>(await Promise.allSettled([t]),e);var Kbe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=tbe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Bbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=Vbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),P=[],x=Wbe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),R=A_t(m,t,S),O=x_t(h,S);try{return await Promise.race([Promise.all([{},nbe(v),Promise.all(g),w,x,PEe(t,d),...R,...O]),_,I_t(t,y),...wEe(t,s,f,y),...HSe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...bEe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(A){return f.terminationReason??="other",Promise.all([{error:A},v,Promise.all(g.map(b=>D6(b))),D6(w),Ybe(x,P),Promise.allSettled(R),Promise.allSettled(O)])}},A_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Ab(n,i,r)),x_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Qs(s,{checkOpen:!1})&&!Js(s)).map(({type:i,value:s,stream:o=s})=>Ab(o,n,e,{isSameDirection:Es.has(i),stopOnExit:i==="native"}))),I_t=async(t,{signal:e})=>{let[r]=await R_t(t,"error",{signal:e});throw r};var Jbe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),xb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Qo();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Lg=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 P_t}from"stream";import{callbackify as O_t}from"util";import{finished as Zbe}from"stream/promises";var F6=async t=>{if(t!==void 0)try{await j6(t)}catch{}},Xbe=async t=>{if(t!==void 0)try{await q6(t)}catch{}},j6=async t=>{await Zbe(t,{cleanup:!0,readable:!1,writable:!0})},q6=async t=>{await Zbe(t,{cleanup:!0,readable:!0,writable:!1})},rC=async(t,e)=>{if(await t,e)throw e},nC=(t,e,r)=>{r&&!tC(r)?t.destroy(r):e&&t.destroy()};var Qbe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||$i.has(r),{subprocessStdout:a,waitReadableDestroy:c}=B6(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=z6(a,o),{read:f,onStdoutDataDone:p}=V6({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new P_t({read:f,destroy:O_t(G6.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return H6({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},B6=(t,e,r)=>{let n=xg(t,e),i=xb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},z6=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:L6},V6=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Qo(),o=eC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){C_t(this,o,s)},onStdoutDataDone:s}},C_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},H6=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await q6(t),await n,await F6(i),await e,r.readable&&r.push(null)}catch(s){await F6(i),eTe(r,s)}},G6=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Lg(r,e)&&(eTe(t,n),await rC(e,n))},eTe=(t,e)=>{nC(t,t.readable,e)};import{Writable as N_t}from"stream";import{callbackify as tTe}from"util";var rTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=W6(t,r,e),o=new N_t({...Y6(n,t,i),destroy:tTe(J6.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return K6(n,o),o},W6=(t,e,r)=>{let n=yO(t,e),i=xb(r,n,"writableFinal"),s=xb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},Y6=(t,e,r)=>({write:k_t.bind(void 0,t),final:tTe($_t.bind(void 0,t,e,r))}),k_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},$_t=async(t,e,r)=>{await Lg(r,e)&&(t.writable&&t.end(),await e)},K6=async(t,e,r)=>{try{await j6(t),e.writable&&e.end()}catch(n){await Xbe(r),nTe(e,n)}},J6=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Lg(r,e),await Lg(n,e)&&(nTe(t,i),await rC(e,i))},nTe=(t,e)=>{nC(t,t.writable,e)};import{Duplex as L_t}from"stream";import{callbackify as D_t}from"util";var iTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||$i.has(r),{subprocessStdout:c,waitReadableDestroy:l}=B6(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=W6(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=z6(c,a),{read:_,onStdoutDataDone:y}=V6({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new L_t({read:_,...Y6(u,t,d),destroy:D_t(M_t.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return H6({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),K6(u,v,c),v},M_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([G6({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),J6({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var Z6=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||$i.has(e),o=xg(t,r),a=eC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return U_t(a,o,t)},U_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var sTe=(t,{encoding:e})=>{let r=Jbe();t.readable=Qbe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=rTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=iTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Z6.bind(void 0,t,e),t[Symbol.asyncIterator]=Z6.bind(void 0,t,e,{})};var oTe=(t,e)=>{for(let[r,n]of j_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},F_t=(async()=>{})().constructor.prototype,j_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(F_t,t)]);var aTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=z_t(t,e,r),{subprocess:f,promise:p}=H_t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=QO.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),oTe(f,p),ea.set(f,{options:u,fileDescriptors:d}),f},z_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=lO(t,e,r),{file:a,commandArguments:c,options:l}=PO(t,e,r),u=V_t(l),d=ybe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},V_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}},H_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=B_t(...OO(t,e,r))}catch(h){return hbe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;q_t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];xbe(c,a,l),Pbe(c,r,l);let d={},f=Qo();c.kill=zSe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=zbe(c,r),sTe(c,r),dbe(c,r);let p=G_t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},G_t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await Kbe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,w)=>vc(g,e,w)),v=vc(m,e,"all"),S=W_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ng(S,n,e)},W_t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?vb({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ta,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):UO({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var iC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Y_t(n,t[n],i)]));return{...t,...r}},Y_t=(t,e,r)=>K_t.has(t)&&mr(e)&&mr(r)?{...e,...r}:r,K_t=new Set(["env",...xG]);var Su=(t,e,r,n)=>{let i=(o,a,c)=>Su(o,a,r,c),s=(...o)=>J_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},J_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(mr(s))return i(t,iC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=Z_t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?sbe(a,c,l):aTe(a,c,l,i)},Z_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=yye(e)?Sye(e,r):[e,...r],[o,a,c]=XP(...s),l=iC(iC(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var cTe=({file:t,commandArguments:e})=>uTe(t,e),lTe=({file:t,commandArguments:e})=>({...uTe(t,e),isSync:!0}),uTe=(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]=X_t(t);return{file:r,commandArguments:n}},X_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(Q_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Q_t=/ +/g;var dTe=(t,e,r)=>{t.sync=e(eyt,r),t.s=t.sync},fTe=({options:t})=>pTe(t),eyt=({options:t})=>({...pTe(t),isSync:!0}),pTe=t=>({options:{...tyt(t),...t}}),tyt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},hTe={preferLocal:!0};var mTe=Su(()=>({})),Qor=Su(()=>({isSync:!0})),gTe=Su(cTe),ear=Su(lTe),tar=Su(AEe),rar=Su(fTe,{},hTe,dTe),{sendMessage:nar,getOneMessage:iar,getEachMessage:sar,getCancelSignal:oar}=fbe();import{Transform as ryt}from"stream";var nyt=["NETLIFY_AI_GATEWAY_KEY"];function iyt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...nyt])]}function syt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function oyt(){let e=iyt().map(r=>process.env[r]).filter(r=>!(!r||syt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function vs(t){if(typeof t!="string")return t;let e=oyt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(ayt(n),"g");r=r.replace(i,"******")}),r}function ayt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ib=class extends ryt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=vs(i);n(null,s)}},sC=Symbol("maskedWrite");function _Te(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[sC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?vs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[sC]=!0,process.stdout.write=r}if(!process.stderr.write[sC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?vs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[sC]=!0,process.stderr.write=r}}}var yTe=!1,STe=()=>{yTe=!0},hi=()=>yTe;var Pb=null,ETe=t=>(Pb&&Pb.destroy(),Pb=new bc({totalAllowedTime:t}),Pb),vTe=()=>Pb;var bc=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&hi())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await JP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Pe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var bTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-test.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var dyt=lyt(import.meta.url),fyt=Tc.dirname(dyt),pyt=uyt(import.meta.url),Dg=be("shell"),X6=new Set,TTe={preferLocal:!0},Hn=(t,e,r)=>{let[n,i]=hyt(e,r),s={...TTe,...i},o=mTe(t,n,s);RTe(o,s),ITe(o);let a=r?.idleTimeout;return a&&a>0&&xTe(o,a),o},wTe=(t,e)=>{let r={...TTe,...e},n=gTe(t,r);return RTe(n,r),ITe(n),e?.idleTimeout&&e.idleTimeout>0&&xTe(n,e.idleTimeout),n},hyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},RTe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(wc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Ib).pipe(wc.stdout),t.stderr?.pipe(new Ib).pipe(wc.stderr);return}t.stdout?.pipe(wc.stdout),t.stderr?.pipe(wc.stderr)},Q6=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(wc.kill(-t.pid,e),Dg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Dg.error("Error killing process:",r),!1}},ATe=t=>Q6(t,"SIGKILL"),xTe=(t,e)=>{let r=null,n=()=>{Dg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Q6(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Dg.log(`Force killing idle process ${t.pid}`),ATe(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)},ITe=t=>{X6.add(t);let e=vTe();if(e){let r=e.onTimesUp(()=>{Dg.log(`Global timer expired, killing process ${t.pid}`),Q6(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Dg.log(`Force killing process ${t.pid} after timeout`),ATe(t))},5e3)});t.on("exit",()=>{X6.delete(t),r()}),t.on("error",()=>{X6.delete(t),r()})}};function na(t,e){if(!wc.env.NETLIFY_LOCAL_MODE)try{let i=pyt.resolve(bTe.name),s=Tc.dirname(i);for(;s!==Tc.dirname(s);){let o=Tc.dirname(s);if(Tc.basename(o)==="node_modules"){let a=Tc.join(o,".bin",e);if(oC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(wc.env.NODE_PATH){let i=Tc.join(wc.env.NODE_PATH,".bin",e);if(oC.existsSync(i))return i}let r=Tc.join(t,"node_modules",".bin",e);if(oC.existsSync(r))return r;let n=Tc.join(fyt,"..","node_modules",".bin",e);if(oC.existsSync(n))return n}import uL from"process";import{fileURLToPath as nCt}from"url";import{createRequire as iCt}from"module";import dL from"path";var myt="__netlify__getTracer",gyt="__netlify__shutdownTracers",ft=(t,e)=>globalThis[myt]?.(t,e),PTe=async()=>globalThis[gyt]?.();function Uf(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as ZOt}from"timers/promises";import fEt from"process";var OTe=typeof globalThis=="object"?globalThis:global;var Rc="1.9.0";var CTe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function _yt(t){var e=new Set([t]),r=new Set,n=t.match(CTe);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(c){return c===t};function s(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(CTe);if(!l)return s(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||i.major!==u.major?s(c):i.major===0?i.minor===u.minor&&i.patch<=u.patch?o(c):s(c):i.minor<=u.minor?o(c):s(c)}}var NTe=_yt(Rc);var yyt=Rc.split(".")[0],Ob=Symbol.for("opentelemetry.js.api."+yyt),Cb=OTe;function Eu(t,e,r,n){var i;n===void 0&&(n=!1);var s=Cb[Ob]=(i=Cb[Ob])!==null&&i!==void 0?i:{version:Rc};if(!n&&s[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(s.version!==Rc){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+Rc);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Rc+"."),!0}function eo(t){var e,r,n=(e=Cb[Ob])===null||e===void 0?void 0:e.version;if(!(!n||!NTe(n)))return(r=Cb[Ob])===null||r===void 0?void 0:r[t]}function vu(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Rc+".");var r=Cb[Ob];r&&delete r[t]}var Syt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Eyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},kTe=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Nb("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Nb("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Nb("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Nb("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Nb("verbose",this._namespace,e)},t})();function Nb(t,e,r){var n=eo("diag");if(n)return r.unshift(e),n[t].apply(n,Eyt([],Syt(r),!1))}var Gn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(Gn||(Gn={}));function $Te(t,e){t<Gn.NONE?t=Gn.NONE:t>Gn.ALL&&(t=Gn.ALL),e=e||{};function r(n,i){var s=e[n];return typeof s=="function"&&t>=i?s.bind(e):function(){}}return{error:r("error",Gn.ERROR),warn:r("warn",Gn.WARN),info:r("info",Gn.INFO),debug:r("debug",Gn.DEBUG),verbose:r("verbose",Gn.VERBOSE)}}var vyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},byt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Tyt="diag",Li=(function(){function t(){function e(i){return function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];var a=eo("diag");if(a)return a[i].apply(a,byt([],vyt(s),!1))}}var r=this,n=function(i,s){var o,a,c;if(s===void 0&&(s={logLevel:Gn.INFO}),i===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof s=="number"&&(s={logLevel:s});var u=eo("diag"),d=$Te((a=s.logLevel)!==null&&a!==void 0?a:Gn.INFO,i);if(u&&!s.suppressOverrideMessage){var f=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return Eu("diag",d,r,!0)};r.setLogger=n,r.disable=function(){vu(Tyt,r)},r.createComponentLogger=function(i){return new kTe(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var wyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Ryt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},LTe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=wyt(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=new t(this._entries);try{for(var o=Ryt(n),a=o.next();!a.done;a=o.next()){var c=a.value;s._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return s},t.prototype.clear=function(){return new t},t})();var Jar=Li.instance();function DTe(t){return t===void 0&&(t={}),new LTe(new Map(Object.entries(t)))}function aC(t){return Symbol.for(t)}var Ayt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var s=new t(r._currentContext);return s._currentContext.set(n,i),s},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t})(),MTe=new Ayt;var UTe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},FTe={set:function(t,e,r){t!=null&&(t[e]=r)}};var xyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Iyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},jTe=(function(){function t(){}return t.prototype.active=function(){return MTe},t.prototype.with=function(e,r,n){for(var i=[],s=3;s<arguments.length;s++)i[s-3]=arguments[s];return r.call.apply(r,Iyt([n],xyt(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var Pyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Oyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},e3="context",Cyt=new jTe,bu=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Eu(e3,e,Li.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Oyt([e,r,n],Pyt(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return eo(e3)||Cyt},t.prototype.disable=function(){this._getContextManager().disable(),vu(e3,Li.instance())},t})();var cC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(cC||(cC={}));var t3="0000000000000000",r3="00000000000000000000000000000000",qTe={traceId:r3,spanId:t3,traceFlags:cC.NONE};var Tu=(function(){function t(e){e===void 0&&(e=qTe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var n3=aC("OpenTelemetry Context Key SPAN");function lC(t){return t.getValue(n3)||void 0}function BTe(){return lC(bu.getInstance().active())}function kb(t,e){return t.setValue(n3,e)}function zTe(t){return t.deleteValue(n3)}function VTe(t,e){return kb(t,new Tu(e))}function uC(t){var e;return(e=lC(t))===null||e===void 0?void 0:e.spanContext()}var Nyt=/^([0-9a-f]{32})$/i,kyt=/^[0-9a-f]{16}$/i;function $yt(t){return Nyt.test(t)&&t!==r3}function Lyt(t){return kyt.test(t)&&t!==t3}function dC(t){return $yt(t.traceId)&&Lyt(t.spanId)}function HTe(t){return new Tu(t)}var i3=bu.getInstance(),fC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=i3.active());var i=!!r?.root;if(i)return new Tu;var s=n&&uC(n);return Dyt(s)&&dC(s)?new Tu(s):new Tu},t.prototype.startActiveSpan=function(e,r,n,i){var s,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(s=r,a=n):(s=r,o=n,a=i);var c=o??i3.active(),l=this.startSpan(e,s,c),u=kb(c,l);return i3.with(u,a,void 0,l)}},t})();function Dyt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var Myt=new fC,GTe=(function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,i){var s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Myt},t})();var WTe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new fC},t})();var Uyt=new WTe,s3=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new GTe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Uyt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)},t})();var wu;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(wu||(wu={}));var ia;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(ia||(ia={}));var Ac=bu.getInstance();var o3=Li.instance();var YTe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var a3=aC("OpenTelemetry Baggage Key");function c3(t){return t.getValue(a3)||void 0}function KTe(){return c3(bu.getInstance().active())}function JTe(t,e){return t.setValue(a3,e)}function ZTe(t){return t.deleteValue(a3)}var l3="propagation",Fyt=new YTe,XTe=(function(){function t(){this.createBaggage=DTe,this.getBaggage=c3,this.getActiveBaggage=KTe,this.setBaggage=JTe,this.deleteBaggage=ZTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Eu(l3,e,Li.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=FTe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=UTe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){vu(l3,Li.instance())},t.prototype._getGlobalPropagator=function(){return eo(l3)||Fyt},t})();var $b=XTe.getInstance();var u3="trace",QTe=(function(){function t(){this._proxyTracerProvider=new s3,this.wrapSpanContext=HTe,this.isSpanContextValid=dC,this.deleteSpan=zTe,this.getSpan=lC,this.getActiveSpan=BTe,this.getSpanContext=uC,this.setSpan=kb,this.setSpanContext=VTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Eu(u3,this._proxyTracerProvider,Li.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return eo(u3)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){vu(u3,Li.instance()),this._proxyTracerProvider=new s3},t})();var Lb=QTe.getInstance();var qyt=function(t,e){e.recordException(t),e.setStatus({code:ia.ERROR})};var Ff=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,i){var s=ewe(r,n,i),o=s.opts,a=s.ctx,c=s.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return twe(l,o,c)})},t.prototype.withSpan=function(e,r,n,i){var s=ewe(r,n,i),o=s.opts,a=s.ctx,c=s.fn,l=this._tracer.startSpan(e,o,a);return twe(l,o,c)},t})();function ewe(t,e,r){var n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Ac.active(),{opts:n,ctx:i,fn:s}}function twe(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:qyt,s=function(a){throw i(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},s):(t.end(),o)}catch(a){throw s(a)}}aW();Qe();var oT=class{emit(e){}enabled(){return!1}},hRe=new oT;var aT=Symbol.for("io.opentelemetry.js.api.logs"),Gg=globalThis;function mRe(t,e,r){return n=>n===t?e:r}var cW=1;var lW=class{getLogger(e,r,n){return new oT}},nN=new lW;var iN=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):hRe}};var cT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new iN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:nN}_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 sN=class t{constructor(){this._proxyLoggerProvider=new cT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Gg[aT]?this.getLoggerProvider():(Gg[aT]=mRe(cW,e,nN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Gg[aT])===null||e===void 0?void 0:e.call(Gg,cW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Gg[aT],this._proxyLoggerProvider=new cT}};var gRe=sN.getInstance();function _Re(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 yRe(t){t.forEach(e=>e.disable())}function uW(t){let e=t.tracerProvider||Ir.getTracerProvider(),r=t.meterProvider||Gb.getMeterProvider(),n=t.loggerProvider||gRe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return _Re(i,e,r,n),()=>{yRe(i)}}cr();var xN=$n(AW(),1);cr();var ZRe=t=>{throw TypeError(t)},OW=(t,e,r)=>e.has(t)||ZRe("Cannot "+r),AN=(t,e,r)=>(OW(t,e,"read from private field"),r?r.call(t):e.get(t)),xW=(t,e,r)=>e.has(t)?ZRe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),YRe=(t,e,r,n)=>(OW(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),dEt=(t,e,r)=>(OW(t,e,"access private method"),r),KRe="__netlify__getTracer",pEt="__netlify__shutdownTracers",hEt="__nfOTLPTrace",uT,dT,PW,XRe,mEt=class{constructor(){xW(this,PW),xW(this,uT),xW(this,dT),YRe(this,uT,new da(dEt(this,PW,XRe),this)),YRe(this,dT,o3.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(AN(this,dT).debug(`export ${t.length.toString()} spans`),AN(this,uT).isCalled){e({code:Wt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(hEt,JSON.stringify(gEt(t))),e({code:Wt.SUCCESS})}shutdown(){return AN(this,uT).call()}};uT=new WeakMap;dT=new WeakMap;PW=new WeakSet;XRe=function(){return AN(this,dT).debug("Shutting down"),Promise.resolve()};function gEt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:RN(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||wu.SERVER,startTimeUnixNano:IW(e.startTime),endTimeUnixNano:IW(e.endTime),attributes:RN(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:IW(n.time),attributes:RN(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:RN(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function RN(t){return Object.keys(t).map(e=>QRe(e,t[e]))}function QRe(t,e){return{key:t,value:eAe(e)}}function eAe(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(eAe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>QRe(r,n))}}:{}}function IW(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var JRe={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},tAe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,KRe))return;let e=fEt.version.slice(1),r=rN({"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??[_Et()],i=new xN.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Cc});let s=t.instrumentations??[];uW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,KRe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Ff(Lb.getTracer(a,c)):new Ff(Lb.getTracer(JRe.name,JRe.version))}}),Object.defineProperty(globalThis,pEt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},_Et=()=>new xN.SimpleSpanProcessor(new mEt);cr();var fT=$n(AW(),1);import*as IN from"diagnostics_channel";var rAe=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?ia.ERROR:ia.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Ff?t:new Ff(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){IN.subscribe(t,e);let r=()=>IN.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:wu.CLIENT},Ac.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:ia.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 hke=$n(fke(),1);var cL=be("tracing"),pke=8e3,XOt=5e3,Rw=async(t=XOt)=>{try{await Promise.race([PTe(),ZOt(t)])}catch(e){cL.warn("Failed to flush tracers on shutdown",e)}},mke=async(t,e,r)=>{if(!ft()){let n=[new fT.SimpleSpanProcessor(new h9),new fT.SimpleSpanProcessor(new hke.OTLPTraceExporter({url:r.exporterUrl}))];await tAe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new rAe({skipHeaders:!0})]})}return r.traceparent?($b.setGlobalPropagator(new Cc),$b.extract(Ac.active(),{traceparent:r.traceparent,isRemote:!0})):Ac.active()};function Ft(t,e,r){return cL.log(`\u23F3 TRACE: ${e} starting...`),Uf(t,e,r)}var h9=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(", ")}]`:"";cL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&cL.log(` \u274C Error: ${e.status.message}`)}};function m9(){return lt().captureLlmContentEnabled}function gke(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function lL(t,e,r){let n={role:t,parts:[{type:"text",content:vs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function _ke(t,e,r,n){if(!t.length)return;let i=ft();if(!i)return;let s=m9(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.title||a.type||`step-${a.id??c}`,f=a.type==="tool_use"||a.type==="tool_result",p=a.message?a.message.length>pke?`${a.message.slice(0,pke)}\u2026`:a.message:void 0;i.startSpan(d,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":d,"gen_ai.operation.name":f?"execute_tool":"chat",...f?{"gen_ai.tool.name":d}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&p?f?{"gen_ai.tool.call.result":vs(p)}:{"gen_ai.output.messages":lL("assistant",p)}:{}}}).end(u)})}import{readdir as QOt,rm as eCt}from"fs/promises";import{join as tCt}from"path";async function yke(t,e=[]){let n=(await QOt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>eCt(tCt(t,i),{recursive:!0,force:!0})))}var rCt=700,Ske=t=>t.mode==="create"&&(t.accountType===El||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=rCt);var sCt=dL.dirname(nCt(import.meta.url)),Eke=iCt(import.meta.url),oCt=dL.resolve(sCt,"scripts/scaffold.js"),aCt="scripts/scaffold.js",cCt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,g9=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},lCt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),uCt=t=>{let e=g9(t);return e==="node"||e.endsWith("/node")},Xc=t=>{if(typeof t!="string")return!1;let e=t.match(cCt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&lCt(g9(e[r]));)r+=1;if(r>=e.length||!uCt(e[r]))return!1;let n=e[r+1];return n?g9(n).includes(aCt):!1},z_=be("create_stage"),vke="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.",dCt=`${vke}
|
|
581
|
+
if (condition) { yield value; }`)};import{Buffer as Emt}from"buffer";import{StringDecoder as vmt}from"string_decoder";var VO=(t,e,r)=>{if(r)return;if(t)return{transform:bmt.bind(void 0,new TextEncoder)};let n=new vmt(e);return{transform:Tmt.bind(void 0,n),final:wmt.bind(void 0,n)}},bmt=function*(t,e){Emt.isBuffer(e)?yield yc(e):typeof e=="string"?yield t.encode(e):yield e},Tmt=function*(t,e){yield xr(e)?t.write(e):e},wmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as zve}from"util";var m6=zve(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),HO=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Amt}=e[r];for await(let i of n(t))yield*HO(i,e,r+1)},Vve=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Rmt(r,Number(e),t)},Rmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*HO(n,r,e+1)},Hve=zve(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Amt=function*(t){yield t};var g6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Gve=(t,e)=>[...e.flatMap(r=>[...Lf(r,t,0)]),...bb(t)],Lf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Imt}=e[r];for(let i of n(t))yield*Lf(i,e,r+1)},bb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*xmt(r,Number(e),t)},xmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Lf(n,r,e+1)},Imt=function*(t){yield t};var _6=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Yve(t,o,s),l=$f(e),u=$f(r),d=l?m6.bind(void 0,HO,a):g6.bind(void 0,Lf),f=l||u?m6.bind(void 0,Vve,a):g6.bind(void 0,bb),p=l||u?Hve.bind(void 0,a):void 0;return{stream:new Pmt({writableObjectMode:n,writableHighWaterMark:Wve(n),readableObjectMode:i,readableHighWaterMark:Wve(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},GO=(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=Yve(o,r,a);t=Gve(c,t)}return t},Yve=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:jve(n,a)},VO(r,o,n),zO(r,s,n,c),{transform:t,final:e},{transform:qve(i,a)},Fve({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Kve=(t,e)=>{for(let r of Omt(t))Cmt(t,r,e)},Omt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Cmt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${yu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Nmt(a,n));r.input=fb(o)},Nmt=(t,e)=>{let r=GO(t,e,"utf8",!0);return kmt(r),fb(r)},kmt=t=>{let e=t.find(r=>typeof r!="string"&&!xr(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 Mmt,appendFileSync as Umt}from"fs";var WO=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&bg(r,n)&&!$i.has(e)&&$mt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Lmt.has(s))||t.every(({type:i})=>Es.has(i))),$mt=t=>t===1||t===2,Lmt=new Set(["pipe","overlapped"]),Jve=async(t,e,r,n)=>{for await(let i of t)Dmt(e)||Xve(i,r,n)},Zve=(t,e,r)=>{for(let n of t)Xve(n,e,r)},Dmt=t=>t._readableState.pipes.length>0,Xve=(t,e,r)=>{let n=aO(t);Xo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Qve=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>Fmt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Fmt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=eve(t,s,d),p=yc(f),{stdioItems:h,objectMode:m}=e[r],_=jmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=qmt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Bmt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&zmt(y,h,i),S}catch(g){return n.error=g,S}},jmt=(t,e,r,n)=>{try{return GO(t,e,r,!1)}catch(i){return n.error=i,t}},qmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:fb(t)};let o=hye(t,r);return n[s]?{serializedResult:o,finalResult:h6(o,!i[s],e)}:{serializedResult:o}},Bmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!WO({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=h6(t,!1,o);try{Zve(a,e,n)}catch(c){r.error??=c}},zmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>qO.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?Umt(n,t):(r.add(s),Mmt(n,t))}};var ebe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,vc(e,r,"all")]:Array.isArray(e)?[vc(t,r,"all"),...e]:xr(t)&&xr(e)?TG([t,e]):`${t}${e}`};import{once as y6}from"events";var tbe=async(t,e)=>{let[r,n]=await Vmt(t);return e.isForcefullyTerminated??=!1,[r,n]},Vmt=async t=>{let[e,r]=await Promise.allSettled([y6(t,"spawn"),y6(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?rbe(t):r.value},rbe=async t=>{try{return await y6(t,"exit")}catch{return rbe(t)}},nbe=async t=>{let[e,r]=await t;if(!Hmt(e,r)&&S6(e,r))throw new Zs;return[e,r]},Hmt=(t,e)=>t===void 0&&e===void 0,S6=(t,e)=>t!==0||e!==null;var ibe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Gmt(t,e,r),o=s?.code==="ETIMEDOUT",a=QEe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Gmt=(t,e,r)=>t!==void 0?t:S6(e,r)?new Zs:void 0;var sbe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Ymt(t,e,r),d=Zmt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ng(d,c,l)},Ymt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=lO(t,e,r),a=Kmt(r),{file:c,commandArguments:l,options:u}=PO(t,e,a);Jmt(u);let d=Lve(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Kmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Jmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&YO("ipcInput"),t&&YO("ipc: true"),r&&YO("detached: true"),n&&YO("cancelSignal")},YO=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Zmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Xmt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=ibe(c,r),{output:h,error:m=l}=Qve({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>vc(v,r,S)),y=vc(ebe(h,r),r,"all");return egt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Xmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Kve(s,r);let a=Qmt(r);return Wmt(...OO(t,e,a))}catch(a){return Cg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Qmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:MO(e)}),egt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?UO({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):vb({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as q_t}from"events";import{spawn as B_t}from"child_process";import ube from"process";import{once as E6,on as tgt}from"events";var obe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Rg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:TO(t)}),rgt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),rgt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{SO(e,i);let s=_u(t,e,r),o=new AbortController;try{return await Promise.race([ngt(s,n,o),igt(s,r,o),sgt(s,r,o)])}catch(a){throw Ag(t),a}finally{o.abort(),EO(e,i)}},ngt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await E6(t,"message",{signal:r});return n}for await(let[n]of tgt(t,"message",{signal:r}))if(e(n))return n},igt=async(t,e,{signal:r})=>{await E6(t,"disconnect",{signal:r}),GSe(e)},sgt=async(t,e,{signal:r})=>{let[n]=await E6(t,"strict:error",{signal:r});throw gO(n,e)};import{once as cbe,on as ogt}from"events";var lbe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>v6({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),v6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Rg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:TO(t)}),SO(e,s);let o=_u(t,e,r),a=new AbortController,c={};return agt(t,o,a),cgt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),lgt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},agt=async(t,e,r)=>{try{await cbe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},cgt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await cbe(t,"strict:error",{signal:r.signal});n.error=gO(i,e),r.abort()}catch{}},lgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of ogt(r,"message",{signal:s.signal}))abe(o),yield c}catch{abe(o)}finally{s.abort(),EO(e,a),n||Ag(t),i&&await t}},abe=({error:t})=>{if(t)throw t};var dbe=(t,{ipc:e})=>{Object.assign(t,pbe(t,!1,e))},fbe=()=>{let t=ube,e=!0,r=ube.channel!==void 0;return{...pbe(t,e,r),getCancelSignal:SEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},pbe=(t,e,r)=>({sendMessage:xO.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:obe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:lbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as ugt}from"child_process";import{PassThrough as dgt,Readable as fgt,Writable as pgt,Duplex as hgt}from"stream";var hbe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{d6(n);let a=new ugt;mgt(a,n),Object.assign(a,{readable:ggt,writable:_gt,duplex:ygt});let c=Cg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Sgt(c,o,i);return{subprocess:a,promise:l}},mgt=(t,e)=>{let r=Tb(),n=Tb(),i=Tb(),s=Array.from({length:e.length-3},Tb),o=Tb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Tb=()=>{let t=new dgt;return t.end(),t},ggt=()=>new fgt({read(){}}),_gt=()=>new pgt({write(){}}),ygt=()=>new hgt({read(){},write(){}}),Sgt=async(t,e,r)=>Ng(t,e,r);import{createReadStream as mbe,createWriteStream as gbe}from"fs";import{Buffer as Egt}from"buffer";import{Readable as wb,Writable as vgt,Duplex as bgt}from"stream";var ybe=(t,e)=>BO(Tgt,t,e,!1),Rb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${yu[t]}.`)},_be={fileNumber:Rb,generator:_6,asyncGenerator:_6,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:bgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Tgt={input:{..._be,fileUrl:({value:t})=>({stream:mbe(t)}),filePath:({value:{file:t}})=>({stream:mbe(t)}),webStream:({value:t})=>({stream:wb.fromWeb(t)}),iterable:({value:t})=>({stream:wb.from(t)}),asyncIterable:({value:t})=>({stream:wb.from(t)}),string:({value:t})=>({stream:wb.from(t)}),uint8Array:({value:t})=>({stream:wb.from(Egt.from(t))})},output:{..._be,fileUrl:({value:t})=>({stream:gbe(t)}),filePath:({value:{file:t,append:e}})=>({stream:gbe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:vgt.fromWeb(t)}),iterable:Rb,asyncIterable:Rb,string:Rb,uint8Array:Rb}};import{on as wgt,once as Sbe}from"events";import{PassThrough as Rgt,getDefaultHighWaterMark as Agt}from"stream";import{finished as bbe}from"stream/promises";function Df(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)T6(i);let e=t.some(({readableObjectMode:i})=>i),r=xgt(t,e),n=new b6({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var xgt=(t,e)=>{if(t.length===0)return Agt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},b6=class extends Rgt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(T6(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Igt(this,this.#e,this.#s);let r=Cgt({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(T6(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)}},Igt=async(t,e,r)=>{KO(t,Ebe);let n=new AbortController;try{await Promise.race([Pgt(t,n),Ogt(t,e,r,n)])}finally{n.abort(),KO(t,-Ebe)}},Pgt=async(t,{signal:e})=>{try{await bbe(t,{signal:e,cleanup:!0})}catch(r){throw Tbe(t,r),r}},Ogt=async(t,e,r,{signal:n})=>{for await(let[i]of wgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},T6=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Cgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{KO(t,vbe);let a=new AbortController;try{await Promise.race([Ngt(s,e,a),kgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),$gt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),KO(t,-vbe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?w6(t):Lgt(t))},Ngt=async(t,e,{signal:r})=>{try{await t,r.aborted||w6(e)}catch(n){r.aborted||Tbe(e,n)}},kgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await bbe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;wbe(o)?i.add(e):Rbe(t,o)}},$gt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Sbe(t,i,{signal:s}),!t.readable)return Sbe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Lgt=t=>{t.writable&&t.end()},Tbe=(t,e)=>{wbe(e)?w6(t):Rbe(t,e)},wbe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",w6=t=>{(t.readable||t.writable)&&t.destroy()},Rbe=(t,e)=>{t.destroyed||(t.once("error",Dgt),t.destroy(e))},Dgt=()=>{},KO=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Ebe=2,vbe=1;import{finished as Abe}from"stream/promises";var $g=(t,e)=>{t.pipe(e),Mgt(t,e),Ugt(t,e)},Mgt=async(t,e)=>{if(!(Js(t)||Js(e))){try{await Abe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}R6(e)}},R6=t=>{t.writable&&t.end()},Ugt=async(t,e)=>{if(!(Js(t)||Js(e))){try{await Abe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}A6(t)}},A6=t=>{t.readable&&t.destroy()};var xbe=(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})=>Es.has(c)))Fgt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Es.has(c)))qgt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Df(s);$g(o,i)}},Fgt=(t,e,r,n)=>{r==="output"?$g(t.stdio[n],e):$g(e,t.stdio[n]);let i=jgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},jgt=["stdin","stdout","stderr"],qgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;Bgt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},Bgt=(t,{signal:e})=>{Js(t)&&Nf(t,zgt,e)},zgt=2;import{addAbortListener as Ggt}from"events";var Mf=[];Mf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Mf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Mf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var JO=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",x6=Symbol.for("signal-exit emitter"),I6=globalThis,Vgt=Object.defineProperty.bind(Object),P6=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(I6[x6])return I6[x6];Vgt(I6,x6,{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}},ZO=class{},Hgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),O6=class extends ZO{onExit(){return()=>{}}load(){}unload(){}},C6=class extends ZO{#e=N6.platform==="win32"?"SIGINT":"SIGHUP";#r=new P6;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Mf)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!JO(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Mf)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Mf.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return JO(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"&&JO(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)}},N6=globalThis.process,{onExit:Ibe,load:cir,unload:lir}=Hgt(JO(N6)?new C6(N6):new O6);var Pbe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Ibe(()=>{t.kill()});Ggt(n,()=>{i()})};var Cbe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=cO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Wgt(r,n,i),{sourceStream:d,sourceError:f}=Kgt(t,l),{options:p,fileDescriptors:h}=ea.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},Wgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Ygt(t,e,...r),a=yO(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Ygt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Obe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||vG(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]=XP(r,...n);return{destination:e(Obe)(i,s,o),pipeOptions:o}}if(ea.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}`)},Obe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Kgt=(t,e)=>{try{return{sourceStream:xg(t,e)}}catch(r){return{sourceError:r}}};var kbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Jgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw k6({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Jgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return A6(t),n;if(e!==void 0)return R6(r),e},k6=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Cg({error:t,command:Nbe,escapedCommand:Nbe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Nbe="source.pipe(destination)";var $be=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 Zgt}from"stream/promises";var Lbe=(t,e,r)=>{let n=XO.has(e)?Qgt(t,e):Xgt(t,e);return Nf(t,t_t,r.signal),Nf(e,r_t,r.signal),e_t(e),n},Xgt=(t,e)=>{let r=Df([t]);return $g(r,e),XO.set(e,r),r},Qgt=(t,e)=>{let r=XO.get(e);return r.add(t),r},e_t=async t=>{try{await Zgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}XO.delete(t)},XO=new WeakMap,t_t=2,r_t=1;import{aborted as n_t}from"util";var Dbe=(t,e)=>t===void 0?[]:[i_t(t,e)],i_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await n_t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw k6({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var QO=(t,...e)=>{if(mr(e[0]))return QO.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Cbe(t,...e),i=s_t({...n,destination:r});return i.pipe=QO.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},s_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=o_t(t,i);kbe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Lbe(e,s,d);return await Promise.race([$be(u),...Dbe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},o_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as p_t}from"timers/promises";import{on as a_t}from"events";import{getDefaultHighWaterMark as c_t}from"stream";var eC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return l_t(e,o),Ube({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},l_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},$6=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;u_t(e,o,t);let a=t.readableObjectMode&&!s;return Ube({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},u_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Ube=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=a_t(t,"data",{signal:e.signal,highWaterMark:Mbe,highWatermark:Mbe});return d_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},L6=c_t(!0),Mbe=L6,d_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=f_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Lf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*bb(a)}},f_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[VO(t,r,!e),zO(t,i,!n,{})].filter(Boolean);var Fbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=h_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([m_t(t),d]);return}let f=f6(c,r),p=$6({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([g_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},h_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!WO({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=$6({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Jve(a,t,r,s)},m_t=async t=>{await p_t(),t.readableFlowing===null&&t.resume()},g_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await $O(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await LO(r,{maxBuffer:s})):await Og(r,{maxBuffer:s})}catch(a){return jbe(JEe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},D6=async t=>{try{return await t}catch(e){return jbe(e)}},jbe=({bufferedData:t})=>fye(t)?new Uint8Array(t):t;import{finished as __t}from"stream/promises";var Ab=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=y_t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],__t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||v_t(a,e,r,n)}finally{o.abort()}},y_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&S_t(t,r,n),n},S_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{E_t(e,r),n.call(t,...i)}},E_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},v_t=(t,e,r,n)=>{if(!b_t(t,e,r,n))throw t},b_t=(t,e,r,n=!0)=>r.propagating?qbe(t)||tC(t):(r.propagating=!0,M6(r,e)===n?qbe(t):tC(t)),M6=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",tC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",qbe=t=>t?.code==="EPIPE";var Bbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>U6({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),U6=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Ab(t,e,l);if(M6(l,e)){await u;return}let[d]=await Promise.all([Fbe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var zbe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Df([t,e].filter(Boolean)):void 0,Vbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>U6({...T_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:w_t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),T_t=({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}},w_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as R_t}from"events";var Hbe=t=>bg(t,"ipc"),Gbe=(t,e)=>{let r=aO(t);Xo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Wbe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Hbe(s),a=Sc(e,"ipc"),c=Sc(r,"ipc");for await(let l of v6({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ZEe(t,i,c),i.push(l)),o&&Gbe(l,s);return i},Ybe=async(t,e)=>(await Promise.allSettled([t]),e);var Kbe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=tbe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Bbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=Vbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),P=[],x=Wbe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),R=A_t(m,t,S),O=x_t(h,S);try{return await Promise.race([Promise.all([{},nbe(v),Promise.all(g),w,x,PEe(t,d),...R,...O]),_,I_t(t,y),...wEe(t,s,f,y),...HSe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...bEe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(A){return f.terminationReason??="other",Promise.all([{error:A},v,Promise.all(g.map(b=>D6(b))),D6(w),Ybe(x,P),Promise.allSettled(R),Promise.allSettled(O)])}},A_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Ab(n,i,r)),x_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Qs(s,{checkOpen:!1})&&!Js(s)).map(({type:i,value:s,stream:o=s})=>Ab(o,n,e,{isSameDirection:Es.has(i),stopOnExit:i==="native"}))),I_t=async(t,{signal:e})=>{let[r]=await R_t(t,"error",{signal:e});throw r};var Jbe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),xb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Qo();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Lg=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 P_t}from"stream";import{callbackify as O_t}from"util";import{finished as Zbe}from"stream/promises";var F6=async t=>{if(t!==void 0)try{await j6(t)}catch{}},Xbe=async t=>{if(t!==void 0)try{await q6(t)}catch{}},j6=async t=>{await Zbe(t,{cleanup:!0,readable:!1,writable:!0})},q6=async t=>{await Zbe(t,{cleanup:!0,readable:!0,writable:!1})},rC=async(t,e)=>{if(await t,e)throw e},nC=(t,e,r)=>{r&&!tC(r)?t.destroy(r):e&&t.destroy()};var Qbe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||$i.has(r),{subprocessStdout:a,waitReadableDestroy:c}=B6(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=z6(a,o),{read:f,onStdoutDataDone:p}=V6({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new P_t({read:f,destroy:O_t(G6.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return H6({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},B6=(t,e,r)=>{let n=xg(t,e),i=xb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},z6=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:L6},V6=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Qo(),o=eC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){C_t(this,o,s)},onStdoutDataDone:s}},C_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},H6=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await q6(t),await n,await F6(i),await e,r.readable&&r.push(null)}catch(s){await F6(i),eTe(r,s)}},G6=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Lg(r,e)&&(eTe(t,n),await rC(e,n))},eTe=(t,e)=>{nC(t,t.readable,e)};import{Writable as N_t}from"stream";import{callbackify as tTe}from"util";var rTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=W6(t,r,e),o=new N_t({...Y6(n,t,i),destroy:tTe(J6.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return K6(n,o),o},W6=(t,e,r)=>{let n=yO(t,e),i=xb(r,n,"writableFinal"),s=xb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},Y6=(t,e,r)=>({write:k_t.bind(void 0,t),final:tTe($_t.bind(void 0,t,e,r))}),k_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},$_t=async(t,e,r)=>{await Lg(r,e)&&(t.writable&&t.end(),await e)},K6=async(t,e,r)=>{try{await j6(t),e.writable&&e.end()}catch(n){await Xbe(r),nTe(e,n)}},J6=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Lg(r,e),await Lg(n,e)&&(nTe(t,i),await rC(e,i))},nTe=(t,e)=>{nC(t,t.writable,e)};import{Duplex as L_t}from"stream";import{callbackify as D_t}from"util";var iTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||$i.has(r),{subprocessStdout:c,waitReadableDestroy:l}=B6(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=W6(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=z6(c,a),{read:_,onStdoutDataDone:y}=V6({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new L_t({read:_,...Y6(u,t,d),destroy:D_t(M_t.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return H6({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),K6(u,v,c),v},M_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([G6({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),J6({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var Z6=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||$i.has(e),o=xg(t,r),a=eC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return U_t(a,o,t)},U_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var sTe=(t,{encoding:e})=>{let r=Jbe();t.readable=Qbe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=rTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=iTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Z6.bind(void 0,t,e),t[Symbol.asyncIterator]=Z6.bind(void 0,t,e,{})};var oTe=(t,e)=>{for(let[r,n]of j_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},F_t=(async()=>{})().constructor.prototype,j_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(F_t,t)]);var aTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=z_t(t,e,r),{subprocess:f,promise:p}=H_t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=QO.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),oTe(f,p),ea.set(f,{options:u,fileDescriptors:d}),f},z_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=lO(t,e,r),{file:a,commandArguments:c,options:l}=PO(t,e,r),u=V_t(l),d=ybe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},V_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}},H_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=B_t(...OO(t,e,r))}catch(h){return hbe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;q_t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];xbe(c,a,l),Pbe(c,r,l);let d={},f=Qo();c.kill=zSe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=zbe(c,r),sTe(c,r),dbe(c,r);let p=G_t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},G_t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await Kbe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,w)=>vc(g,e,w)),v=vc(m,e,"all"),S=W_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ng(S,n,e)},W_t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?vb({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ta,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):UO({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var iC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Y_t(n,t[n],i)]));return{...t,...r}},Y_t=(t,e,r)=>K_t.has(t)&&mr(e)&&mr(r)?{...e,...r}:r,K_t=new Set(["env",...xG]);var Su=(t,e,r,n)=>{let i=(o,a,c)=>Su(o,a,r,c),s=(...o)=>J_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},J_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(mr(s))return i(t,iC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=Z_t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?sbe(a,c,l):aTe(a,c,l,i)},Z_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=yye(e)?Sye(e,r):[e,...r],[o,a,c]=XP(...s),l=iC(iC(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var cTe=({file:t,commandArguments:e})=>uTe(t,e),lTe=({file:t,commandArguments:e})=>({...uTe(t,e),isSync:!0}),uTe=(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]=X_t(t);return{file:r,commandArguments:n}},X_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(Q_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Q_t=/ +/g;var dTe=(t,e,r)=>{t.sync=e(eyt,r),t.s=t.sync},fTe=({options:t})=>pTe(t),eyt=({options:t})=>({...pTe(t),isSync:!0}),pTe=t=>({options:{...tyt(t),...t}}),tyt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},hTe={preferLocal:!0};var mTe=Su(()=>({})),Qor=Su(()=>({isSync:!0})),gTe=Su(cTe),ear=Su(lTe),tar=Su(AEe),rar=Su(fTe,{},hTe,dTe),{sendMessage:nar,getOneMessage:iar,getEachMessage:sar,getCancelSignal:oar}=fbe();import{Transform as ryt}from"stream";var nyt=["NETLIFY_AI_GATEWAY_KEY"];function iyt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...nyt])]}function syt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function oyt(){let e=iyt().map(r=>process.env[r]).filter(r=>!(!r||syt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function vs(t){if(typeof t!="string")return t;let e=oyt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(ayt(n),"g");r=r.replace(i,"******")}),r}function ayt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ib=class extends ryt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=vs(i);n(null,s)}},sC=Symbol("maskedWrite");function _Te(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[sC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?vs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[sC]=!0,process.stdout.write=r}if(!process.stderr.write[sC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?vs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[sC]=!0,process.stderr.write=r}}}var yTe=!1,STe=()=>{yTe=!0},hi=()=>yTe;var Pb=null,ETe=t=>(Pb&&Pb.destroy(),Pb=new bc({totalAllowedTime:t}),Pb),vTe=()=>Pb;var bc=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&hi())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await JP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Pe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var bTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-test.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var dyt=lyt(import.meta.url),fyt=Tc.dirname(dyt),pyt=uyt(import.meta.url),Dg=be("shell"),X6=new Set,TTe={preferLocal:!0},Hn=(t,e,r)=>{let[n,i]=hyt(e,r),s={...TTe,...i},o=mTe(t,n,s);RTe(o,s),ITe(o);let a=r?.idleTimeout;return a&&a>0&&xTe(o,a),o},wTe=(t,e)=>{let r={...TTe,...e},n=gTe(t,r);return RTe(n,r),ITe(n),e?.idleTimeout&&e.idleTimeout>0&&xTe(n,e.idleTimeout),n},hyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},RTe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(wc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Ib).pipe(wc.stdout),t.stderr?.pipe(new Ib).pipe(wc.stderr);return}t.stdout?.pipe(wc.stdout),t.stderr?.pipe(wc.stderr)},Q6=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(wc.kill(-t.pid,e),Dg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Dg.error("Error killing process:",r),!1}},ATe=t=>Q6(t,"SIGKILL"),xTe=(t,e)=>{let r=null,n=()=>{Dg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Q6(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Dg.log(`Force killing idle process ${t.pid}`),ATe(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)},ITe=t=>{X6.add(t);let e=vTe();if(e){let r=e.onTimesUp(()=>{Dg.log(`Global timer expired, killing process ${t.pid}`),Q6(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Dg.log(`Force killing process ${t.pid} after timeout`),ATe(t))},5e3)});t.on("exit",()=>{X6.delete(t),r()}),t.on("error",()=>{X6.delete(t),r()})}};function na(t,e){if(!wc.env.NETLIFY_LOCAL_MODE)try{let i=pyt.resolve(bTe.name),s=Tc.dirname(i);for(;s!==Tc.dirname(s);){let o=Tc.dirname(s);if(Tc.basename(o)==="node_modules"){let a=Tc.join(o,".bin",e);if(oC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(wc.env.NODE_PATH){let i=Tc.join(wc.env.NODE_PATH,".bin",e);if(oC.existsSync(i))return i}let r=Tc.join(t,"node_modules",".bin",e);if(oC.existsSync(r))return r;let n=Tc.join(fyt,"..","node_modules",".bin",e);if(oC.existsSync(n))return n}import uL from"process";import{fileURLToPath as nCt}from"url";import{createRequire as iCt}from"module";import dL from"path";var myt="__netlify__getTracer",gyt="__netlify__shutdownTracers",ft=(t,e)=>globalThis[myt]?.(t,e),PTe=async()=>globalThis[gyt]?.();function Uf(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as ZOt}from"timers/promises";import fEt from"process";var OTe=typeof globalThis=="object"?globalThis:global;var Rc="1.9.0";var CTe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function _yt(t){var e=new Set([t]),r=new Set,n=t.match(CTe);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(c){return c===t};function s(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(CTe);if(!l)return s(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||i.major!==u.major?s(c):i.major===0?i.minor===u.minor&&i.patch<=u.patch?o(c):s(c):i.minor<=u.minor?o(c):s(c)}}var NTe=_yt(Rc);var yyt=Rc.split(".")[0],Ob=Symbol.for("opentelemetry.js.api."+yyt),Cb=OTe;function Eu(t,e,r,n){var i;n===void 0&&(n=!1);var s=Cb[Ob]=(i=Cb[Ob])!==null&&i!==void 0?i:{version:Rc};if(!n&&s[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(s.version!==Rc){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+Rc);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Rc+"."),!0}function eo(t){var e,r,n=(e=Cb[Ob])===null||e===void 0?void 0:e.version;if(!(!n||!NTe(n)))return(r=Cb[Ob])===null||r===void 0?void 0:r[t]}function vu(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Rc+".");var r=Cb[Ob];r&&delete r[t]}var Syt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Eyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},kTe=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Nb("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Nb("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Nb("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Nb("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Nb("verbose",this._namespace,e)},t})();function Nb(t,e,r){var n=eo("diag");if(n)return r.unshift(e),n[t].apply(n,Eyt([],Syt(r),!1))}var Gn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(Gn||(Gn={}));function $Te(t,e){t<Gn.NONE?t=Gn.NONE:t>Gn.ALL&&(t=Gn.ALL),e=e||{};function r(n,i){var s=e[n];return typeof s=="function"&&t>=i?s.bind(e):function(){}}return{error:r("error",Gn.ERROR),warn:r("warn",Gn.WARN),info:r("info",Gn.INFO),debug:r("debug",Gn.DEBUG),verbose:r("verbose",Gn.VERBOSE)}}var vyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},byt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Tyt="diag",Li=(function(){function t(){function e(i){return function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];var a=eo("diag");if(a)return a[i].apply(a,byt([],vyt(s),!1))}}var r=this,n=function(i,s){var o,a,c;if(s===void 0&&(s={logLevel:Gn.INFO}),i===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof s=="number"&&(s={logLevel:s});var u=eo("diag"),d=$Te((a=s.logLevel)!==null&&a!==void 0?a:Gn.INFO,i);if(u&&!s.suppressOverrideMessage){var f=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return Eu("diag",d,r,!0)};r.setLogger=n,r.disable=function(){vu(Tyt,r)},r.createComponentLogger=function(i){return new kTe(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var wyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Ryt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},LTe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=wyt(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=new t(this._entries);try{for(var o=Ryt(n),a=o.next();!a.done;a=o.next()){var c=a.value;s._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return s},t.prototype.clear=function(){return new t},t})();var Jar=Li.instance();function DTe(t){return t===void 0&&(t={}),new LTe(new Map(Object.entries(t)))}function aC(t){return Symbol.for(t)}var Ayt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var s=new t(r._currentContext);return s._currentContext.set(n,i),s},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t})(),MTe=new Ayt;var UTe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},FTe={set:function(t,e,r){t!=null&&(t[e]=r)}};var xyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Iyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},jTe=(function(){function t(){}return t.prototype.active=function(){return MTe},t.prototype.with=function(e,r,n){for(var i=[],s=3;s<arguments.length;s++)i[s-3]=arguments[s];return r.call.apply(r,Iyt([n],xyt(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var Pyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Oyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},e3="context",Cyt=new jTe,bu=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Eu(e3,e,Li.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Oyt([e,r,n],Pyt(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return eo(e3)||Cyt},t.prototype.disable=function(){this._getContextManager().disable(),vu(e3,Li.instance())},t})();var cC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(cC||(cC={}));var t3="0000000000000000",r3="00000000000000000000000000000000",qTe={traceId:r3,spanId:t3,traceFlags:cC.NONE};var Tu=(function(){function t(e){e===void 0&&(e=qTe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var n3=aC("OpenTelemetry Context Key SPAN");function lC(t){return t.getValue(n3)||void 0}function BTe(){return lC(bu.getInstance().active())}function kb(t,e){return t.setValue(n3,e)}function zTe(t){return t.deleteValue(n3)}function VTe(t,e){return kb(t,new Tu(e))}function uC(t){var e;return(e=lC(t))===null||e===void 0?void 0:e.spanContext()}var Nyt=/^([0-9a-f]{32})$/i,kyt=/^[0-9a-f]{16}$/i;function $yt(t){return Nyt.test(t)&&t!==r3}function Lyt(t){return kyt.test(t)&&t!==t3}function dC(t){return $yt(t.traceId)&&Lyt(t.spanId)}function HTe(t){return new Tu(t)}var i3=bu.getInstance(),fC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=i3.active());var i=!!r?.root;if(i)return new Tu;var s=n&&uC(n);return Dyt(s)&&dC(s)?new Tu(s):new Tu},t.prototype.startActiveSpan=function(e,r,n,i){var s,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(s=r,a=n):(s=r,o=n,a=i);var c=o??i3.active(),l=this.startSpan(e,s,c),u=kb(c,l);return i3.with(u,a,void 0,l)}},t})();function Dyt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var Myt=new fC,GTe=(function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,i){var s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Myt},t})();var WTe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new fC},t})();var Uyt=new WTe,s3=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new GTe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Uyt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)},t})();var wu;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(wu||(wu={}));var ia;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(ia||(ia={}));var Ac=bu.getInstance();var o3=Li.instance();var YTe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var a3=aC("OpenTelemetry Baggage Key");function c3(t){return t.getValue(a3)||void 0}function KTe(){return c3(bu.getInstance().active())}function JTe(t,e){return t.setValue(a3,e)}function ZTe(t){return t.deleteValue(a3)}var l3="propagation",Fyt=new YTe,XTe=(function(){function t(){this.createBaggage=DTe,this.getBaggage=c3,this.getActiveBaggage=KTe,this.setBaggage=JTe,this.deleteBaggage=ZTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Eu(l3,e,Li.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=FTe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=UTe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){vu(l3,Li.instance())},t.prototype._getGlobalPropagator=function(){return eo(l3)||Fyt},t})();var $b=XTe.getInstance();var u3="trace",QTe=(function(){function t(){this._proxyTracerProvider=new s3,this.wrapSpanContext=HTe,this.isSpanContextValid=dC,this.deleteSpan=zTe,this.getSpan=lC,this.getActiveSpan=BTe,this.getSpanContext=uC,this.setSpan=kb,this.setSpanContext=VTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Eu(u3,this._proxyTracerProvider,Li.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return eo(u3)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){vu(u3,Li.instance()),this._proxyTracerProvider=new s3},t})();var Lb=QTe.getInstance();var qyt=function(t,e){e.recordException(t),e.setStatus({code:ia.ERROR})};var Ff=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,i){var s=ewe(r,n,i),o=s.opts,a=s.ctx,c=s.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return twe(l,o,c)})},t.prototype.withSpan=function(e,r,n,i){var s=ewe(r,n,i),o=s.opts,a=s.ctx,c=s.fn,l=this._tracer.startSpan(e,o,a);return twe(l,o,c)},t})();function ewe(t,e,r){var n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Ac.active(),{opts:n,ctx:i,fn:s}}function twe(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:qyt,s=function(a){throw i(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},s):(t.end(),o)}catch(a){throw s(a)}}aW();Qe();var oT=class{emit(e){}enabled(){return!1}},hRe=new oT;var aT=Symbol.for("io.opentelemetry.js.api.logs"),Gg=globalThis;function mRe(t,e,r){return n=>n===t?e:r}var cW=1;var lW=class{getLogger(e,r,n){return new oT}},nN=new lW;var iN=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):hRe}};var cT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new iN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:nN}_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 sN=class t{constructor(){this._proxyLoggerProvider=new cT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Gg[aT]?this.getLoggerProvider():(Gg[aT]=mRe(cW,e,nN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Gg[aT])===null||e===void 0?void 0:e.call(Gg,cW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Gg[aT],this._proxyLoggerProvider=new cT}};var gRe=sN.getInstance();function _Re(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 yRe(t){t.forEach(e=>e.disable())}function uW(t){let e=t.tracerProvider||Ir.getTracerProvider(),r=t.meterProvider||Gb.getMeterProvider(),n=t.loggerProvider||gRe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return _Re(i,e,r,n),()=>{yRe(i)}}cr();var xN=$n(AW(),1);cr();var ZRe=t=>{throw TypeError(t)},OW=(t,e,r)=>e.has(t)||ZRe("Cannot "+r),AN=(t,e,r)=>(OW(t,e,"read from private field"),r?r.call(t):e.get(t)),xW=(t,e,r)=>e.has(t)?ZRe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),YRe=(t,e,r,n)=>(OW(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),dEt=(t,e,r)=>(OW(t,e,"access private method"),r),KRe="__netlify__getTracer",pEt="__netlify__shutdownTracers",hEt="__nfOTLPTrace",uT,dT,PW,XRe,mEt=class{constructor(){xW(this,PW),xW(this,uT),xW(this,dT),YRe(this,uT,new da(dEt(this,PW,XRe),this)),YRe(this,dT,o3.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(AN(this,dT).debug(`export ${t.length.toString()} spans`),AN(this,uT).isCalled){e({code:Wt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(hEt,JSON.stringify(gEt(t))),e({code:Wt.SUCCESS})}shutdown(){return AN(this,uT).call()}};uT=new WeakMap;dT=new WeakMap;PW=new WeakSet;XRe=function(){return AN(this,dT).debug("Shutting down"),Promise.resolve()};function gEt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:RN(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||wu.SERVER,startTimeUnixNano:IW(e.startTime),endTimeUnixNano:IW(e.endTime),attributes:RN(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:IW(n.time),attributes:RN(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:RN(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function RN(t){return Object.keys(t).map(e=>QRe(e,t[e]))}function QRe(t,e){return{key:t,value:eAe(e)}}function eAe(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(eAe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>QRe(r,n))}}:{}}function IW(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var JRe={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},tAe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,KRe))return;let e=fEt.version.slice(1),r=rN({"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??[_Et()],i=new xN.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Cc});let s=t.instrumentations??[];uW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,KRe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Ff(Lb.getTracer(a,c)):new Ff(Lb.getTracer(JRe.name,JRe.version))}}),Object.defineProperty(globalThis,pEt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},_Et=()=>new xN.SimpleSpanProcessor(new mEt);cr();var fT=$n(AW(),1);import*as IN from"diagnostics_channel";var rAe=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?ia.ERROR:ia.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Ff?t:new Ff(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){IN.subscribe(t,e);let r=()=>IN.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:wu.CLIENT},Ac.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:ia.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 hke=$n(fke(),1);var cL=be("tracing"),pke=8e3,XOt=5e3,Rw=async(t=XOt)=>{try{await Promise.race([PTe(),ZOt(t)])}catch(e){cL.warn("Failed to flush tracers on shutdown",e)}},mke=async(t,e,r)=>{if(!ft()){let n=[new fT.SimpleSpanProcessor(new h9),new fT.SimpleSpanProcessor(new hke.OTLPTraceExporter({url:r.exporterUrl}))];await tAe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new rAe({skipHeaders:!0})]})}return r.traceparent?($b.setGlobalPropagator(new Cc),$b.extract(Ac.active(),{traceparent:r.traceparent,isRemote:!0})):Ac.active()};function Ft(t,e,r){return cL.log(`\u23F3 TRACE: ${e} starting...`),Uf(t,e,r)}var h9=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(", ")}]`:"";cL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&cL.log(` \u274C Error: ${e.status.message}`)}};function m9(){return lt().captureLlmContentEnabled}function gke(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function lL(t,e,r){let n={role:t,parts:[{type:"text",content:vs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function _ke(t,e,r,n){if(!t.length)return;let i=ft();if(!i)return;let s=m9(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.title||a.type||`step-${a.id??c}`,f=a.type==="tool_use"||a.type==="tool_result",p=a.message?a.message.length>pke?`${a.message.slice(0,pke)}\u2026`:a.message:void 0;i.startSpan(d,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":d,"gen_ai.operation.name":f?"execute_tool":"chat",...f?{"gen_ai.tool.name":d}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&p?f?{"gen_ai.tool.call.result":vs(p)}:{"gen_ai.output.messages":lL("assistant",p)}:{}}}).end(u)})}import{readdir as QOt,rm as eCt}from"fs/promises";import{join as tCt}from"path";async function yke(t,e=[]){let n=(await QOt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>eCt(tCt(t,i),{recursive:!0,force:!0})))}var rCt=700,Ske=t=>t.mode==="create"&&(t.accountType===El||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=rCt);var sCt=dL.dirname(nCt(import.meta.url)),Eke=iCt(import.meta.url),oCt=dL.resolve(sCt,"scripts/scaffold.js"),aCt="scripts/scaffold.js",cCt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,g9=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},lCt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),uCt=t=>{let e=g9(t);return e==="node"||e.endsWith("/node")},Xc=t=>{if(typeof t!="string")return!1;let e=t.match(cCt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&lCt(g9(e[r]));)r+=1;if(r>=e.length||!uCt(e[r]))return!1;let n=e[r+1];return n?g9(n).includes(aCt):!1},z_=be("create_stage"),vke="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.",dCt=`${vke}
|
|
582
582
|
|
|
583
583
|
Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,fCt=`${vke}
|
|
584
584
|
|
package/dist/index.js
CHANGED
|
@@ -98,7 +98,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
98
98
|
`,LF:`
|
|
99
99
|
`,concatBytes:_D},nNe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},iNe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:nNe};import{Buffer as oNe}from"buffer";var FQ=(t,e)=>t?void 0:sNe.bind(void 0,e),sNe=function*(t,e){if(typeof e!="string"&&!Ut(e)&&!oNe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},BQ=(t,e)=>t?aNe.bind(void 0,e):cNe.bind(void 0,e),aNe=function*(t,e){jQ(t,e),yield e},cNe=function*(t,e){if(jQ(t,e),typeof e!="string"&&!Ut(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},jQ=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
100
100
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
101
|
-
if (condition) { yield value; }`)};import{Buffer as lNe}from"buffer";import{StringDecoder as uNe}from"string_decoder";var _x=(t,e,r)=>{if(r)return;if(t)return{transform:dNe.bind(void 0,new TextEncoder)};let n=new uNe(e);return{transform:fNe.bind(void 0,n),final:pNe.bind(void 0,n)}},dNe=function*(t,e){lNe.isBuffer(e)?yield cs(e):typeof e=="string"?yield t.encode(e):yield e},fNe=function*(t,e){yield Ut(e)?t.write(e):e},pNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as zQ}from"util";var SD=zQ(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),yx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=mNe}=e[r];for await(let i of n(t))yield*yx(i,e,r+1)},GQ=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*hNe(r,Number(e),t)},hNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*yx(n,r,e+1)},VQ=zQ(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),mNe=function*(t){yield t};var ED=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},qQ=(t,e)=>[...e.flatMap(r=>[...El(r,t,0)]),...Xg(t)],El=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_Ne}=e[r];for(let i of n(t))yield*El(i,e,r+1)},Xg=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*gNe(r,Number(e),t)},gNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*El(n,r,e+1)},_Ne=function*(t){yield t};var vD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=WQ(t,s,o),l=Sl(e),u=Sl(r),d=l?SD.bind(void 0,yx,a):ED.bind(void 0,El),f=l||u?SD.bind(void 0,GQ,a):ED.bind(void 0,Xg),p=l||u?VQ.bind(void 0,a):void 0;return{stream:new yNe({writableObjectMode:n,writableHighWaterMark:HQ(n),readableObjectMode:i,readableHighWaterMark:HQ(i),transform(m,y,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Sx=(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=WQ(s,r,a);t=qQ(c,t)}return t},WQ=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:FQ(n,a)},_x(r,s,n),gx(r,o,n,c),{transform:t,final:e},{transform:BQ(i,a)},UQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var YQ=(t,e)=>{for(let r of SNe(t))ENe(t,r,e)},SNe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),ENe=(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 ${Aa[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>vNe(a,n));r.input=zg(s)},vNe=(t,e)=>{let r=Sx(t,e,"utf8",!0);return bNe(r),zg(r)},bNe=t=>{let e=t.find(r=>typeof r!="string"&&!Ut(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 ANe,appendFileSync as RNe}from"fs";var Ex=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ld(r,n)&&!fn.has(e)&&TNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&xNe.has(o))||t.every(({type:i})=>zn.has(i))),TNe=t=>t===1||t===2,xNe=new Set(["pipe","overlapped"]),KQ=async(t,e,r,n)=>{for await(let i of t)wNe(e)||JQ(i,r,n)},ZQ=(t,e,r)=>{for(let n of t)JQ(n,e,r)},wNe=t=>t._readableState.pipes.length>0,JQ=(t,e,r)=>{let n=MT(t);oo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var XQ=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>INe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},INe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=QX(t,o,d),p=cs(f),{stdioItems:h,objectMode:m}=e[r],y=CNe([p],h,c,n),{serializedResult:E,finalResult:b=E}=PNe({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});ONe({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?b:void 0;try{return n.error===void 0&&NNe(E,h,i),w}catch(v){return n.error=v,w}},CNe=(t,e,r,n)=>{try{return Sx(t,e,r,!1)}catch(i){return n.error=i,t}},PNe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:zg(t)};let s=p9(t,r);return n[o]?{serializedResult:s,finalResult:yD(s,!i[o],e)}:{serializedResult:s}},ONe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Ex({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=yD(t,!1,s);try{ZQ(a,e,n)}catch(c){r.error??=c}},NNe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>hx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?RNe(n,t):(r.add(o),ANe(n,t))}};var QQ=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ds(e,r,"all")]:Array.isArray(e)?[ds(t,r,"all"),...e]:Ut(t)&&Ut(e)?RM([t,e]):`${t}${e}`};import{once as bD}from"events";var e7=async(t,e)=>{let[r,n]=await kNe(t);return e.isForcefullyTerminated??=!1,[r,n]},kNe=async t=>{let[e,r]=await Promise.allSettled([bD(t,"spawn"),bD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?t7(t):r.value},t7=async t=>{try{return await bD(t,"exit")}catch{return t7(t)}},r7=async t=>{let[e,r]=await t;if(!MNe(e,r)&&TD(e,r))throw new vi;return[e,r]},MNe=(t,e)=>t===void 0&&e===void 0,TD=(t,e)=>t!==0||e!==null;var n7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=DNe(t,e,r),s=o?.code==="ETIMEDOUT",a=XX(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},DNe=(t,e,r)=>t!==void 0?t:TD(e,r)?new vi:void 0;var i7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=$Ne(t,e,r),d=BNe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Hd(d,c,l)},$Ne=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=LT(t,e,r),a=UNe(r),{file:c,commandArguments:l,options:u}=rx(t,e,a);FNe(u);let d=MQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},UNe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,FNe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&vx("ipcInput"),t&&vx("ipc: true"),r&&vx("detached: true"),n&&vx("cancelSignal")},vx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},BNe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=jNe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=n7(c,r),{output:h,error:m=l}=XQ({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((b,w)=>ds(b,r,w)),E=ds(QQ(h,r),r,"all");return GNe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:E,options:r,command:n,escapedCommand:i,startTime:a})},jNe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{YQ(o,r);let a=zNe(r);return LNe(...nx(t,e,a))}catch(a){return qd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},zNe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:ux(e)}),GNe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?dx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Jg({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as PMe}from"events";import{spawn as OMe}from"child_process";import l7 from"process";import{once as xD,on as VNe}from"events";var o7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Fd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ZT(t)}),qNe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),qNe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{HT(e,i);let o=wa(t,e,r),s=new AbortController;try{return await Promise.race([HNe(o,n,s),WNe(o,r,s),YNe(o,r,s)])}catch(a){throw Bd(t),a}finally{s.abort(),WT(e,i)}},HNe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await xD(t,"message",{signal:r});return n}for await(let[n]of VNe(t,"message",{signal:r}))if(e(n))return n},WNe=async(t,e,{signal:r})=>{await xD(t,"disconnect",{signal:r}),qJ(e)},YNe=async(t,e,{signal:r})=>{let[n]=await xD(t,"strict:error",{signal:r});throw GT(n,e)};import{once as a7,on as KNe}from"events";var c7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>wD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),wD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Fd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ZT(t)}),HT(e,o);let s=wa(t,e,r),a=new AbortController,c={};return ZNe(t,s,a),JNe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),XNe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},ZNe=async(t,e,r)=>{try{await a7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},JNe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await a7(t,"strict:error",{signal:r.signal});n.error=GT(i,e),r.abort()}catch{}},XNe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of KNe(r,"message",{signal:o.signal}))s7(s),yield c}catch{s7(s)}finally{o.abort(),WT(e,a),n||Bd(t),i&&await t}},s7=({error:t})=>{if(t)throw t};var u7=(t,{ipc:e})=>{Object.assign(t,f7(t,!1,e))},d7=()=>{let t=l7,e=!0,r=l7.channel!==void 0;return{...f7(t,e,r),getCancelSignal:yX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},f7=(t,e,r)=>({sendMessage:ex.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:o7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:c7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as QNe}from"child_process";import{PassThrough as eke,Readable as tke,Writable as rke,Duplex as nke}from"stream";var p7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{mD(n);let a=new QNe;ike(a,n),Object.assign(a,{readable:oke,writable:ske,duplex:ake});let c=qd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=cke(c,s,i);return{subprocess:a,promise:l}},ike=(t,e)=>{let r=Qg(),n=Qg(),i=Qg(),o=Array.from({length:e.length-3},Qg),s=Qg(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Qg=()=>{let t=new eke;return t.end(),t},oke=()=>new tke({read(){}}),ske=()=>new rke({write(){}}),ake=()=>new nke({read(){},write(){}}),cke=async(t,e,r)=>Hd(t,e,r);import{createReadStream as h7,createWriteStream as m7}from"fs";import{Buffer as lke}from"buffer";import{Readable as e_,Writable as uke,Duplex as dke}from"stream";var _7=(t,e)=>mx(fke,t,e,!1),t_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Aa[t]}.`)},g7={fileNumber:t_,generator:vD,asyncGenerator:vD,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:dke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},fke={input:{...g7,fileUrl:({value:t})=>({stream:h7(t)}),filePath:({value:{file:t}})=>({stream:h7(t)}),webStream:({value:t})=>({stream:e_.fromWeb(t)}),iterable:({value:t})=>({stream:e_.from(t)}),asyncIterable:({value:t})=>({stream:e_.from(t)}),string:({value:t})=>({stream:e_.from(t)}),uint8Array:({value:t})=>({stream:e_.from(lke.from(t))})},output:{...g7,fileUrl:({value:t})=>({stream:m7(t)}),filePath:({value:{file:t,append:e}})=>({stream:m7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:uke.fromWeb(t)}),iterable:t_,asyncIterable:t_,string:t_,uint8Array:t_}};import{on as pke,once as y7}from"events";import{PassThrough as hke,getDefaultHighWaterMark as mke}from"stream";import{finished as v7}from"stream/promises";function vl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)RD(i);let e=t.some(({readableObjectMode:i})=>i),r=gke(t,e),n=new AD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var gke=(t,e)=>{if(t.length===0)return mke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AD=class extends hke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(RD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=_ke(this,this.#e,this.#o);let r=Eke({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(RD(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)}},_ke=async(t,e,r)=>{bx(t,S7);let n=new AbortController;try{await Promise.race([yke(t,n),Ske(t,e,r,n)])}finally{n.abort(),bx(t,-S7)}},yke=async(t,{signal:e})=>{try{await v7(t,{signal:e,cleanup:!0})}catch(r){throw b7(t,r),r}},Ske=async(t,e,r,{signal:n})=>{for await(let[i]of pke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},RD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Eke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{bx(t,E7);let a=new AbortController;try{await Promise.race([vke(o,e,a),bke({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Tke({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),bx(t,-E7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?ID(t):xke(t))},vke=async(t,e,{signal:r})=>{try{await t,r.aborted||ID(e)}catch(n){r.aborted||b7(e,n)}},bke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await v7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;T7(s)?i.add(e):x7(t,s)}},Tke=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await y7(t,i,{signal:o}),!t.readable)return y7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},xke=t=>{t.writable&&t.end()},b7=(t,e)=>{T7(e)?ID(t):x7(t,e)},T7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",ID=t=>{(t.readable||t.writable)&&t.destroy()},x7=(t,e)=>{t.destroyed||(t.once("error",wke),t.destroy(e))},wke=()=>{},bx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},S7=2,E7=1;import{finished as w7}from"stream/promises";var Yd=(t,e)=>{t.pipe(e),Ake(t,e),Rke(t,e)},Ake=async(t,e)=>{if(!(Ei(t)||Ei(e))){try{await w7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}CD(e)}},CD=t=>{t.writable&&t.end()},Rke=async(t,e)=>{if(!(Ei(t)||Ei(e))){try{await w7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}PD(t)}},PD=t=>{t.readable&&t.destroy()};var A7=(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})=>zn.has(c)))Ike(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!zn.has(c)))Pke({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]:vl(o);Yd(s,i)}},Ike=(t,e,r,n)=>{r==="output"?Yd(t.stdio[n],e):Yd(e,t.stdio[n]);let i=Cke[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Cke=["stdin","stdout","stderr"],Pke=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Oke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Oke=(t,{signal:e})=>{Ei(t)&&_l(t,Nke,e)},Nke=2;import{addAbortListener as Dke}from"events";var bl=[];bl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&bl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&bl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Tx=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",OD=Symbol.for("signal-exit emitter"),ND=globalThis,kke=Object.defineProperty.bind(Object),kD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ND[OD])return ND[OD];kke(ND,OD,{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}},xx=class{},Mke=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),MD=class extends xx{onExit(){return()=>{}}load(){}unload(){}},DD=class extends xx{#e=LD.platform==="win32"?"SIGINT":"SIGHUP";#r=new kD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of bl)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(!Tx(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 bl)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,bl.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 Tx(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"&&Tx(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)}},LD=globalThis.process,{onExit:R7,load:fpt,unload:ppt}=Mke(Tx(LD)?new DD(LD):new MD);var I7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=R7(()=>{t.kill()});Dke(n,()=>{i()})};var P7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=DT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Lke(r,n,i),{sourceStream:d,sourceError:f}=Uke(t,l),{options:p,fileDescriptors:h}=ao.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},Lke=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=$ke(t,e,...r),a=qT(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},$ke=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(C7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||wM(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]=wT(r,...n);return{destination:e(C7)(i,o,s),pipeOptions:s}}if(ao.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}`)},C7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Uke=(t,e)=>{try{return{sourceStream:jd(t,e)}}catch(r){return{sourceError:r}}};var N7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Fke({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw $D({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Fke=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return PD(t),n;if(e!==void 0)return CD(r),e},$D=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>qd({error:t,command:O7,escapedCommand:O7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),O7="source.pipe(destination)";var k7=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 Bke}from"stream/promises";var M7=(t,e,r)=>{let n=wx.has(e)?zke(t,e):jke(t,e);return _l(t,Vke,r.signal),_l(e,qke,r.signal),Gke(e),n},jke=(t,e)=>{let r=vl([t]);return Yd(r,e),wx.set(e,r),r},zke=(t,e)=>{let r=wx.get(e);return r.add(t),r},Gke=async t=>{try{await Bke(t,{cleanup:!0,readable:!1,writable:!0})}catch{}wx.delete(t)},wx=new WeakMap,Vke=2,qke=1;import{aborted as Hke}from"util";var D7=(t,e)=>t===void 0?[]:[Wke(t,e)],Wke=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Hke(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw $D({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Ax=(t,...e)=>{if(At(e[0]))return Ax.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=P7(t,...e),i=Yke({...n,destination:r});return i.pipe=Ax.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Yke=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=Kke(t,i);N7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=M7(e,o,d);return await Promise.race([k7(u),...D7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},Kke=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as rMe}from"timers/promises";import{on as Zke}from"events";import{getDefaultHighWaterMark as Jke}from"stream";var Rx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return Xke(e,s),$7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},Xke=async(t,e)=>{try{await t}catch{}finally{e.abort()}},UD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;Qke(e,s,t);let a=t.readableObjectMode&&!o;return $7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Qke=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},$7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Zke(t,"data",{signal:e.signal,highWaterMark:L7,highWatermark:L7});return eMe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},FD=Jke(!0),L7=FD,eMe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=tMe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*El(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Xg(a)}},tMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[_x(t,r,!e),gx(t,i,!n,{})].filter(Boolean);var U7=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=nMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([iMe(t),d]);return}let f=gD(c,r),p=UD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([oMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},nMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Ex({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=UD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await KQ(a,t,r,o)},iMe=async t=>{await rMe(),t.readableFlowing===null&&t.resume()},oMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await ax(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await cx(r,{maxBuffer:o})):await Vd(r,{maxBuffer:o})}catch(a){return F7(KX({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},BD=async t=>{try{return await t}catch(e){return F7(e)}},F7=({bufferedData:t})=>d9(t)?new Uint8Array(t):t;import{finished as sMe}from"stream/promises";var r_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=aMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],sMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||uMe(a,e,r,n)}finally{s.abort()}},aMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&cMe(t,r,n),n},cMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{lMe(e,r),n.call(t,...i)}},lMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},uMe=(t,e,r,n)=>{if(!dMe(t,e,r,n))throw t},dMe=(t,e,r,n=!0)=>r.propagating?B7(t)||Ix(t):(r.propagating=!0,jD(r,e)===n?B7(t):Ix(t)),jD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Ix=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",B7=t=>t?.code==="EPIPE";var j7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>zD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),zD=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=r_(t,e,l);if(jD(l,e)){await u;return}let[d]=await Promise.all([U7({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var z7=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?vl([t,e].filter(Boolean)):void 0,G7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>zD({...fMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:pMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),fMe=({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}},pMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as hMe}from"events";var V7=t=>Ld(t,"ipc"),q7=(t,e)=>{let r=MT(t);oo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var H7=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=V7(o),a=ls(e,"ipc"),c=ls(r,"ipc");for await(let l of wD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ZX(t,i,c),i.push(l)),s&&q7(l,o);return i},W7=async(t,e)=>(await Promise.allSettled([t]),e);var Y7=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:y,controller:E})=>{let b=e7(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=j7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),N=G7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),C=[],$=H7({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:C,verboseInfo:p}),O=mMe(m,t,w),M=gMe(h,w);try{return await Promise.race([Promise.all([{},r7(b),Promise.all(v),N,$,IX(t,d),...O,...M]),y,_Me(t,E),...TX(t,o,f,E),...VJ({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...vX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(j){return f.terminationReason??="other",Promise.all([{error:j},b,Promise.all(v.map(_=>BD(_))),BD(N),W7($,C),Promise.allSettled(O),Promise.allSettled(M)])}},mMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:r_(n,i,r)),gMe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ti(o,{checkOpen:!1})&&!Ei(o)).map(({type:i,value:o,stream:s=o})=>r_(s,n,e,{isSameDirection:zn.has(i),stopOnExit:i==="native"}))),_Me=async(t,{signal:e})=>{let[r]=await hMe(t,"error",{signal:e});throw r};var K7=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),n_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=so();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Kd=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 yMe}from"stream";import{callbackify as SMe}from"util";import{finished as Z7}from"stream/promises";var GD=async t=>{if(t!==void 0)try{await VD(t)}catch{}},J7=async t=>{if(t!==void 0)try{await qD(t)}catch{}},VD=async t=>{await Z7(t,{cleanup:!0,readable:!1,writable:!0})},qD=async t=>{await Z7(t,{cleanup:!0,readable:!0,writable:!1})},Cx=async(t,e)=>{if(await t,e)throw e},Px=(t,e,r)=>{r&&!Ix(r)?t.destroy(r):e&&t.destroy()};var X7=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||fn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=HD(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=WD(a,s),{read:f,onStdoutDataDone:p}=YD({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new yMe({read:f,destroy:SMe(ZD.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return KD({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},HD=(t,e,r)=>{let n=jd(t,e),i=n_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},WD=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:FD},YD=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=so(),s=Rx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){EMe(this,s,o)},onStdoutDataDone:o}},EMe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},KD=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await qD(t),await n,await GD(i),await e,r.readable&&r.push(null)}catch(o){await GD(i),Q7(r,o)}},ZD=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Kd(r,e)&&(Q7(t,n),await Cx(e,n))},Q7=(t,e)=>{Px(t,t.readable,e)};import{Writable as vMe}from"stream";import{callbackify as eee}from"util";var tee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=JD(t,r,e),s=new vMe({...XD(n,t,i),destroy:eee(eL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return QD(n,s),s},JD=(t,e,r)=>{let n=qT(t,e),i=n_(r,n,"writableFinal"),o=n_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},XD=(t,e,r)=>({write:bMe.bind(void 0,t),final:eee(TMe.bind(void 0,t,e,r))}),bMe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},TMe=async(t,e,r)=>{await Kd(r,e)&&(t.writable&&t.end(),await e)},QD=async(t,e,r)=>{try{await VD(t),e.writable&&e.end()}catch(n){await J7(r),ree(e,n)}},eL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Kd(r,e),await Kd(n,e)&&(ree(t,i),await Cx(e,i))},ree=(t,e)=>{Px(t,t.writable,e)};import{Duplex as xMe}from"stream";import{callbackify as wMe}from"util";var nee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||fn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=HD(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=JD(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=WD(c,a),{read:y,onStdoutDataDone:E}=YD({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new xMe({read:y,...XD(u,t,d),destroy:wMe(AMe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return KD({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),QD(u,b,c),b},AMe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([ZD({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),eL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var tL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||fn.has(e),s=jd(t,r),a=Rx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return RMe(a,s,t)},RMe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var iee=(t,{encoding:e})=>{let r=K7();t.readable=X7.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=tee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=nee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=tL.bind(void 0,t,e),t[Symbol.asyncIterator]=tL.bind(void 0,t,e,{})};var oee=(t,e)=>{for(let[r,n]of CMe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},IMe=(async()=>{})().constructor.prototype,CMe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(IMe,t)]);var see=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=NMe(t,e,r),{subprocess:f,promise:p}=MMe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Ax.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),oee(f,p),ao.set(f,{options:u,fileDescriptors:d}),f},NMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=LT(t,e,r),{file:a,commandArguments:c,options:l}=rx(t,e,r),u=kMe(l),d=_7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},kMe=({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}},MMe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=OMe(...nx(t,e,r))}catch(h){return p7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;PMe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];A7(c,a,l),I7(c,r,l);let d={},f=so();c.kill=zJ.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=z7(c,r),iee(c,r),u7(c,r);let p=DMe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},DMe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,y]=await Y7({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((v,N)=>ds(v,e,N)),b=ds(m,e,"all"),w=LMe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Hd(w,n,e)},LMe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Jg({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof co,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):dx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Ox=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,$Me(n,t[n],i)]));return{...t,...r}},$Me=(t,e,r)=>UMe.has(t)&&At(e)&&At(r)?{...e,...r}:r,UMe=new Set(["env",...OM]);var Ra=(t,e,r,n)=>{let i=(s,a,c)=>Ra(s,a,r,c),o=(...s)=>FMe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},FMe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(At(o))return i(t,Ox(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=BMe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?i7(a,c,l):see(a,c,l,i)},BMe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=_9(e)?y9(e,r):[e,...r],[s,a,c]=wT(...o),l=Ox(Ox(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var aee=({file:t,commandArguments:e})=>lee(t,e),cee=({file:t,commandArguments:e})=>({...lee(t,e),isSync:!0}),lee=(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]=jMe(t);return{file:r,commandArguments:n}},jMe=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(zMe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},zMe=/ +/g;var uee=(t,e,r)=>{t.sync=e(GMe,r),t.s=t.sync},dee=({options:t})=>fee(t),GMe=({options:t})=>({...fee(t),isSync:!0}),fee=t=>({options:{...VMe(t),...t}}),VMe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},pee={preferLocal:!0};var hee=Ra(()=>({})),rgt=Ra(()=>({isSync:!0})),mee=Ra(aee),ngt=Ra(cee),igt=Ra(wX),ogt=Ra(dee,{},pee,uee),{sendMessage:sgt,getOneMessage:agt,getEachMessage:cgt,getCancelSignal:lgt}=d7();var gee=!1,_ee=()=>{gee=!0},uo=()=>gee;var i_=null,yee=t=>(i_&&i_.destroy(),i_=new fs({totalAllowedTime:t}),i_),See=()=>i_;var fs=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&&uo())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await ST({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Se.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Eee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-test.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var YMe=HMe(import.meta.url),KMe=ps.dirname(YMe),ZMe=WMe(import.meta.url),Zd=ye("shell"),rL=new Set,vee={preferLocal:!0},Cr=(t,e,r)=>{let[n,i]=JMe(e,r),o={...vee,...i},s=hee(t,n,o);Tee(s,o),Aee(s);let a=r?.idleTimeout;return a&&a>0&&wee(s,a),s},bee=(t,e)=>{let r={...vee,...e},n=mee(t,r);return Tee(n,r),Aee(n),e?.idleTimeout&&e.idleTimeout>0&&wee(n,e.idleTimeout),n},JMe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Tee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(hs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Mg).pipe(hs.stdout),t.stderr?.pipe(new Mg).pipe(hs.stderr);return}t.stdout?.pipe(hs.stdout),t.stderr?.pipe(hs.stderr)},nL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(hs.kill(-t.pid,e),Zd.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Zd.error("Error killing process:",r),!1}},xee=t=>nL(t,"SIGKILL"),wee=(t,e)=>{let r=null,n=()=>{Zd.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),nL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zd.log(`Force killing idle process ${t.pid}`),xee(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)},Aee=t=>{rL.add(t);let e=See();if(e){let r=e.onTimesUp(()=>{Zd.log(`Global timer expired, killing process ${t.pid}`),nL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zd.log(`Force killing process ${t.pid} after timeout`),xee(t))},5e3)});t.on("exit",()=>{rL.delete(t),r()}),t.on("error",()=>{rL.delete(t),r()})}};function fo(t,e){if(!hs.env.NETLIFY_LOCAL_MODE)try{let i=ZMe.resolve(Eee.name),o=ps.dirname(i);for(;o!==ps.dirname(o);){let s=ps.dirname(o);if(ps.basename(s)==="node_modules"){let a=ps.join(s,".bin",e);if(Nx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(hs.env.NODE_PATH){let i=ps.join(hs.env.NODE_PATH,".bin",e);if(Nx.existsSync(i))return i}let r=ps.join(t,"node_modules",".bin",e);if(Nx.existsSync(r))return r;let n=ps.join(KMe,"..","node_modules",".bin",e);if(Nx.existsSync(n))return n}var XMe=ye("utils"),QMe=t=>new Promise(e=>{setTimeout(e,t)});var kx=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await QMe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Ia=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Ree=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):XMe.error("Could not parse JSON",n))}},eDe=t=>t.charAt(0).toUpperCase()+t.slice(1),po=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():eDe(e)).join(" ");function ms(t,e){e&&t.log(`Skill invoked: ${e}`)}var Mx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Iee=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var iL=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},tDe=1e4,oL=(t,e=tDe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as Cee}from"buffer";import rDe from"path";var Pee=ye("repo"),Vr=(t,e={})=>Cr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Dx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Pee.info("Getting runner diffs");let n=await iDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=sDe(o);await aDe(m,r)}Pee.info("Changes after processing"),await aL(r);let s=await lL(o,r);if(await sL(s,r),i=await oDe(r),!i)return{hasChanges:!1,ignored:s};await Vr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Vr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Oee(r),{hasChanges:!1,ignored:s};let u=await Vr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Vr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let y=await Vr(["diff",t.sha,"HEAD","--binary"],a),E=String(y.stdout??"");f!==E&&(p=Cee.from(E).toString("base64"))}await Oee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Cee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Oee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Vr(["reset","--soft","HEAD~1"],{cwd:t})},sL=async(t=[],e=process.cwd())=>{await Vr(["add",".",...t],{cwd:e})},aL=async(t=process.cwd())=>{let e=await Vr(["status","-s"],{cwd:t});return String(e.stdout??"")},Nee=/.. (.+)?\.log$/,nDe=[Nee],iDe=async(t=process.cwd())=>{let e=await aL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
101
|
+
if (condition) { yield value; }`)};import{Buffer as lNe}from"buffer";import{StringDecoder as uNe}from"string_decoder";var _x=(t,e,r)=>{if(r)return;if(t)return{transform:dNe.bind(void 0,new TextEncoder)};let n=new uNe(e);return{transform:fNe.bind(void 0,n),final:pNe.bind(void 0,n)}},dNe=function*(t,e){lNe.isBuffer(e)?yield cs(e):typeof e=="string"?yield t.encode(e):yield e},fNe=function*(t,e){yield Ut(e)?t.write(e):e},pNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as zQ}from"util";var SD=zQ(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),yx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=mNe}=e[r];for await(let i of n(t))yield*yx(i,e,r+1)},GQ=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*hNe(r,Number(e),t)},hNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*yx(n,r,e+1)},VQ=zQ(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),mNe=function*(t){yield t};var ED=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},qQ=(t,e)=>[...e.flatMap(r=>[...El(r,t,0)]),...Xg(t)],El=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_Ne}=e[r];for(let i of n(t))yield*El(i,e,r+1)},Xg=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*gNe(r,Number(e),t)},gNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*El(n,r,e+1)},_Ne=function*(t){yield t};var vD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=WQ(t,s,o),l=Sl(e),u=Sl(r),d=l?SD.bind(void 0,yx,a):ED.bind(void 0,El),f=l||u?SD.bind(void 0,GQ,a):ED.bind(void 0,Xg),p=l||u?VQ.bind(void 0,a):void 0;return{stream:new yNe({writableObjectMode:n,writableHighWaterMark:HQ(n),readableObjectMode:i,readableHighWaterMark:HQ(i),transform(m,y,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Sx=(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=WQ(s,r,a);t=qQ(c,t)}return t},WQ=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:FQ(n,a)},_x(r,s,n),gx(r,o,n,c),{transform:t,final:e},{transform:BQ(i,a)},UQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var YQ=(t,e)=>{for(let r of SNe(t))ENe(t,r,e)},SNe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),ENe=(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 ${Aa[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>vNe(a,n));r.input=zg(s)},vNe=(t,e)=>{let r=Sx(t,e,"utf8",!0);return bNe(r),zg(r)},bNe=t=>{let e=t.find(r=>typeof r!="string"&&!Ut(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 ANe,appendFileSync as RNe}from"fs";var Ex=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ld(r,n)&&!fn.has(e)&&TNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&xNe.has(o))||t.every(({type:i})=>zn.has(i))),TNe=t=>t===1||t===2,xNe=new Set(["pipe","overlapped"]),KQ=async(t,e,r,n)=>{for await(let i of t)wNe(e)||JQ(i,r,n)},ZQ=(t,e,r)=>{for(let n of t)JQ(n,e,r)},wNe=t=>t._readableState.pipes.length>0,JQ=(t,e,r)=>{let n=MT(t);oo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var XQ=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>INe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},INe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=QX(t,o,d),p=cs(f),{stdioItems:h,objectMode:m}=e[r],y=CNe([p],h,c,n),{serializedResult:E,finalResult:b=E}=PNe({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});ONe({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?b:void 0;try{return n.error===void 0&&NNe(E,h,i),w}catch(v){return n.error=v,w}},CNe=(t,e,r,n)=>{try{return Sx(t,e,r,!1)}catch(i){return n.error=i,t}},PNe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:zg(t)};let s=p9(t,r);return n[o]?{serializedResult:s,finalResult:yD(s,!i[o],e)}:{serializedResult:s}},ONe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Ex({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=yD(t,!1,s);try{ZQ(a,e,n)}catch(c){r.error??=c}},NNe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>hx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?RNe(n,t):(r.add(o),ANe(n,t))}};var QQ=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ds(e,r,"all")]:Array.isArray(e)?[ds(t,r,"all"),...e]:Ut(t)&&Ut(e)?RM([t,e]):`${t}${e}`};import{once as bD}from"events";var e7=async(t,e)=>{let[r,n]=await kNe(t);return e.isForcefullyTerminated??=!1,[r,n]},kNe=async t=>{let[e,r]=await Promise.allSettled([bD(t,"spawn"),bD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?t7(t):r.value},t7=async t=>{try{return await bD(t,"exit")}catch{return t7(t)}},r7=async t=>{let[e,r]=await t;if(!MNe(e,r)&&TD(e,r))throw new vi;return[e,r]},MNe=(t,e)=>t===void 0&&e===void 0,TD=(t,e)=>t!==0||e!==null;var n7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=DNe(t,e,r),s=o?.code==="ETIMEDOUT",a=XX(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},DNe=(t,e,r)=>t!==void 0?t:TD(e,r)?new vi:void 0;var i7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=$Ne(t,e,r),d=BNe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Hd(d,c,l)},$Ne=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=LT(t,e,r),a=UNe(r),{file:c,commandArguments:l,options:u}=rx(t,e,a);FNe(u);let d=MQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},UNe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,FNe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&vx("ipcInput"),t&&vx("ipc: true"),r&&vx("detached: true"),n&&vx("cancelSignal")},vx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},BNe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=jNe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=n7(c,r),{output:h,error:m=l}=XQ({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((b,w)=>ds(b,r,w)),E=ds(QQ(h,r),r,"all");return GNe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:E,options:r,command:n,escapedCommand:i,startTime:a})},jNe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{YQ(o,r);let a=zNe(r);return LNe(...nx(t,e,a))}catch(a){return qd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},zNe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:ux(e)}),GNe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?dx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Jg({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as PMe}from"events";import{spawn as OMe}from"child_process";import l7 from"process";import{once as xD,on as VNe}from"events";var o7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Fd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ZT(t)}),qNe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),qNe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{HT(e,i);let o=wa(t,e,r),s=new AbortController;try{return await Promise.race([HNe(o,n,s),WNe(o,r,s),YNe(o,r,s)])}catch(a){throw Bd(t),a}finally{s.abort(),WT(e,i)}},HNe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await xD(t,"message",{signal:r});return n}for await(let[n]of VNe(t,"message",{signal:r}))if(e(n))return n},WNe=async(t,e,{signal:r})=>{await xD(t,"disconnect",{signal:r}),qJ(e)},YNe=async(t,e,{signal:r})=>{let[n]=await xD(t,"strict:error",{signal:r});throw GT(n,e)};import{once as a7,on as KNe}from"events";var c7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>wD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),wD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Fd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ZT(t)}),HT(e,o);let s=wa(t,e,r),a=new AbortController,c={};return ZNe(t,s,a),JNe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),XNe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},ZNe=async(t,e,r)=>{try{await a7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},JNe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await a7(t,"strict:error",{signal:r.signal});n.error=GT(i,e),r.abort()}catch{}},XNe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of KNe(r,"message",{signal:o.signal}))s7(s),yield c}catch{s7(s)}finally{o.abort(),WT(e,a),n||Bd(t),i&&await t}},s7=({error:t})=>{if(t)throw t};var u7=(t,{ipc:e})=>{Object.assign(t,f7(t,!1,e))},d7=()=>{let t=l7,e=!0,r=l7.channel!==void 0;return{...f7(t,e,r),getCancelSignal:yX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},f7=(t,e,r)=>({sendMessage:ex.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:o7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:c7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as QNe}from"child_process";import{PassThrough as eke,Readable as tke,Writable as rke,Duplex as nke}from"stream";var p7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{mD(n);let a=new QNe;ike(a,n),Object.assign(a,{readable:oke,writable:ske,duplex:ake});let c=qd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=cke(c,s,i);return{subprocess:a,promise:l}},ike=(t,e)=>{let r=Qg(),n=Qg(),i=Qg(),o=Array.from({length:e.length-3},Qg),s=Qg(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Qg=()=>{let t=new eke;return t.end(),t},oke=()=>new tke({read(){}}),ske=()=>new rke({write(){}}),ake=()=>new nke({read(){},write(){}}),cke=async(t,e,r)=>Hd(t,e,r);import{createReadStream as h7,createWriteStream as m7}from"fs";import{Buffer as lke}from"buffer";import{Readable as e_,Writable as uke,Duplex as dke}from"stream";var _7=(t,e)=>mx(fke,t,e,!1),t_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Aa[t]}.`)},g7={fileNumber:t_,generator:vD,asyncGenerator:vD,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:dke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},fke={input:{...g7,fileUrl:({value:t})=>({stream:h7(t)}),filePath:({value:{file:t}})=>({stream:h7(t)}),webStream:({value:t})=>({stream:e_.fromWeb(t)}),iterable:({value:t})=>({stream:e_.from(t)}),asyncIterable:({value:t})=>({stream:e_.from(t)}),string:({value:t})=>({stream:e_.from(t)}),uint8Array:({value:t})=>({stream:e_.from(lke.from(t))})},output:{...g7,fileUrl:({value:t})=>({stream:m7(t)}),filePath:({value:{file:t,append:e}})=>({stream:m7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:uke.fromWeb(t)}),iterable:t_,asyncIterable:t_,string:t_,uint8Array:t_}};import{on as pke,once as y7}from"events";import{PassThrough as hke,getDefaultHighWaterMark as mke}from"stream";import{finished as v7}from"stream/promises";function vl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)RD(i);let e=t.some(({readableObjectMode:i})=>i),r=gke(t,e),n=new AD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var gke=(t,e)=>{if(t.length===0)return mke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AD=class extends hke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(RD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=_ke(this,this.#e,this.#o);let r=Eke({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(RD(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)}},_ke=async(t,e,r)=>{bx(t,S7);let n=new AbortController;try{await Promise.race([yke(t,n),Ske(t,e,r,n)])}finally{n.abort(),bx(t,-S7)}},yke=async(t,{signal:e})=>{try{await v7(t,{signal:e,cleanup:!0})}catch(r){throw b7(t,r),r}},Ske=async(t,e,r,{signal:n})=>{for await(let[i]of pke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},RD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Eke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{bx(t,E7);let a=new AbortController;try{await Promise.race([vke(o,e,a),bke({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Tke({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),bx(t,-E7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?ID(t):xke(t))},vke=async(t,e,{signal:r})=>{try{await t,r.aborted||ID(e)}catch(n){r.aborted||b7(e,n)}},bke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await v7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;T7(s)?i.add(e):x7(t,s)}},Tke=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await y7(t,i,{signal:o}),!t.readable)return y7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},xke=t=>{t.writable&&t.end()},b7=(t,e)=>{T7(e)?ID(t):x7(t,e)},T7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",ID=t=>{(t.readable||t.writable)&&t.destroy()},x7=(t,e)=>{t.destroyed||(t.once("error",wke),t.destroy(e))},wke=()=>{},bx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},S7=2,E7=1;import{finished as w7}from"stream/promises";var Yd=(t,e)=>{t.pipe(e),Ake(t,e),Rke(t,e)},Ake=async(t,e)=>{if(!(Ei(t)||Ei(e))){try{await w7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}CD(e)}},CD=t=>{t.writable&&t.end()},Rke=async(t,e)=>{if(!(Ei(t)||Ei(e))){try{await w7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}PD(t)}},PD=t=>{t.readable&&t.destroy()};var A7=(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})=>zn.has(c)))Ike(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!zn.has(c)))Pke({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]:vl(o);Yd(s,i)}},Ike=(t,e,r,n)=>{r==="output"?Yd(t.stdio[n],e):Yd(e,t.stdio[n]);let i=Cke[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Cke=["stdin","stdout","stderr"],Pke=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Oke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Oke=(t,{signal:e})=>{Ei(t)&&_l(t,Nke,e)},Nke=2;import{addAbortListener as Dke}from"events";var bl=[];bl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&bl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&bl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Tx=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",OD=Symbol.for("signal-exit emitter"),ND=globalThis,kke=Object.defineProperty.bind(Object),kD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ND[OD])return ND[OD];kke(ND,OD,{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}},xx=class{},Mke=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),MD=class extends xx{onExit(){return()=>{}}load(){}unload(){}},DD=class extends xx{#e=LD.platform==="win32"?"SIGINT":"SIGHUP";#r=new kD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of bl)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(!Tx(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 bl)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,bl.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 Tx(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"&&Tx(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)}},LD=globalThis.process,{onExit:R7,load:fpt,unload:ppt}=Mke(Tx(LD)?new DD(LD):new MD);var I7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=R7(()=>{t.kill()});Dke(n,()=>{i()})};var P7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=DT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Lke(r,n,i),{sourceStream:d,sourceError:f}=Uke(t,l),{options:p,fileDescriptors:h}=ao.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},Lke=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=$ke(t,e,...r),a=qT(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},$ke=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(C7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||wM(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]=wT(r,...n);return{destination:e(C7)(i,o,s),pipeOptions:s}}if(ao.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}`)},C7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Uke=(t,e)=>{try{return{sourceStream:jd(t,e)}}catch(r){return{sourceError:r}}};var N7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Fke({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw $D({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Fke=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return PD(t),n;if(e!==void 0)return CD(r),e},$D=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>qd({error:t,command:O7,escapedCommand:O7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),O7="source.pipe(destination)";var k7=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 Bke}from"stream/promises";var M7=(t,e,r)=>{let n=wx.has(e)?zke(t,e):jke(t,e);return _l(t,Vke,r.signal),_l(e,qke,r.signal),Gke(e),n},jke=(t,e)=>{let r=vl([t]);return Yd(r,e),wx.set(e,r),r},zke=(t,e)=>{let r=wx.get(e);return r.add(t),r},Gke=async t=>{try{await Bke(t,{cleanup:!0,readable:!1,writable:!0})}catch{}wx.delete(t)},wx=new WeakMap,Vke=2,qke=1;import{aborted as Hke}from"util";var D7=(t,e)=>t===void 0?[]:[Wke(t,e)],Wke=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Hke(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw $D({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Ax=(t,...e)=>{if(At(e[0]))return Ax.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=P7(t,...e),i=Yke({...n,destination:r});return i.pipe=Ax.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Yke=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=Kke(t,i);N7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=M7(e,o,d);return await Promise.race([k7(u),...D7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},Kke=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as rMe}from"timers/promises";import{on as Zke}from"events";import{getDefaultHighWaterMark as Jke}from"stream";var Rx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return Xke(e,s),$7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},Xke=async(t,e)=>{try{await t}catch{}finally{e.abort()}},UD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;Qke(e,s,t);let a=t.readableObjectMode&&!o;return $7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Qke=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},$7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Zke(t,"data",{signal:e.signal,highWaterMark:L7,highWatermark:L7});return eMe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},FD=Jke(!0),L7=FD,eMe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=tMe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*El(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Xg(a)}},tMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[_x(t,r,!e),gx(t,i,!n,{})].filter(Boolean);var U7=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=nMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([iMe(t),d]);return}let f=gD(c,r),p=UD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([oMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},nMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Ex({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=UD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await KQ(a,t,r,o)},iMe=async t=>{await rMe(),t.readableFlowing===null&&t.resume()},oMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await ax(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await cx(r,{maxBuffer:o})):await Vd(r,{maxBuffer:o})}catch(a){return F7(KX({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},BD=async t=>{try{return await t}catch(e){return F7(e)}},F7=({bufferedData:t})=>d9(t)?new Uint8Array(t):t;import{finished as sMe}from"stream/promises";var r_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=aMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],sMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||uMe(a,e,r,n)}finally{s.abort()}},aMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&cMe(t,r,n),n},cMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{lMe(e,r),n.call(t,...i)}},lMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},uMe=(t,e,r,n)=>{if(!dMe(t,e,r,n))throw t},dMe=(t,e,r,n=!0)=>r.propagating?B7(t)||Ix(t):(r.propagating=!0,jD(r,e)===n?B7(t):Ix(t)),jD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Ix=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",B7=t=>t?.code==="EPIPE";var j7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>zD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),zD=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=r_(t,e,l);if(jD(l,e)){await u;return}let[d]=await Promise.all([U7({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var z7=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?vl([t,e].filter(Boolean)):void 0,G7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>zD({...fMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:pMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),fMe=({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}},pMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as hMe}from"events";var V7=t=>Ld(t,"ipc"),q7=(t,e)=>{let r=MT(t);oo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var H7=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=V7(o),a=ls(e,"ipc"),c=ls(r,"ipc");for await(let l of wD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ZX(t,i,c),i.push(l)),s&&q7(l,o);return i},W7=async(t,e)=>(await Promise.allSettled([t]),e);var Y7=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:y,controller:E})=>{let b=e7(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=j7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),N=G7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),C=[],$=H7({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:C,verboseInfo:p}),O=mMe(m,t,w),M=gMe(h,w);try{return await Promise.race([Promise.all([{},r7(b),Promise.all(v),N,$,IX(t,d),...O,...M]),y,_Me(t,E),...TX(t,o,f,E),...VJ({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...vX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(j){return f.terminationReason??="other",Promise.all([{error:j},b,Promise.all(v.map(_=>BD(_))),BD(N),W7($,C),Promise.allSettled(O),Promise.allSettled(M)])}},mMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:r_(n,i,r)),gMe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ti(o,{checkOpen:!1})&&!Ei(o)).map(({type:i,value:o,stream:s=o})=>r_(s,n,e,{isSameDirection:zn.has(i),stopOnExit:i==="native"}))),_Me=async(t,{signal:e})=>{let[r]=await hMe(t,"error",{signal:e});throw r};var K7=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),n_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=so();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Kd=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 yMe}from"stream";import{callbackify as SMe}from"util";import{finished as Z7}from"stream/promises";var GD=async t=>{if(t!==void 0)try{await VD(t)}catch{}},J7=async t=>{if(t!==void 0)try{await qD(t)}catch{}},VD=async t=>{await Z7(t,{cleanup:!0,readable:!1,writable:!0})},qD=async t=>{await Z7(t,{cleanup:!0,readable:!0,writable:!1})},Cx=async(t,e)=>{if(await t,e)throw e},Px=(t,e,r)=>{r&&!Ix(r)?t.destroy(r):e&&t.destroy()};var X7=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||fn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=HD(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=WD(a,s),{read:f,onStdoutDataDone:p}=YD({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new yMe({read:f,destroy:SMe(ZD.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return KD({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},HD=(t,e,r)=>{let n=jd(t,e),i=n_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},WD=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:FD},YD=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=so(),s=Rx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){EMe(this,s,o)},onStdoutDataDone:o}},EMe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},KD=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await qD(t),await n,await GD(i),await e,r.readable&&r.push(null)}catch(o){await GD(i),Q7(r,o)}},ZD=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Kd(r,e)&&(Q7(t,n),await Cx(e,n))},Q7=(t,e)=>{Px(t,t.readable,e)};import{Writable as vMe}from"stream";import{callbackify as eee}from"util";var tee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=JD(t,r,e),s=new vMe({...XD(n,t,i),destroy:eee(eL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return QD(n,s),s},JD=(t,e,r)=>{let n=qT(t,e),i=n_(r,n,"writableFinal"),o=n_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},XD=(t,e,r)=>({write:bMe.bind(void 0,t),final:eee(TMe.bind(void 0,t,e,r))}),bMe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},TMe=async(t,e,r)=>{await Kd(r,e)&&(t.writable&&t.end(),await e)},QD=async(t,e,r)=>{try{await VD(t),e.writable&&e.end()}catch(n){await J7(r),ree(e,n)}},eL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Kd(r,e),await Kd(n,e)&&(ree(t,i),await Cx(e,i))},ree=(t,e)=>{Px(t,t.writable,e)};import{Duplex as xMe}from"stream";import{callbackify as wMe}from"util";var nee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||fn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=HD(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=JD(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=WD(c,a),{read:y,onStdoutDataDone:E}=YD({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new xMe({read:y,...XD(u,t,d),destroy:wMe(AMe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return KD({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),QD(u,b,c),b},AMe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([ZD({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),eL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var tL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||fn.has(e),s=jd(t,r),a=Rx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return RMe(a,s,t)},RMe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var iee=(t,{encoding:e})=>{let r=K7();t.readable=X7.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=tee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=nee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=tL.bind(void 0,t,e),t[Symbol.asyncIterator]=tL.bind(void 0,t,e,{})};var oee=(t,e)=>{for(let[r,n]of CMe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},IMe=(async()=>{})().constructor.prototype,CMe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(IMe,t)]);var see=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=NMe(t,e,r),{subprocess:f,promise:p}=MMe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Ax.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),oee(f,p),ao.set(f,{options:u,fileDescriptors:d}),f},NMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=LT(t,e,r),{file:a,commandArguments:c,options:l}=rx(t,e,r),u=kMe(l),d=_7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},kMe=({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}},MMe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=OMe(...nx(t,e,r))}catch(h){return p7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;PMe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];A7(c,a,l),I7(c,r,l);let d={},f=so();c.kill=zJ.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=z7(c,r),iee(c,r),u7(c,r);let p=DMe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},DMe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,y]=await Y7({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((v,N)=>ds(v,e,N)),b=ds(m,e,"all"),w=LMe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Hd(w,n,e)},LMe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Jg({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof co,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):dx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Ox=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,$Me(n,t[n],i)]));return{...t,...r}},$Me=(t,e,r)=>UMe.has(t)&&At(e)&&At(r)?{...e,...r}:r,UMe=new Set(["env",...OM]);var Ra=(t,e,r,n)=>{let i=(s,a,c)=>Ra(s,a,r,c),o=(...s)=>FMe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},FMe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(At(o))return i(t,Ox(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=BMe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?i7(a,c,l):see(a,c,l,i)},BMe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=_9(e)?y9(e,r):[e,...r],[s,a,c]=wT(...o),l=Ox(Ox(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var aee=({file:t,commandArguments:e})=>lee(t,e),cee=({file:t,commandArguments:e})=>({...lee(t,e),isSync:!0}),lee=(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]=jMe(t);return{file:r,commandArguments:n}},jMe=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(zMe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},zMe=/ +/g;var uee=(t,e,r)=>{t.sync=e(GMe,r),t.s=t.sync},dee=({options:t})=>fee(t),GMe=({options:t})=>({...fee(t),isSync:!0}),fee=t=>({options:{...VMe(t),...t}}),VMe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},pee={preferLocal:!0};var hee=Ra(()=>({})),rgt=Ra(()=>({isSync:!0})),mee=Ra(aee),ngt=Ra(cee),igt=Ra(wX),ogt=Ra(dee,{},pee,uee),{sendMessage:sgt,getOneMessage:agt,getEachMessage:cgt,getCancelSignal:lgt}=d7();var gee=!1,_ee=()=>{gee=!0},uo=()=>gee;var i_=null,yee=t=>(i_&&i_.destroy(),i_=new fs({totalAllowedTime:t}),i_),See=()=>i_;var fs=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&&uo())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await ST({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Se.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Eee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-test.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var YMe=HMe(import.meta.url),KMe=ps.dirname(YMe),ZMe=WMe(import.meta.url),Zd=ye("shell"),rL=new Set,vee={preferLocal:!0},Cr=(t,e,r)=>{let[n,i]=JMe(e,r),o={...vee,...i},s=hee(t,n,o);Tee(s,o),Aee(s);let a=r?.idleTimeout;return a&&a>0&&wee(s,a),s},bee=(t,e)=>{let r={...vee,...e},n=mee(t,r);return Tee(n,r),Aee(n),e?.idleTimeout&&e.idleTimeout>0&&wee(n,e.idleTimeout),n},JMe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Tee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(hs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Mg).pipe(hs.stdout),t.stderr?.pipe(new Mg).pipe(hs.stderr);return}t.stdout?.pipe(hs.stdout),t.stderr?.pipe(hs.stderr)},nL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(hs.kill(-t.pid,e),Zd.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Zd.error("Error killing process:",r),!1}},xee=t=>nL(t,"SIGKILL"),wee=(t,e)=>{let r=null,n=()=>{Zd.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),nL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zd.log(`Force killing idle process ${t.pid}`),xee(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)},Aee=t=>{rL.add(t);let e=See();if(e){let r=e.onTimesUp(()=>{Zd.log(`Global timer expired, killing process ${t.pid}`),nL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zd.log(`Force killing process ${t.pid} after timeout`),xee(t))},5e3)});t.on("exit",()=>{rL.delete(t),r()}),t.on("error",()=>{rL.delete(t),r()})}};function fo(t,e){if(!hs.env.NETLIFY_LOCAL_MODE)try{let i=ZMe.resolve(Eee.name),o=ps.dirname(i);for(;o!==ps.dirname(o);){let s=ps.dirname(o);if(ps.basename(s)==="node_modules"){let a=ps.join(s,".bin",e);if(Nx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(hs.env.NODE_PATH){let i=ps.join(hs.env.NODE_PATH,".bin",e);if(Nx.existsSync(i))return i}let r=ps.join(t,"node_modules",".bin",e);if(Nx.existsSync(r))return r;let n=ps.join(KMe,"..","node_modules",".bin",e);if(Nx.existsSync(n))return n}var XMe=ye("utils"),QMe=t=>new Promise(e=>{setTimeout(e,t)});var kx=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await QMe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Ia=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Ree=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):XMe.error("Could not parse JSON",n))}},eDe=t=>t.charAt(0).toUpperCase()+t.slice(1),po=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():eDe(e)).join(" ");function ms(t,e){e&&t.log(`Skill invoked: ${e}`)}var Mx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Iee=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var iL=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},tDe=1e4,oL=(t,e=tDe)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as Cee}from"buffer";import rDe from"path";var Pee=ye("repo"),Vr=(t,e={})=>Cr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Dx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Pee.info("Getting runner diffs");let n=await iDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=sDe(o);await aDe(m,r)}Pee.info("Changes after processing"),await aL(r);let s=await lL(o,r);if(await sL(s,r),i=await oDe(r),!i)return{hasChanges:!1,ignored:s};await Vr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Vr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Oee(r),{hasChanges:!1,ignored:s};let u=await Vr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Vr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let y=await Vr(["diff",t.sha,"HEAD","--binary"],a),E=String(y.stdout??"");f!==E&&(p=Cee.from(E).toString("base64"))}await Oee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Cee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Oee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Vr(["reset","--soft","HEAD~1"],{cwd:t})},sL=async(t=[],e=process.cwd())=>{await Vr(["add",".",...t],{cwd:e})},aL=async(t=process.cwd())=>{let e=await Vr(["status","-s"],{cwd:t});return String(e.stdout??"")},Nee=/.. (.+)?\.log$/,nDe=[Nee],iDe=async(t=process.cwd())=>{let e=await aL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
102
|
`).filter(i=>nDe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},oDe=async(t=process.cwd())=>{try{return await Vr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},cL=async(t=process.cwd())=>{let{stdout:e}=await Vr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},kee=async(t=process.cwd())=>{let{stdout:e}=await Vr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},lL=async(t,e=process.cwd())=>{t||=await aL(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
103
103
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${rDe.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Nee)?.[1];o&&n.push(`:!${o}.log`)}),n},uL=async(t=process.cwd())=>{await Vr(["reset","--hard","HEAD"],{cwd:t})},Mee=async(t=process.cwd())=>{let e=await Vr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
104
104
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},sDe=t=>{let e=t.split(`
|
|
@@ -114,7 +114,7 @@ export default defineConfig({
|
|
|
114
114
|
### Step 5: Generate migrations
|
|
115
115
|
|
|
116
116
|
Every time you change the schema, run `drizzle-kit generate` with a `--name` describing the change
|
|
117
|
-
(snake_case, starting with an imperative verb like add, create, drop, alter, rename, index):
|
|
117
|
+
(max 50 characters, snake_case, starting with an imperative verb like add, create, drop, alter, rename, index):
|
|
118
118
|
|
|
119
119
|
```bash
|
|
120
120
|
npx drizzle-kit generate --name add_users_bio
|
package/package.json
CHANGED