@netlify/agent-runner-cli 1.156.0-ask-clarify.2 → 1.156.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin-local.js CHANGED
@@ -99,7 +99,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
99
99
  `,LF:`
100
100
  `,concatBytes:qL},v$e=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},T$e={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:v$e};import{Buffer as b$e}from"buffer";var gre=(t,e)=>t?void 0:A$e.bind(void 0,e),A$e=function*(t,e){if(typeof e!="string"&&!jt(e)&&!b$e.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},_re=(t,e)=>t?x$e.bind(void 0,e):w$e.bind(void 0,e),x$e=function*(t,e){yre(t,e),yield e},w$e=function*(t,e){if(yre(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},yre=(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 R$e}from"buffer";import{StringDecoder as I$e}from"string_decoder";var vx=(t,e,r)=>{if(r)return;if(t)return{transform:C$e.bind(void 0,new TextEncoder)};let n=new I$e(e);return{transform:P$e.bind(void 0,n),final:O$e.bind(void 0,n)}},C$e=function*(t,e){R$e.isBuffer(e)?yield fs(e):typeof e=="string"?yield t.encode(e):yield e},P$e=function*(t,e){yield jt(e)?t.write(e):e},O$e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Sre}from"util";var HL=Sre(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=k$e}=e[r];for await(let i of n(t))yield*Tx(i,e,r+1)},Ere=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*N$e(r,Number(e),t)},N$e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Tx(n,r,e+1)},vre=Sre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),k$e=function*(t){yield t};var WL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Tre=(t,e)=>[...e.flatMap(r=>[...Nl(r,t,0)]),...P_(t)],Nl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=D$e}=e[r];for(let i of n(t))yield*Nl(i,e,r+1)},P_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*M$e(r,Number(e),t)},M$e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Nl(n,r,e+1)},D$e=function*(t){yield t};var YL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Are(t,s,o),l=Ol(e),u=Ol(r),d=l?HL.bind(void 0,Tx,a):WL.bind(void 0,Nl),f=l||u?HL.bind(void 0,Ere,a):WL.bind(void 0,P_),p=l||u?vre.bind(void 0,a):void 0;return{stream:new L$e({writableObjectMode:n,writableHighWaterMark:bre(n),readableObjectMode:i,readableHighWaterMark:bre(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},bx=(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=Are(s,r,a);t=Tre(c,t)}return t},Are=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:gre(n,a)},vx(r,s,n),Ex(r,o,n,c),{transform:t,final:e},{transform:_re(i,a)},mre({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var xre=(t,e)=>{for(let r of $$e(t))U$e(t,r,e)},$$e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),U$e=(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 ${Ma[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>F$e(a,n));r.input=E_(s)},F$e=(t,e)=>{let r=bx(t,e,"utf8",!0);return B$e(r),E_(r)},B$e=t=>{let e=t.find(r=>typeof r!="string"&&!jt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as q$e,appendFileSync as V$e}from"fs";var Ax=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&uf(r,n)&&!_n.has(e)&&j$e(n)&&(t.some(({type:i,value:o})=>i==="native"&&z$e.has(o))||t.every(({type:i})=>Wn.has(i))),j$e=t=>t===1||t===2,z$e=new Set(["pipe","overlapped"]),wre=async(t,e,r,n)=>{for await(let i of t)G$e(e)||Ire(i,r,n)},Rre=(t,e,r)=>{for(let n of t)Ire(n,e,r)},G$e=t=>t._readableState.pipes.length>0,Ire=(t,e,r)=>{let n=UA(t);uo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Cre=({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)=>H$e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},H$e=({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=Pte(t,o,d),p=fs(f),{stdioItems:h,objectMode:m}=e[r],S=W$e([p],h,c,n),{serializedResult:E,finalResult:b=E}=Y$e({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});K$e({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&Z$e(E,h,i),A}catch(y){return n.error=y,A}},W$e=(t,e,r,n)=>{try{return bx(t,e,r,!1)}catch(i){return n.error=i,t}},Y$e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:E_(t)};let s=qQ(t,r);return n[o]?{serializedResult:s,finalResult:VL(s,!i[o],e)}:{serializedResult:s}},K$e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Ax({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=VL(t,!1,s);try{Rre(a,e,n)}catch(c){r.error??=c}},Z$e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>yx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?V$e(n,t):(r.add(o),q$e(n,t))}};var Pre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ms(e,r,"all")]:Array.isArray(e)?[ms(t,r,"all"),...e]:jt(t)&&jt(e)?eL([t,e]):`${t}${e}`};import{once as KL}from"events";var Ore=async(t,e)=>{let[r,n]=await J$e(t);return e.isForcefullyTerminated??=!1,[r,n]},J$e=async t=>{let[e,r]=await Promise.allSettled([KL(t,"spawn"),KL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Nre(t):r.value},Nre=async t=>{try{return await KL(t,"exit")}catch{return Nre(t)}},kre=async t=>{let[e,r]=await t;if(!X$e(e,r)&&ZL(e,r))throw new wi;return[e,r]},X$e=(t,e)=>t===void 0&&e===void 0,ZL=(t,e)=>t!==0||e!==null;var Mre=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=Q$e(t,e,r),s=o?.code==="ETIMEDOUT",a=Cte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},Q$e=(t,e,r)=>t!==void 0?t:ZL(e,r)?new wi:void 0;var Dre=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=t1e(t,e,r),d=i1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Ef(d,c,l)},t1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BA(t,e,r),a=r1e(r),{file:c,commandArguments:l,options:u}=sx(t,e,a);n1e(u);let d=dre(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},r1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,n1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&xx("ipcInput"),t&&xx("ipc: true"),r&&xx("detached: true"),n&&xx("cancelSignal")},xx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},i1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=o1e({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}=Mre(c,r),{output:h,error:m=l}=Cre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,A)=>ms(b,r,A)),E=ms(Pre(h,r),r,"all");return a1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},o1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{xre(o,r);let a=s1e(r);return e1e(...ax(t,e,a))}catch(a){return Sf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},s1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:hx(e)}),a1e=({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?mx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):C_({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 YUe}from"events";import{spawn as KUe}from"child_process";import Bre from"process";import{once as JL,on as c1e}from"events";var Lre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(pf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),l1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),l1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ZA(e,i);let o=ka(t,e,r),s=new AbortController;try{return await Promise.race([u1e(o,n,s),d1e(o,r,s),f1e(o,r,s)])}catch(a){throw hf(t),a}finally{s.abort(),JA(e,i)}},u1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await JL(t,"message",{signal:r});return n}for await(let[n]of c1e(t,"message",{signal:r}))if(e(n))return n},d1e=async(t,e,{signal:r})=>{await JL(t,"disconnect",{signal:r}),Tee(e)},f1e=async(t,e,{signal:r})=>{let[n]=await JL(t,"strict:error",{signal:r});throw WA(n,e)};import{once as Ure,on as p1e}from"events";var Fre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>XL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),XL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{pf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),ZA(e,o);let s=ka(t,e,r),a=new AbortController,c={};return h1e(t,s,a),m1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),g1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},h1e=async(t,e,r)=>{try{await Ure(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},m1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Ure(t,"strict:error",{signal:r.signal});n.error=WA(i,e),r.abort()}catch{}},g1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of p1e(r,"message",{signal:o.signal}))$re(s),yield c}catch{$re(s)}finally{o.abort(),JA(e,a),n||hf(t),i&&await t}},$re=({error:t})=>{if(t)throw t};var jre=(t,{ipc:e})=>{Object.assign(t,Gre(t,!1,e))},zre=()=>{let t=Bre,e=!0,r=Bre.channel!==void 0;return{...Gre(t,e,r),getCancelSignal:Kee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Gre=(t,e,r)=>({sendMessage:ix.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Lre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Fre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as _1e}from"child_process";import{PassThrough as y1e,Readable as S1e,Writable as E1e,Duplex as v1e}from"stream";var qre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{zL(n);let a=new _1e;T1e(a,n),Object.assign(a,{readable:b1e,writable:A1e,duplex:x1e});let c=Sf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=w1e(c,s,i);return{subprocess:a,promise:l}},T1e=(t,e)=>{let r=O_(),n=O_(),i=O_(),o=Array.from({length:e.length-3},O_),s=O_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},O_=()=>{let t=new y1e;return t.end(),t},b1e=()=>new S1e({read(){}}),A1e=()=>new E1e({write(){}}),x1e=()=>new v1e({read(){},write(){}}),w1e=async(t,e,r)=>Ef(t,e,r);import{createReadStream as Vre,createWriteStream as Hre}from"fs";import{Buffer as R1e}from"buffer";import{Readable as N_,Writable as I1e,Duplex as C1e}from"stream";var Yre=(t,e)=>Sx(P1e,t,e,!1),k_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ma[t]}.`)},Wre={fileNumber:k_,generator:YL,asyncGenerator:YL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:C1e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},P1e={input:{...Wre,fileUrl:({value:t})=>({stream:Vre(t)}),filePath:({value:{file:t}})=>({stream:Vre(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(R1e.from(t))})},output:{...Wre,fileUrl:({value:t})=>({stream:Hre(t)}),filePath:({value:{file:t,append:e}})=>({stream:Hre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:I1e.fromWeb(t)}),iterable:k_,asyncIterable:k_,string:k_,uint8Array:k_}};import{on as O1e,once as Kre}from"events";import{PassThrough as N1e,getDefaultHighWaterMark as k1e}from"stream";import{finished as Xre}from"stream/promises";function kl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)e$(i);let e=t.some(({readableObjectMode:i})=>i),r=M1e(t,e),n=new QL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var M1e=(t,e)=>{if(t.length===0)return k1e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},QL=class extends N1e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(e$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=D1e(this,this.#e,this.#o);let r=U1e({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(e$(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)}},D1e=async(t,e,r)=>{wx(t,Zre);let n=new AbortController;try{await Promise.race([L1e(t,n),$1e(t,e,r,n)])}finally{n.abort(),wx(t,-Zre)}},L1e=async(t,{signal:e})=>{try{await Xre(t,{signal:e,cleanup:!0})}catch(r){throw Qre(t,r),r}},$1e=async(t,e,r,{signal:n})=>{for await(let[i]of O1e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},e$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},U1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{wx(t,Jre);let a=new AbortController;try{await Promise.race([F1e(o,e,a),B1e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),j1e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),wx(t,-Jre)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?t$(t):z1e(t))},F1e=async(t,e,{signal:r})=>{try{await t,r.aborted||t$(e)}catch(n){r.aborted||Qre(e,n)}},B1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Xre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;ene(s)?i.add(e):tne(t,s)}},j1e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Kre(t,i,{signal:o}),!t.readable)return Kre(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},z1e=t=>{t.writable&&t.end()},Qre=(t,e)=>{ene(e)?t$(t):tne(t,e)},ene=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",t$=t=>{(t.readable||t.writable)&&t.destroy()},tne=(t,e)=>{t.destroyed||(t.once("error",G1e),t.destroy(e))},G1e=()=>{},wx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Zre=2,Jre=1;import{finished as rne}from"stream/promises";var Tf=(t,e)=>{t.pipe(e),q1e(t,e),V1e(t,e)},q1e=async(t,e)=>{if(!(xi(t)||xi(e))){try{await rne(t,{cleanup:!0,readable:!0,writable:!1})}catch{}r$(e)}},r$=t=>{t.writable&&t.end()},V1e=async(t,e)=>{if(!(xi(t)||xi(e))){try{await rne(e,{cleanup:!0,readable:!1,writable:!0})}catch{}n$(t)}},n$=t=>{t.readable&&t.destroy()};var nne=(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})=>Wn.has(c)))H1e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Wn.has(c)))Y1e({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]:kl(o);Tf(s,i)}},H1e=(t,e,r,n)=>{r==="output"?Tf(t.stdio[n],e):Tf(e,t.stdio[n]);let i=W1e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},W1e=["stdin","stdout","stderr"],Y1e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;K1e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},K1e=(t,{signal:e})=>{xi(t)&&Cl(t,Z1e,e)},Z1e=2;import{addAbortListener as Q1e}from"events";var Ml=[];Ml.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ml.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ml.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Rx=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",i$=Symbol.for("signal-exit emitter"),o$=globalThis,J1e=Object.defineProperty.bind(Object),s$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(o$[i$])return o$[i$];J1e(o$,i$,{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}},Ix=class{},X1e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),a$=class extends Ix{onExit(){return()=>{}}load(){}unload(){}},c$=class extends Ix{#e=l$.platform==="win32"?"SIGINT":"SIGHUP";#r=new s$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ml)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(!Rx(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 Ml)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,Ml.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 Rx(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"&&Rx(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},l$=globalThis.process,{onExit:ine,load:nvt,unload:ivt}=X1e(Rx(l$)?new c$(l$):new a$);var one=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ine(()=>{t.kill()});Q1e(n,()=>{i()})};var ane=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=FA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=eUe(r,n,i),{sourceStream:d,sourceError:f}=rUe(t,l),{options:p,fileDescriptors:h}=po.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},eUe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=tUe(t,e,...r),a=KA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},tUe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(sne,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||XD(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]=CA(r,...n);return{destination:e(sne)(i,o,s),pipeOptions:s}}if(po.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}`)},sne=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),rUe=(t,e)=>{try{return{sourceStream:mf(t,e)}}catch(r){return{sourceError:r}}};var lne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=nUe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw u$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},nUe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return n$(t),n;if(e!==void 0)return r$(r),e},u$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Sf({error:t,command:cne,escapedCommand:cne,fileDescriptors:e,options:r,startTime:n,isSync:!1}),cne="source.pipe(destination)";var une=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 iUe}from"stream/promises";var dne=(t,e,r)=>{let n=Cx.has(e)?sUe(t,e):oUe(t,e);return Cl(t,cUe,r.signal),Cl(e,lUe,r.signal),aUe(e),n},oUe=(t,e)=>{let r=kl([t]);return Tf(r,e),Cx.set(e,r),r},sUe=(t,e)=>{let r=Cx.get(e);return r.add(t),r},aUe=async t=>{try{await iUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Cx.delete(t)},Cx=new WeakMap,cUe=2,lUe=1;import{aborted as uUe}from"util";var fne=(t,e)=>t===void 0?[]:[dUe(t,e)],dUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await uUe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw u$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Px=(t,...e)=>{if(Ot(e[0]))return Px.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ane(t,...e),i=fUe({...n,destination:r});return i.pipe=Px.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},fUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=pUe(t,i);lne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=dne(e,o,d);return await Promise.race([une(u),...fne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},pUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as EUe}from"timers/promises";import{on as hUe}from"events";import{getDefaultHighWaterMark as mUe}from"stream";var Ox=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return gUe(e,s),hne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},gUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},d$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;_Ue(e,s,t);let a=t.readableObjectMode&&!o;return hne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},_Ue=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},hne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=hUe(t,"data",{signal:e.signal,highWaterMark:pne,highWatermark:pne});return yUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},f$=mUe(!0),pne=f$,yUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=SUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Nl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*P_(a)}},SUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[vx(t,r,!e),Ex(t,i,!n,{})].filter(Boolean);var mne=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=vUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([TUe(t),d]);return}let f=GL(c,r),p=d$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([bUe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},vUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Ax({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=d$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await wre(a,t,r,o)},TUe=async t=>{await EUe(),t.readableFlowing===null&&t.resume()},bUe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await dx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await fx(r,{maxBuffer:o})):await yf(r,{maxBuffer:o})}catch(a){return gne(wte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},p$=async t=>{try{return await t}catch(e){return gne(e)}},gne=({bufferedData:t})=>zQ(t)?new Uint8Array(t):t;import{finished as AUe}from"stream/promises";var M_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=xUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],AUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||IUe(a,e,r,n)}finally{s.abort()}},xUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&wUe(t,r,n),n},wUe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{RUe(e,r),n.call(t,...i)}},RUe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},IUe=(t,e,r,n)=>{if(!CUe(t,e,r,n))throw t},CUe=(t,e,r,n=!0)=>r.propagating?_ne(t)||Nx(t):(r.propagating=!0,h$(r,e)===n?_ne(t):Nx(t)),h$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Nx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_ne=t=>t?.code==="EPIPE";var yne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>m$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),m$=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=M_(t,e,l);if(h$(l,e)){await u;return}let[d]=await Promise.all([mne({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 Sne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?kl([t,e].filter(Boolean)):void 0,Ene=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>m$({...PUe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:OUe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),PUe=({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}},OUe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as NUe}from"events";var vne=t=>uf(t,"ipc"),Tne=(t,e)=>{let r=UA(t);uo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var bne=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=vne(o),a=ps(e,"ipc"),c=ps(r,"ipc");for await(let l of XL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Rte(t,i,c),i.push(l)),s&&Tne(l,o);return i},Ane=async(t,e)=>(await Promise.allSettled([t]),e);var xne=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=Ore(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=yne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),x=Ene({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),R=[],C=bne({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),O=kUe(m,t,A),k=MUe(h,A);try{return await Promise.race([Promise.all([{},kre(b),Promise.all(y),x,C,ote(t,d),...O,...k]),S,DUe(t,E),...ete(t,o,f,E),...vee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...Xee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},b,Promise.all(y.map(_=>p$(_))),p$(x),Ane(C,R),Promise.allSettled(O),Promise.allSettled(k)])}},kUe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:M_(n,i,r)),MUe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ii(o,{checkOpen:!1})&&!xi(o)).map(({type:i,value:o,stream:s=o})=>M_(s,n,e,{isSameDirection:Wn.has(i),stopOnExit:i==="native"}))),DUe=async(t,{signal:e})=>{let[r]=await NUe(t,"error",{signal:e});throw r};var wne=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),D_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=fo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},bf=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 LUe}from"stream";import{callbackify as $Ue}from"util";import{finished as Rne}from"stream/promises";var g$=async t=>{if(t!==void 0)try{await _$(t)}catch{}},Ine=async t=>{if(t!==void 0)try{await y$(t)}catch{}},_$=async t=>{await Rne(t,{cleanup:!0,readable:!1,writable:!0})},y$=async t=>{await Rne(t,{cleanup:!0,readable:!0,writable:!1})},kx=async(t,e)=>{if(await t,e)throw e},Mx=(t,e,r)=>{r&&!Nx(r)?t.destroy(r):e&&t.destroy()};var Cne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_n.has(r),{subprocessStdout:a,waitReadableDestroy:c}=S$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=E$(a,s),{read:f,onStdoutDataDone:p}=v$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new LUe({read:f,destroy:$Ue(b$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return T$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},S$=(t,e,r)=>{let n=mf(t,e),i=D_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},E$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:f$},v$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=fo(),s=Ox({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){UUe(this,s,o)},onStdoutDataDone:o}},UUe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},T$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await y$(t),await n,await g$(i),await e,r.readable&&r.push(null)}catch(o){await g$(i),Pne(r,o)}},b$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await bf(r,e)&&(Pne(t,n),await kx(e,n))},Pne=(t,e)=>{Mx(t,t.readable,e)};import{Writable as FUe}from"stream";import{callbackify as One}from"util";var Nne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=A$(t,r,e),s=new FUe({...x$(n,t,i),destroy:One(R$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return w$(n,s),s},A$=(t,e,r)=>{let n=KA(t,e),i=D_(r,n,"writableFinal"),o=D_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},x$=(t,e,r)=>({write:BUe.bind(void 0,t),final:One(jUe.bind(void 0,t,e,r))}),BUe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},jUe=async(t,e,r)=>{await bf(r,e)&&(t.writable&&t.end(),await e)},w$=async(t,e,r)=>{try{await _$(t),e.writable&&e.end()}catch(n){await Ine(r),kne(e,n)}},R$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await bf(r,e),await bf(n,e)&&(kne(t,i),await kx(e,i))},kne=(t,e)=>{Mx(t,t.writable,e)};import{Duplex as zUe}from"stream";import{callbackify as GUe}from"util";var Mne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_n.has(r),{subprocessStdout:c,waitReadableDestroy:l}=S$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=A$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=E$(c,a),{read:S,onStdoutDataDone:E}=v$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new zUe({read:S,...x$(u,t,d),destroy:GUe(qUe.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 T$({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),w$(u,b,c),b},qUe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([b$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),R$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var I$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_n.has(e),s=mf(t,r),a=Ox({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return VUe(a,s,t)},VUe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Dne=(t,{encoding:e})=>{let r=wne();t.readable=Cne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Nne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Mne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=I$.bind(void 0,t,e),t[Symbol.asyncIterator]=I$.bind(void 0,t,e,{})};var Lne=(t,e)=>{for(let[r,n]of WUe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},HUe=(async()=>{})().constructor.prototype,WUe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(HUe,t)]);var $ne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=ZUe(t,e,r),{subprocess:f,promise:p}=XUe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Px.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Lne(f,p),po.set(f,{options:u,fileDescriptors:d}),f},ZUe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BA(t,e,r),{file:a,commandArguments:c,options:l}=sx(t,e,r),u=JUe(l),d=Yre(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},JUe=({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}},XUe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=KUe(...ax(t,e,r))}catch(h){return qre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;YUe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];nne(c,a,l),one(c,r,l);let d={},f=fo();c.kill=See.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Sne(c,r),Dne(c,r),jre(c,r);let p=QUe({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}},QUe=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 xne({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,x)=>ms(y,e,x)),b=ms(m,e,"all"),A=eFe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Ef(A,n,e)},eFe=({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?C_({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 ho,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):mx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Dx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,tFe(n,t[n],i)]));return{...t,...r}},tFe=(t,e,r)=>rFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,rFe=new Set(["env",...iL]);var Da=(t,e,r,n)=>{let i=(s,a,c)=>Da(s,a,r,c),o=(...s)=>nFe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},nFe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Dx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=iFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Dre(a,c,l):$ne(a,c,l,i)},iFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=YQ(e)?KQ(e,r):[e,...r],[s,a,c]=CA(...o),l=Dx(Dx(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 Une=({file:t,commandArguments:e})=>Bne(t,e),Fne=({file:t,commandArguments:e})=>({...Bne(t,e),isSync:!0}),Bne=(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]=oFe(t);return{file:r,commandArguments:n}},oFe=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(sFe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},sFe=/ +/g;var jne=(t,e,r)=>{t.sync=e(aFe,r),t.s=t.sync},zne=({options:t})=>Gne(t),aFe=({options:t})=>({...Gne(t),isSync:!0}),Gne=t=>({options:{...cFe(t),...t}}),cFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},qne={preferLocal:!0};var Vne=Da(()=>({})),Wbt=Da(()=>({isSync:!0})),Hne=Da(Une),Ybt=Da(Fne),Kbt=Da(rte),Zbt=Da(zne,{},qne,jne),{sendMessage:Jbt,getOneMessage:Xbt,getEachMessage:Qbt,getCancelSignal:eAt}=zre();var Wne=!1,Yne=()=>{Wne=!0},go=()=>Wne;var L_=null,Kne=t=>(L_&&L_.destroy(),L_=new gs({totalAllowedTime:t}),L_),Zne=()=>L_;var gs=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&&go())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await TA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{de.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 Jne={name:"@netlify/agent-runner-cli",type:"module",version:"1.156.0-ask-clarify.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.5","@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 fFe=uFe(import.meta.url),pFe=_s.dirname(fFe),hFe=dFe(import.meta.url),Af=pe("shell"),C$=new Set,Xne={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=mFe(e,r),o={...Xne,...i},s=Vne(t,n,o);eie(s,o),nie(s);let a=r?.idleTimeout;return a&&a>0&&rie(s,a),s},Qne=(t,e)=>{let r={...Xne,...e},n=Hne(t,r);return eie(n,r),nie(n),e?.idleTimeout&&e.idleTimeout>0&&rie(n,e.idleTimeout),n},mFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},eie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(ys.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new u_).pipe(ys.stdout),t.stderr?.pipe(new u_).pipe(ys.stderr);return}t.stdout?.pipe(ys.stdout),t.stderr?.pipe(ys.stderr)},P$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ys.kill(-t.pid,e),Af.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Af.error("Error killing process:",r),!1}},tie=t=>P$(t,"SIGKILL"),rie=(t,e)=>{let r=null,n=()=>{Af.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),P$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Af.log(`Force killing idle process ${t.pid}`),tie(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)},nie=t=>{C$.add(t);let e=Zne();if(e){let r=e.onTimesUp(()=>{Af.log(`Global timer expired, killing process ${t.pid}`),P$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Af.log(`Force killing process ${t.pid} after timeout`),tie(t))},5e3)});t.on("exit",()=>{C$.delete(t),r()}),t.on("error",()=>{C$.delete(t),r()})}};function $x(t,e){return!!Ci(t,e)}function Ci(t,e){if(!ys.env.NETLIFY_LOCAL_MODE)try{let i=hFe.resolve(Jne.name),o=_s.dirname(i);for(;o!==_s.dirname(o);){let s=_s.dirname(o);if(_s.basename(s)==="node_modules"){let a=_s.join(s,".bin",e);if(Lx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ys.env.NODE_PATH){let i=_s.join(ys.env.NODE_PATH,".bin",e);if(Lx.existsSync(i))return i}let r=_s.join(t,"node_modules",".bin",e);if(Lx.existsSync(r))return r;let n=_s.join(pFe,"..","node_modules",".bin",e);if(Lx.existsSync(n))return n}var gFe=pe("utils"),_Fe=t=>new Promise(e=>{setTimeout(e,t)});var O$=t=>{try{return new URL(t).hostname||null}catch{return null}},Ux=(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 _Fe(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},La=(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},iie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):gFe.error("Could not parse JSON",n))}},yFe=t=>t.charAt(0).toUpperCase()+t.slice(1),_o=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():yFe(e)).join(" ");function Ss(t,e){e&&t.log(`Skill invoked: ${e}`)}var Fx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),oie=(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 N$=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}},SFe=1e4,k$=(t,e=SFe)=>{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{createHash as EFe}from"crypto";import{createReadStream as vFe}from"fs";import Bx from"fs/promises";import uie from"os";import jx from"path";var sie=pe("repo"),die="runner-diffs-",fie=t=>`${die}${t}-`,pie=async t=>{let e=uie.tmpdir(),r;try{r=await Bx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(die)&&!n.startsWith(fie(t))).map(n=>Bx.rm(jx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xr=(t,e={})=>zt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),zx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{sie.info("Getting runner diffs");let n=await bFe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=xFe(o);await wFe(h,r)}sie.info("Changes after processing"),await D$(r);let s=await L$(o,r);if(await M$(s,r),i=await AFe(r),!i)return{hasChanges:!1,ignored:s};await Xr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Bx.mkdtemp(jx.join(uie.tmpdir(),fie(t.sessionId))),c=async({from:h,to:m,fileName:S,binary:E})=>{let b=jx.join(a,S);await Xr([...E?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:y}=await Bx.stat(b);return{path:b,size:y}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await lie(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await cie(d,h)||(f=h)}await lie(r),de.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await cie(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},aie=async t=>{let e=EFe("sha256");for await(let r of vFe(t))e.update(r);return e.digest("hex")},cie=async(t,e)=>t.size===e.size&&await aie(t.path)===await aie(e.path),lie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xr(["reset","--soft","HEAD~1"],{cwd:t})},M$=async(t=[],e=process.cwd())=>{await Xr(["add",".",...t],{cwd:e})},D$=async(t=process.cwd())=>{let e=await Xr(["status","-s"],{cwd:t});return String(e.stdout??"")},hie=/.. (.+)?\.log$/,TFe=[hie],bFe=async(t=process.cwd())=>{let e=await D$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
102
+ if (condition) { yield value; }`)};import{Buffer as R$e}from"buffer";import{StringDecoder as I$e}from"string_decoder";var vx=(t,e,r)=>{if(r)return;if(t)return{transform:C$e.bind(void 0,new TextEncoder)};let n=new I$e(e);return{transform:P$e.bind(void 0,n),final:O$e.bind(void 0,n)}},C$e=function*(t,e){R$e.isBuffer(e)?yield fs(e):typeof e=="string"?yield t.encode(e):yield e},P$e=function*(t,e){yield jt(e)?t.write(e):e},O$e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Sre}from"util";var HL=Sre(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=k$e}=e[r];for await(let i of n(t))yield*Tx(i,e,r+1)},Ere=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*N$e(r,Number(e),t)},N$e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Tx(n,r,e+1)},vre=Sre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),k$e=function*(t){yield t};var WL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Tre=(t,e)=>[...e.flatMap(r=>[...Nl(r,t,0)]),...P_(t)],Nl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=D$e}=e[r];for(let i of n(t))yield*Nl(i,e,r+1)},P_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*M$e(r,Number(e),t)},M$e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Nl(n,r,e+1)},D$e=function*(t){yield t};var YL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Are(t,s,o),l=Ol(e),u=Ol(r),d=l?HL.bind(void 0,Tx,a):WL.bind(void 0,Nl),f=l||u?HL.bind(void 0,Ere,a):WL.bind(void 0,P_),p=l||u?vre.bind(void 0,a):void 0;return{stream:new L$e({writableObjectMode:n,writableHighWaterMark:bre(n),readableObjectMode:i,readableHighWaterMark:bre(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},bx=(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=Are(s,r,a);t=Tre(c,t)}return t},Are=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:gre(n,a)},vx(r,s,n),Ex(r,o,n,c),{transform:t,final:e},{transform:_re(i,a)},mre({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var xre=(t,e)=>{for(let r of $$e(t))U$e(t,r,e)},$$e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),U$e=(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 ${Ma[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>F$e(a,n));r.input=E_(s)},F$e=(t,e)=>{let r=bx(t,e,"utf8",!0);return B$e(r),E_(r)},B$e=t=>{let e=t.find(r=>typeof r!="string"&&!jt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as q$e,appendFileSync as V$e}from"fs";var Ax=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&uf(r,n)&&!_n.has(e)&&j$e(n)&&(t.some(({type:i,value:o})=>i==="native"&&z$e.has(o))||t.every(({type:i})=>Wn.has(i))),j$e=t=>t===1||t===2,z$e=new Set(["pipe","overlapped"]),wre=async(t,e,r,n)=>{for await(let i of t)G$e(e)||Ire(i,r,n)},Rre=(t,e,r)=>{for(let n of t)Ire(n,e,r)},G$e=t=>t._readableState.pipes.length>0,Ire=(t,e,r)=>{let n=UA(t);uo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Cre=({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)=>H$e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},H$e=({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=Pte(t,o,d),p=fs(f),{stdioItems:h,objectMode:m}=e[r],S=W$e([p],h,c,n),{serializedResult:E,finalResult:b=E}=Y$e({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});K$e({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&Z$e(E,h,i),A}catch(y){return n.error=y,A}},W$e=(t,e,r,n)=>{try{return bx(t,e,r,!1)}catch(i){return n.error=i,t}},Y$e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:E_(t)};let s=qQ(t,r);return n[o]?{serializedResult:s,finalResult:VL(s,!i[o],e)}:{serializedResult:s}},K$e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Ax({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=VL(t,!1,s);try{Rre(a,e,n)}catch(c){r.error??=c}},Z$e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>yx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?V$e(n,t):(r.add(o),q$e(n,t))}};var Pre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ms(e,r,"all")]:Array.isArray(e)?[ms(t,r,"all"),...e]:jt(t)&&jt(e)?eL([t,e]):`${t}${e}`};import{once as KL}from"events";var Ore=async(t,e)=>{let[r,n]=await J$e(t);return e.isForcefullyTerminated??=!1,[r,n]},J$e=async t=>{let[e,r]=await Promise.allSettled([KL(t,"spawn"),KL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Nre(t):r.value},Nre=async t=>{try{return await KL(t,"exit")}catch{return Nre(t)}},kre=async t=>{let[e,r]=await t;if(!X$e(e,r)&&ZL(e,r))throw new wi;return[e,r]},X$e=(t,e)=>t===void 0&&e===void 0,ZL=(t,e)=>t!==0||e!==null;var Mre=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=Q$e(t,e,r),s=o?.code==="ETIMEDOUT",a=Cte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},Q$e=(t,e,r)=>t!==void 0?t:ZL(e,r)?new wi:void 0;var Dre=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=t1e(t,e,r),d=i1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Ef(d,c,l)},t1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BA(t,e,r),a=r1e(r),{file:c,commandArguments:l,options:u}=sx(t,e,a);n1e(u);let d=dre(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},r1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,n1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&xx("ipcInput"),t&&xx("ipc: true"),r&&xx("detached: true"),n&&xx("cancelSignal")},xx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},i1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=o1e({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}=Mre(c,r),{output:h,error:m=l}=Cre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,A)=>ms(b,r,A)),E=ms(Pre(h,r),r,"all");return a1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},o1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{xre(o,r);let a=s1e(r);return e1e(...ax(t,e,a))}catch(a){return Sf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},s1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:hx(e)}),a1e=({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?mx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):C_({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 YUe}from"events";import{spawn as KUe}from"child_process";import Bre from"process";import{once as JL,on as c1e}from"events";var Lre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(pf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),l1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),l1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ZA(e,i);let o=ka(t,e,r),s=new AbortController;try{return await Promise.race([u1e(o,n,s),d1e(o,r,s),f1e(o,r,s)])}catch(a){throw hf(t),a}finally{s.abort(),JA(e,i)}},u1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await JL(t,"message",{signal:r});return n}for await(let[n]of c1e(t,"message",{signal:r}))if(e(n))return n},d1e=async(t,e,{signal:r})=>{await JL(t,"disconnect",{signal:r}),Tee(e)},f1e=async(t,e,{signal:r})=>{let[n]=await JL(t,"strict:error",{signal:r});throw WA(n,e)};import{once as Ure,on as p1e}from"events";var Fre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>XL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),XL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{pf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),ZA(e,o);let s=ka(t,e,r),a=new AbortController,c={};return h1e(t,s,a),m1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),g1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},h1e=async(t,e,r)=>{try{await Ure(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},m1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Ure(t,"strict:error",{signal:r.signal});n.error=WA(i,e),r.abort()}catch{}},g1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of p1e(r,"message",{signal:o.signal}))$re(s),yield c}catch{$re(s)}finally{o.abort(),JA(e,a),n||hf(t),i&&await t}},$re=({error:t})=>{if(t)throw t};var jre=(t,{ipc:e})=>{Object.assign(t,Gre(t,!1,e))},zre=()=>{let t=Bre,e=!0,r=Bre.channel!==void 0;return{...Gre(t,e,r),getCancelSignal:Kee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Gre=(t,e,r)=>({sendMessage:ix.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Lre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Fre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as _1e}from"child_process";import{PassThrough as y1e,Readable as S1e,Writable as E1e,Duplex as v1e}from"stream";var qre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{zL(n);let a=new _1e;T1e(a,n),Object.assign(a,{readable:b1e,writable:A1e,duplex:x1e});let c=Sf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=w1e(c,s,i);return{subprocess:a,promise:l}},T1e=(t,e)=>{let r=O_(),n=O_(),i=O_(),o=Array.from({length:e.length-3},O_),s=O_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},O_=()=>{let t=new y1e;return t.end(),t},b1e=()=>new S1e({read(){}}),A1e=()=>new E1e({write(){}}),x1e=()=>new v1e({read(){},write(){}}),w1e=async(t,e,r)=>Ef(t,e,r);import{createReadStream as Vre,createWriteStream as Hre}from"fs";import{Buffer as R1e}from"buffer";import{Readable as N_,Writable as I1e,Duplex as C1e}from"stream";var Yre=(t,e)=>Sx(P1e,t,e,!1),k_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ma[t]}.`)},Wre={fileNumber:k_,generator:YL,asyncGenerator:YL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:C1e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},P1e={input:{...Wre,fileUrl:({value:t})=>({stream:Vre(t)}),filePath:({value:{file:t}})=>({stream:Vre(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(R1e.from(t))})},output:{...Wre,fileUrl:({value:t})=>({stream:Hre(t)}),filePath:({value:{file:t,append:e}})=>({stream:Hre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:I1e.fromWeb(t)}),iterable:k_,asyncIterable:k_,string:k_,uint8Array:k_}};import{on as O1e,once as Kre}from"events";import{PassThrough as N1e,getDefaultHighWaterMark as k1e}from"stream";import{finished as Xre}from"stream/promises";function kl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)e$(i);let e=t.some(({readableObjectMode:i})=>i),r=M1e(t,e),n=new QL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var M1e=(t,e)=>{if(t.length===0)return k1e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},QL=class extends N1e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(e$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=D1e(this,this.#e,this.#o);let r=U1e({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(e$(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)}},D1e=async(t,e,r)=>{wx(t,Zre);let n=new AbortController;try{await Promise.race([L1e(t,n),$1e(t,e,r,n)])}finally{n.abort(),wx(t,-Zre)}},L1e=async(t,{signal:e})=>{try{await Xre(t,{signal:e,cleanup:!0})}catch(r){throw Qre(t,r),r}},$1e=async(t,e,r,{signal:n})=>{for await(let[i]of O1e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},e$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},U1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{wx(t,Jre);let a=new AbortController;try{await Promise.race([F1e(o,e,a),B1e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),j1e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),wx(t,-Jre)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?t$(t):z1e(t))},F1e=async(t,e,{signal:r})=>{try{await t,r.aborted||t$(e)}catch(n){r.aborted||Qre(e,n)}},B1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Xre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;ene(s)?i.add(e):tne(t,s)}},j1e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Kre(t,i,{signal:o}),!t.readable)return Kre(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},z1e=t=>{t.writable&&t.end()},Qre=(t,e)=>{ene(e)?t$(t):tne(t,e)},ene=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",t$=t=>{(t.readable||t.writable)&&t.destroy()},tne=(t,e)=>{t.destroyed||(t.once("error",G1e),t.destroy(e))},G1e=()=>{},wx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Zre=2,Jre=1;import{finished as rne}from"stream/promises";var Tf=(t,e)=>{t.pipe(e),q1e(t,e),V1e(t,e)},q1e=async(t,e)=>{if(!(xi(t)||xi(e))){try{await rne(t,{cleanup:!0,readable:!0,writable:!1})}catch{}r$(e)}},r$=t=>{t.writable&&t.end()},V1e=async(t,e)=>{if(!(xi(t)||xi(e))){try{await rne(e,{cleanup:!0,readable:!1,writable:!0})}catch{}n$(t)}},n$=t=>{t.readable&&t.destroy()};var nne=(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})=>Wn.has(c)))H1e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Wn.has(c)))Y1e({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]:kl(o);Tf(s,i)}},H1e=(t,e,r,n)=>{r==="output"?Tf(t.stdio[n],e):Tf(e,t.stdio[n]);let i=W1e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},W1e=["stdin","stdout","stderr"],Y1e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;K1e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},K1e=(t,{signal:e})=>{xi(t)&&Cl(t,Z1e,e)},Z1e=2;import{addAbortListener as Q1e}from"events";var Ml=[];Ml.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ml.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ml.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Rx=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",i$=Symbol.for("signal-exit emitter"),o$=globalThis,J1e=Object.defineProperty.bind(Object),s$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(o$[i$])return o$[i$];J1e(o$,i$,{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}},Ix=class{},X1e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),a$=class extends Ix{onExit(){return()=>{}}load(){}unload(){}},c$=class extends Ix{#e=l$.platform==="win32"?"SIGINT":"SIGHUP";#r=new s$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ml)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(!Rx(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 Ml)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,Ml.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 Rx(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"&&Rx(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},l$=globalThis.process,{onExit:ine,load:nvt,unload:ivt}=X1e(Rx(l$)?new c$(l$):new a$);var one=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ine(()=>{t.kill()});Q1e(n,()=>{i()})};var ane=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=FA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=eUe(r,n,i),{sourceStream:d,sourceError:f}=rUe(t,l),{options:p,fileDescriptors:h}=po.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},eUe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=tUe(t,e,...r),a=KA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},tUe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(sne,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||XD(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]=CA(r,...n);return{destination:e(sne)(i,o,s),pipeOptions:s}}if(po.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}`)},sne=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),rUe=(t,e)=>{try{return{sourceStream:mf(t,e)}}catch(r){return{sourceError:r}}};var lne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=nUe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw u$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},nUe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return n$(t),n;if(e!==void 0)return r$(r),e},u$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Sf({error:t,command:cne,escapedCommand:cne,fileDescriptors:e,options:r,startTime:n,isSync:!1}),cne="source.pipe(destination)";var une=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 iUe}from"stream/promises";var dne=(t,e,r)=>{let n=Cx.has(e)?sUe(t,e):oUe(t,e);return Cl(t,cUe,r.signal),Cl(e,lUe,r.signal),aUe(e),n},oUe=(t,e)=>{let r=kl([t]);return Tf(r,e),Cx.set(e,r),r},sUe=(t,e)=>{let r=Cx.get(e);return r.add(t),r},aUe=async t=>{try{await iUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Cx.delete(t)},Cx=new WeakMap,cUe=2,lUe=1;import{aborted as uUe}from"util";var fne=(t,e)=>t===void 0?[]:[dUe(t,e)],dUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await uUe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw u$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Px=(t,...e)=>{if(Ot(e[0]))return Px.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ane(t,...e),i=fUe({...n,destination:r});return i.pipe=Px.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},fUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=pUe(t,i);lne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=dne(e,o,d);return await Promise.race([une(u),...fne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},pUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as EUe}from"timers/promises";import{on as hUe}from"events";import{getDefaultHighWaterMark as mUe}from"stream";var Ox=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return gUe(e,s),hne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},gUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},d$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;_Ue(e,s,t);let a=t.readableObjectMode&&!o;return hne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},_Ue=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},hne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=hUe(t,"data",{signal:e.signal,highWaterMark:pne,highWatermark:pne});return yUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},f$=mUe(!0),pne=f$,yUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=SUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Nl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*P_(a)}},SUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[vx(t,r,!e),Ex(t,i,!n,{})].filter(Boolean);var mne=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=vUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([TUe(t),d]);return}let f=GL(c,r),p=d$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([bUe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},vUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Ax({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=d$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await wre(a,t,r,o)},TUe=async t=>{await EUe(),t.readableFlowing===null&&t.resume()},bUe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await dx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await fx(r,{maxBuffer:o})):await yf(r,{maxBuffer:o})}catch(a){return gne(wte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},p$=async t=>{try{return await t}catch(e){return gne(e)}},gne=({bufferedData:t})=>zQ(t)?new Uint8Array(t):t;import{finished as AUe}from"stream/promises";var M_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=xUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],AUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||IUe(a,e,r,n)}finally{s.abort()}},xUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&wUe(t,r,n),n},wUe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{RUe(e,r),n.call(t,...i)}},RUe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},IUe=(t,e,r,n)=>{if(!CUe(t,e,r,n))throw t},CUe=(t,e,r,n=!0)=>r.propagating?_ne(t)||Nx(t):(r.propagating=!0,h$(r,e)===n?_ne(t):Nx(t)),h$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Nx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_ne=t=>t?.code==="EPIPE";var yne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>m$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),m$=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=M_(t,e,l);if(h$(l,e)){await u;return}let[d]=await Promise.all([mne({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 Sne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?kl([t,e].filter(Boolean)):void 0,Ene=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>m$({...PUe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:OUe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),PUe=({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}},OUe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as NUe}from"events";var vne=t=>uf(t,"ipc"),Tne=(t,e)=>{let r=UA(t);uo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var bne=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=vne(o),a=ps(e,"ipc"),c=ps(r,"ipc");for await(let l of XL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Rte(t,i,c),i.push(l)),s&&Tne(l,o);return i},Ane=async(t,e)=>(await Promise.allSettled([t]),e);var xne=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=Ore(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=yne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),x=Ene({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),R=[],C=bne({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),O=kUe(m,t,A),k=MUe(h,A);try{return await Promise.race([Promise.all([{},kre(b),Promise.all(y),x,C,ote(t,d),...O,...k]),S,DUe(t,E),...ete(t,o,f,E),...vee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...Xee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},b,Promise.all(y.map(_=>p$(_))),p$(x),Ane(C,R),Promise.allSettled(O),Promise.allSettled(k)])}},kUe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:M_(n,i,r)),MUe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ii(o,{checkOpen:!1})&&!xi(o)).map(({type:i,value:o,stream:s=o})=>M_(s,n,e,{isSameDirection:Wn.has(i),stopOnExit:i==="native"}))),DUe=async(t,{signal:e})=>{let[r]=await NUe(t,"error",{signal:e});throw r};var wne=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),D_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=fo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},bf=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 LUe}from"stream";import{callbackify as $Ue}from"util";import{finished as Rne}from"stream/promises";var g$=async t=>{if(t!==void 0)try{await _$(t)}catch{}},Ine=async t=>{if(t!==void 0)try{await y$(t)}catch{}},_$=async t=>{await Rne(t,{cleanup:!0,readable:!1,writable:!0})},y$=async t=>{await Rne(t,{cleanup:!0,readable:!0,writable:!1})},kx=async(t,e)=>{if(await t,e)throw e},Mx=(t,e,r)=>{r&&!Nx(r)?t.destroy(r):e&&t.destroy()};var Cne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_n.has(r),{subprocessStdout:a,waitReadableDestroy:c}=S$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=E$(a,s),{read:f,onStdoutDataDone:p}=v$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new LUe({read:f,destroy:$Ue(b$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return T$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},S$=(t,e,r)=>{let n=mf(t,e),i=D_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},E$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:f$},v$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=fo(),s=Ox({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){UUe(this,s,o)},onStdoutDataDone:o}},UUe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},T$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await y$(t),await n,await g$(i),await e,r.readable&&r.push(null)}catch(o){await g$(i),Pne(r,o)}},b$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await bf(r,e)&&(Pne(t,n),await kx(e,n))},Pne=(t,e)=>{Mx(t,t.readable,e)};import{Writable as FUe}from"stream";import{callbackify as One}from"util";var Nne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=A$(t,r,e),s=new FUe({...x$(n,t,i),destroy:One(R$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return w$(n,s),s},A$=(t,e,r)=>{let n=KA(t,e),i=D_(r,n,"writableFinal"),o=D_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},x$=(t,e,r)=>({write:BUe.bind(void 0,t),final:One(jUe.bind(void 0,t,e,r))}),BUe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},jUe=async(t,e,r)=>{await bf(r,e)&&(t.writable&&t.end(),await e)},w$=async(t,e,r)=>{try{await _$(t),e.writable&&e.end()}catch(n){await Ine(r),kne(e,n)}},R$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await bf(r,e),await bf(n,e)&&(kne(t,i),await kx(e,i))},kne=(t,e)=>{Mx(t,t.writable,e)};import{Duplex as zUe}from"stream";import{callbackify as GUe}from"util";var Mne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_n.has(r),{subprocessStdout:c,waitReadableDestroy:l}=S$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=A$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=E$(c,a),{read:S,onStdoutDataDone:E}=v$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new zUe({read:S,...x$(u,t,d),destroy:GUe(qUe.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 T$({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),w$(u,b,c),b},qUe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([b$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),R$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var I$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_n.has(e),s=mf(t,r),a=Ox({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return VUe(a,s,t)},VUe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Dne=(t,{encoding:e})=>{let r=wne();t.readable=Cne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Nne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Mne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=I$.bind(void 0,t,e),t[Symbol.asyncIterator]=I$.bind(void 0,t,e,{})};var Lne=(t,e)=>{for(let[r,n]of WUe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},HUe=(async()=>{})().constructor.prototype,WUe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(HUe,t)]);var $ne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=ZUe(t,e,r),{subprocess:f,promise:p}=XUe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Px.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Lne(f,p),po.set(f,{options:u,fileDescriptors:d}),f},ZUe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BA(t,e,r),{file:a,commandArguments:c,options:l}=sx(t,e,r),u=JUe(l),d=Yre(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},JUe=({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}},XUe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=KUe(...ax(t,e,r))}catch(h){return qre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;YUe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];nne(c,a,l),one(c,r,l);let d={},f=fo();c.kill=See.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Sne(c,r),Dne(c,r),jre(c,r);let p=QUe({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}},QUe=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 xne({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,x)=>ms(y,e,x)),b=ms(m,e,"all"),A=eFe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Ef(A,n,e)},eFe=({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?C_({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 ho,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):mx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Dx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,tFe(n,t[n],i)]));return{...t,...r}},tFe=(t,e,r)=>rFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,rFe=new Set(["env",...iL]);var Da=(t,e,r,n)=>{let i=(s,a,c)=>Da(s,a,r,c),o=(...s)=>nFe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},nFe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Dx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=iFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Dre(a,c,l):$ne(a,c,l,i)},iFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=YQ(e)?KQ(e,r):[e,...r],[s,a,c]=CA(...o),l=Dx(Dx(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 Une=({file:t,commandArguments:e})=>Bne(t,e),Fne=({file:t,commandArguments:e})=>({...Bne(t,e),isSync:!0}),Bne=(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]=oFe(t);return{file:r,commandArguments:n}},oFe=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(sFe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},sFe=/ +/g;var jne=(t,e,r)=>{t.sync=e(aFe,r),t.s=t.sync},zne=({options:t})=>Gne(t),aFe=({options:t})=>({...Gne(t),isSync:!0}),Gne=t=>({options:{...cFe(t),...t}}),cFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},qne={preferLocal:!0};var Vne=Da(()=>({})),Wbt=Da(()=>({isSync:!0})),Hne=Da(Une),Ybt=Da(Fne),Kbt=Da(rte),Zbt=Da(zne,{},qne,jne),{sendMessage:Jbt,getOneMessage:Xbt,getEachMessage:Qbt,getCancelSignal:eAt}=zre();var Wne=!1,Yne=()=>{Wne=!0},go=()=>Wne;var L_=null,Kne=t=>(L_&&L_.destroy(),L_=new gs({totalAllowedTime:t}),L_),Zne=()=>L_;var gs=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&&go())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await TA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{de.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 Jne={name:"@netlify/agent-runner-cli",type:"module",version:"1.156.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.5","@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 fFe=uFe(import.meta.url),pFe=_s.dirname(fFe),hFe=dFe(import.meta.url),Af=pe("shell"),C$=new Set,Xne={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=mFe(e,r),o={...Xne,...i},s=Vne(t,n,o);eie(s,o),nie(s);let a=r?.idleTimeout;return a&&a>0&&rie(s,a),s},Qne=(t,e)=>{let r={...Xne,...e},n=Hne(t,r);return eie(n,r),nie(n),e?.idleTimeout&&e.idleTimeout>0&&rie(n,e.idleTimeout),n},mFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},eie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(ys.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new u_).pipe(ys.stdout),t.stderr?.pipe(new u_).pipe(ys.stderr);return}t.stdout?.pipe(ys.stdout),t.stderr?.pipe(ys.stderr)},P$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ys.kill(-t.pid,e),Af.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Af.error("Error killing process:",r),!1}},tie=t=>P$(t,"SIGKILL"),rie=(t,e)=>{let r=null,n=()=>{Af.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),P$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Af.log(`Force killing idle process ${t.pid}`),tie(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)},nie=t=>{C$.add(t);let e=Zne();if(e){let r=e.onTimesUp(()=>{Af.log(`Global timer expired, killing process ${t.pid}`),P$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Af.log(`Force killing process ${t.pid} after timeout`),tie(t))},5e3)});t.on("exit",()=>{C$.delete(t),r()}),t.on("error",()=>{C$.delete(t),r()})}};function $x(t,e){return!!Ci(t,e)}function Ci(t,e){if(!ys.env.NETLIFY_LOCAL_MODE)try{let i=hFe.resolve(Jne.name),o=_s.dirname(i);for(;o!==_s.dirname(o);){let s=_s.dirname(o);if(_s.basename(s)==="node_modules"){let a=_s.join(s,".bin",e);if(Lx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ys.env.NODE_PATH){let i=_s.join(ys.env.NODE_PATH,".bin",e);if(Lx.existsSync(i))return i}let r=_s.join(t,"node_modules",".bin",e);if(Lx.existsSync(r))return r;let n=_s.join(pFe,"..","node_modules",".bin",e);if(Lx.existsSync(n))return n}var gFe=pe("utils"),_Fe=t=>new Promise(e=>{setTimeout(e,t)});var O$=t=>{try{return new URL(t).hostname||null}catch{return null}},Ux=(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 _Fe(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},La=(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},iie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):gFe.error("Could not parse JSON",n))}},yFe=t=>t.charAt(0).toUpperCase()+t.slice(1),_o=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():yFe(e)).join(" ");function Ss(t,e){e&&t.log(`Skill invoked: ${e}`)}var Fx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),oie=(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 N$=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}},SFe=1e4,k$=(t,e=SFe)=>{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{createHash as EFe}from"crypto";import{createReadStream as vFe}from"fs";import Bx from"fs/promises";import uie from"os";import jx from"path";var sie=pe("repo"),die="runner-diffs-",fie=t=>`${die}${t}-`,pie=async t=>{let e=uie.tmpdir(),r;try{r=await Bx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(die)&&!n.startsWith(fie(t))).map(n=>Bx.rm(jx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xr=(t,e={})=>zt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),zx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{sie.info("Getting runner diffs");let n=await bFe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=xFe(o);await wFe(h,r)}sie.info("Changes after processing"),await D$(r);let s=await L$(o,r);if(await M$(s,r),i=await AFe(r),!i)return{hasChanges:!1,ignored:s};await Xr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Bx.mkdtemp(jx.join(uie.tmpdir(),fie(t.sessionId))),c=async({from:h,to:m,fileName:S,binary:E})=>{let b=jx.join(a,S);await Xr([...E?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:y}=await Bx.stat(b);return{path:b,size:y}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await lie(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await cie(d,h)||(f=h)}await lie(r),de.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await cie(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},aie=async t=>{let e=EFe("sha256");for await(let r of vFe(t))e.update(r);return e.digest("hex")},cie=async(t,e)=>t.size===e.size&&await aie(t.path)===await aie(e.path),lie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xr(["reset","--soft","HEAD~1"],{cwd:t})},M$=async(t=[],e=process.cwd())=>{await Xr(["add",".",...t],{cwd:e})},D$=async(t=process.cwd())=>{let e=await Xr(["status","-s"],{cwd:t});return String(e.stdout??"")},hie=/.. (.+)?\.log$/,TFe=[hie],bFe=async(t=process.cwd())=>{let e=await D$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
103
103
  `).filter(i=>TFe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},AFe=async(t=process.cwd())=>{try{return await Xr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},$_=async(t=process.cwd())=>{let{stdout:e}=await Xr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},mie=async(t=process.cwd())=>{let{stdout:e}=await Xr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},L$=async(t,e=process.cwd())=>{t||=await D$(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}${jx.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(hie)?.[1];o&&n.push(`:!${o}.log`)}),n},gie=async(t=process.cwd())=>{await Xr(["reset","--hard","HEAD"],{cwd:t})},_ie=async(t=process.cwd())=>{let e=await Xr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
105
105
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},xFe=t=>{let e=t.split(`
package/dist/bin.js CHANGED
@@ -587,7 +587,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
587
587
  `,LF:`
588
588
  `,concatBytes:w3},SSt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},ESt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:SSt};import{Buffer as vSt}from"buffer";var wTe=(t,e)=>t?void 0:bSt.bind(void 0,e),bSt=function*(t,e){if(typeof e!="string"&&!Cr(e)&&!vSt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},ATe=(t,e)=>t?TSt.bind(void 0,e):wSt.bind(void 0,e),TSt=function*(t,e){RTe(t,e),yield e},wSt=function*(t,e){if(RTe(t,e),typeof e!="string"&&!Cr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},RTe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
589
589
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
590
- if (condition) { yield value; }`)};import{Buffer as ASt}from"buffer";import{StringDecoder as RSt}from"string_decoder";var AC=(t,e,r)=>{if(r)return;if(t)return{transform:xSt.bind(void 0,new TextEncoder)};let n=new RSt(e);return{transform:ISt.bind(void 0,n),final:OSt.bind(void 0,n)}},xSt=function*(t,e){ASt.isBuffer(e)?yield bc(e):typeof e=="string"?yield t.encode(e):yield e},ISt=function*(t,e){yield Cr(e)?t.write(e):e},OSt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as xTe}from"util";var R3=xTe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),RC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=CSt}=e[r];for await(let i of n(t))yield*RC(i,e,r+1)},ITe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*PSt(r,Number(e),t)},PSt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*RC(n,r,e+1)},OTe=xTe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),CSt=function*(t){yield t};var x3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},PTe=(t,e)=>[...e.flatMap(r=>[...zf(r,t,0)]),...Kb(t)],zf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=kSt}=e[r];for(let i of n(t))yield*zf(i,e,r+1)},Kb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*NSt(r,Number(e),t)},NSt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*zf(n,r,e+1)},kSt=function*(t){yield t};var I3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=NTe(t,o,s),l=Bf(e),u=Bf(r),d=l?R3.bind(void 0,RC,a):x3.bind(void 0,zf),f=l||u?R3.bind(void 0,ITe,a):x3.bind(void 0,Kb),p=l||u?OTe.bind(void 0,a):void 0;return{stream:new $St({writableObjectMode:n,writableHighWaterMark:CTe(n),readableObjectMode:i,readableHighWaterMark:CTe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},xC=(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=NTe(o,r,a);t=PTe(c,t)}return t},NTe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:wTe(n,a)},AC(r,o,n),wC(r,s,n,c),{transform:t,final:e},{transform:ATe(i,a)},TTe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var kTe=(t,e)=>{for(let r of LSt(t))DSt(t,r,e)},LSt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),DSt=(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 ${Au[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>MSt(a,n));r.input=Fb(o)},MSt=(t,e)=>{let r=xC(t,e,"utf8",!0);return USt(r),Fb(r)},USt=t=>{let e=t.find(r=>typeof r!="string"&&!Cr(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 BSt,appendFileSync as zSt}from"fs";var IC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&$g(r,n)&&!Ui.has(e)&&FSt(n)&&(t.some(({type:i,value:s})=>i==="native"&&jSt.has(s))||t.every(({type:i})=>bs.has(i))),FSt=t=>t===1||t===2,jSt=new Set(["pipe","overlapped"]),$Te=async(t,e,r,n)=>{for await(let i of t)qSt(e)||DTe(i,r,n)},LTe=(t,e,r)=>{for(let n of t)DTe(n,e,r)},qSt=t=>t._readableState.pipes.length>0,DTe=(t,e,r)=>{let n=BP(t);na({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var MTe=({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)=>VSt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},VSt=({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=Ube(t,s,d),p=bc(f),{stdioItems:h,objectMode:m}=e[r],_=HSt([p],h,c,n),{serializedResult:y,finalResult:v=y}=GSt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});WSt({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&&YSt(y,h,i),S}catch(g){return n.error=g,S}},HSt=(t,e,r,n)=>{try{return xC(t,e,r,!1)}catch(i){return n.error=i,t}},GSt=({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=XSe(t,r);return n[s]?{serializedResult:o,finalResult:A3(o,!i[s],e)}:{serializedResult:o}},WSt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!IC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=A3(t,!1,o);try{LTe(a,e,n)}catch(c){r.error??=c}},YSt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>bC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?zSt(n,t):(r.add(s),BSt(n,t))}};var UTe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ac(e,r,"all")]:Array.isArray(e)?[Ac(t,r,"all"),...e]:Cr(t)&&Cr(e)?$6([t,e]):`${t}${e}`};import{once as O3}from"events";var FTe=async(t,e)=>{let[r,n]=await KSt(t);return e.isForcefullyTerminated??=!1,[r,n]},KSt=async t=>{let[e,r]=await Promise.allSettled([O3(t,"spawn"),O3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?jTe(t):r.value},jTe=async t=>{try{return await O3(t,"exit")}catch{return jTe(t)}},qTe=async t=>{let[e,r]=await t;if(!JSt(e,r)&&P3(e,r))throw new no;return[e,r]},JSt=(t,e)=>t===void 0&&e===void 0,P3=(t,e)=>t!==0||e!==null;var BTe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ZSt(t,e,r),o=s?.code==="ETIMEDOUT",a=Mbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ZSt=(t,e,r)=>t!==void 0?t:P3(e,r)?new no:void 0;var zTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=QSt(t,e,r),d=rEt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Vg(d,c,l)},QSt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=VP(t,e,r),a=eEt(r),{file:c,commandArguments:l,options:u}=uC(t,e,a);tEt(u);let d=STe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},eEt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,tEt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&OC("ipcInput"),t&&OC("ipc: true"),r&&OC("detached: true"),n&&OC("cancelSignal")},OC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},rEt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=nEt({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}=BTe(c,r),{output:h,error:m=l}=MTe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>Ac(v,r,S)),y=Ac(UTe(h,r),r,"all");return sEt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},nEt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{kTe(s,r);let a=iEt(r);return XSt(...dC(t,e,a))}catch(a){return zg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},iEt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:yC(e)}),sEt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?SC({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Yb({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 Gvt}from"events";import{spawn as Wvt}from"child_process";import YTe from"process";import{once as C3,on as oEt}from"events";var VTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Mg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:iC(t)}),aEt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),aEt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{eC(e,i);let s=wu(t,e,r),o=new AbortController;try{return await Promise.race([cEt(s,n,o),lEt(s,r,o),uEt(s,r,o)])}catch(a){throw Ug(t),a}finally{o.abort(),tC(e,i)}},cEt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await C3(t,"message",{signal:r});return n}for await(let[n]of oEt(t,"message",{signal:r}))if(e(n))return n},lEt=async(t,e,{signal:r})=>{await C3(t,"disconnect",{signal:r}),Pve(e)},uEt=async(t,e,{signal:r})=>{let[n]=await C3(t,"strict:error",{signal:r});throw ZP(n,e)};import{once as GTe,on as dEt}from"events";var WTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>N3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),N3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Mg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:iC(t)}),eC(e,s);let o=wu(t,e,r),a=new AbortController,c={};return fEt(t,o,a),pEt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),hEt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},fEt=async(t,e,r)=>{try{await GTe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},pEt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await GTe(t,"strict:error",{signal:r.signal});n.error=ZP(i,e),r.abort()}catch{}},hEt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of dEt(r,"message",{signal:s.signal}))HTe(o),yield c}catch{HTe(o)}finally{s.abort(),tC(e,a),n||Ug(t),i&&await t}},HTe=({error:t})=>{if(t)throw t};var KTe=(t,{ipc:e})=>{Object.assign(t,ZTe(t,!1,e))},JTe=()=>{let t=YTe,e=!0,r=YTe.channel!==void 0;return{...ZTe(t,e,r),getCancelSignal:nbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ZTe=(t,e,r)=>({sendMessage:cC.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:VTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:WTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as mEt}from"child_process";import{PassThrough as gEt,Readable as _Et,Writable as yEt,Duplex as SEt}from"stream";var XTe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{b3(n);let a=new mEt;EEt(a,n),Object.assign(a,{readable:vEt,writable:bEt,duplex:TEt});let c=zg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=wEt(c,o,i);return{subprocess:a,promise:l}},EEt=(t,e)=>{let r=Jb(),n=Jb(),i=Jb(),s=Array.from({length:e.length-3},Jb),o=Jb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Jb=()=>{let t=new gEt;return t.end(),t},vEt=()=>new _Et({read(){}}),bEt=()=>new yEt({write(){}}),TEt=()=>new SEt({read(){},write(){}}),wEt=async(t,e,r)=>Vg(t,e,r);import{createReadStream as QTe,createWriteStream as ewe}from"fs";import{Buffer as AEt}from"buffer";import{Readable as Zb,Writable as REt,Duplex as xEt}from"stream";var rwe=(t,e)=>TC(IEt,t,e,!1),Xb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Au[t]}.`)},twe={fileNumber:Xb,generator:I3,asyncGenerator:I3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:xEt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},IEt={input:{...twe,fileUrl:({value:t})=>({stream:QTe(t)}),filePath:({value:{file:t}})=>({stream:QTe(t)}),webStream:({value:t})=>({stream:Zb.fromWeb(t)}),iterable:({value:t})=>({stream:Zb.from(t)}),asyncIterable:({value:t})=>({stream:Zb.from(t)}),string:({value:t})=>({stream:Zb.from(t)}),uint8Array:({value:t})=>({stream:Zb.from(AEt.from(t))})},output:{...twe,fileUrl:({value:t})=>({stream:ewe(t)}),filePath:({value:{file:t,append:e}})=>({stream:ewe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:REt.fromWeb(t)}),iterable:Xb,asyncIterable:Xb,string:Xb,uint8Array:Xb}};import{on as OEt,once as nwe}from"events";import{PassThrough as PEt,getDefaultHighWaterMark as CEt}from"stream";import{finished as owe}from"stream/promises";function Vf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)$3(i);let e=t.some(({readableObjectMode:i})=>i),r=NEt(t,e),n=new k3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var NEt=(t,e)=>{if(t.length===0)return CEt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},k3=class extends PEt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if($3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=kEt(this,this.#e,this.#s);let r=DEt({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($3(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)}},kEt=async(t,e,r)=>{PC(t,iwe);let n=new AbortController;try{await Promise.race([$Et(t,n),LEt(t,e,r,n)])}finally{n.abort(),PC(t,-iwe)}},$Et=async(t,{signal:e})=>{try{await owe(t,{signal:e,cleanup:!0})}catch(r){throw awe(t,r),r}},LEt=async(t,e,r,{signal:n})=>{for await(let[i]of OEt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},$3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},DEt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{PC(t,swe);let a=new AbortController;try{await Promise.race([MEt(s,e,a),UEt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),FEt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),PC(t,-swe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?L3(t):jEt(t))},MEt=async(t,e,{signal:r})=>{try{await t,r.aborted||L3(e)}catch(n){r.aborted||awe(e,n)}},UEt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await owe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;cwe(o)?i.add(e):lwe(t,o)}},FEt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await nwe(t,i,{signal:s}),!t.readable)return nwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},jEt=t=>{t.writable&&t.end()},awe=(t,e)=>{cwe(e)?L3(t):lwe(t,e)},cwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",L3=t=>{(t.readable||t.writable)&&t.destroy()},lwe=(t,e)=>{t.destroyed||(t.once("error",qEt),t.destroy(e))},qEt=()=>{},PC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},iwe=2,swe=1;import{finished as uwe}from"stream/promises";var Gg=(t,e)=>{t.pipe(e),BEt(t,e),zEt(t,e)},BEt=async(t,e)=>{if(!(ro(t)||ro(e))){try{await uwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}D3(e)}},D3=t=>{t.writable&&t.end()},zEt=async(t,e)=>{if(!(ro(t)||ro(e))){try{await uwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}M3(t)}},M3=t=>{t.readable&&t.destroy()};var dwe=(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})=>bs.has(c)))VEt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!bs.has(c)))GEt({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]:Vf(s);Gg(o,i)}},VEt=(t,e,r,n)=>{r==="output"?Gg(t.stdio[n],e):Gg(e,t.stdio[n]);let i=HEt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},HEt=["stdin","stdout","stderr"],GEt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;WEt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},WEt=(t,{signal:e})=>{ro(t)&&jf(t,YEt,e)},YEt=2;import{addAbortListener as ZEt}from"events";var Hf=[];Hf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Hf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Hf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var CC=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",U3=Symbol.for("signal-exit emitter"),F3=globalThis,KEt=Object.defineProperty.bind(Object),j3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(F3[U3])return F3[U3];KEt(F3,U3,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},NC=class{},JEt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),q3=class extends NC{onExit(){return()=>{}}load(){}unload(){}},B3=class extends NC{#e=z3.platform==="win32"?"SIGINT":"SIGHUP";#r=new j3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Hf)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(!CC(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 Hf)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,Hf.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 CC(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"&&CC(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)}},z3=globalThis.process,{onExit:fwe,load:eur,unload:tur}=JEt(CC(z3)?new B3(z3):new q3);var pwe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=fwe(()=>{t.kill()});ZEt(n,()=>{i()})};var mwe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=zP(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=XEt(r,n,i),{sourceStream:d,sourceError:f}=evt(t,l),{options:p,fileDescriptors:h}=sa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},XEt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=QEt(t,e,...r),a=QP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},QEt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(hwe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||N6(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]=kP(r,...n);return{destination:e(hwe)(i,s,o),pipeOptions:o}}if(sa.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}`)},hwe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),evt=(t,e)=>{try{return{sourceStream:Fg(t,e)}}catch(r){return{sourceError:r}}};var _we=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=tvt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw V3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},tvt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return M3(t),n;if(e!==void 0)return D3(r),e},V3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>zg({error:t,command:gwe,escapedCommand:gwe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),gwe="source.pipe(destination)";var ywe=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 rvt}from"stream/promises";var Swe=(t,e,r)=>{let n=kC.has(e)?ivt(t,e):nvt(t,e);return jf(t,ovt,r.signal),jf(e,avt,r.signal),svt(e),n},nvt=(t,e)=>{let r=Vf([t]);return Gg(r,e),kC.set(e,r),r},ivt=(t,e)=>{let r=kC.get(e);return r.add(t),r},svt=async t=>{try{await rvt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kC.delete(t)},kC=new WeakMap,ovt=2,avt=1;import{aborted as cvt}from"util";var Ewe=(t,e)=>t===void 0?[]:[lvt(t,e)],lvt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await cvt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw V3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var $C=(t,...e)=>{if(gr(e[0]))return $C.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=mwe(t,...e),i=uvt({...n,destination:r});return i.pipe=$C.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},uvt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=dvt(t,i);_we({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Swe(e,s,d);return await Promise.race([ywe(u),...Ewe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},dvt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as yvt}from"timers/promises";import{on as fvt}from"events";import{getDefaultHighWaterMark as pvt}from"stream";var LC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return hvt(e,o),bwe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},hvt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},H3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;mvt(e,o,t);let a=t.readableObjectMode&&!s;return bwe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},mvt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},bwe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=fvt(t,"data",{signal:e.signal,highWaterMark:vwe,highWatermark:vwe});return gvt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},G3=pvt(!0),vwe=G3,gvt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=_vt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*zf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Kb(a)}},_vt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[AC(t,r,!e),wC(t,i,!n,{})].filter(Boolean);var Twe=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=Svt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([Evt(t),d]);return}let f=T3(c,r),p=H3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([vvt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},Svt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!IC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=H3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await $Te(a,t,r,s)},Evt=async t=>{await yvt(),t.readableFlowing===null&&t.resume()},vvt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await mC(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await gC(r,{maxBuffer:s})):await Bg(r,{maxBuffer:s})}catch(a){return wwe($be({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},W3=async t=>{try{return await t}catch(e){return wwe(e)}},wwe=({bufferedData:t})=>JSe(t)?new Uint8Array(t):t;import{finished as bvt}from"stream/promises";var Qb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=Tvt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],bvt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Rvt(a,e,r,n)}finally{o.abort()}},Tvt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&wvt(t,r,n),n},wvt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Avt(e,r),n.call(t,...i)}},Avt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Rvt=(t,e,r,n)=>{if(!xvt(t,e,r,n))throw t},xvt=(t,e,r,n=!0)=>r.propagating?Awe(t)||DC(t):(r.propagating=!0,Y3(r,e)===n?Awe(t):DC(t)),Y3=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",DC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Awe=t=>t?.code==="EPIPE";var Rwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>K3({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),K3=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=Qb(t,e,l);if(Y3(l,e)){await u;return}let[d]=await Promise.all([Twe({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 xwe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Vf([t,e].filter(Boolean)):void 0,Iwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>K3({...Ivt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Ovt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Ivt=({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}},Ovt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Pvt}from"events";var Owe=t=>$g(t,"ipc"),Pwe=(t,e)=>{let r=BP(t);na({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Cwe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Owe(s),a=Tc(e,"ipc"),c=Tc(r,"ipc");for await(let l of N3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Lbe(t,i,c),i.push(l)),o&&Pwe(l,s);return i},Nwe=async(t,e)=>(await Promise.allSettled([t]),e);var kwe=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=FTe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Rwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),T=Iwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),I=[],x=Cwe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),A=Cvt(m,t,S),O=Nvt(h,S);try{return await Promise.race([Promise.all([{},qTe(v),Promise.all(g),T,x,pbe(t,d),...A,...O]),_,kvt(t,y),...cbe(t,s,f,y),...Ove({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...obe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(R){return f.terminationReason??="other",Promise.all([{error:R},v,Promise.all(g.map(b=>W3(b))),W3(T),Nwe(x,I),Promise.allSettled(A),Promise.allSettled(O)])}},Cvt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Qb(n,i,r)),Nvt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>so(s,{checkOpen:!1})&&!ro(s)).map(({type:i,value:s,stream:o=s})=>Qb(o,n,e,{isSameDirection:bs.has(i),stopOnExit:i==="native"}))),kvt=async(t,{signal:e})=>{let[r]=await Pvt(t,"error",{signal:e});throw r};var $we=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),eT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ia();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Wg=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 $vt}from"stream";import{callbackify as Lvt}from"util";import{finished as Lwe}from"stream/promises";var J3=async t=>{if(t!==void 0)try{await Z3(t)}catch{}},Dwe=async t=>{if(t!==void 0)try{await X3(t)}catch{}},Z3=async t=>{await Lwe(t,{cleanup:!0,readable:!1,writable:!0})},X3=async t=>{await Lwe(t,{cleanup:!0,readable:!0,writable:!1})},MC=async(t,e)=>{if(await t,e)throw e},UC=(t,e,r)=>{r&&!DC(r)?t.destroy(r):e&&t.destroy()};var Mwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Ui.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Q3(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=eW(a,o),{read:f,onStdoutDataDone:p}=tW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new $vt({read:f,destroy:Lvt(nW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return rW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Q3=(t,e,r)=>{let n=Fg(t,e),i=eT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},eW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:G3},tW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ia(),o=LC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Dvt(this,o,s)},onStdoutDataDone:s}},Dvt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},rW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await X3(t),await n,await J3(i),await e,r.readable&&r.push(null)}catch(s){await J3(i),Uwe(r,s)}},nW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Wg(r,e)&&(Uwe(t,n),await MC(e,n))},Uwe=(t,e)=>{UC(t,t.readable,e)};import{Writable as Mvt}from"stream";import{callbackify as Fwe}from"util";var jwe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=iW(t,r,e),o=new Mvt({...sW(n,t,i),destroy:Fwe(aW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return oW(n,o),o},iW=(t,e,r)=>{let n=QP(t,e),i=eT(r,n,"writableFinal"),s=eT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},sW=(t,e,r)=>({write:Uvt.bind(void 0,t),final:Fwe(Fvt.bind(void 0,t,e,r))}),Uvt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Fvt=async(t,e,r)=>{await Wg(r,e)&&(t.writable&&t.end(),await e)},oW=async(t,e,r)=>{try{await Z3(t),e.writable&&e.end()}catch(n){await Dwe(r),qwe(e,n)}},aW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Wg(r,e),await Wg(n,e)&&(qwe(t,i),await MC(e,i))},qwe=(t,e)=>{UC(t,t.writable,e)};import{Duplex as jvt}from"stream";import{callbackify as qvt}from"util";var Bwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Ui.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Q3(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=iW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=eW(c,a),{read:_,onStdoutDataDone:y}=tW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new jvt({read:_,...sW(u,t,d),destroy:qvt(Bvt.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 rW({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),oW(u,v,c),v},Bvt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([nW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),aW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var cW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Ui.has(e),o=Fg(t,r),a=LC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return zvt(a,o,t)},zvt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var zwe=(t,{encoding:e})=>{let r=$we();t.readable=Mwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=jwe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Bwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=cW.bind(void 0,t,e),t[Symbol.asyncIterator]=cW.bind(void 0,t,e,{})};var Vwe=(t,e)=>{for(let[r,n]of Hvt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Vvt=(async()=>{})().constructor.prototype,Hvt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Vvt,t)]);var Hwe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Yvt(t,e,r),{subprocess:f,promise:p}=Jvt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=$C.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Vwe(f,p),sa.set(f,{options:u,fileDescriptors:d}),f},Yvt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=VP(t,e,r),{file:a,commandArguments:c,options:l}=uC(t,e,r),u=Kvt(l),d=rwe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Kvt=({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}},Jvt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Wvt(...dC(t,e,r))}catch(h){return XTe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;Gvt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];dwe(c,a,l),pwe(c,r,l);let d={},f=ia();c.kill=xve.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=xwe(c,r),zwe(c,r),KTe(c,r);let p=Zvt({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}},Zvt=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 kwe({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,T)=>Ac(g,e,T)),v=Ac(m,e,"all"),S=Xvt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Vg(S,n,e)},Xvt=({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?Yb({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 oa,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):SC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var FC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Qvt(n,t[n],i)]));return{...t,...r}},Qvt=(t,e,r)=>ebt.has(t)&&gr(e)&&gr(r)?{...e,...r}:r,ebt=new Set(["env",...U6]);var Ru=(t,e,r,n)=>{let i=(o,a,c)=>Ru(o,a,r,c),s=(...o)=>tbt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},tbt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(gr(s))return i(t,FC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=rbt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?zTe(a,c,l):Hwe(a,c,l,i)},rbt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=rEe(e)?nEe(e,r):[e,...r],[o,a,c]=kP(...s),l=FC(FC(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 Gwe=({file:t,commandArguments:e})=>Ywe(t,e),Wwe=({file:t,commandArguments:e})=>({...Ywe(t,e),isSync:!0}),Ywe=(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]=nbt(t);return{file:r,commandArguments:n}},nbt=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(ibt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},ibt=/ +/g;var Kwe=(t,e,r)=>{t.sync=e(sbt,r),t.s=t.sync},Jwe=({options:t})=>Zwe(t),sbt=({options:t})=>({...Zwe(t),isSync:!0}),Zwe=t=>({options:{...obt(t),...t}}),obt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Xwe={preferLocal:!0};var Qwe=Ru(()=>({})),Vfr=Ru(()=>({isSync:!0})),e0e=Ru(Gwe),Hfr=Ru(Wwe),Gfr=Ru(ube),Wfr=Ru(Jwe,{},Xwe,Kwe),{sendMessage:Yfr,getOneMessage:Kfr,getEachMessage:Jfr,getCancelSignal:Zfr}=JTe();import{Transform as abt}from"stream";var cbt=["NETLIFY_AI_GATEWAY_KEY"];function lbt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...cbt])]}function ubt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function dbt(){let e=lbt().map(r=>process.env[r]).filter(r=>!(!r||ubt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ts(t){if(typeof t!="string")return t;let e=dbt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(fbt(n),"g");r=r.replace(i,"******")}),r}function fbt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var tT=class extends abt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ts(i);n(null,s)}},jC=Symbol("maskedWrite");function t0e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[jC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ts(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[jC]=!0,process.stdout.write=r}if(!process.stderr.write[jC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ts(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[jC]=!0,process.stderr.write=r}}}var r0e=!1,n0e=()=>{r0e=!0},_i=()=>r0e;var rT=null,i0e=t=>(rT&&rT.destroy(),rT=new Rc({totalAllowedTime:t}),rT),s0e=()=>rT;var Rc=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&_i())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await CP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{_e.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 o0e={name:"@netlify/agent-runner-cli",type:"module",version:"1.156.0-ask-clarify.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.5","@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 gbt=hbt(import.meta.url),_bt=xc.dirname(gbt),ybt=mbt(import.meta.url),Yg=Se("shell"),lW=new Set,a0e={preferLocal:!0},fn=(t,e,r)=>{let[n,i]=Sbt(e,r),s={...a0e,...i},o=Qwe(t,n,s);l0e(o,s),f0e(o);let a=r?.idleTimeout;return a&&a>0&&d0e(o,a),o},c0e=(t,e)=>{let r={...a0e,...e},n=e0e(t,r);return l0e(n,r),f0e(n),e?.idleTimeout&&e.idleTimeout>0&&d0e(n,e.idleTimeout),n},Sbt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},l0e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ic.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new tT).pipe(Ic.stdout),t.stderr?.pipe(new tT).pipe(Ic.stderr);return}t.stdout?.pipe(Ic.stdout),t.stderr?.pipe(Ic.stderr)},uW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ic.kill(-t.pid,e),Yg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Yg.error("Error killing process:",r),!1}},u0e=t=>uW(t,"SIGKILL"),d0e=(t,e)=>{let r=null,n=()=>{Yg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),uW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yg.log(`Force killing idle process ${t.pid}`),u0e(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)},f0e=t=>{lW.add(t);let e=s0e();if(e){let r=e.onTimesUp(()=>{Yg.log(`Global timer expired, killing process ${t.pid}`),uW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yg.log(`Force killing process ${t.pid} after timeout`),u0e(t))},5e3)});t.on("exit",()=>{lW.delete(t),r()}),t.on("error",()=>{lW.delete(t),r()})}};function ca(t,e){if(!Ic.env.NETLIFY_LOCAL_MODE)try{let i=ybt.resolve(o0e.name),s=xc.dirname(i);for(;s!==xc.dirname(s);){let o=xc.dirname(s);if(xc.basename(o)==="node_modules"){let a=xc.join(o,".bin",e);if(qC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ic.env.NODE_PATH){let i=xc.join(Ic.env.NODE_PATH,".bin",e);if(qC.existsSync(i))return i}let r=xc.join(t,"node_modules",".bin",e);if(qC.existsSync(r))return r;let n=xc.join(_bt,"..","node_modules",".bin",e);if(qC.existsSync(n))return n}import uD from"process";import{fileURLToPath as YLt}from"url";import{createRequire as KLt}from"module";import dD from"path";var Ebt="__netlify__getTracer",vbt="__netlify__shutdownTracers",gt=(t,e)=>globalThis[Ebt]?.(t,e),p0e=async()=>globalThis[vbt]?.();function Gf(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 qLt}from"timers/promises";ke();import bwt from"process";ke();var Hbt=(t,e)=>{e.recordException(t),e.setStatus({code:In.ERROR})};var Cc=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=oAe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>aAe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=oAe(r,n,i),c=this._tracer.startSpan(e,s,o);return aAe(c,s,a)}};function oAe(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Ft.active(),{opts:n,ctx:i,fn:s}}function aAe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:Hbt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}ke();var t_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var VW=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=_Ae(e),n._asyncAttributesPending=e.filter(([i,s])=>t_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(t_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=_Ae(this._rawAttributes),this._schemaUrl=Gbt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,t_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ce.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(t_(n)){ce.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=Wbt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function HW(t,e){return VW.FromAttributeList(Object.entries(t),e)}function _Ae(t){return t.map(([e,r])=>t_(r)?[e,r.catch(n=>{ce.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function Gbt(t){if(typeof t=="string"||t===void 0)return t;ce.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function Wbt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ce.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}ke();var hT=class{emit(e){}enabled(){return!1}},yAe=new hT;var mT=Symbol.for("io.opentelemetry.js.api.logs"),r_=globalThis;function SAe(t,e,r){return n=>n===t?e:r}var GW=1;var WW=class{getLogger(e,r,n){return new hT}},uN=new WW;var dN=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):yAe}};var gT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new dN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:uN}_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 fN=class t{constructor(){this._proxyLoggerProvider=new gT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return r_[mT]?this.getLoggerProvider():(r_[mT]=SAe(GW,e,uN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=r_[mT])===null||e===void 0?void 0:e.call(r_,GW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete r_[mT],this._proxyLoggerProvider=new gT}};var EAe=fN.getInstance();function vAe(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 bAe(t){t.forEach(e=>e.disable())}function YW(t){let e=t.tracerProvider||Rt.getTracerProvider(),r=t.meterProvider||pT.getMeterProvider(),n=t.loggerProvider||EAe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return vAe(i,e,r,n),()=>{bAe(i)}}ke();var Ybt=qr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function TAe(t){return t.getValue(Ybt)===!0}var n_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(n_||(n_={}));ke();var KW="[_0-9a-z-*/]",Kbt=`[a-z]${KW}{0,255}`,Jbt=`[a-z0-9]${KW}{0,240}@[a-z]${KW}{0,13}`,Zbt=new RegExp(`^(?:${Kbt}|${Jbt})$`),Xbt=/^[ -~]{0,255}[!-~]$/,Qbt=/,|=/;function JW(t){return Zbt.test(t)}function ZW(t){return Xbt.test(t)&&!Qbt.test(t)}var eTt=32,wAe=512,AAe=",",RAe="=",pN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!JW(e)||!ZW(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>wAe)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=AAe+e),e=`${n[0]}${RAe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(AAe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(RAe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!JW(a)||!ZW(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>wAe)&&(r.set(a,c),n=l,r.size>=eTt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var hN="traceparent",mN="tracestate",tTt="00",rTt="(?!ff)[\\da-f]{2}",nTt="(?![0]{32})[\\da-f]{32}",iTt="(?![0]{16})[\\da-f]{16}",sTt="[\\da-f]{2}",oTt=new RegExp(`^\\s?(${rTt})-(${nTt})-(${iTt})-(${sTt})(-.*)?\\s?$`);function xAe(t){let e=oTt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Ou=class{inject(e,r,n){let i=Rt.getSpanContext(e);if(!i||TAe(e)||!yi(i))return;let s=`${tTt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||ur.NONE).toString(16)}`;n.set(r,hN,s),i.traceState&&n.set(r,mN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,hN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=xAe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,mN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new pN(typeof c=="string"?c:void 0)}return Rt.setSpanContext(e,o)}fields(){return[hN,mN]}};var gN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var _T=class{_isCalled=!1;_deferred=new gN;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var ak=Mn(DY(),1);ke();var lIe=t=>{throw TypeError(t)},jY=(t,e,r)=>e.has(t)||lIe("Cannot "+r),ok=(t,e,r)=>(jY(t,e,"read from private field"),r?r.call(t):e.get(t)),MY=(t,e,r)=>e.has(t)?lIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),oIe=(t,e,r,n)=>(jY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),vwt=(t,e,r)=>(jY(t,e,"access private method"),r),aIe="__netlify__getTracer",Twt="__netlify__shutdownTracers",wwt="__nfOTLPTrace",NT,kT,FY,uIe,Awt=class{constructor(){MY(this,FY),MY(this,NT),MY(this,kT),oIe(this,NT,new _T(vwt(this,FY,uIe),this)),oIe(this,kT,ce.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(ok(this,kT).debug(`export ${t.length.toString()} spans`),ok(this,NT).isCalled){e({code:n_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(wwt,JSON.stringify(Rwt(t))),e({code:n_.SUCCESS})}shutdown(){return ok(this,NT).call()}};NT=new WeakMap;kT=new WeakMap;FY=new WeakSet;uIe=function(){return ok(this,kT).debug("Shutting down"),Promise.resolve()};function Rwt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:sk(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||oo.SERVER,startTimeUnixNano:UY(e.startTime),endTimeUnixNano:UY(e.endTime),attributes:sk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:UY(n.time),attributes:sk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:sk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function sk(t){return Object.keys(t).map(e=>dIe(e,t[e]))}function dIe(t,e){return{key:t,value:fIe(e)}}function fIe(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(fIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>dIe(r,n))}}:{}}function UY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var cIe={name:"@netlify/otel",version:"6.0.5",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.7",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},pIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,aIe))return;let e=bwt.version.slice(1),r=HW({"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??[xwt()],i=new ak.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Ou});let s=t.instrumentations??[];YW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,aIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Cc(Rt.getTracer(a,c)):new Cc(Rt.getTracer(cIe.name,cIe.version))}}),Object.defineProperty(globalThis,Twt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},xwt=()=>new ak.SimpleSpanProcessor(new Awt);ke();var $T=Mn(DY(),1);ke();import*as ck from"diagnostics_channel";var hIe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?In.ERROR:In.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Cc?t:new Cc(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){ck.subscribe(t,e);let r=()=>ck.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:oo.CLIENT},Ft.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:In.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var UDe=Mn(DDe(),1);var cD=Se("tracing"),MDe=8e3,BLt=5e3,Xw=async(t=BLt)=>{try{await Promise.race([p0e(),qLt(t)])}catch(e){cD.warn("Failed to flush tracers on shutdown",e)}},FDe=async(t,e,r)=>{if(!gt()){let n=[new $T.SimpleSpanProcessor(new qJ),new $T.SimpleSpanProcessor(new UDe.OTLPTraceExporter({url:r.exporterUrl}))];await pIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new hIe({skipHeaders:!0})]})}return r.traceparent?(Yn.setGlobalPropagator(new Ou),Yn.extract(Ft.active(),{traceparent:r.traceparent,isRemote:!0})):Ft.active()};function Vt(t,e,r){return cD.log(`\u23F3 TRACE: ${e} starting...`),Gf(t,e,r)}var qJ=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(", ")}]`:"";cD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&cD.log(` \u274C Error: ${e.status.message}`)}};function BJ(){return Ze().captureLlmContentEnabled}function jDe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function lD(t,e,r){let n={role:t,parts:[{type:"text",content:Ts(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var zLt=new Set([Q.Task,Q.RunCommand,Q.Explore,Q.FileRead,Q.FileWrite,Q.Notebook,Q.Web,Q.Todo,Q.Skill,Q.Tool,Q.Memorize,Q.Deployment,Q.SiteGeneration]);function qDe(t,e,r,n){if(!t.length)return;let i=gt();if(!i)return;let s=BJ(),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.type==="tool_use"||a.type==="tool_result"||a.category!=null&&zLt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>MDe?`${a.message.slice(0,MDe)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Ts(_)}:{"gen_ai.output.messages":lD("assistant",_)}:{}}}).end(u)})}import{readdir as VLt,rm as HLt}from"fs/promises";import{join as GLt}from"path";async function BDe(t,e=[]){let n=(await VLt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>HLt(GLt(t,i),{recursive:!0,force:!0})))}var WLt=700,zDe=t=>t.mode==="create"&&(t.accountType===wl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=WLt);var JLt=dD.dirname(YLt(import.meta.url)),VDe=KLt(import.meta.url),ZLt=dD.resolve(JLt,"scripts/scaffold.js"),XLt="scripts/scaffold.js",QLt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,zJ=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},eDt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),tDt=t=>{let e=zJ(t);return e==="node"||e.endsWith("/node")},tl=t=>{if(typeof t!="string")return!1;let e=t.match(QLt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&eDt(zJ(e[r]));)r+=1;if(r>=e.length||!tDt(e[r]))return!1;let n=e[r+1];return n?zJ(n).includes(XLt):!1},hy=Se("create_stage"),HDe="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.",rDt=`${HDe}
590
+ if (condition) { yield value; }`)};import{Buffer as ASt}from"buffer";import{StringDecoder as RSt}from"string_decoder";var AC=(t,e,r)=>{if(r)return;if(t)return{transform:xSt.bind(void 0,new TextEncoder)};let n=new RSt(e);return{transform:ISt.bind(void 0,n),final:OSt.bind(void 0,n)}},xSt=function*(t,e){ASt.isBuffer(e)?yield bc(e):typeof e=="string"?yield t.encode(e):yield e},ISt=function*(t,e){yield Cr(e)?t.write(e):e},OSt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as xTe}from"util";var R3=xTe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),RC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=CSt}=e[r];for await(let i of n(t))yield*RC(i,e,r+1)},ITe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*PSt(r,Number(e),t)},PSt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*RC(n,r,e+1)},OTe=xTe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),CSt=function*(t){yield t};var x3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},PTe=(t,e)=>[...e.flatMap(r=>[...zf(r,t,0)]),...Kb(t)],zf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=kSt}=e[r];for(let i of n(t))yield*zf(i,e,r+1)},Kb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*NSt(r,Number(e),t)},NSt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*zf(n,r,e+1)},kSt=function*(t){yield t};var I3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=NTe(t,o,s),l=Bf(e),u=Bf(r),d=l?R3.bind(void 0,RC,a):x3.bind(void 0,zf),f=l||u?R3.bind(void 0,ITe,a):x3.bind(void 0,Kb),p=l||u?OTe.bind(void 0,a):void 0;return{stream:new $St({writableObjectMode:n,writableHighWaterMark:CTe(n),readableObjectMode:i,readableHighWaterMark:CTe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},xC=(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=NTe(o,r,a);t=PTe(c,t)}return t},NTe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:wTe(n,a)},AC(r,o,n),wC(r,s,n,c),{transform:t,final:e},{transform:ATe(i,a)},TTe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var kTe=(t,e)=>{for(let r of LSt(t))DSt(t,r,e)},LSt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),DSt=(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 ${Au[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>MSt(a,n));r.input=Fb(o)},MSt=(t,e)=>{let r=xC(t,e,"utf8",!0);return USt(r),Fb(r)},USt=t=>{let e=t.find(r=>typeof r!="string"&&!Cr(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 BSt,appendFileSync as zSt}from"fs";var IC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&$g(r,n)&&!Ui.has(e)&&FSt(n)&&(t.some(({type:i,value:s})=>i==="native"&&jSt.has(s))||t.every(({type:i})=>bs.has(i))),FSt=t=>t===1||t===2,jSt=new Set(["pipe","overlapped"]),$Te=async(t,e,r,n)=>{for await(let i of t)qSt(e)||DTe(i,r,n)},LTe=(t,e,r)=>{for(let n of t)DTe(n,e,r)},qSt=t=>t._readableState.pipes.length>0,DTe=(t,e,r)=>{let n=BP(t);na({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var MTe=({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)=>VSt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},VSt=({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=Ube(t,s,d),p=bc(f),{stdioItems:h,objectMode:m}=e[r],_=HSt([p],h,c,n),{serializedResult:y,finalResult:v=y}=GSt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});WSt({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&&YSt(y,h,i),S}catch(g){return n.error=g,S}},HSt=(t,e,r,n)=>{try{return xC(t,e,r,!1)}catch(i){return n.error=i,t}},GSt=({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=XSe(t,r);return n[s]?{serializedResult:o,finalResult:A3(o,!i[s],e)}:{serializedResult:o}},WSt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!IC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=A3(t,!1,o);try{LTe(a,e,n)}catch(c){r.error??=c}},YSt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>bC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?zSt(n,t):(r.add(s),BSt(n,t))}};var UTe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ac(e,r,"all")]:Array.isArray(e)?[Ac(t,r,"all"),...e]:Cr(t)&&Cr(e)?$6([t,e]):`${t}${e}`};import{once as O3}from"events";var FTe=async(t,e)=>{let[r,n]=await KSt(t);return e.isForcefullyTerminated??=!1,[r,n]},KSt=async t=>{let[e,r]=await Promise.allSettled([O3(t,"spawn"),O3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?jTe(t):r.value},jTe=async t=>{try{return await O3(t,"exit")}catch{return jTe(t)}},qTe=async t=>{let[e,r]=await t;if(!JSt(e,r)&&P3(e,r))throw new no;return[e,r]},JSt=(t,e)=>t===void 0&&e===void 0,P3=(t,e)=>t!==0||e!==null;var BTe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ZSt(t,e,r),o=s?.code==="ETIMEDOUT",a=Mbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ZSt=(t,e,r)=>t!==void 0?t:P3(e,r)?new no:void 0;var zTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=QSt(t,e,r),d=rEt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Vg(d,c,l)},QSt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=VP(t,e,r),a=eEt(r),{file:c,commandArguments:l,options:u}=uC(t,e,a);tEt(u);let d=STe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},eEt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,tEt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&OC("ipcInput"),t&&OC("ipc: true"),r&&OC("detached: true"),n&&OC("cancelSignal")},OC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},rEt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=nEt({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}=BTe(c,r),{output:h,error:m=l}=MTe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>Ac(v,r,S)),y=Ac(UTe(h,r),r,"all");return sEt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},nEt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{kTe(s,r);let a=iEt(r);return XSt(...dC(t,e,a))}catch(a){return zg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},iEt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:yC(e)}),sEt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?SC({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Yb({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 Gvt}from"events";import{spawn as Wvt}from"child_process";import YTe from"process";import{once as C3,on as oEt}from"events";var VTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Mg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:iC(t)}),aEt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),aEt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{eC(e,i);let s=wu(t,e,r),o=new AbortController;try{return await Promise.race([cEt(s,n,o),lEt(s,r,o),uEt(s,r,o)])}catch(a){throw Ug(t),a}finally{o.abort(),tC(e,i)}},cEt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await C3(t,"message",{signal:r});return n}for await(let[n]of oEt(t,"message",{signal:r}))if(e(n))return n},lEt=async(t,e,{signal:r})=>{await C3(t,"disconnect",{signal:r}),Pve(e)},uEt=async(t,e,{signal:r})=>{let[n]=await C3(t,"strict:error",{signal:r});throw ZP(n,e)};import{once as GTe,on as dEt}from"events";var WTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>N3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),N3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Mg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:iC(t)}),eC(e,s);let o=wu(t,e,r),a=new AbortController,c={};return fEt(t,o,a),pEt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),hEt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},fEt=async(t,e,r)=>{try{await GTe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},pEt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await GTe(t,"strict:error",{signal:r.signal});n.error=ZP(i,e),r.abort()}catch{}},hEt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of dEt(r,"message",{signal:s.signal}))HTe(o),yield c}catch{HTe(o)}finally{s.abort(),tC(e,a),n||Ug(t),i&&await t}},HTe=({error:t})=>{if(t)throw t};var KTe=(t,{ipc:e})=>{Object.assign(t,ZTe(t,!1,e))},JTe=()=>{let t=YTe,e=!0,r=YTe.channel!==void 0;return{...ZTe(t,e,r),getCancelSignal:nbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},ZTe=(t,e,r)=>({sendMessage:cC.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:VTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:WTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as mEt}from"child_process";import{PassThrough as gEt,Readable as _Et,Writable as yEt,Duplex as SEt}from"stream";var XTe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{b3(n);let a=new mEt;EEt(a,n),Object.assign(a,{readable:vEt,writable:bEt,duplex:TEt});let c=zg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=wEt(c,o,i);return{subprocess:a,promise:l}},EEt=(t,e)=>{let r=Jb(),n=Jb(),i=Jb(),s=Array.from({length:e.length-3},Jb),o=Jb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Jb=()=>{let t=new gEt;return t.end(),t},vEt=()=>new _Et({read(){}}),bEt=()=>new yEt({write(){}}),TEt=()=>new SEt({read(){},write(){}}),wEt=async(t,e,r)=>Vg(t,e,r);import{createReadStream as QTe,createWriteStream as ewe}from"fs";import{Buffer as AEt}from"buffer";import{Readable as Zb,Writable as REt,Duplex as xEt}from"stream";var rwe=(t,e)=>TC(IEt,t,e,!1),Xb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Au[t]}.`)},twe={fileNumber:Xb,generator:I3,asyncGenerator:I3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:xEt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},IEt={input:{...twe,fileUrl:({value:t})=>({stream:QTe(t)}),filePath:({value:{file:t}})=>({stream:QTe(t)}),webStream:({value:t})=>({stream:Zb.fromWeb(t)}),iterable:({value:t})=>({stream:Zb.from(t)}),asyncIterable:({value:t})=>({stream:Zb.from(t)}),string:({value:t})=>({stream:Zb.from(t)}),uint8Array:({value:t})=>({stream:Zb.from(AEt.from(t))})},output:{...twe,fileUrl:({value:t})=>({stream:ewe(t)}),filePath:({value:{file:t,append:e}})=>({stream:ewe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:REt.fromWeb(t)}),iterable:Xb,asyncIterable:Xb,string:Xb,uint8Array:Xb}};import{on as OEt,once as nwe}from"events";import{PassThrough as PEt,getDefaultHighWaterMark as CEt}from"stream";import{finished as owe}from"stream/promises";function Vf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)$3(i);let e=t.some(({readableObjectMode:i})=>i),r=NEt(t,e),n=new k3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var NEt=(t,e)=>{if(t.length===0)return CEt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},k3=class extends PEt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if($3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=kEt(this,this.#e,this.#s);let r=DEt({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($3(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)}},kEt=async(t,e,r)=>{PC(t,iwe);let n=new AbortController;try{await Promise.race([$Et(t,n),LEt(t,e,r,n)])}finally{n.abort(),PC(t,-iwe)}},$Et=async(t,{signal:e})=>{try{await owe(t,{signal:e,cleanup:!0})}catch(r){throw awe(t,r),r}},LEt=async(t,e,r,{signal:n})=>{for await(let[i]of OEt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},$3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},DEt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{PC(t,swe);let a=new AbortController;try{await Promise.race([MEt(s,e,a),UEt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),FEt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),PC(t,-swe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?L3(t):jEt(t))},MEt=async(t,e,{signal:r})=>{try{await t,r.aborted||L3(e)}catch(n){r.aborted||awe(e,n)}},UEt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await owe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;cwe(o)?i.add(e):lwe(t,o)}},FEt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await nwe(t,i,{signal:s}),!t.readable)return nwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},jEt=t=>{t.writable&&t.end()},awe=(t,e)=>{cwe(e)?L3(t):lwe(t,e)},cwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",L3=t=>{(t.readable||t.writable)&&t.destroy()},lwe=(t,e)=>{t.destroyed||(t.once("error",qEt),t.destroy(e))},qEt=()=>{},PC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},iwe=2,swe=1;import{finished as uwe}from"stream/promises";var Gg=(t,e)=>{t.pipe(e),BEt(t,e),zEt(t,e)},BEt=async(t,e)=>{if(!(ro(t)||ro(e))){try{await uwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}D3(e)}},D3=t=>{t.writable&&t.end()},zEt=async(t,e)=>{if(!(ro(t)||ro(e))){try{await uwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}M3(t)}},M3=t=>{t.readable&&t.destroy()};var dwe=(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})=>bs.has(c)))VEt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!bs.has(c)))GEt({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]:Vf(s);Gg(o,i)}},VEt=(t,e,r,n)=>{r==="output"?Gg(t.stdio[n],e):Gg(e,t.stdio[n]);let i=HEt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},HEt=["stdin","stdout","stderr"],GEt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;WEt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},WEt=(t,{signal:e})=>{ro(t)&&jf(t,YEt,e)},YEt=2;import{addAbortListener as ZEt}from"events";var Hf=[];Hf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Hf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Hf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var CC=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",U3=Symbol.for("signal-exit emitter"),F3=globalThis,KEt=Object.defineProperty.bind(Object),j3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(F3[U3])return F3[U3];KEt(F3,U3,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},NC=class{},JEt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),q3=class extends NC{onExit(){return()=>{}}load(){}unload(){}},B3=class extends NC{#e=z3.platform==="win32"?"SIGINT":"SIGHUP";#r=new j3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Hf)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(!CC(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 Hf)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,Hf.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 CC(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"&&CC(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)}},z3=globalThis.process,{onExit:fwe,load:eur,unload:tur}=JEt(CC(z3)?new B3(z3):new q3);var pwe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=fwe(()=>{t.kill()});ZEt(n,()=>{i()})};var mwe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=zP(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=XEt(r,n,i),{sourceStream:d,sourceError:f}=evt(t,l),{options:p,fileDescriptors:h}=sa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},XEt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=QEt(t,e,...r),a=QP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},QEt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(hwe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||N6(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]=kP(r,...n);return{destination:e(hwe)(i,s,o),pipeOptions:o}}if(sa.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}`)},hwe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),evt=(t,e)=>{try{return{sourceStream:Fg(t,e)}}catch(r){return{sourceError:r}}};var _we=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=tvt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw V3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},tvt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return M3(t),n;if(e!==void 0)return D3(r),e},V3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>zg({error:t,command:gwe,escapedCommand:gwe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),gwe="source.pipe(destination)";var ywe=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 rvt}from"stream/promises";var Swe=(t,e,r)=>{let n=kC.has(e)?ivt(t,e):nvt(t,e);return jf(t,ovt,r.signal),jf(e,avt,r.signal),svt(e),n},nvt=(t,e)=>{let r=Vf([t]);return Gg(r,e),kC.set(e,r),r},ivt=(t,e)=>{let r=kC.get(e);return r.add(t),r},svt=async t=>{try{await rvt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kC.delete(t)},kC=new WeakMap,ovt=2,avt=1;import{aborted as cvt}from"util";var Ewe=(t,e)=>t===void 0?[]:[lvt(t,e)],lvt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await cvt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw V3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var $C=(t,...e)=>{if(gr(e[0]))return $C.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=mwe(t,...e),i=uvt({...n,destination:r});return i.pipe=$C.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},uvt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=dvt(t,i);_we({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Swe(e,s,d);return await Promise.race([ywe(u),...Ewe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},dvt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as yvt}from"timers/promises";import{on as fvt}from"events";import{getDefaultHighWaterMark as pvt}from"stream";var LC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return hvt(e,o),bwe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},hvt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},H3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;mvt(e,o,t);let a=t.readableObjectMode&&!s;return bwe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},mvt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},bwe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=fvt(t,"data",{signal:e.signal,highWaterMark:vwe,highWatermark:vwe});return gvt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},G3=pvt(!0),vwe=G3,gvt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=_vt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*zf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Kb(a)}},_vt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[AC(t,r,!e),wC(t,i,!n,{})].filter(Boolean);var Twe=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=Svt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([Evt(t),d]);return}let f=T3(c,r),p=H3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([vvt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},Svt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!IC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=H3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await $Te(a,t,r,s)},Evt=async t=>{await yvt(),t.readableFlowing===null&&t.resume()},vvt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await mC(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await gC(r,{maxBuffer:s})):await Bg(r,{maxBuffer:s})}catch(a){return wwe($be({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},W3=async t=>{try{return await t}catch(e){return wwe(e)}},wwe=({bufferedData:t})=>JSe(t)?new Uint8Array(t):t;import{finished as bvt}from"stream/promises";var Qb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=Tvt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],bvt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Rvt(a,e,r,n)}finally{o.abort()}},Tvt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&wvt(t,r,n),n},wvt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Avt(e,r),n.call(t,...i)}},Avt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Rvt=(t,e,r,n)=>{if(!xvt(t,e,r,n))throw t},xvt=(t,e,r,n=!0)=>r.propagating?Awe(t)||DC(t):(r.propagating=!0,Y3(r,e)===n?Awe(t):DC(t)),Y3=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",DC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Awe=t=>t?.code==="EPIPE";var Rwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>K3({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),K3=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=Qb(t,e,l);if(Y3(l,e)){await u;return}let[d]=await Promise.all([Twe({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 xwe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Vf([t,e].filter(Boolean)):void 0,Iwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>K3({...Ivt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Ovt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Ivt=({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}},Ovt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Pvt}from"events";var Owe=t=>$g(t,"ipc"),Pwe=(t,e)=>{let r=BP(t);na({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Cwe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Owe(s),a=Tc(e,"ipc"),c=Tc(r,"ipc");for await(let l of N3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Lbe(t,i,c),i.push(l)),o&&Pwe(l,s);return i},Nwe=async(t,e)=>(await Promise.allSettled([t]),e);var kwe=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=FTe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Rwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),T=Iwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),I=[],x=Cwe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),A=Cvt(m,t,S),O=Nvt(h,S);try{return await Promise.race([Promise.all([{},qTe(v),Promise.all(g),T,x,pbe(t,d),...A,...O]),_,kvt(t,y),...cbe(t,s,f,y),...Ove({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...obe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(R){return f.terminationReason??="other",Promise.all([{error:R},v,Promise.all(g.map(b=>W3(b))),W3(T),Nwe(x,I),Promise.allSettled(A),Promise.allSettled(O)])}},Cvt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Qb(n,i,r)),Nvt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>so(s,{checkOpen:!1})&&!ro(s)).map(({type:i,value:s,stream:o=s})=>Qb(o,n,e,{isSameDirection:bs.has(i),stopOnExit:i==="native"}))),kvt=async(t,{signal:e})=>{let[r]=await Pvt(t,"error",{signal:e});throw r};var $we=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),eT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ia();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Wg=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 $vt}from"stream";import{callbackify as Lvt}from"util";import{finished as Lwe}from"stream/promises";var J3=async t=>{if(t!==void 0)try{await Z3(t)}catch{}},Dwe=async t=>{if(t!==void 0)try{await X3(t)}catch{}},Z3=async t=>{await Lwe(t,{cleanup:!0,readable:!1,writable:!0})},X3=async t=>{await Lwe(t,{cleanup:!0,readable:!0,writable:!1})},MC=async(t,e)=>{if(await t,e)throw e},UC=(t,e,r)=>{r&&!DC(r)?t.destroy(r):e&&t.destroy()};var Mwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Ui.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Q3(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=eW(a,o),{read:f,onStdoutDataDone:p}=tW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new $vt({read:f,destroy:Lvt(nW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return rW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Q3=(t,e,r)=>{let n=Fg(t,e),i=eT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},eW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:G3},tW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ia(),o=LC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Dvt(this,o,s)},onStdoutDataDone:s}},Dvt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},rW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await X3(t),await n,await J3(i),await e,r.readable&&r.push(null)}catch(s){await J3(i),Uwe(r,s)}},nW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Wg(r,e)&&(Uwe(t,n),await MC(e,n))},Uwe=(t,e)=>{UC(t,t.readable,e)};import{Writable as Mvt}from"stream";import{callbackify as Fwe}from"util";var jwe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=iW(t,r,e),o=new Mvt({...sW(n,t,i),destroy:Fwe(aW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return oW(n,o),o},iW=(t,e,r)=>{let n=QP(t,e),i=eT(r,n,"writableFinal"),s=eT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},sW=(t,e,r)=>({write:Uvt.bind(void 0,t),final:Fwe(Fvt.bind(void 0,t,e,r))}),Uvt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Fvt=async(t,e,r)=>{await Wg(r,e)&&(t.writable&&t.end(),await e)},oW=async(t,e,r)=>{try{await Z3(t),e.writable&&e.end()}catch(n){await Dwe(r),qwe(e,n)}},aW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Wg(r,e),await Wg(n,e)&&(qwe(t,i),await MC(e,i))},qwe=(t,e)=>{UC(t,t.writable,e)};import{Duplex as jvt}from"stream";import{callbackify as qvt}from"util";var Bwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Ui.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Q3(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=iW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=eW(c,a),{read:_,onStdoutDataDone:y}=tW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new jvt({read:_,...sW(u,t,d),destroy:qvt(Bvt.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 rW({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),oW(u,v,c),v},Bvt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([nW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),aW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var cW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Ui.has(e),o=Fg(t,r),a=LC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return zvt(a,o,t)},zvt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var zwe=(t,{encoding:e})=>{let r=$we();t.readable=Mwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=jwe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Bwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=cW.bind(void 0,t,e),t[Symbol.asyncIterator]=cW.bind(void 0,t,e,{})};var Vwe=(t,e)=>{for(let[r,n]of Hvt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Vvt=(async()=>{})().constructor.prototype,Hvt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Vvt,t)]);var Hwe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Yvt(t,e,r),{subprocess:f,promise:p}=Jvt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=$C.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Vwe(f,p),sa.set(f,{options:u,fileDescriptors:d}),f},Yvt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=VP(t,e,r),{file:a,commandArguments:c,options:l}=uC(t,e,r),u=Kvt(l),d=rwe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Kvt=({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}},Jvt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Wvt(...dC(t,e,r))}catch(h){return XTe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;Gvt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];dwe(c,a,l),pwe(c,r,l);let d={},f=ia();c.kill=xve.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=xwe(c,r),zwe(c,r),KTe(c,r);let p=Zvt({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}},Zvt=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 kwe({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,T)=>Ac(g,e,T)),v=Ac(m,e,"all"),S=Xvt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Vg(S,n,e)},Xvt=({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?Yb({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 oa,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):SC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var FC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Qvt(n,t[n],i)]));return{...t,...r}},Qvt=(t,e,r)=>ebt.has(t)&&gr(e)&&gr(r)?{...e,...r}:r,ebt=new Set(["env",...U6]);var Ru=(t,e,r,n)=>{let i=(o,a,c)=>Ru(o,a,r,c),s=(...o)=>tbt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},tbt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(gr(s))return i(t,FC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=rbt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?zTe(a,c,l):Hwe(a,c,l,i)},rbt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=rEe(e)?nEe(e,r):[e,...r],[o,a,c]=kP(...s),l=FC(FC(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 Gwe=({file:t,commandArguments:e})=>Ywe(t,e),Wwe=({file:t,commandArguments:e})=>({...Ywe(t,e),isSync:!0}),Ywe=(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]=nbt(t);return{file:r,commandArguments:n}},nbt=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(ibt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},ibt=/ +/g;var Kwe=(t,e,r)=>{t.sync=e(sbt,r),t.s=t.sync},Jwe=({options:t})=>Zwe(t),sbt=({options:t})=>({...Zwe(t),isSync:!0}),Zwe=t=>({options:{...obt(t),...t}}),obt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Xwe={preferLocal:!0};var Qwe=Ru(()=>({})),Vfr=Ru(()=>({isSync:!0})),e0e=Ru(Gwe),Hfr=Ru(Wwe),Gfr=Ru(ube),Wfr=Ru(Jwe,{},Xwe,Kwe),{sendMessage:Yfr,getOneMessage:Kfr,getEachMessage:Jfr,getCancelSignal:Zfr}=JTe();import{Transform as abt}from"stream";var cbt=["NETLIFY_AI_GATEWAY_KEY"];function lbt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...cbt])]}function ubt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function dbt(){let e=lbt().map(r=>process.env[r]).filter(r=>!(!r||ubt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ts(t){if(typeof t!="string")return t;let e=dbt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(fbt(n),"g");r=r.replace(i,"******")}),r}function fbt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var tT=class extends abt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ts(i);n(null,s)}},jC=Symbol("maskedWrite");function t0e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[jC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ts(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[jC]=!0,process.stdout.write=r}if(!process.stderr.write[jC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ts(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[jC]=!0,process.stderr.write=r}}}var r0e=!1,n0e=()=>{r0e=!0},_i=()=>r0e;var rT=null,i0e=t=>(rT&&rT.destroy(),rT=new Rc({totalAllowedTime:t}),rT),s0e=()=>rT;var Rc=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&_i())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await CP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{_e.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 o0e={name:"@netlify/agent-runner-cli",type:"module",version:"1.156.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.5","@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 gbt=hbt(import.meta.url),_bt=xc.dirname(gbt),ybt=mbt(import.meta.url),Yg=Se("shell"),lW=new Set,a0e={preferLocal:!0},fn=(t,e,r)=>{let[n,i]=Sbt(e,r),s={...a0e,...i},o=Qwe(t,n,s);l0e(o,s),f0e(o);let a=r?.idleTimeout;return a&&a>0&&d0e(o,a),o},c0e=(t,e)=>{let r={...a0e,...e},n=e0e(t,r);return l0e(n,r),f0e(n),e?.idleTimeout&&e.idleTimeout>0&&d0e(n,e.idleTimeout),n},Sbt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},l0e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ic.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new tT).pipe(Ic.stdout),t.stderr?.pipe(new tT).pipe(Ic.stderr);return}t.stdout?.pipe(Ic.stdout),t.stderr?.pipe(Ic.stderr)},uW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ic.kill(-t.pid,e),Yg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Yg.error("Error killing process:",r),!1}},u0e=t=>uW(t,"SIGKILL"),d0e=(t,e)=>{let r=null,n=()=>{Yg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),uW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yg.log(`Force killing idle process ${t.pid}`),u0e(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)},f0e=t=>{lW.add(t);let e=s0e();if(e){let r=e.onTimesUp(()=>{Yg.log(`Global timer expired, killing process ${t.pid}`),uW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yg.log(`Force killing process ${t.pid} after timeout`),u0e(t))},5e3)});t.on("exit",()=>{lW.delete(t),r()}),t.on("error",()=>{lW.delete(t),r()})}};function ca(t,e){if(!Ic.env.NETLIFY_LOCAL_MODE)try{let i=ybt.resolve(o0e.name),s=xc.dirname(i);for(;s!==xc.dirname(s);){let o=xc.dirname(s);if(xc.basename(o)==="node_modules"){let a=xc.join(o,".bin",e);if(qC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ic.env.NODE_PATH){let i=xc.join(Ic.env.NODE_PATH,".bin",e);if(qC.existsSync(i))return i}let r=xc.join(t,"node_modules",".bin",e);if(qC.existsSync(r))return r;let n=xc.join(_bt,"..","node_modules",".bin",e);if(qC.existsSync(n))return n}import uD from"process";import{fileURLToPath as YLt}from"url";import{createRequire as KLt}from"module";import dD from"path";var Ebt="__netlify__getTracer",vbt="__netlify__shutdownTracers",gt=(t,e)=>globalThis[Ebt]?.(t,e),p0e=async()=>globalThis[vbt]?.();function Gf(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 qLt}from"timers/promises";ke();import bwt from"process";ke();var Hbt=(t,e)=>{e.recordException(t),e.setStatus({code:In.ERROR})};var Cc=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=oAe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>aAe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=oAe(r,n,i),c=this._tracer.startSpan(e,s,o);return aAe(c,s,a)}};function oAe(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Ft.active(),{opts:n,ctx:i,fn:s}}function aAe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:Hbt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}ke();var t_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var VW=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=_Ae(e),n._asyncAttributesPending=e.filter(([i,s])=>t_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(t_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=_Ae(this._rawAttributes),this._schemaUrl=Gbt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,t_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ce.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(t_(n)){ce.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=Wbt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function HW(t,e){return VW.FromAttributeList(Object.entries(t),e)}function _Ae(t){return t.map(([e,r])=>t_(r)?[e,r.catch(n=>{ce.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function Gbt(t){if(typeof t=="string"||t===void 0)return t;ce.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function Wbt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ce.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}ke();var hT=class{emit(e){}enabled(){return!1}},yAe=new hT;var mT=Symbol.for("io.opentelemetry.js.api.logs"),r_=globalThis;function SAe(t,e,r){return n=>n===t?e:r}var GW=1;var WW=class{getLogger(e,r,n){return new hT}},uN=new WW;var dN=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):yAe}};var gT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new dN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:uN}_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 fN=class t{constructor(){this._proxyLoggerProvider=new gT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return r_[mT]?this.getLoggerProvider():(r_[mT]=SAe(GW,e,uN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=r_[mT])===null||e===void 0?void 0:e.call(r_,GW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete r_[mT],this._proxyLoggerProvider=new gT}};var EAe=fN.getInstance();function vAe(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 bAe(t){t.forEach(e=>e.disable())}function YW(t){let e=t.tracerProvider||Rt.getTracerProvider(),r=t.meterProvider||pT.getMeterProvider(),n=t.loggerProvider||EAe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return vAe(i,e,r,n),()=>{bAe(i)}}ke();var Ybt=qr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function TAe(t){return t.getValue(Ybt)===!0}var n_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(n_||(n_={}));ke();var KW="[_0-9a-z-*/]",Kbt=`[a-z]${KW}{0,255}`,Jbt=`[a-z0-9]${KW}{0,240}@[a-z]${KW}{0,13}`,Zbt=new RegExp(`^(?:${Kbt}|${Jbt})$`),Xbt=/^[ -~]{0,255}[!-~]$/,Qbt=/,|=/;function JW(t){return Zbt.test(t)}function ZW(t){return Xbt.test(t)&&!Qbt.test(t)}var eTt=32,wAe=512,AAe=",",RAe="=",pN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!JW(e)||!ZW(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>wAe)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=AAe+e),e=`${n[0]}${RAe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(AAe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(RAe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!JW(a)||!ZW(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>wAe)&&(r.set(a,c),n=l,r.size>=eTt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var hN="traceparent",mN="tracestate",tTt="00",rTt="(?!ff)[\\da-f]{2}",nTt="(?![0]{32})[\\da-f]{32}",iTt="(?![0]{16})[\\da-f]{16}",sTt="[\\da-f]{2}",oTt=new RegExp(`^\\s?(${rTt})-(${nTt})-(${iTt})-(${sTt})(-.*)?\\s?$`);function xAe(t){let e=oTt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Ou=class{inject(e,r,n){let i=Rt.getSpanContext(e);if(!i||TAe(e)||!yi(i))return;let s=`${tTt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||ur.NONE).toString(16)}`;n.set(r,hN,s),i.traceState&&n.set(r,mN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,hN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=xAe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,mN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new pN(typeof c=="string"?c:void 0)}return Rt.setSpanContext(e,o)}fields(){return[hN,mN]}};var gN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var _T=class{_isCalled=!1;_deferred=new gN;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var ak=Mn(DY(),1);ke();var lIe=t=>{throw TypeError(t)},jY=(t,e,r)=>e.has(t)||lIe("Cannot "+r),ok=(t,e,r)=>(jY(t,e,"read from private field"),r?r.call(t):e.get(t)),MY=(t,e,r)=>e.has(t)?lIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),oIe=(t,e,r,n)=>(jY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),vwt=(t,e,r)=>(jY(t,e,"access private method"),r),aIe="__netlify__getTracer",Twt="__netlify__shutdownTracers",wwt="__nfOTLPTrace",NT,kT,FY,uIe,Awt=class{constructor(){MY(this,FY),MY(this,NT),MY(this,kT),oIe(this,NT,new _T(vwt(this,FY,uIe),this)),oIe(this,kT,ce.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(ok(this,kT).debug(`export ${t.length.toString()} spans`),ok(this,NT).isCalled){e({code:n_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(wwt,JSON.stringify(Rwt(t))),e({code:n_.SUCCESS})}shutdown(){return ok(this,NT).call()}};NT=new WeakMap;kT=new WeakMap;FY=new WeakSet;uIe=function(){return ok(this,kT).debug("Shutting down"),Promise.resolve()};function Rwt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:sk(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||oo.SERVER,startTimeUnixNano:UY(e.startTime),endTimeUnixNano:UY(e.endTime),attributes:sk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:UY(n.time),attributes:sk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:sk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function sk(t){return Object.keys(t).map(e=>dIe(e,t[e]))}function dIe(t,e){return{key:t,value:fIe(e)}}function fIe(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(fIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>dIe(r,n))}}:{}}function UY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var cIe={name:"@netlify/otel",version:"6.0.5",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.7",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},pIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,aIe))return;let e=bwt.version.slice(1),r=HW({"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??[xwt()],i=new ak.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Ou});let s=t.instrumentations??[];YW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,aIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Cc(Rt.getTracer(a,c)):new Cc(Rt.getTracer(cIe.name,cIe.version))}}),Object.defineProperty(globalThis,Twt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},xwt=()=>new ak.SimpleSpanProcessor(new Awt);ke();var $T=Mn(DY(),1);ke();import*as ck from"diagnostics_channel";var hIe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?In.ERROR:In.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Cc?t:new Cc(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){ck.subscribe(t,e);let r=()=>ck.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:oo.CLIENT},Ft.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:In.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var UDe=Mn(DDe(),1);var cD=Se("tracing"),MDe=8e3,BLt=5e3,Xw=async(t=BLt)=>{try{await Promise.race([p0e(),qLt(t)])}catch(e){cD.warn("Failed to flush tracers on shutdown",e)}},FDe=async(t,e,r)=>{if(!gt()){let n=[new $T.SimpleSpanProcessor(new qJ),new $T.SimpleSpanProcessor(new UDe.OTLPTraceExporter({url:r.exporterUrl}))];await pIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new hIe({skipHeaders:!0})]})}return r.traceparent?(Yn.setGlobalPropagator(new Ou),Yn.extract(Ft.active(),{traceparent:r.traceparent,isRemote:!0})):Ft.active()};function Vt(t,e,r){return cD.log(`\u23F3 TRACE: ${e} starting...`),Gf(t,e,r)}var qJ=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(", ")}]`:"";cD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&cD.log(` \u274C Error: ${e.status.message}`)}};function BJ(){return Ze().captureLlmContentEnabled}function jDe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function lD(t,e,r){let n={role:t,parts:[{type:"text",content:Ts(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var zLt=new Set([Q.Task,Q.RunCommand,Q.Explore,Q.FileRead,Q.FileWrite,Q.Notebook,Q.Web,Q.Todo,Q.Skill,Q.Tool,Q.Memorize,Q.Deployment,Q.SiteGeneration]);function qDe(t,e,r,n){if(!t.length)return;let i=gt();if(!i)return;let s=BJ(),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.type==="tool_use"||a.type==="tool_result"||a.category!=null&&zLt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>MDe?`${a.message.slice(0,MDe)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Ts(_)}:{"gen_ai.output.messages":lD("assistant",_)}:{}}}).end(u)})}import{readdir as VLt,rm as HLt}from"fs/promises";import{join as GLt}from"path";async function BDe(t,e=[]){let n=(await VLt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>HLt(GLt(t,i),{recursive:!0,force:!0})))}var WLt=700,zDe=t=>t.mode==="create"&&(t.accountType===wl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=WLt);var JLt=dD.dirname(YLt(import.meta.url)),VDe=KLt(import.meta.url),ZLt=dD.resolve(JLt,"scripts/scaffold.js"),XLt="scripts/scaffold.js",QLt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,zJ=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},eDt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),tDt=t=>{let e=zJ(t);return e==="node"||e.endsWith("/node")},tl=t=>{if(typeof t!="string")return!1;let e=t.match(QLt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&eDt(zJ(e[r]));)r+=1;if(r>=e.length||!tDt(e[r]))return!1;let n=e[r+1];return n?zJ(n).includes(XLt):!1},hy=Se("create_stage"),HDe="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.",rDt=`${HDe}
591
591
 
592
592
  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.`,nDt=`${HDe}
593
593
 
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:UL},o$e=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},s$e={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:o$e};import{Buffer as a$e}from"buffer";var ore=(t,e)=>t?void 0:c$e.bind(void 0,e),c$e=function*(t,e){if(typeof e!="string"&&!jt(e)&&!a$e.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},sre=(t,e)=>t?l$e.bind(void 0,e):u$e.bind(void 0,e),l$e=function*(t,e){are(t,e),yield e},u$e=function*(t,e){if(are(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},are=(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 d$e}from"buffer";import{StringDecoder as f$e}from"string_decoder";var gx=(t,e,r)=>{if(r)return;if(t)return{transform:p$e.bind(void 0,new TextEncoder)};let n=new f$e(e);return{transform:h$e.bind(void 0,n),final:m$e.bind(void 0,n)}},p$e=function*(t,e){d$e.isBuffer(e)?yield ls(e):typeof e=="string"?yield t.encode(e):yield e},h$e=function*(t,e){yield jt(e)?t.write(e):e},m$e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as cre}from"util";var BL=cre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),_x=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_$e}=e[r];for await(let i of n(t))yield*_x(i,e,r+1)},lre=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*g$e(r,Number(e),t)},g$e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*_x(n,r,e+1)},ure=cre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),_$e=function*(t){yield t};var jL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},dre=(t,e)=>[...e.flatMap(r=>[...Cl(r,t,0)]),...R_(t)],Cl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=S$e}=e[r];for(let i of n(t))yield*Cl(i,e,r+1)},R_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*y$e(r,Number(e),t)},y$e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Cl(n,r,e+1)},S$e=function*(t){yield t};var zL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=pre(t,s,o),l=Il(e),u=Il(r),d=l?BL.bind(void 0,_x,a):jL.bind(void 0,Cl),f=l||u?BL.bind(void 0,lre,a):jL.bind(void 0,R_),p=l||u?ure.bind(void 0,a):void 0;return{stream:new E$e({writableObjectMode:n,writableHighWaterMark:fre(n),readableObjectMode:i,readableHighWaterMark:fre(i),transform(m,y,T){d([m,c,0],this,T)},flush(m){f([c],this,m)},destroy:p})}},yx=(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=pre(s,r,a);t=dre(c,t)}return t},pre=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:ore(n,a)},gx(r,s,n),mx(r,o,n,c),{transform:t,final:e},{transform:sre(i,a)},ire({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var hre=(t,e)=>{for(let r of v$e(t))T$e(t,r,e)},v$e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),T$e=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Oa[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>b$e(a,n));r.input=__(s)},b$e=(t,e)=>{let r=yx(t,e,"utf8",!0);return A$e(r),__(r)},A$e=t=>{let e=t.find(r=>typeof r!="string"&&!jt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as I$e,appendFileSync as C$e}from"fs";var Sx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&af(r,n)&&!mn.has(e)&&x$e(n)&&(t.some(({type:i,value:o})=>i==="native"&&w$e.has(o))||t.every(({type:i})=>qn.has(i))),x$e=t=>t===1||t===2,w$e=new Set(["pipe","overlapped"]),mre=async(t,e,r,n)=>{for await(let i of t)R$e(e)||_re(i,r,n)},gre=(t,e,r)=>{for(let n of t)_re(n,e,r)},R$e=t=>t._readableState.pipes.length>0,_re=(t,e,r)=>{let n=kA(t);so({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var yre=({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)=>P$e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},P$e=({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=Ste(t,o,d),p=ls(f),{stdioItems:h,objectMode:m}=e[r],y=O$e([p],h,c,n),{serializedResult:T,finalResult:b=T}=N$e({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});k$e({serializedResult:T,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&M$e(T,h,i),A}catch(S){return n.error=S,A}},O$e=(t,e,r,n)=>{try{return yx(t,e,r,!1)}catch(i){return n.error=i,t}},N$e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:__(t)};let s=kQ(t,r);return n[o]?{serializedResult:s,finalResult:FL(s,!i[o],e)}:{serializedResult:s}},k$e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Sx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=FL(t,!1,s);try{gre(a,e,n)}catch(c){r.error??=c}},M$e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>px.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?C$e(n,t):(r.add(o),I$e(n,t))}};var Sre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,fs(e,r,"all")]:Array.isArray(e)?[fs(t,r,"all"),...e]:jt(t)&&jt(e)?YD([t,e]):`${t}${e}`};import{once as GL}from"events";var Ere=async(t,e)=>{let[r,n]=await D$e(t);return e.isForcefullyTerminated??=!1,[r,n]},D$e=async t=>{let[e,r]=await Promise.allSettled([GL(t,"spawn"),GL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?vre(t):r.value},vre=async t=>{try{return await GL(t,"exit")}catch{return vre(t)}},Tre=async t=>{let[e,r]=await t;if(!L$e(e,r)&&qL(e,r))throw new bi;return[e,r]},L$e=(t,e)=>t===void 0&&e===void 0,qL=(t,e)=>t!==0||e!==null;var bre=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=$$e(t,e,r),s=o?.code==="ETIMEDOUT",a=yte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},$$e=(t,e,r)=>t!==void 0?t:qL(e,r)?new bi:void 0;var Are=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=F$e(t,e,r),d=z$e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return _f(d,c,l)},F$e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=DA(t,e,r),a=B$e(r),{file:c,commandArguments:l,options:u}=tx(t,e,a);j$e(u);let d=ere(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},B$e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,j$e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Ex("ipcInput"),t&&Ex("ipc: true"),r&&Ex("detached: true"),n&&Ex("cancelSignal")},Ex=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},z$e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=G$e({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}=bre(c,r),{output:h,error:m=l}=yre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((b,A)=>fs(b,r,A)),T=fs(Sre(h,r),r,"all");return V$e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:T,options:r,command:n,escapedCommand:i,startTime:a})},G$e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{hre(o,r);let a=q$e(r);return U$e(...rx(t,e,a))}catch(a){return gf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},q$e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:lx(e)}),V$e=({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?ux({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):w_({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 NUe}from"events";import{spawn as kUe}from"child_process";import Cre from"process";import{once as VL,on as H$e}from"events";var xre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(uf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:KA(t)}),W$e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),W$e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{VA(e,i);let o=Pa(t,e,r),s=new AbortController;try{return await Promise.race([Y$e(o,n,s),K$e(o,r,s),Z$e(o,r,s)])}catch(a){throw df(t),a}finally{s.abort(),HA(e,i)}},Y$e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await VL(t,"message",{signal:r});return n}for await(let[n]of H$e(t,"message",{signal:r}))if(e(n))return n},K$e=async(t,e,{signal:r})=>{await VL(t,"disconnect",{signal:r}),dee(e)},Z$e=async(t,e,{signal:r})=>{let[n]=await VL(t,"strict:error",{signal:r});throw zA(n,e)};import{once as Rre,on as J$e}from"events";var Ire=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>HL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),HL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{uf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:KA(t)}),VA(e,o);let s=Pa(t,e,r),a=new AbortController,c={};return X$e(t,s,a),Q$e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),e1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},X$e=async(t,e,r)=>{try{await Rre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Q$e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Rre(t,"strict:error",{signal:r.signal});n.error=zA(i,e),r.abort()}catch{}},e1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of J$e(r,"message",{signal:o.signal}))wre(s),yield c}catch{wre(s)}finally{o.abort(),HA(e,a),n||df(t),i&&await t}},wre=({error:t})=>{if(t)throw t};var Pre=(t,{ipc:e})=>{Object.assign(t,Nre(t,!1,e))},Ore=()=>{let t=Cre,e=!0,r=Cre.channel!==void 0;return{...Nre(t,e,r),getCancelSignal:Uee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Nre=(t,e,r)=>({sendMessage:QA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:xre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Ire.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as t1e}from"child_process";import{PassThrough as r1e,Readable as n1e,Writable as i1e,Duplex as o1e}from"stream";var kre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{LL(n);let a=new t1e;s1e(a,n),Object.assign(a,{readable:a1e,writable:c1e,duplex:l1e});let c=gf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=u1e(c,s,i);return{subprocess:a,promise:l}},s1e=(t,e)=>{let r=I_(),n=I_(),i=I_(),o=Array.from({length:e.length-3},I_),s=I_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},I_=()=>{let t=new r1e;return t.end(),t},a1e=()=>new n1e({read(){}}),c1e=()=>new i1e({write(){}}),l1e=()=>new o1e({read(){},write(){}}),u1e=async(t,e,r)=>_f(t,e,r);import{createReadStream as Mre,createWriteStream as Dre}from"fs";import{Buffer as d1e}from"buffer";import{Readable as C_,Writable as f1e,Duplex as p1e}from"stream";var $re=(t,e)=>hx(h1e,t,e,!1),P_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Oa[t]}.`)},Lre={fileNumber:P_,generator:zL,asyncGenerator:zL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:p1e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},h1e={input:{...Lre,fileUrl:({value:t})=>({stream:Mre(t)}),filePath:({value:{file:t}})=>({stream:Mre(t)}),webStream:({value:t})=>({stream:C_.fromWeb(t)}),iterable:({value:t})=>({stream:C_.from(t)}),asyncIterable:({value:t})=>({stream:C_.from(t)}),string:({value:t})=>({stream:C_.from(t)}),uint8Array:({value:t})=>({stream:C_.from(d1e.from(t))})},output:{...Lre,fileUrl:({value:t})=>({stream:Dre(t)}),filePath:({value:{file:t,append:e}})=>({stream:Dre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:f1e.fromWeb(t)}),iterable:P_,asyncIterable:P_,string:P_,uint8Array:P_}};import{on as m1e,once as Ure}from"events";import{PassThrough as g1e,getDefaultHighWaterMark as _1e}from"stream";import{finished as jre}from"stream/promises";function Pl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)YL(i);let e=t.some(({readableObjectMode:i})=>i),r=y1e(t,e),n=new WL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var y1e=(t,e)=>{if(t.length===0)return _1e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},WL=class extends g1e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(YL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=S1e(this,this.#e,this.#o);let r=T1e({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(YL(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},S1e=async(t,e,r)=>{vx(t,Fre);let n=new AbortController;try{await Promise.race([E1e(t,n),v1e(t,e,r,n)])}finally{n.abort(),vx(t,-Fre)}},E1e=async(t,{signal:e})=>{try{await jre(t,{signal:e,cleanup:!0})}catch(r){throw zre(t,r),r}},v1e=async(t,e,r,{signal:n})=>{for await(let[i]of m1e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},YL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},T1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{vx(t,Bre);let a=new AbortController;try{await Promise.race([b1e(o,e,a),A1e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),x1e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),vx(t,-Bre)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?KL(t):w1e(t))},b1e=async(t,e,{signal:r})=>{try{await t,r.aborted||KL(e)}catch(n){r.aborted||zre(e,n)}},A1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await jre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Gre(s)?i.add(e):qre(t,s)}},x1e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Ure(t,i,{signal:o}),!t.readable)return Ure(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},w1e=t=>{t.writable&&t.end()},zre=(t,e)=>{Gre(e)?KL(t):qre(t,e)},Gre=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",KL=t=>{(t.readable||t.writable)&&t.destroy()},qre=(t,e)=>{t.destroyed||(t.once("error",R1e),t.destroy(e))},R1e=()=>{},vx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Fre=2,Bre=1;import{finished as Vre}from"stream/promises";var Sf=(t,e)=>{t.pipe(e),I1e(t,e),C1e(t,e)},I1e=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await Vre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}ZL(e)}},ZL=t=>{t.writable&&t.end()},C1e=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await Vre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}JL(t)}},JL=t=>{t.readable&&t.destroy()};var Hre=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>qn.has(c)))P1e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!qn.has(c)))N1e({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]:Pl(o);Sf(s,i)}},P1e=(t,e,r,n)=>{r==="output"?Sf(t.stdio[n],e):Sf(e,t.stdio[n]);let i=O1e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},O1e=["stdin","stdout","stderr"],N1e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;k1e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},k1e=(t,{signal:e})=>{Ti(t)&&wl(t,M1e,e)},M1e=2;import{addAbortListener as $1e}from"events";var Ol=[];Ol.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ol.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ol.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",XL=Symbol.for("signal-exit emitter"),QL=globalThis,D1e=Object.defineProperty.bind(Object),e$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(QL[XL])return QL[XL];D1e(QL,XL,{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}},bx=class{},L1e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),t$=class extends bx{onExit(){return()=>{}}load(){}unload(){}},r$=class extends bx{#e=n$.platform==="win32"?"SIGINT":"SIGHUP";#r=new e$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ol)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 Ol)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,Ol.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)}},n$=globalThis.process,{onExit:Wre,load:BEt,unload:jEt}=L1e(Tx(n$)?new r$(n$):new t$);var Yre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Wre(()=>{t.kill()});$1e(n,()=>{i()})};var Zre=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=MA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=U1e(r,n,i),{sourceStream:d,sourceError:f}=B1e(t,l),{options:p,fileDescriptors:h}=co.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},U1e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=F1e(t,e,...r),a=qA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},F1e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Kre,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||HD(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]=AA(r,...n);return{destination:e(Kre)(i,o,s),pipeOptions:s}}if(co.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}`)},Kre=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),B1e=(t,e)=>{try{return{sourceStream:ff(t,e)}}catch(r){return{sourceError:r}}};var Xre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=j1e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw i$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},j1e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return JL(t),n;if(e!==void 0)return ZL(r),e},i$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>gf({error:t,command:Jre,escapedCommand:Jre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Jre="source.pipe(destination)";var Qre=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 z1e}from"stream/promises";var ene=(t,e,r)=>{let n=Ax.has(e)?q1e(t,e):G1e(t,e);return wl(t,H1e,r.signal),wl(e,W1e,r.signal),V1e(e),n},G1e=(t,e)=>{let r=Pl([t]);return Sf(r,e),Ax.set(e,r),r},q1e=(t,e)=>{let r=Ax.get(e);return r.add(t),r},V1e=async t=>{try{await z1e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Ax.delete(t)},Ax=new WeakMap,H1e=2,W1e=1;import{aborted as Y1e}from"util";var tne=(t,e)=>t===void 0?[]:[K1e(t,e)],K1e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Y1e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw i$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var xx=(t,...e)=>{if(Ot(e[0]))return xx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Zre(t,...e),i=Z1e({...n,destination:r});return i.pipe=xx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Z1e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=J1e(t,i);Xre({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=ene(e,o,d);return await Promise.race([Qre(u),...tne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},J1e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as iUe}from"timers/promises";import{on as X1e}from"events";import{getDefaultHighWaterMark as Q1e}from"stream";var wx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return eUe(e,s),nne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},eUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},o$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;tUe(e,s,t);let a=t.readableObjectMode&&!o;return nne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},tUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},nne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=X1e(t,"data",{signal:e.signal,highWaterMark:rne,highWatermark:rne});return rUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},s$=Q1e(!0),rne=s$,rUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=nUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Cl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*R_(a)}},nUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[gx(t,r,!e),mx(t,i,!n,{})].filter(Boolean);var ine=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=oUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([sUe(t),d]);return}let f=$L(c,r),p=o$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([aUe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},oUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Sx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=o$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await mre(a,t,r,o)},sUe=async t=>{await iUe(),t.readableFlowing===null&&t.resume()},aUe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await sx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await ax(r,{maxBuffer:o})):await mf(r,{maxBuffer:o})}catch(a){return one(mte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},a$=async t=>{try{return await t}catch(e){return one(e)}},one=({bufferedData:t})=>OQ(t)?new Uint8Array(t):t;import{finished as cUe}from"stream/promises";var O_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=lUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],cUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||fUe(a,e,r,n)}finally{s.abort()}},lUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&uUe(t,r,n),n},uUe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{dUe(e,r),n.call(t,...i)}},dUe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},fUe=(t,e,r,n)=>{if(!pUe(t,e,r,n))throw t},pUe=(t,e,r,n=!0)=>r.propagating?sne(t)||Rx(t):(r.propagating=!0,c$(r,e)===n?sne(t):Rx(t)),c$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Rx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",sne=t=>t?.code==="EPIPE";var ane=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>l$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),l$=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(c$(l,e)){await u;return}let[d]=await Promise.all([ine({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 cne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Pl([t,e].filter(Boolean)):void 0,lne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>l$({...hUe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:mUe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),hUe=({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}},mUe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as gUe}from"events";var une=t=>af(t,"ipc"),dne=(t,e)=>{let r=kA(t);so({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var fne=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=une(o),a=us(e,"ipc"),c=us(r,"ipc");for await(let l of HL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(gte(t,i,c),i.push(l)),s&&dne(l,o);return i},pne=async(t,e)=>(await Promise.allSettled([t]),e);var hne=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:T})=>{let b=Ere(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=ane({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),w=lne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),I=[],D=fne({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),O=_Ue(m,t,A),M=yUe(h,A);try{return await Promise.race([Promise.all([{},Tre(b),Promise.all(S),w,D,Yee(t,d),...O,...M]),y,SUe(t,T),...Gee(t,o,f,T),...uee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:T}),...jee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:T})])}catch(G){return f.terminationReason??="other",Promise.all([{error:G},b,Promise.all(S.map(_=>a$(_))),a$(w),pne(D,I),Promise.allSettled(O),Promise.allSettled(M)])}},_Ue=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:O_(n,i,r)),yUe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>xi(o,{checkOpen:!1})&&!Ti(o)).map(({type:i,value:o,stream:s=o})=>O_(s,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),SUe=async(t,{signal:e})=>{let[r]=await gUe(t,"error",{signal:e});throw r};var mne=()=>({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=ao();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Ef=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 EUe}from"stream";import{callbackify as vUe}from"util";import{finished as gne}from"stream/promises";var u$=async t=>{if(t!==void 0)try{await d$(t)}catch{}},_ne=async t=>{if(t!==void 0)try{await f$(t)}catch{}},d$=async t=>{await gne(t,{cleanup:!0,readable:!1,writable:!0})},f$=async t=>{await gne(t,{cleanup:!0,readable:!0,writable:!1})},Ix=async(t,e)=>{if(await t,e)throw e},Cx=(t,e,r)=>{r&&!Rx(r)?t.destroy(r):e&&t.destroy()};var yne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||mn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=p$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=h$(a,s),{read:f,onStdoutDataDone:p}=m$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new EUe({read:f,destroy:vUe(_$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return g$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},p$=(t,e,r)=>{let n=ff(t,e),i=N_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},h$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:s$},m$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ao(),s=wx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){TUe(this,s,o)},onStdoutDataDone:o}},TUe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},g$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await f$(t),await n,await u$(i),await e,r.readable&&r.push(null)}catch(o){await u$(i),Sne(r,o)}},_$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Ef(r,e)&&(Sne(t,n),await Ix(e,n))},Sne=(t,e)=>{Cx(t,t.readable,e)};import{Writable as bUe}from"stream";import{callbackify as Ene}from"util";var vne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=y$(t,r,e),s=new bUe({...S$(n,t,i),destroy:Ene(v$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return E$(n,s),s},y$=(t,e,r)=>{let n=qA(t,e),i=N_(r,n,"writableFinal"),o=N_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},S$=(t,e,r)=>({write:AUe.bind(void 0,t),final:Ene(xUe.bind(void 0,t,e,r))}),AUe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},xUe=async(t,e,r)=>{await Ef(r,e)&&(t.writable&&t.end(),await e)},E$=async(t,e,r)=>{try{await d$(t),e.writable&&e.end()}catch(n){await _ne(r),Tne(e,n)}},v$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Ef(r,e),await Ef(n,e)&&(Tne(t,i),await Ix(e,i))},Tne=(t,e)=>{Cx(t,t.writable,e)};import{Duplex as wUe}from"stream";import{callbackify as RUe}from"util";var bne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||mn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=p$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=y$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=h$(c,a),{read:y,onStdoutDataDone:T}=m$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new wUe({read:y,...S$(u,t,d),destroy:RUe(IUe.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 g$({subprocessStdout:c,onStdoutDataDone:T,readable:b,subprocess:t,subprocessStdin:u}),E$(u,b,c),b},IUe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([_$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),v$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var T$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||mn.has(e),s=ff(t,r),a=wx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return CUe(a,s,t)},CUe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Ane=(t,{encoding:e})=>{let r=mne();t.readable=yne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=vne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=bne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=T$.bind(void 0,t,e),t[Symbol.asyncIterator]=T$.bind(void 0,t,e,{})};var xne=(t,e)=>{for(let[r,n]of OUe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},PUe=(async()=>{})().constructor.prototype,OUe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(PUe,t)]);var wne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=MUe(t,e,r),{subprocess:f,promise:p}=LUe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=xx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),xne(f,p),co.set(f,{options:u,fileDescriptors:d}),f},MUe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=DA(t,e,r),{file:a,commandArguments:c,options:l}=tx(t,e,r),u=DUe(l),d=$re(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},DUe=({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}},LUe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=kUe(...rx(t,e,r))}catch(h){return kre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;NUe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Hre(c,a,l),Yre(c,r,l);let d={},f=ao();c.kill=cee.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=cne(c,r),Ane(c,r),Pre(c,r);let p=$Ue({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}},$Ue=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 hne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let T=h.map((S,w)=>fs(S,e,w)),b=fs(m,e,"all"),A=UUe({errorInfo:d,exitCode:f,signal:p,stdio:T,all:b,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return _f(A,n,e)},UUe=({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?w_({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 lo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):ux({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Px=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,FUe(n,t[n],i)]));return{...t,...r}},FUe=(t,e,r)=>BUe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,BUe=new Set(["env",...XD]);var Na=(t,e,r,n)=>{let i=(s,a,c)=>Na(s,a,r,c),o=(...s)=>jUe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},jUe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Px(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=zUe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Are(a,c,l):wne(a,c,l,i)},zUe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=$Q(e)?UQ(e,r):[e,...r],[s,a,c]=AA(...o),l=Px(Px(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 Rne=({file:t,commandArguments:e})=>Cne(t,e),Ine=({file:t,commandArguments:e})=>({...Cne(t,e),isSync:!0}),Cne=(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]=GUe(t);return{file:r,commandArguments:n}},GUe=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(qUe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},qUe=/ +/g;var Pne=(t,e,r)=>{t.sync=e(VUe,r),t.s=t.sync},One=({options:t})=>Nne(t),VUe=({options:t})=>({...Nne(t),isSync:!0}),Nne=t=>({options:{...HUe(t),...t}}),HUe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},kne={preferLocal:!0};var Mne=Na(()=>({})),Pbt=Na(()=>({isSync:!0})),Dne=Na(Rne),Obt=Na(Ine),Nbt=Na(Vee),kbt=Na(One,{},kne,Pne),{sendMessage:Mbt,getOneMessage:Dbt,getEachMessage:Lbt,getCancelSignal:$bt}=Ore();var Lne=!1,$ne=()=>{Lne=!0},fo=()=>Lne;var k_=null,Une=t=>(k_&&k_.destroy(),k_=new ps({totalAllowedTime:t}),k_),Fne=()=>k_;var ps=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&&fo())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 _A({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{de.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 Bne={name:"@netlify/agent-runner-cli",type:"module",version:"1.156.0-ask-clarify.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.5","@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 ZUe=YUe(import.meta.url),JUe=hs.dirname(ZUe),XUe=KUe(import.meta.url),vf=he("shell"),b$=new Set,jne={preferLocal:!0},ur=(t,e,r)=>{let[n,i]=QUe(e,r),o={...jne,...i},s=Mne(t,n,o);Gne(s,o),Hne(s);let a=r?.idleTimeout;return a&&a>0&&Vne(s,a),s},zne=(t,e)=>{let r={...jne,...e},n=Dne(t,r);return Gne(n,r),Hne(n),e?.idleTimeout&&e.idleTimeout>0&&Vne(n,e.idleTimeout),n},QUe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Gne=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(ms.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new a_).pipe(ms.stdout),t.stderr?.pipe(new a_).pipe(ms.stderr);return}t.stdout?.pipe(ms.stdout),t.stderr?.pipe(ms.stderr)},A$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ms.kill(-t.pid,e),vf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return vf.error("Error killing process:",r),!1}},qne=t=>A$(t,"SIGKILL"),Vne=(t,e)=>{let r=null,n=()=>{vf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),A$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(vf.log(`Force killing idle process ${t.pid}`),qne(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Hne=t=>{b$.add(t);let e=Fne();if(e){let r=e.onTimesUp(()=>{vf.log(`Global timer expired, killing process ${t.pid}`),A$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(vf.log(`Force killing process ${t.pid} after timeout`),qne(t))},5e3)});t.on("exit",()=>{b$.delete(t),r()}),t.on("error",()=>{b$.delete(t),r()})}};function po(t,e){if(!ms.env.NETLIFY_LOCAL_MODE)try{let i=XUe.resolve(Bne.name),o=hs.dirname(i);for(;o!==hs.dirname(o);){let s=hs.dirname(o);if(hs.basename(s)==="node_modules"){let a=hs.join(s,".bin",e);if(Ox.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ms.env.NODE_PATH){let i=hs.join(ms.env.NODE_PATH,".bin",e);if(Ox.existsSync(i))return i}let r=hs.join(t,"node_modules",".bin",e);if(Ox.existsSync(r))return r;let n=hs.join(JUe,"..","node_modules",".bin",e);if(Ox.existsSync(n))return n}var eFe=he("utils"),tFe=t=>new Promise(e=>{setTimeout(e,t)});var x$=t=>{try{return new URL(t).hostname||null}catch{return null}},Nx=(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 tFe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},ka=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Wne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):eFe.error("Could not parse JSON",n))}},rFe=t=>t.charAt(0).toUpperCase()+t.slice(1),ho=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():rFe(e)).join(" ");function gs(t,e){e&&t.log(`Skill invoked: ${e}`)}var kx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Yne=(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 w$=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}},nFe=1e4,R$=(t,e=nFe)=>{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{createHash as iFe}from"crypto";import{createReadStream as oFe}from"fs";import Mx from"fs/promises";import Qne from"os";import Dx from"path";var Kne=he("repo"),eie="runner-diffs-",tie=t=>`${eie}${t}-`,rie=async t=>{let e=Qne.tmpdir(),r;try{r=await Mx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(eie)&&!n.startsWith(tie(t))).map(n=>Mx.rm(Dx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Kr=(t,e={})=>ur("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Lx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Kne.info("Getting runner diffs");let n=await aFe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=lFe(o);await uFe(h,r)}Kne.info("Changes after processing"),await C$(r);let s=await O$(o,r);if(await I$(s,r),i=await cFe(r),!i)return{hasChanges:!1,ignored:s};await Kr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Mx.mkdtemp(Dx.join(Qne.tmpdir(),tie(t.sessionId))),c=async({from:h,to:m,fileName:y,binary:T})=>{let b=Dx.join(a,y);await Kr([...T?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await Mx.stat(b);return{path:b,size:S}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Xne(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await Jne(d,h)||(f=h)}await Xne(r),de.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Jne(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},Zne=async t=>{let e=iFe("sha256");for await(let r of oFe(t))e.update(r);return e.digest("hex")},Jne=async(t,e)=>t.size===e.size&&await Zne(t.path)===await Zne(e.path),Xne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Kr(["reset","--soft","HEAD~1"],{cwd:t})},I$=async(t=[],e=process.cwd())=>{await Kr(["add",".",...t],{cwd:e})},C$=async(t=process.cwd())=>{let e=await Kr(["status","-s"],{cwd:t});return String(e.stdout??"")},nie=/.. (.+)?\.log$/,sFe=[nie],aFe=async(t=process.cwd())=>{let e=await C$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
101
+ if (condition) { yield value; }`)};import{Buffer as d$e}from"buffer";import{StringDecoder as f$e}from"string_decoder";var gx=(t,e,r)=>{if(r)return;if(t)return{transform:p$e.bind(void 0,new TextEncoder)};let n=new f$e(e);return{transform:h$e.bind(void 0,n),final:m$e.bind(void 0,n)}},p$e=function*(t,e){d$e.isBuffer(e)?yield ls(e):typeof e=="string"?yield t.encode(e):yield e},h$e=function*(t,e){yield jt(e)?t.write(e):e},m$e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as cre}from"util";var BL=cre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),_x=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_$e}=e[r];for await(let i of n(t))yield*_x(i,e,r+1)},lre=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*g$e(r,Number(e),t)},g$e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*_x(n,r,e+1)},ure=cre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),_$e=function*(t){yield t};var jL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},dre=(t,e)=>[...e.flatMap(r=>[...Cl(r,t,0)]),...R_(t)],Cl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=S$e}=e[r];for(let i of n(t))yield*Cl(i,e,r+1)},R_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*y$e(r,Number(e),t)},y$e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Cl(n,r,e+1)},S$e=function*(t){yield t};var zL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=pre(t,s,o),l=Il(e),u=Il(r),d=l?BL.bind(void 0,_x,a):jL.bind(void 0,Cl),f=l||u?BL.bind(void 0,lre,a):jL.bind(void 0,R_),p=l||u?ure.bind(void 0,a):void 0;return{stream:new E$e({writableObjectMode:n,writableHighWaterMark:fre(n),readableObjectMode:i,readableHighWaterMark:fre(i),transform(m,y,T){d([m,c,0],this,T)},flush(m){f([c],this,m)},destroy:p})}},yx=(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=pre(s,r,a);t=dre(c,t)}return t},pre=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:ore(n,a)},gx(r,s,n),mx(r,o,n,c),{transform:t,final:e},{transform:sre(i,a)},ire({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var hre=(t,e)=>{for(let r of v$e(t))T$e(t,r,e)},v$e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),T$e=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Oa[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>b$e(a,n));r.input=__(s)},b$e=(t,e)=>{let r=yx(t,e,"utf8",!0);return A$e(r),__(r)},A$e=t=>{let e=t.find(r=>typeof r!="string"&&!jt(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as I$e,appendFileSync as C$e}from"fs";var Sx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&af(r,n)&&!mn.has(e)&&x$e(n)&&(t.some(({type:i,value:o})=>i==="native"&&w$e.has(o))||t.every(({type:i})=>qn.has(i))),x$e=t=>t===1||t===2,w$e=new Set(["pipe","overlapped"]),mre=async(t,e,r,n)=>{for await(let i of t)R$e(e)||_re(i,r,n)},gre=(t,e,r)=>{for(let n of t)_re(n,e,r)},R$e=t=>t._readableState.pipes.length>0,_re=(t,e,r)=>{let n=kA(t);so({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var yre=({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)=>P$e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},P$e=({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=Ste(t,o,d),p=ls(f),{stdioItems:h,objectMode:m}=e[r],y=O$e([p],h,c,n),{serializedResult:T,finalResult:b=T}=N$e({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});k$e({serializedResult:T,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&M$e(T,h,i),A}catch(S){return n.error=S,A}},O$e=(t,e,r,n)=>{try{return yx(t,e,r,!1)}catch(i){return n.error=i,t}},N$e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:__(t)};let s=kQ(t,r);return n[o]?{serializedResult:s,finalResult:FL(s,!i[o],e)}:{serializedResult:s}},k$e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Sx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=FL(t,!1,s);try{gre(a,e,n)}catch(c){r.error??=c}},M$e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>px.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?C$e(n,t):(r.add(o),I$e(n,t))}};var Sre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,fs(e,r,"all")]:Array.isArray(e)?[fs(t,r,"all"),...e]:jt(t)&&jt(e)?YD([t,e]):`${t}${e}`};import{once as GL}from"events";var Ere=async(t,e)=>{let[r,n]=await D$e(t);return e.isForcefullyTerminated??=!1,[r,n]},D$e=async t=>{let[e,r]=await Promise.allSettled([GL(t,"spawn"),GL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?vre(t):r.value},vre=async t=>{try{return await GL(t,"exit")}catch{return vre(t)}},Tre=async t=>{let[e,r]=await t;if(!L$e(e,r)&&qL(e,r))throw new bi;return[e,r]},L$e=(t,e)=>t===void 0&&e===void 0,qL=(t,e)=>t!==0||e!==null;var bre=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=$$e(t,e,r),s=o?.code==="ETIMEDOUT",a=yte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},$$e=(t,e,r)=>t!==void 0?t:qL(e,r)?new bi:void 0;var Are=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=F$e(t,e,r),d=z$e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return _f(d,c,l)},F$e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=DA(t,e,r),a=B$e(r),{file:c,commandArguments:l,options:u}=tx(t,e,a);j$e(u);let d=ere(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},B$e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,j$e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Ex("ipcInput"),t&&Ex("ipc: true"),r&&Ex("detached: true"),n&&Ex("cancelSignal")},Ex=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},z$e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=G$e({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}=bre(c,r),{output:h,error:m=l}=yre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((b,A)=>fs(b,r,A)),T=fs(Sre(h,r),r,"all");return V$e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:T,options:r,command:n,escapedCommand:i,startTime:a})},G$e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{hre(o,r);let a=q$e(r);return U$e(...rx(t,e,a))}catch(a){return gf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},q$e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:lx(e)}),V$e=({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?ux({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):w_({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 NUe}from"events";import{spawn as kUe}from"child_process";import Cre from"process";import{once as VL,on as H$e}from"events";var xre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(uf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:KA(t)}),W$e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),W$e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{VA(e,i);let o=Pa(t,e,r),s=new AbortController;try{return await Promise.race([Y$e(o,n,s),K$e(o,r,s),Z$e(o,r,s)])}catch(a){throw df(t),a}finally{s.abort(),HA(e,i)}},Y$e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await VL(t,"message",{signal:r});return n}for await(let[n]of H$e(t,"message",{signal:r}))if(e(n))return n},K$e=async(t,e,{signal:r})=>{await VL(t,"disconnect",{signal:r}),dee(e)},Z$e=async(t,e,{signal:r})=>{let[n]=await VL(t,"strict:error",{signal:r});throw zA(n,e)};import{once as Rre,on as J$e}from"events";var Ire=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>HL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),HL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{uf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:KA(t)}),VA(e,o);let s=Pa(t,e,r),a=new AbortController,c={};return X$e(t,s,a),Q$e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),e1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},X$e=async(t,e,r)=>{try{await Rre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Q$e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Rre(t,"strict:error",{signal:r.signal});n.error=zA(i,e),r.abort()}catch{}},e1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of J$e(r,"message",{signal:o.signal}))wre(s),yield c}catch{wre(s)}finally{o.abort(),HA(e,a),n||df(t),i&&await t}},wre=({error:t})=>{if(t)throw t};var Pre=(t,{ipc:e})=>{Object.assign(t,Nre(t,!1,e))},Ore=()=>{let t=Cre,e=!0,r=Cre.channel!==void 0;return{...Nre(t,e,r),getCancelSignal:Uee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Nre=(t,e,r)=>({sendMessage:QA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:xre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Ire.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as t1e}from"child_process";import{PassThrough as r1e,Readable as n1e,Writable as i1e,Duplex as o1e}from"stream";var kre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{LL(n);let a=new t1e;s1e(a,n),Object.assign(a,{readable:a1e,writable:c1e,duplex:l1e});let c=gf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=u1e(c,s,i);return{subprocess:a,promise:l}},s1e=(t,e)=>{let r=I_(),n=I_(),i=I_(),o=Array.from({length:e.length-3},I_),s=I_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},I_=()=>{let t=new r1e;return t.end(),t},a1e=()=>new n1e({read(){}}),c1e=()=>new i1e({write(){}}),l1e=()=>new o1e({read(){},write(){}}),u1e=async(t,e,r)=>_f(t,e,r);import{createReadStream as Mre,createWriteStream as Dre}from"fs";import{Buffer as d1e}from"buffer";import{Readable as C_,Writable as f1e,Duplex as p1e}from"stream";var $re=(t,e)=>hx(h1e,t,e,!1),P_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Oa[t]}.`)},Lre={fileNumber:P_,generator:zL,asyncGenerator:zL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:p1e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},h1e={input:{...Lre,fileUrl:({value:t})=>({stream:Mre(t)}),filePath:({value:{file:t}})=>({stream:Mre(t)}),webStream:({value:t})=>({stream:C_.fromWeb(t)}),iterable:({value:t})=>({stream:C_.from(t)}),asyncIterable:({value:t})=>({stream:C_.from(t)}),string:({value:t})=>({stream:C_.from(t)}),uint8Array:({value:t})=>({stream:C_.from(d1e.from(t))})},output:{...Lre,fileUrl:({value:t})=>({stream:Dre(t)}),filePath:({value:{file:t,append:e}})=>({stream:Dre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:f1e.fromWeb(t)}),iterable:P_,asyncIterable:P_,string:P_,uint8Array:P_}};import{on as m1e,once as Ure}from"events";import{PassThrough as g1e,getDefaultHighWaterMark as _1e}from"stream";import{finished as jre}from"stream/promises";function Pl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)YL(i);let e=t.some(({readableObjectMode:i})=>i),r=y1e(t,e),n=new WL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var y1e=(t,e)=>{if(t.length===0)return _1e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},WL=class extends g1e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(YL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=S1e(this,this.#e,this.#o);let r=T1e({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(YL(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},S1e=async(t,e,r)=>{vx(t,Fre);let n=new AbortController;try{await Promise.race([E1e(t,n),v1e(t,e,r,n)])}finally{n.abort(),vx(t,-Fre)}},E1e=async(t,{signal:e})=>{try{await jre(t,{signal:e,cleanup:!0})}catch(r){throw zre(t,r),r}},v1e=async(t,e,r,{signal:n})=>{for await(let[i]of m1e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},YL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},T1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{vx(t,Bre);let a=new AbortController;try{await Promise.race([b1e(o,e,a),A1e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),x1e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),vx(t,-Bre)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?KL(t):w1e(t))},b1e=async(t,e,{signal:r})=>{try{await t,r.aborted||KL(e)}catch(n){r.aborted||zre(e,n)}},A1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await jre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Gre(s)?i.add(e):qre(t,s)}},x1e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Ure(t,i,{signal:o}),!t.readable)return Ure(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},w1e=t=>{t.writable&&t.end()},zre=(t,e)=>{Gre(e)?KL(t):qre(t,e)},Gre=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",KL=t=>{(t.readable||t.writable)&&t.destroy()},qre=(t,e)=>{t.destroyed||(t.once("error",R1e),t.destroy(e))},R1e=()=>{},vx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Fre=2,Bre=1;import{finished as Vre}from"stream/promises";var Sf=(t,e)=>{t.pipe(e),I1e(t,e),C1e(t,e)},I1e=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await Vre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}ZL(e)}},ZL=t=>{t.writable&&t.end()},C1e=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await Vre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}JL(t)}},JL=t=>{t.readable&&t.destroy()};var Hre=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>qn.has(c)))P1e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!qn.has(c)))N1e({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]:Pl(o);Sf(s,i)}},P1e=(t,e,r,n)=>{r==="output"?Sf(t.stdio[n],e):Sf(e,t.stdio[n]);let i=O1e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},O1e=["stdin","stdout","stderr"],N1e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;k1e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},k1e=(t,{signal:e})=>{Ti(t)&&wl(t,M1e,e)},M1e=2;import{addAbortListener as $1e}from"events";var Ol=[];Ol.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ol.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ol.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",XL=Symbol.for("signal-exit emitter"),QL=globalThis,D1e=Object.defineProperty.bind(Object),e$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(QL[XL])return QL[XL];D1e(QL,XL,{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}},bx=class{},L1e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),t$=class extends bx{onExit(){return()=>{}}load(){}unload(){}},r$=class extends bx{#e=n$.platform==="win32"?"SIGINT":"SIGHUP";#r=new e$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ol)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 Ol)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,Ol.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)}},n$=globalThis.process,{onExit:Wre,load:BEt,unload:jEt}=L1e(Tx(n$)?new r$(n$):new t$);var Yre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Wre(()=>{t.kill()});$1e(n,()=>{i()})};var Zre=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=MA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=U1e(r,n,i),{sourceStream:d,sourceError:f}=B1e(t,l),{options:p,fileDescriptors:h}=co.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},U1e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=F1e(t,e,...r),a=qA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},F1e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Kre,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||HD(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]=AA(r,...n);return{destination:e(Kre)(i,o,s),pipeOptions:s}}if(co.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}`)},Kre=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),B1e=(t,e)=>{try{return{sourceStream:ff(t,e)}}catch(r){return{sourceError:r}}};var Xre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=j1e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw i$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},j1e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return JL(t),n;if(e!==void 0)return ZL(r),e},i$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>gf({error:t,command:Jre,escapedCommand:Jre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Jre="source.pipe(destination)";var Qre=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 z1e}from"stream/promises";var ene=(t,e,r)=>{let n=Ax.has(e)?q1e(t,e):G1e(t,e);return wl(t,H1e,r.signal),wl(e,W1e,r.signal),V1e(e),n},G1e=(t,e)=>{let r=Pl([t]);return Sf(r,e),Ax.set(e,r),r},q1e=(t,e)=>{let r=Ax.get(e);return r.add(t),r},V1e=async t=>{try{await z1e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Ax.delete(t)},Ax=new WeakMap,H1e=2,W1e=1;import{aborted as Y1e}from"util";var tne=(t,e)=>t===void 0?[]:[K1e(t,e)],K1e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Y1e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw i$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var xx=(t,...e)=>{if(Ot(e[0]))return xx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Zre(t,...e),i=Z1e({...n,destination:r});return i.pipe=xx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Z1e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=J1e(t,i);Xre({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=ene(e,o,d);return await Promise.race([Qre(u),...tne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},J1e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as iUe}from"timers/promises";import{on as X1e}from"events";import{getDefaultHighWaterMark as Q1e}from"stream";var wx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return eUe(e,s),nne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},eUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},o$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;tUe(e,s,t);let a=t.readableObjectMode&&!o;return nne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},tUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},nne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=X1e(t,"data",{signal:e.signal,highWaterMark:rne,highWatermark:rne});return rUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},s$=Q1e(!0),rne=s$,rUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=nUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Cl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*R_(a)}},nUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[gx(t,r,!e),mx(t,i,!n,{})].filter(Boolean);var ine=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=oUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([sUe(t),d]);return}let f=$L(c,r),p=o$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([aUe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},oUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Sx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=o$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await mre(a,t,r,o)},sUe=async t=>{await iUe(),t.readableFlowing===null&&t.resume()},aUe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await sx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await ax(r,{maxBuffer:o})):await mf(r,{maxBuffer:o})}catch(a){return one(mte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},a$=async t=>{try{return await t}catch(e){return one(e)}},one=({bufferedData:t})=>OQ(t)?new Uint8Array(t):t;import{finished as cUe}from"stream/promises";var O_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=lUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],cUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||fUe(a,e,r,n)}finally{s.abort()}},lUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&uUe(t,r,n),n},uUe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{dUe(e,r),n.call(t,...i)}},dUe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},fUe=(t,e,r,n)=>{if(!pUe(t,e,r,n))throw t},pUe=(t,e,r,n=!0)=>r.propagating?sne(t)||Rx(t):(r.propagating=!0,c$(r,e)===n?sne(t):Rx(t)),c$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Rx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",sne=t=>t?.code==="EPIPE";var ane=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>l$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),l$=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(c$(l,e)){await u;return}let[d]=await Promise.all([ine({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 cne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Pl([t,e].filter(Boolean)):void 0,lne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>l$({...hUe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:mUe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),hUe=({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}},mUe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as gUe}from"events";var une=t=>af(t,"ipc"),dne=(t,e)=>{let r=kA(t);so({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var fne=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=une(o),a=us(e,"ipc"),c=us(r,"ipc");for await(let l of HL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(gte(t,i,c),i.push(l)),s&&dne(l,o);return i},pne=async(t,e)=>(await Promise.allSettled([t]),e);var hne=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:T})=>{let b=Ere(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=ane({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),w=lne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),I=[],D=fne({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),O=_Ue(m,t,A),M=yUe(h,A);try{return await Promise.race([Promise.all([{},Tre(b),Promise.all(S),w,D,Yee(t,d),...O,...M]),y,SUe(t,T),...Gee(t,o,f,T),...uee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:T}),...jee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:T})])}catch(G){return f.terminationReason??="other",Promise.all([{error:G},b,Promise.all(S.map(_=>a$(_))),a$(w),pne(D,I),Promise.allSettled(O),Promise.allSettled(M)])}},_Ue=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:O_(n,i,r)),yUe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>xi(o,{checkOpen:!1})&&!Ti(o)).map(({type:i,value:o,stream:s=o})=>O_(s,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),SUe=async(t,{signal:e})=>{let[r]=await gUe(t,"error",{signal:e});throw r};var mne=()=>({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=ao();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Ef=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 EUe}from"stream";import{callbackify as vUe}from"util";import{finished as gne}from"stream/promises";var u$=async t=>{if(t!==void 0)try{await d$(t)}catch{}},_ne=async t=>{if(t!==void 0)try{await f$(t)}catch{}},d$=async t=>{await gne(t,{cleanup:!0,readable:!1,writable:!0})},f$=async t=>{await gne(t,{cleanup:!0,readable:!0,writable:!1})},Ix=async(t,e)=>{if(await t,e)throw e},Cx=(t,e,r)=>{r&&!Rx(r)?t.destroy(r):e&&t.destroy()};var yne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||mn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=p$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=h$(a,s),{read:f,onStdoutDataDone:p}=m$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new EUe({read:f,destroy:vUe(_$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return g$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},p$=(t,e,r)=>{let n=ff(t,e),i=N_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},h$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:s$},m$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ao(),s=wx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){TUe(this,s,o)},onStdoutDataDone:o}},TUe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},g$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await f$(t),await n,await u$(i),await e,r.readable&&r.push(null)}catch(o){await u$(i),Sne(r,o)}},_$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Ef(r,e)&&(Sne(t,n),await Ix(e,n))},Sne=(t,e)=>{Cx(t,t.readable,e)};import{Writable as bUe}from"stream";import{callbackify as Ene}from"util";var vne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=y$(t,r,e),s=new bUe({...S$(n,t,i),destroy:Ene(v$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return E$(n,s),s},y$=(t,e,r)=>{let n=qA(t,e),i=N_(r,n,"writableFinal"),o=N_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},S$=(t,e,r)=>({write:AUe.bind(void 0,t),final:Ene(xUe.bind(void 0,t,e,r))}),AUe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},xUe=async(t,e,r)=>{await Ef(r,e)&&(t.writable&&t.end(),await e)},E$=async(t,e,r)=>{try{await d$(t),e.writable&&e.end()}catch(n){await _ne(r),Tne(e,n)}},v$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Ef(r,e),await Ef(n,e)&&(Tne(t,i),await Ix(e,i))},Tne=(t,e)=>{Cx(t,t.writable,e)};import{Duplex as wUe}from"stream";import{callbackify as RUe}from"util";var bne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||mn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=p$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=y$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=h$(c,a),{read:y,onStdoutDataDone:T}=m$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new wUe({read:y,...S$(u,t,d),destroy:RUe(IUe.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 g$({subprocessStdout:c,onStdoutDataDone:T,readable:b,subprocess:t,subprocessStdin:u}),E$(u,b,c),b},IUe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([_$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),v$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var T$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||mn.has(e),s=ff(t,r),a=wx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return CUe(a,s,t)},CUe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Ane=(t,{encoding:e})=>{let r=mne();t.readable=yne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=vne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=bne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=T$.bind(void 0,t,e),t[Symbol.asyncIterator]=T$.bind(void 0,t,e,{})};var xne=(t,e)=>{for(let[r,n]of OUe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},PUe=(async()=>{})().constructor.prototype,OUe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(PUe,t)]);var wne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=MUe(t,e,r),{subprocess:f,promise:p}=LUe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=xx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),xne(f,p),co.set(f,{options:u,fileDescriptors:d}),f},MUe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=DA(t,e,r),{file:a,commandArguments:c,options:l}=tx(t,e,r),u=DUe(l),d=$re(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},DUe=({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}},LUe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=kUe(...rx(t,e,r))}catch(h){return kre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;NUe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Hre(c,a,l),Yre(c,r,l);let d={},f=ao();c.kill=cee.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=cne(c,r),Ane(c,r),Pre(c,r);let p=$Ue({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}},$Ue=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 hne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let T=h.map((S,w)=>fs(S,e,w)),b=fs(m,e,"all"),A=UUe({errorInfo:d,exitCode:f,signal:p,stdio:T,all:b,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return _f(A,n,e)},UUe=({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?w_({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 lo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):ux({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Px=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,FUe(n,t[n],i)]));return{...t,...r}},FUe=(t,e,r)=>BUe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,BUe=new Set(["env",...XD]);var Na=(t,e,r,n)=>{let i=(s,a,c)=>Na(s,a,r,c),o=(...s)=>jUe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},jUe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Px(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=zUe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Are(a,c,l):wne(a,c,l,i)},zUe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=$Q(e)?UQ(e,r):[e,...r],[s,a,c]=AA(...o),l=Px(Px(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 Rne=({file:t,commandArguments:e})=>Cne(t,e),Ine=({file:t,commandArguments:e})=>({...Cne(t,e),isSync:!0}),Cne=(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]=GUe(t);return{file:r,commandArguments:n}},GUe=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(qUe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},qUe=/ +/g;var Pne=(t,e,r)=>{t.sync=e(VUe,r),t.s=t.sync},One=({options:t})=>Nne(t),VUe=({options:t})=>({...Nne(t),isSync:!0}),Nne=t=>({options:{...HUe(t),...t}}),HUe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},kne={preferLocal:!0};var Mne=Na(()=>({})),Pbt=Na(()=>({isSync:!0})),Dne=Na(Rne),Obt=Na(Ine),Nbt=Na(Vee),kbt=Na(One,{},kne,Pne),{sendMessage:Mbt,getOneMessage:Dbt,getEachMessage:Lbt,getCancelSignal:$bt}=Ore();var Lne=!1,$ne=()=>{Lne=!0},fo=()=>Lne;var k_=null,Une=t=>(k_&&k_.destroy(),k_=new ps({totalAllowedTime:t}),k_),Fne=()=>k_;var ps=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&&fo())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 _A({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{de.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 Bne={name:"@netlify/agent-runner-cli",type:"module",version:"1.156.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.2","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.5","@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 ZUe=YUe(import.meta.url),JUe=hs.dirname(ZUe),XUe=KUe(import.meta.url),vf=he("shell"),b$=new Set,jne={preferLocal:!0},ur=(t,e,r)=>{let[n,i]=QUe(e,r),o={...jne,...i},s=Mne(t,n,o);Gne(s,o),Hne(s);let a=r?.idleTimeout;return a&&a>0&&Vne(s,a),s},zne=(t,e)=>{let r={...jne,...e},n=Dne(t,r);return Gne(n,r),Hne(n),e?.idleTimeout&&e.idleTimeout>0&&Vne(n,e.idleTimeout),n},QUe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Gne=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(ms.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new a_).pipe(ms.stdout),t.stderr?.pipe(new a_).pipe(ms.stderr);return}t.stdout?.pipe(ms.stdout),t.stderr?.pipe(ms.stderr)},A$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ms.kill(-t.pid,e),vf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return vf.error("Error killing process:",r),!1}},qne=t=>A$(t,"SIGKILL"),Vne=(t,e)=>{let r=null,n=()=>{vf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),A$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(vf.log(`Force killing idle process ${t.pid}`),qne(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Hne=t=>{b$.add(t);let e=Fne();if(e){let r=e.onTimesUp(()=>{vf.log(`Global timer expired, killing process ${t.pid}`),A$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(vf.log(`Force killing process ${t.pid} after timeout`),qne(t))},5e3)});t.on("exit",()=>{b$.delete(t),r()}),t.on("error",()=>{b$.delete(t),r()})}};function po(t,e){if(!ms.env.NETLIFY_LOCAL_MODE)try{let i=XUe.resolve(Bne.name),o=hs.dirname(i);for(;o!==hs.dirname(o);){let s=hs.dirname(o);if(hs.basename(s)==="node_modules"){let a=hs.join(s,".bin",e);if(Ox.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ms.env.NODE_PATH){let i=hs.join(ms.env.NODE_PATH,".bin",e);if(Ox.existsSync(i))return i}let r=hs.join(t,"node_modules",".bin",e);if(Ox.existsSync(r))return r;let n=hs.join(JUe,"..","node_modules",".bin",e);if(Ox.existsSync(n))return n}var eFe=he("utils"),tFe=t=>new Promise(e=>{setTimeout(e,t)});var x$=t=>{try{return new URL(t).hostname||null}catch{return null}},Nx=(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 tFe(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},ka=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},Wne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):eFe.error("Could not parse JSON",n))}},rFe=t=>t.charAt(0).toUpperCase()+t.slice(1),ho=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():rFe(e)).join(" ");function gs(t,e){e&&t.log(`Skill invoked: ${e}`)}var kx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Yne=(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 w$=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}},nFe=1e4,R$=(t,e=nFe)=>{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{createHash as iFe}from"crypto";import{createReadStream as oFe}from"fs";import Mx from"fs/promises";import Qne from"os";import Dx from"path";var Kne=he("repo"),eie="runner-diffs-",tie=t=>`${eie}${t}-`,rie=async t=>{let e=Qne.tmpdir(),r;try{r=await Mx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(eie)&&!n.startsWith(tie(t))).map(n=>Mx.rm(Dx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Kr=(t,e={})=>ur("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Lx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Kne.info("Getting runner diffs");let n=await aFe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=lFe(o);await uFe(h,r)}Kne.info("Changes after processing"),await C$(r);let s=await O$(o,r);if(await I$(s,r),i=await cFe(r),!i)return{hasChanges:!1,ignored:s};await Kr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Mx.mkdtemp(Dx.join(Qne.tmpdir(),tie(t.sessionId))),c=async({from:h,to:m,fileName:y,binary:T})=>{let b=Dx.join(a,y);await Kr([...T?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await Mx.stat(b);return{path:b,size:S}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Xne(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await Jne(d,h)||(f=h)}await Xne(r),de.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Jne(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},Zne=async t=>{let e=iFe("sha256");for await(let r of oFe(t))e.update(r);return e.digest("hex")},Jne=async(t,e)=>t.size===e.size&&await Zne(t.path)===await Zne(e.path),Xne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Kr(["reset","--soft","HEAD~1"],{cwd:t})},I$=async(t=[],e=process.cwd())=>{await Kr(["add",".",...t],{cwd:e})},C$=async(t=process.cwd())=>{let e=await Kr(["status","-s"],{cwd:t});return String(e.stdout??"")},nie=/.. (.+)?\.log$/,sFe=[nie],aFe=async(t=process.cwd())=>{let e=await C$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
102
102
  `).filter(i=>sFe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},cFe=async(t=process.cwd())=>{try{return await Kr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},P$=async(t=process.cwd())=>{let{stdout:e}=await Kr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},iie=async(t=process.cwd())=>{let{stdout:e}=await Kr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},O$=async(t,e=process.cwd())=>{t||=await C$(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}${Dx.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(nie)?.[1];o&&n.push(`:!${o}.log`)}),n},oie=async(t=process.cwd())=>{await Kr(["reset","--hard","HEAD"],{cwd:t})},sie=async(t=process.cwd())=>{let e=await Kr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
104
104
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},lFe=t=>{let e=t.split(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/agent-runner-cli",
3
3
  "type": "module",
4
- "version": "1.156.0-ask-clarify.2",
4
+ "version": "1.156.0",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",