@netlify/agent-runner-cli 1.200.2-bug.6 → 1.200.2-bug.7

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
@@ -385,7 +385,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
385
385
  `,LF:`
386
386
  `,concatBytes:wY},Fct=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},zct={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Fct};import{Buffer as jct}from"buffer";var pwe=(t,e)=>t?void 0:qct.bind(void 0,e),qct=function*(t,e){if(typeof e!="string"&&!zr(e)&&!jct.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},hwe=(t,e)=>t?Bct.bind(void 0,e):Vct.bind(void 0,e),Bct=function*(t,e){mwe(t,e),yield e},Vct=function*(t,e){if(mwe(t,e),typeof e!="string"&&!zr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},mwe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
387
387
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
388
- if (condition) { yield value; }`)};import{Buffer as Gct}from"buffer";import{StringDecoder as Hct}from"string_decoder";var qD=(t,e,r)=>{if(r)return;if(t)return{transform:Wct.bind(void 0,new TextEncoder)};let n=new Hct(e);return{transform:Kct.bind(void 0,n),final:Yct.bind(void 0,n)}},Wct=function*(t,e){Gct.isBuffer(e)?yield ou(e):typeof e=="string"?yield t.encode(e):yield e},Kct=function*(t,e){yield zr(e)?t.write(e):e},Yct=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as gwe}from"util";var AY=gwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),BD=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Jct}=e[r];for await(let i of n(t))yield*BD(i,e,r+1)},_we=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Zct(r,Number(e),t)},Zct=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*BD(n,r,e+1)},ywe=gwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Jct=function*(t){yield t};var RY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Swe=(t,e)=>[...e.flatMap(r=>[...wp(r,t,0)]),...UT(t)],wp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Xct}=e[r];for(let i of n(t))yield*wp(i,e,r+1)},UT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Qct(r,Number(e),t)},Qct=function*(t,e,r){if(t!==void 0)for(let n of t())yield*wp(n,r,e+1)},Xct=function*(t){yield t};var xY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Ewe(t,o,s),u=bp(e),l=bp(r),d=u?AY.bind(void 0,BD,a):RY.bind(void 0,wp),f=u||l?AY.bind(void 0,_we,a):RY.bind(void 0,UT),p=u||l?ywe.bind(void 0,a):void 0;return{stream:new eut({writableObjectMode:n,writableHighWaterMark:vwe(n),readableObjectMode:i,readableHighWaterMark:vwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},VD=(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=Ewe(o,r,a);t=Swe(c,t)}return t},Ewe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:pwe(n,a)},qD(r,o,n),jD(r,s,n,c),{transform:t,final:e},{transform:hwe(i,a)},fwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var bwe=(t,e)=>{for(let r of tut(t))rut(t,r,e)},tut=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),rut=(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 ${Bl[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>nut(a,n));r.input=OT(o)},nut=(t,e)=>{let r=VD(t,e,"utf8",!0);return iut(r),OT(r)},iut=t=>{let e=t.find(r=>typeof r!="string"&&!zr(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 cut,appendFileSync as uut}from"fs";var GD=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&R_(r,n)&&!ts.has(e)&&sut(n)&&(t.some(({type:i,value:s})=>i==="native"&&out.has(s))||t.every(({type:i})=>Ls.has(i))),sut=t=>t===1||t===2,out=new Set(["pipe","overlapped"]),wwe=async(t,e,r,n)=>{for await(let i of t)aut(e)||Awe(i,r,n)},Twe=(t,e,r)=>{for(let n of t)Awe(n,e,r)},aut=t=>t._readableState.pipes.length>0,Awe=(t,e,r)=>{let n=sD(t);Ga({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Rwe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>lut({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},lut=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=xbe(t,s,d),p=ou(f),{stdioItems:h,objectMode:m}=e[r],_=dut([p],h,c,n),{serializedResult:S,finalResult:b=S}=fut({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});put({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let R=a[r]?b:void 0;try{return n.error===void 0&&hut(S,h,i),R}catch(y){return n.error=y,R}},dut=(t,e,r,n)=>{try{return VD(t,e,r,!1)}catch(i){return n.error=i,t}},fut=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:OT(t)};let o=jSe(t,r);return n[s]?{serializedResult:o,finalResult:TY(o,!i[s],e)}:{serializedResult:o}},put=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!GD({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=TY(t,!1,o);try{Twe(a,e,n)}catch(c){r.error??=c}},hut=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>FD.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?uut(n,t):(r.add(s),cut(n,t))}};var xwe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,uu(e,r,"all")]:Array.isArray(e)?[uu(t,r,"all"),...e]:zr(t)&&zr(e)?NK([t,e]):`${t}${e}`};import{once as OY}from"events";var Owe=async(t,e)=>{let[r,n]=await mut(t);return e.isForcefullyTerminated??=!1,[r,n]},mut=async t=>{let[e,r]=await Promise.allSettled([OY(t,"spawn"),OY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Iwe(t):r.value},Iwe=async t=>{try{return await OY(t,"exit")}catch{return Iwe(t)}},Pwe=async t=>{let[e,r]=await t;if(!gut(e,r)&&IY(e,r))throw new Ko;return[e,r]},gut=(t,e)=>t===void 0&&e===void 0,IY=(t,e)=>t!==0||e!==null;var Cwe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=_ut(t,e,r),o=s?.code==="ETIMEDOUT",a=Rbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},_ut=(t,e,r)=>t!==void 0?t:IY(e,r)?new Ko:void 0;var kwe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Sut(t,e,r),d=but({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return $_(d,c,u)},Sut=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=aD(t,e,r),a=vut(r),{file:c,commandArguments:u,options:l}=xD(t,e,a);Eut(l);let d=cwe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},vut=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Eut=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&HD("ipcInput"),t&&HD("ipc: true"),r&&HD("detached: true"),n&&HD("cancelSignal")},HD=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},but=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=wut({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=Cwe(c,r),{output:h,error:m=u}=Rwe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((b,R)=>uu(b,r,R)),S=uu(xwe(h,r),r,"all");return Aut({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},wut=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{bwe(s,r);let a=Tut(r);return yut(...OD(t,e,a))}catch(a){return M_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Tut=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:MD(e)}),Aut=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?$D({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):LT({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as fdt}from"events";import{spawn as pdt}from"child_process";import Lwe from"process";import{once as PY,on as Rut}from"events";var Nwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(I_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ED(t)}),xut({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),xut=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{_D(e,i);let s=ql(t,e,r),o=new AbortController;try{return await Promise.race([Out(s,n,o),Iut(s,r,o),Put(s,r,o)])}catch(a){throw P_(t),a}finally{o.abort(),yD(e,i)}},Out=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await PY(t,"message",{signal:r});return n}for await(let[n]of Rut(t,"message",{signal:r}))if(e(n))return n},Iut=async(t,e,{signal:r})=>{await PY(t,"disconnect",{signal:r}),SEe(e)},Put=async(t,e,{signal:r})=>{let[n]=await PY(t,"strict:error",{signal:r});throw hD(n,e)};import{once as Mwe,on as Cut}from"events";var $we=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>CY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),CY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{I_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ED(t)}),_D(e,s);let o=ql(t,e,r),a=new AbortController,c={};return kut(t,o,a),Nut({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Dut({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},kut=async(t,e,r)=>{try{await Mwe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Nut=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Mwe(t,"strict:error",{signal:r.signal});n.error=hD(i,e),r.abort()}catch{}},Dut=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Cut(r,"message",{signal:s.signal}))Dwe(o),yield c}catch{Dwe(o)}finally{s.abort(),yD(e,a),n||P_(t),i&&await t}},Dwe=({error:t})=>{if(t)throw t};var Uwe=(t,{ipc:e})=>{Object.assign(t,zwe(t,!1,e))},Fwe=()=>{let t=Lwe,e=!0,r=Lwe.channel!==void 0;return{...zwe(t,e,r),getCancelSignal:HEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},zwe=(t,e,r)=>({sendMessage:AD.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Nwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:$we.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Mut}from"child_process";import{PassThrough as $ut,Readable as Lut,Writable as Uut,Duplex as Fut}from"stream";var jwe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{EY(n);let a=new Mut;zut(a,n),Object.assign(a,{readable:jut,writable:qut,duplex:But});let c=M_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Vut(c,o,i);return{subprocess:a,promise:u}},zut=(t,e)=>{let r=FT(),n=FT(),i=FT(),s=Array.from({length:e.length-3},FT),o=FT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},FT=()=>{let t=new $ut;return t.end(),t},jut=()=>new Lut({read(){}}),qut=()=>new Uut({write(){}}),But=()=>new Fut({read(){},write(){}}),Vut=async(t,e,r)=>$_(t,e,r);import{createReadStream as qwe,createWriteStream as Bwe}from"fs";import{Buffer as Gut}from"buffer";import{Readable as zT,Writable as Hut,Duplex as Wut}from"stream";var Gwe=(t,e)=>zD(Kut,t,e,!1),jT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Bl[t]}.`)},Vwe={fileNumber:jT,generator:xY,asyncGenerator:xY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Wut.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Kut={input:{...Vwe,fileUrl:({value:t})=>({stream:qwe(t)}),filePath:({value:{file:t}})=>({stream:qwe(t)}),webStream:({value:t})=>({stream:zT.fromWeb(t)}),iterable:({value:t})=>({stream:zT.from(t)}),asyncIterable:({value:t})=>({stream:zT.from(t)}),string:({value:t})=>({stream:zT.from(t)}),uint8Array:({value:t})=>({stream:zT.from(Gut.from(t))})},output:{...Vwe,fileUrl:({value:t})=>({stream:Bwe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Bwe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Hut.fromWeb(t)}),iterable:jT,asyncIterable:jT,string:jT,uint8Array:jT}};import{on as Yut,once as Hwe}from"events";import{PassThrough as Zut,getDefaultHighWaterMark as Jut}from"stream";import{finished as Ywe}from"stream/promises";function Tp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)NY(i);let e=t.some(({readableObjectMode:i})=>i),r=Qut(t,e),n=new kY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Qut=(t,e)=>{if(t.length===0)return Jut(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},kY=class extends Zut{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(NY(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Xut(this,this.#e,this.#s);let r=rlt({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(NY(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)}},Xut=async(t,e,r)=>{WD(t,Wwe);let n=new AbortController;try{await Promise.race([elt(t,n),tlt(t,e,r,n)])}finally{n.abort(),WD(t,-Wwe)}},elt=async(t,{signal:e})=>{try{await Ywe(t,{signal:e,cleanup:!0})}catch(r){throw Zwe(t,r),r}},tlt=async(t,e,r,{signal:n})=>{for await(let[i]of Yut(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},NY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},rlt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{WD(t,Kwe);let a=new AbortController;try{await Promise.race([nlt(s,e,a),ilt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),slt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),WD(t,-Kwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?DY(t):olt(t))},nlt=async(t,e,{signal:r})=>{try{await t,r.aborted||DY(e)}catch(n){r.aborted||Zwe(e,n)}},ilt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Ywe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Jwe(o)?i.add(e):Qwe(t,o)}},slt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Hwe(t,i,{signal:s}),!t.readable)return Hwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},olt=t=>{t.writable&&t.end()},Zwe=(t,e)=>{Jwe(e)?DY(t):Qwe(t,e)},Jwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",DY=t=>{(t.readable||t.writable)&&t.destroy()},Qwe=(t,e)=>{t.destroyed||(t.once("error",alt),t.destroy(e))},alt=()=>{},WD=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Wwe=2,Kwe=1;import{finished as Xwe}from"stream/promises";var U_=(t,e)=>{t.pipe(e),clt(t,e),ult(t,e)},clt=async(t,e)=>{if(!(Wo(t)||Wo(e))){try{await Xwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}MY(e)}},MY=t=>{t.writable&&t.end()},ult=async(t,e)=>{if(!(Wo(t)||Wo(e))){try{await Xwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}$Y(t)}},$Y=t=>{t.readable&&t.destroy()};var eTe=(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})=>Ls.has(c)))llt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ls.has(c)))flt({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]:Tp(s);U_(o,i)}},llt=(t,e,r,n)=>{r==="output"?U_(t.stdio[n],e):U_(e,t.stdio[n]);let i=dlt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},dlt=["stdin","stdout","stderr"],flt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;plt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},plt=(t,{signal:e})=>{Wo(t)&&vp(t,hlt,e)},hlt=2;import{addAbortListener as _lt}from"events";var Ap=[];Ap.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ap.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ap.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var KD=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",LY=Symbol.for("signal-exit emitter"),UY=globalThis,mlt=Object.defineProperty.bind(Object),FY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(UY[LY])return UY[LY];mlt(UY,LY,{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}},YD=class{},glt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),zY=class extends YD{onExit(){return()=>{}}load(){}unload(){}},jY=class extends YD{#e=qY.platform==="win32"?"SIGINT":"SIGHUP";#r=new FY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ap)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(!KD(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 Ap)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,Ap.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 KD(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"&&KD(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)}},qY=globalThis.process,{onExit:tTe,load:Vir,unload:Gir}=glt(KD(qY)?new jY(qY):new zY);var rTe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=tTe(()=>{t.kill()});_lt(n,()=>{i()})};var iTe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=oD(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=ylt(r,n,i),{sourceStream:d,sourceError:f}=vlt(t,u),{options:p,fileDescriptors:h}=Wa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},ylt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Slt(t,e,...r),a=gD(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Slt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(nTe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||CK(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]=ZN(r,...n);return{destination:e(nTe)(i,s,o),pipeOptions:o}}if(Wa.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}`)},nTe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),vlt=(t,e)=>{try{return{sourceStream:C_(t,e)}}catch(r){return{sourceError:r}}};var oTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Elt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw BY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Elt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return $Y(t),n;if(e!==void 0)return MY(r),e},BY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>M_({error:t,command:sTe,escapedCommand:sTe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),sTe="source.pipe(destination)";var aTe=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 blt}from"stream/promises";var cTe=(t,e,r)=>{let n=ZD.has(e)?Tlt(t,e):wlt(t,e);return vp(t,Rlt,r.signal),vp(e,xlt,r.signal),Alt(e),n},wlt=(t,e)=>{let r=Tp([t]);return U_(r,e),ZD.set(e,r),r},Tlt=(t,e)=>{let r=ZD.get(e);return r.add(t),r},Alt=async t=>{try{await blt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ZD.delete(t)},ZD=new WeakMap,Rlt=2,xlt=1;import{aborted as Olt}from"util";var uTe=(t,e)=>t===void 0?[]:[Ilt(t,e)],Ilt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Olt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw BY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var JD=(t,...e)=>{if(Sr(e[0]))return JD.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=iTe(t,...e),i=Plt({...n,destination:r});return i.pipe=JD.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Plt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Clt(t,i);oTe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=cTe(e,s,d);return await Promise.race([aTe(l),...uTe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Clt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Ult}from"timers/promises";import{on as klt}from"events";import{getDefaultHighWaterMark as Nlt}from"stream";var QD=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Dlt(e,o),dTe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Dlt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},VY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;Mlt(e,o,t);let a=t.readableObjectMode&&!s;return dTe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Mlt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},dTe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=klt(t,"data",{signal:e.signal,highWaterMark:lTe,highWatermark:lTe});return $lt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},GY=Nlt(!0),lTe=GY,$lt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=Llt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*wp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*UT(a)}},Llt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[qD(t,r,!e),jD(t,i,!n,{})].filter(Boolean);var fTe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=Flt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([zlt(t),d]);return}let f=bY(c,r),p=VY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([jlt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},Flt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!GD({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=VY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await wwe(a,t,r,s)},zlt=async t=>{await Ult(),t.readableFlowing===null&&t.resume()},jlt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await kD(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await ND(r,{maxBuffer:s})):await D_(r,{maxBuffer:s})}catch(a){return pTe(wbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},HY=async t=>{try{return await t}catch(e){return pTe(e)}},pTe=({bufferedData:t})=>FSe(t)?new Uint8Array(t):t;import{finished as qlt}from"stream/promises";var qT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=Blt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],qlt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Hlt(a,e,r,n)}finally{o.abort()}},Blt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Vlt(t,r,n),n},Vlt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Glt(e,r),n.call(t,...i)}},Glt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Hlt=(t,e,r,n)=>{if(!Wlt(t,e,r,n))throw t},Wlt=(t,e,r,n=!0)=>r.propagating?hTe(t)||XD(t):(r.propagating=!0,WY(r,e)===n?hTe(t):XD(t)),WY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",XD=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",hTe=t=>t?.code==="EPIPE";var mTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>KY({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),KY=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=qT(t,e,u);if(WY(u,e)){await l;return}let[d]=await Promise.all([fTe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var gTe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Tp([t,e].filter(Boolean)):void 0,_Te=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>KY({...Klt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Ylt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Klt=({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}},Ylt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Zlt}from"events";var yTe=t=>R_(t,"ipc"),STe=(t,e)=>{let r=sD(t);Ga({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var vTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=yTe(s),a=au(e,"ipc"),c=au(r,"ipc");for await(let u of CY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Tbe(t,i,c),i.push(u)),o&&STe(u,s);return i},ETe=async(t,e)=>(await Promise.allSettled([t]),e);var bTe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let b=Owe(t,f),R={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=mTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:R}),v=_Te({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:R}),w=[],O=vTe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:w,verboseInfo:p}),P=Jlt(m,t,R),C=Qlt(h,R);try{return await Promise.race([Promise.all([{},Pwe(b),Promise.all(y),v,O,rbe(t,d),...P,...C]),_,Xlt(t,S),...JEe(t,s,f,S),...yEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...YEe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},b,Promise.all(y.map(T=>HY(T))),HY(v),ETe(O,w),Promise.allSettled(P),Promise.allSettled(C)])}},Jlt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:qT(n,i,r)),Qlt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Zo(s,{checkOpen:!1})&&!Wo(s)).map(({type:i,value:s,stream:o=s})=>qT(o,n,e,{isSameDirection:Ls.has(i),stopOnExit:i==="native"}))),Xlt=async(t,{signal:e})=>{let[r]=await Zlt(t,"error",{signal:e});throw r};var wTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),BT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Ha();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},F_=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 edt}from"stream";import{callbackify as tdt}from"util";import{finished as TTe}from"stream/promises";var YY=async t=>{if(t!==void 0)try{await ZY(t)}catch{}},ATe=async t=>{if(t!==void 0)try{await JY(t)}catch{}},ZY=async t=>{await TTe(t,{cleanup:!0,readable:!1,writable:!0})},JY=async t=>{await TTe(t,{cleanup:!0,readable:!0,writable:!1})},eM=async(t,e)=>{if(await t,e)throw e},tM=(t,e,r)=>{r&&!XD(r)?t.destroy(r):e&&t.destroy()};var RTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ts.has(r),{subprocessStdout:a,waitReadableDestroy:c}=QY(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=XY(a,o),{read:f,onStdoutDataDone:p}=e9({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new edt({read:f,destroy:tdt(r9.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return t9({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},QY=(t,e,r)=>{let n=C_(t,e),i=BT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},XY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:GY},e9=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Ha(),o=QD({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){rdt(this,o,s)},onStdoutDataDone:s}},rdt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},t9=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await JY(t),await n,await YY(i),await e,r.readable&&r.push(null)}catch(s){await YY(i),xTe(r,s)}},r9=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await F_(r,e)&&(xTe(t,n),await eM(e,n))},xTe=(t,e)=>{tM(t,t.readable,e)};import{Writable as ndt}from"stream";import{callbackify as OTe}from"util";var ITe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=n9(t,r,e),o=new ndt({...i9(n,t,i),destroy:OTe(o9.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return s9(n,o),o},n9=(t,e,r)=>{let n=gD(t,e),i=BT(r,n,"writableFinal"),s=BT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},i9=(t,e,r)=>({write:idt.bind(void 0,t),final:OTe(sdt.bind(void 0,t,e,r))}),idt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},sdt=async(t,e,r)=>{await F_(r,e)&&(t.writable&&t.end(),await e)},s9=async(t,e,r)=>{try{await ZY(t),e.writable&&e.end()}catch(n){await ATe(r),PTe(e,n)}},o9=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await F_(r,e),await F_(n,e)&&(PTe(t,i),await eM(e,i))},PTe=(t,e)=>{tM(t,t.writable,e)};import{Duplex as odt}from"stream";import{callbackify as adt}from"util";var CTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ts.has(r),{subprocessStdout:c,waitReadableDestroy:u}=QY(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=n9(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=XY(c,a),{read:_,onStdoutDataDone:S}=e9({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new odt({read:_,...i9(l,t,d),destroy:adt(cdt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return t9({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:l}),s9(l,b,c),b},cdt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([r9({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),o9({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var a9=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ts.has(e),o=C_(t,r),a=QD({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return udt(a,o,t)},udt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var kTe=(t,{encoding:e})=>{let r=wTe();t.readable=RTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=ITe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=CTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=a9.bind(void 0,t,e),t[Symbol.asyncIterator]=a9.bind(void 0,t,e,{})};var NTe=(t,e)=>{for(let[r,n]of ddt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},ldt=(async()=>{})().constructor.prototype,ddt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(ldt,t)]);var DTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=hdt(t,e,r),{subprocess:f,promise:p}=gdt({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=JD.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),NTe(f,p),Wa.set(f,{options:l,fileDescriptors:d}),f},hdt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=aD(t,e,r),{file:a,commandArguments:c,options:u}=xD(t,e,r),l=mdt(u),d=Gwe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},mdt=({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}},gdt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=pdt(...OD(t,e,r))}catch(h){return jwe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;fdt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];eTe(c,a,u),rTe(c,r,u);let d={},f=Ha();c.kill=gEe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=gTe(c,r),kTe(c,r),Uwe(c,r);let p=_dt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},_dt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await bTe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let S=h.map((y,v)=>uu(y,e,v)),b=uu(m,e,"all"),R=ydt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:b,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return $_(R,n,e)},ydt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?LT({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Ka,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):$D({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var rM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Sdt(n,t[n],i)]));return{...t,...r}},Sdt=(t,e,r)=>vdt.has(t)&&Sr(e)&&Sr(r)?{...e,...r}:r,vdt=new Set(["env",...LK]);var Vl=(t,e,r,n)=>{let i=(o,a,c)=>Vl(o,a,r,c),s=(...o)=>Edt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},Edt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Sr(s))return i(t,rM(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=bdt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?kwe(a,c,u):DTe(a,c,u,i)},bdt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=GSe(e)?HSe(e,r):[e,...r],[o,a,c]=ZN(...s),u=rM(rM(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var MTe=({file:t,commandArguments:e})=>LTe(t,e),$Te=({file:t,commandArguments:e})=>({...LTe(t,e),isSync:!0}),LTe=(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]=wdt(t);return{file:r,commandArguments:n}},wdt=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(Tdt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Tdt=/ +/g;var UTe=(t,e,r)=>{t.sync=e(Adt,r),t.s=t.sync},FTe=({options:t})=>zTe(t),Adt=({options:t})=>({...zTe(t),isSync:!0}),zTe=t=>({options:{...Rdt(t),...t}}),Rdt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},jTe={preferLocal:!0};var qTe=Vl(()=>({})),$ar=Vl(()=>({isSync:!0})),BTe=Vl(MTe),Lar=Vl($Te),Uar=Vl(XEe),Far=Vl(FTe,{},jTe,UTe),{sendMessage:zar,getOneMessage:jar,getEachMessage:qar,getCancelSignal:Bar}=Fwe();var VTe=!1,GTe,xdt=t=>{GTe??=t},HTe=t=>{VTe=!0,xdt(t)},Mn=()=>VTe,lu=()=>GTe,WTe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var VT=null,KTe=t=>(VT&&VT.destroy(),VT=new Us({totalAllowedTime:t}),VT),YTe=()=>VT;var Us=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&&Mn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await UC({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{Y.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var ZTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.200.2-bug.6",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@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.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var Cdt=Idt(import.meta.url),kdt=du.dirname(Cdt),Ndt=Pdt(import.meta.url),z_=re("shell"),c9=new Set,JTe={preferLocal:!0},_t=(t,e,r)=>{let[n,i]=Ddt(e,r),s={...JTe,...i},o=qTe(t,n,s);XTe(o,s),rAe(o);let a=r?.idleTimeout;return a&&a>0&&tAe(o,a),o},QTe=(t,e)=>{let r={...JTe,...e},n=BTe(t,r);return XTe(n,r),rAe(n),e?.idleTimeout&&e.idleTimeout>0&&tAe(n,e.idleTimeout),n},Ddt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},XTe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Za.env.NETLIFY_LOCAL_QUIET==="true")return;if(Za.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Nb).pipe(Za.stdout),t.stderr?.pipe(new Nb).pipe(Za.stderr);return}t.stdout?.pipe(Za.stdout),t.stderr?.pipe(Za.stderr)},u9=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Za.kill(-t.pid,e),z_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return z_.error("Error killing process:",r),!1}},eAe=t=>u9(t,"SIGKILL"),tAe=(t,e)=>{let r=null,n=()=>{z_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),u9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(z_.log(`Force killing idle process ${t.pid}`),eAe(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)},rAe=t=>{c9.add(t);let e=YTe();if(e){let r=e.onTimesUp(()=>{z_.log(`Global timer expired, killing process ${t.pid}`),u9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(z_.log(`Force killing process ${t.pid} after timeout`),eAe(t))},5e3)});t.on("exit",()=>{c9.delete(t),r()}),t.on("error",()=>{c9.delete(t),r()})}};function iM(t,e){return!!Jo(t,e)}function Jo(t,e){if(!Za.env.NETLIFY_LOCAL_MODE)try{let i=Ndt.resolve(ZTe.name),s=du.dirname(i);for(;s!==du.dirname(s);){let o=du.dirname(s);if(du.basename(o)==="node_modules"){let a=du.join(o,".bin",e);if(nM.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Za.env.NODE_PATH){let i=du.join(Za.env.NODE_PATH,".bin",e);if(nM.existsSync(i))return i}let r=du.join(t,"node_modules",".bin",e);if(nM.existsSync(r))return r;let n=du.join(kdt,"..","node_modules",".bin",e);if(nM.existsSync(n))return n}var nAe=re("repo"),cAe="runner-diffs-",l9=t=>`${cAe}${t}-`,uAe=async t=>{let e=oM.tmpdir(),r;try{r=await si.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(cAe)&&!n.startsWith(l9(t))).map(n=>si.rm(Fs.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},iAe=async t=>{let e=Mdt("sha256");for await(let r of $dt(t))e.update(r);return e.digest("hex")},sAe=async(t,e)=>t.size===e.size&&await iAe(t.path)===await iAe(e.path),lAe=/.. (.+)?\.log$/,Ldt=[lAe],Udt=1,oAe=t=>{let e=t.split(`
388
+ if (condition) { yield value; }`)};import{Buffer as Gct}from"buffer";import{StringDecoder as Hct}from"string_decoder";var qD=(t,e,r)=>{if(r)return;if(t)return{transform:Wct.bind(void 0,new TextEncoder)};let n=new Hct(e);return{transform:Kct.bind(void 0,n),final:Yct.bind(void 0,n)}},Wct=function*(t,e){Gct.isBuffer(e)?yield ou(e):typeof e=="string"?yield t.encode(e):yield e},Kct=function*(t,e){yield zr(e)?t.write(e):e},Yct=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as gwe}from"util";var AY=gwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),BD=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Jct}=e[r];for await(let i of n(t))yield*BD(i,e,r+1)},_we=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Zct(r,Number(e),t)},Zct=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*BD(n,r,e+1)},ywe=gwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Jct=function*(t){yield t};var RY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Swe=(t,e)=>[...e.flatMap(r=>[...wp(r,t,0)]),...UT(t)],wp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Xct}=e[r];for(let i of n(t))yield*wp(i,e,r+1)},UT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Qct(r,Number(e),t)},Qct=function*(t,e,r){if(t!==void 0)for(let n of t())yield*wp(n,r,e+1)},Xct=function*(t){yield t};var xY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Ewe(t,o,s),u=bp(e),l=bp(r),d=u?AY.bind(void 0,BD,a):RY.bind(void 0,wp),f=u||l?AY.bind(void 0,_we,a):RY.bind(void 0,UT),p=u||l?ywe.bind(void 0,a):void 0;return{stream:new eut({writableObjectMode:n,writableHighWaterMark:vwe(n),readableObjectMode:i,readableHighWaterMark:vwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},VD=(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=Ewe(o,r,a);t=Swe(c,t)}return t},Ewe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:pwe(n,a)},qD(r,o,n),jD(r,s,n,c),{transform:t,final:e},{transform:hwe(i,a)},fwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var bwe=(t,e)=>{for(let r of tut(t))rut(t,r,e)},tut=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),rut=(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 ${Bl[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>nut(a,n));r.input=OT(o)},nut=(t,e)=>{let r=VD(t,e,"utf8",!0);return iut(r),OT(r)},iut=t=>{let e=t.find(r=>typeof r!="string"&&!zr(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 cut,appendFileSync as uut}from"fs";var GD=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&R_(r,n)&&!ts.has(e)&&sut(n)&&(t.some(({type:i,value:s})=>i==="native"&&out.has(s))||t.every(({type:i})=>Ls.has(i))),sut=t=>t===1||t===2,out=new Set(["pipe","overlapped"]),wwe=async(t,e,r,n)=>{for await(let i of t)aut(e)||Awe(i,r,n)},Twe=(t,e,r)=>{for(let n of t)Awe(n,e,r)},aut=t=>t._readableState.pipes.length>0,Awe=(t,e,r)=>{let n=sD(t);Ga({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Rwe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>lut({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},lut=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=xbe(t,s,d),p=ou(f),{stdioItems:h,objectMode:m}=e[r],_=dut([p],h,c,n),{serializedResult:S,finalResult:b=S}=fut({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});put({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let R=a[r]?b:void 0;try{return n.error===void 0&&hut(S,h,i),R}catch(y){return n.error=y,R}},dut=(t,e,r,n)=>{try{return VD(t,e,r,!1)}catch(i){return n.error=i,t}},fut=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:OT(t)};let o=jSe(t,r);return n[s]?{serializedResult:o,finalResult:TY(o,!i[s],e)}:{serializedResult:o}},put=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!GD({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=TY(t,!1,o);try{Twe(a,e,n)}catch(c){r.error??=c}},hut=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>FD.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?uut(n,t):(r.add(s),cut(n,t))}};var xwe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,uu(e,r,"all")]:Array.isArray(e)?[uu(t,r,"all"),...e]:zr(t)&&zr(e)?NK([t,e]):`${t}${e}`};import{once as OY}from"events";var Owe=async(t,e)=>{let[r,n]=await mut(t);return e.isForcefullyTerminated??=!1,[r,n]},mut=async t=>{let[e,r]=await Promise.allSettled([OY(t,"spawn"),OY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Iwe(t):r.value},Iwe=async t=>{try{return await OY(t,"exit")}catch{return Iwe(t)}},Pwe=async t=>{let[e,r]=await t;if(!gut(e,r)&&IY(e,r))throw new Ko;return[e,r]},gut=(t,e)=>t===void 0&&e===void 0,IY=(t,e)=>t!==0||e!==null;var Cwe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=_ut(t,e,r),o=s?.code==="ETIMEDOUT",a=Rbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},_ut=(t,e,r)=>t!==void 0?t:IY(e,r)?new Ko:void 0;var kwe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Sut(t,e,r),d=but({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return $_(d,c,u)},Sut=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=aD(t,e,r),a=vut(r),{file:c,commandArguments:u,options:l}=xD(t,e,a);Eut(l);let d=cwe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},vut=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Eut=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&HD("ipcInput"),t&&HD("ipc: true"),r&&HD("detached: true"),n&&HD("cancelSignal")},HD=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},but=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=wut({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=Cwe(c,r),{output:h,error:m=u}=Rwe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((b,R)=>uu(b,r,R)),S=uu(xwe(h,r),r,"all");return Aut({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},wut=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{bwe(s,r);let a=Tut(r);return yut(...OD(t,e,a))}catch(a){return M_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Tut=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:MD(e)}),Aut=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?$D({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):LT({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as fdt}from"events";import{spawn as pdt}from"child_process";import Lwe from"process";import{once as PY,on as Rut}from"events";var Nwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(I_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ED(t)}),xut({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),xut=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{_D(e,i);let s=ql(t,e,r),o=new AbortController;try{return await Promise.race([Out(s,n,o),Iut(s,r,o),Put(s,r,o)])}catch(a){throw P_(t),a}finally{o.abort(),yD(e,i)}},Out=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await PY(t,"message",{signal:r});return n}for await(let[n]of Rut(t,"message",{signal:r}))if(e(n))return n},Iut=async(t,e,{signal:r})=>{await PY(t,"disconnect",{signal:r}),SEe(e)},Put=async(t,e,{signal:r})=>{let[n]=await PY(t,"strict:error",{signal:r});throw hD(n,e)};import{once as Mwe,on as Cut}from"events";var $we=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>CY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),CY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{I_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ED(t)}),_D(e,s);let o=ql(t,e,r),a=new AbortController,c={};return kut(t,o,a),Nut({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Dut({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},kut=async(t,e,r)=>{try{await Mwe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Nut=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Mwe(t,"strict:error",{signal:r.signal});n.error=hD(i,e),r.abort()}catch{}},Dut=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Cut(r,"message",{signal:s.signal}))Dwe(o),yield c}catch{Dwe(o)}finally{s.abort(),yD(e,a),n||P_(t),i&&await t}},Dwe=({error:t})=>{if(t)throw t};var Uwe=(t,{ipc:e})=>{Object.assign(t,zwe(t,!1,e))},Fwe=()=>{let t=Lwe,e=!0,r=Lwe.channel!==void 0;return{...zwe(t,e,r),getCancelSignal:HEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},zwe=(t,e,r)=>({sendMessage:AD.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Nwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:$we.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Mut}from"child_process";import{PassThrough as $ut,Readable as Lut,Writable as Uut,Duplex as Fut}from"stream";var jwe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{EY(n);let a=new Mut;zut(a,n),Object.assign(a,{readable:jut,writable:qut,duplex:But});let c=M_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Vut(c,o,i);return{subprocess:a,promise:u}},zut=(t,e)=>{let r=FT(),n=FT(),i=FT(),s=Array.from({length:e.length-3},FT),o=FT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},FT=()=>{let t=new $ut;return t.end(),t},jut=()=>new Lut({read(){}}),qut=()=>new Uut({write(){}}),But=()=>new Fut({read(){},write(){}}),Vut=async(t,e,r)=>$_(t,e,r);import{createReadStream as qwe,createWriteStream as Bwe}from"fs";import{Buffer as Gut}from"buffer";import{Readable as zT,Writable as Hut,Duplex as Wut}from"stream";var Gwe=(t,e)=>zD(Kut,t,e,!1),jT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Bl[t]}.`)},Vwe={fileNumber:jT,generator:xY,asyncGenerator:xY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Wut.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Kut={input:{...Vwe,fileUrl:({value:t})=>({stream:qwe(t)}),filePath:({value:{file:t}})=>({stream:qwe(t)}),webStream:({value:t})=>({stream:zT.fromWeb(t)}),iterable:({value:t})=>({stream:zT.from(t)}),asyncIterable:({value:t})=>({stream:zT.from(t)}),string:({value:t})=>({stream:zT.from(t)}),uint8Array:({value:t})=>({stream:zT.from(Gut.from(t))})},output:{...Vwe,fileUrl:({value:t})=>({stream:Bwe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Bwe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Hut.fromWeb(t)}),iterable:jT,asyncIterable:jT,string:jT,uint8Array:jT}};import{on as Yut,once as Hwe}from"events";import{PassThrough as Zut,getDefaultHighWaterMark as Jut}from"stream";import{finished as Ywe}from"stream/promises";function Tp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)NY(i);let e=t.some(({readableObjectMode:i})=>i),r=Qut(t,e),n=new kY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Qut=(t,e)=>{if(t.length===0)return Jut(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},kY=class extends Zut{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(NY(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Xut(this,this.#e,this.#s);let r=rlt({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(NY(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)}},Xut=async(t,e,r)=>{WD(t,Wwe);let n=new AbortController;try{await Promise.race([elt(t,n),tlt(t,e,r,n)])}finally{n.abort(),WD(t,-Wwe)}},elt=async(t,{signal:e})=>{try{await Ywe(t,{signal:e,cleanup:!0})}catch(r){throw Zwe(t,r),r}},tlt=async(t,e,r,{signal:n})=>{for await(let[i]of Yut(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},NY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},rlt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{WD(t,Kwe);let a=new AbortController;try{await Promise.race([nlt(s,e,a),ilt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),slt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),WD(t,-Kwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?DY(t):olt(t))},nlt=async(t,e,{signal:r})=>{try{await t,r.aborted||DY(e)}catch(n){r.aborted||Zwe(e,n)}},ilt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Ywe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Jwe(o)?i.add(e):Qwe(t,o)}},slt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Hwe(t,i,{signal:s}),!t.readable)return Hwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},olt=t=>{t.writable&&t.end()},Zwe=(t,e)=>{Jwe(e)?DY(t):Qwe(t,e)},Jwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",DY=t=>{(t.readable||t.writable)&&t.destroy()},Qwe=(t,e)=>{t.destroyed||(t.once("error",alt),t.destroy(e))},alt=()=>{},WD=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Wwe=2,Kwe=1;import{finished as Xwe}from"stream/promises";var U_=(t,e)=>{t.pipe(e),clt(t,e),ult(t,e)},clt=async(t,e)=>{if(!(Wo(t)||Wo(e))){try{await Xwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}MY(e)}},MY=t=>{t.writable&&t.end()},ult=async(t,e)=>{if(!(Wo(t)||Wo(e))){try{await Xwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}$Y(t)}},$Y=t=>{t.readable&&t.destroy()};var eTe=(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})=>Ls.has(c)))llt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ls.has(c)))flt({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]:Tp(s);U_(o,i)}},llt=(t,e,r,n)=>{r==="output"?U_(t.stdio[n],e):U_(e,t.stdio[n]);let i=dlt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},dlt=["stdin","stdout","stderr"],flt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;plt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},plt=(t,{signal:e})=>{Wo(t)&&vp(t,hlt,e)},hlt=2;import{addAbortListener as _lt}from"events";var Ap=[];Ap.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ap.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ap.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var KD=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",LY=Symbol.for("signal-exit emitter"),UY=globalThis,mlt=Object.defineProperty.bind(Object),FY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(UY[LY])return UY[LY];mlt(UY,LY,{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}},YD=class{},glt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),zY=class extends YD{onExit(){return()=>{}}load(){}unload(){}},jY=class extends YD{#e=qY.platform==="win32"?"SIGINT":"SIGHUP";#r=new FY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ap)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(!KD(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 Ap)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,Ap.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 KD(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"&&KD(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)}},qY=globalThis.process,{onExit:tTe,load:Vir,unload:Gir}=glt(KD(qY)?new jY(qY):new zY);var rTe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=tTe(()=>{t.kill()});_lt(n,()=>{i()})};var iTe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=oD(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=ylt(r,n,i),{sourceStream:d,sourceError:f}=vlt(t,u),{options:p,fileDescriptors:h}=Wa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},ylt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Slt(t,e,...r),a=gD(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Slt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(nTe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||CK(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]=ZN(r,...n);return{destination:e(nTe)(i,s,o),pipeOptions:o}}if(Wa.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}`)},nTe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),vlt=(t,e)=>{try{return{sourceStream:C_(t,e)}}catch(r){return{sourceError:r}}};var oTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Elt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw BY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Elt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return $Y(t),n;if(e!==void 0)return MY(r),e},BY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>M_({error:t,command:sTe,escapedCommand:sTe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),sTe="source.pipe(destination)";var aTe=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 blt}from"stream/promises";var cTe=(t,e,r)=>{let n=ZD.has(e)?Tlt(t,e):wlt(t,e);return vp(t,Rlt,r.signal),vp(e,xlt,r.signal),Alt(e),n},wlt=(t,e)=>{let r=Tp([t]);return U_(r,e),ZD.set(e,r),r},Tlt=(t,e)=>{let r=ZD.get(e);return r.add(t),r},Alt=async t=>{try{await blt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ZD.delete(t)},ZD=new WeakMap,Rlt=2,xlt=1;import{aborted as Olt}from"util";var uTe=(t,e)=>t===void 0?[]:[Ilt(t,e)],Ilt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Olt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw BY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var JD=(t,...e)=>{if(Sr(e[0]))return JD.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=iTe(t,...e),i=Plt({...n,destination:r});return i.pipe=JD.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Plt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Clt(t,i);oTe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=cTe(e,s,d);return await Promise.race([aTe(l),...uTe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Clt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Ult}from"timers/promises";import{on as klt}from"events";import{getDefaultHighWaterMark as Nlt}from"stream";var QD=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Dlt(e,o),dTe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Dlt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},VY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;Mlt(e,o,t);let a=t.readableObjectMode&&!s;return dTe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Mlt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},dTe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=klt(t,"data",{signal:e.signal,highWaterMark:lTe,highWatermark:lTe});return $lt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},GY=Nlt(!0),lTe=GY,$lt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=Llt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*wp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*UT(a)}},Llt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[qD(t,r,!e),jD(t,i,!n,{})].filter(Boolean);var fTe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=Flt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([zlt(t),d]);return}let f=bY(c,r),p=VY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([jlt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},Flt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!GD({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=VY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await wwe(a,t,r,s)},zlt=async t=>{await Ult(),t.readableFlowing===null&&t.resume()},jlt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await kD(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await ND(r,{maxBuffer:s})):await D_(r,{maxBuffer:s})}catch(a){return pTe(wbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},HY=async t=>{try{return await t}catch(e){return pTe(e)}},pTe=({bufferedData:t})=>FSe(t)?new Uint8Array(t):t;import{finished as qlt}from"stream/promises";var qT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=Blt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],qlt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Hlt(a,e,r,n)}finally{o.abort()}},Blt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Vlt(t,r,n),n},Vlt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Glt(e,r),n.call(t,...i)}},Glt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Hlt=(t,e,r,n)=>{if(!Wlt(t,e,r,n))throw t},Wlt=(t,e,r,n=!0)=>r.propagating?hTe(t)||XD(t):(r.propagating=!0,WY(r,e)===n?hTe(t):XD(t)),WY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",XD=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",hTe=t=>t?.code==="EPIPE";var mTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>KY({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),KY=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=qT(t,e,u);if(WY(u,e)){await l;return}let[d]=await Promise.all([fTe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var gTe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Tp([t,e].filter(Boolean)):void 0,_Te=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>KY({...Klt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Ylt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Klt=({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}},Ylt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Zlt}from"events";var yTe=t=>R_(t,"ipc"),STe=(t,e)=>{let r=sD(t);Ga({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var vTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=yTe(s),a=au(e,"ipc"),c=au(r,"ipc");for await(let u of CY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Tbe(t,i,c),i.push(u)),o&&STe(u,s);return i},ETe=async(t,e)=>(await Promise.allSettled([t]),e);var bTe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let b=Owe(t,f),R={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=mTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:R}),v=_Te({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:R}),w=[],O=vTe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:w,verboseInfo:p}),P=Jlt(m,t,R),C=Qlt(h,R);try{return await Promise.race([Promise.all([{},Pwe(b),Promise.all(y),v,O,rbe(t,d),...P,...C]),_,Xlt(t,S),...JEe(t,s,f,S),...yEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...YEe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},b,Promise.all(y.map(T=>HY(T))),HY(v),ETe(O,w),Promise.allSettled(P),Promise.allSettled(C)])}},Jlt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:qT(n,i,r)),Qlt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Zo(s,{checkOpen:!1})&&!Wo(s)).map(({type:i,value:s,stream:o=s})=>qT(o,n,e,{isSameDirection:Ls.has(i),stopOnExit:i==="native"}))),Xlt=async(t,{signal:e})=>{let[r]=await Zlt(t,"error",{signal:e});throw r};var wTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),BT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Ha();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},F_=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 edt}from"stream";import{callbackify as tdt}from"util";import{finished as TTe}from"stream/promises";var YY=async t=>{if(t!==void 0)try{await ZY(t)}catch{}},ATe=async t=>{if(t!==void 0)try{await JY(t)}catch{}},ZY=async t=>{await TTe(t,{cleanup:!0,readable:!1,writable:!0})},JY=async t=>{await TTe(t,{cleanup:!0,readable:!0,writable:!1})},eM=async(t,e)=>{if(await t,e)throw e},tM=(t,e,r)=>{r&&!XD(r)?t.destroy(r):e&&t.destroy()};var RTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ts.has(r),{subprocessStdout:a,waitReadableDestroy:c}=QY(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=XY(a,o),{read:f,onStdoutDataDone:p}=e9({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new edt({read:f,destroy:tdt(r9.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return t9({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},QY=(t,e,r)=>{let n=C_(t,e),i=BT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},XY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:GY},e9=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Ha(),o=QD({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){rdt(this,o,s)},onStdoutDataDone:s}},rdt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},t9=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await JY(t),await n,await YY(i),await e,r.readable&&r.push(null)}catch(s){await YY(i),xTe(r,s)}},r9=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await F_(r,e)&&(xTe(t,n),await eM(e,n))},xTe=(t,e)=>{tM(t,t.readable,e)};import{Writable as ndt}from"stream";import{callbackify as OTe}from"util";var ITe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=n9(t,r,e),o=new ndt({...i9(n,t,i),destroy:OTe(o9.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return s9(n,o),o},n9=(t,e,r)=>{let n=gD(t,e),i=BT(r,n,"writableFinal"),s=BT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},i9=(t,e,r)=>({write:idt.bind(void 0,t),final:OTe(sdt.bind(void 0,t,e,r))}),idt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},sdt=async(t,e,r)=>{await F_(r,e)&&(t.writable&&t.end(),await e)},s9=async(t,e,r)=>{try{await ZY(t),e.writable&&e.end()}catch(n){await ATe(r),PTe(e,n)}},o9=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await F_(r,e),await F_(n,e)&&(PTe(t,i),await eM(e,i))},PTe=(t,e)=>{tM(t,t.writable,e)};import{Duplex as odt}from"stream";import{callbackify as adt}from"util";var CTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ts.has(r),{subprocessStdout:c,waitReadableDestroy:u}=QY(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=n9(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=XY(c,a),{read:_,onStdoutDataDone:S}=e9({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new odt({read:_,...i9(l,t,d),destroy:adt(cdt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return t9({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:l}),s9(l,b,c),b},cdt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([r9({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),o9({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var a9=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ts.has(e),o=C_(t,r),a=QD({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return udt(a,o,t)},udt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var kTe=(t,{encoding:e})=>{let r=wTe();t.readable=RTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=ITe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=CTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=a9.bind(void 0,t,e),t[Symbol.asyncIterator]=a9.bind(void 0,t,e,{})};var NTe=(t,e)=>{for(let[r,n]of ddt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},ldt=(async()=>{})().constructor.prototype,ddt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(ldt,t)]);var DTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=hdt(t,e,r),{subprocess:f,promise:p}=gdt({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=JD.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),NTe(f,p),Wa.set(f,{options:l,fileDescriptors:d}),f},hdt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=aD(t,e,r),{file:a,commandArguments:c,options:u}=xD(t,e,r),l=mdt(u),d=Gwe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},mdt=({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}},gdt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=pdt(...OD(t,e,r))}catch(h){return jwe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;fdt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];eTe(c,a,u),rTe(c,r,u);let d={},f=Ha();c.kill=gEe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=gTe(c,r),kTe(c,r),Uwe(c,r);let p=_dt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},_dt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await bTe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let S=h.map((y,v)=>uu(y,e,v)),b=uu(m,e,"all"),R=ydt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:b,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return $_(R,n,e)},ydt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?LT({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Ka,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):$D({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var rM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Sdt(n,t[n],i)]));return{...t,...r}},Sdt=(t,e,r)=>vdt.has(t)&&Sr(e)&&Sr(r)?{...e,...r}:r,vdt=new Set(["env",...LK]);var Vl=(t,e,r,n)=>{let i=(o,a,c)=>Vl(o,a,r,c),s=(...o)=>Edt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},Edt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Sr(s))return i(t,rM(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=bdt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?kwe(a,c,u):DTe(a,c,u,i)},bdt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=GSe(e)?HSe(e,r):[e,...r],[o,a,c]=ZN(...s),u=rM(rM(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var MTe=({file:t,commandArguments:e})=>LTe(t,e),$Te=({file:t,commandArguments:e})=>({...LTe(t,e),isSync:!0}),LTe=(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]=wdt(t);return{file:r,commandArguments:n}},wdt=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(Tdt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Tdt=/ +/g;var UTe=(t,e,r)=>{t.sync=e(Adt,r),t.s=t.sync},FTe=({options:t})=>zTe(t),Adt=({options:t})=>({...zTe(t),isSync:!0}),zTe=t=>({options:{...Rdt(t),...t}}),Rdt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},jTe={preferLocal:!0};var qTe=Vl(()=>({})),$ar=Vl(()=>({isSync:!0})),BTe=Vl(MTe),Lar=Vl($Te),Uar=Vl(XEe),Far=Vl(FTe,{},jTe,UTe),{sendMessage:zar,getOneMessage:jar,getEachMessage:qar,getCancelSignal:Bar}=Fwe();var VTe=!1,GTe,xdt=t=>{GTe??=t},HTe=t=>{VTe=!0,xdt(t)},Mn=()=>VTe,lu=()=>GTe,WTe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var VT=null,KTe=t=>(VT&&VT.destroy(),VT=new Us({totalAllowedTime:t}),VT),YTe=()=>VT;var Us=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&&Mn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await UC({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{Y.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var ZTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.200.2-bug.7",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@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.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var Cdt=Idt(import.meta.url),kdt=du.dirname(Cdt),Ndt=Pdt(import.meta.url),z_=re("shell"),c9=new Set,JTe={preferLocal:!0},_t=(t,e,r)=>{let[n,i]=Ddt(e,r),s={...JTe,...i},o=qTe(t,n,s);XTe(o,s),rAe(o);let a=r?.idleTimeout;return a&&a>0&&tAe(o,a),o},QTe=(t,e)=>{let r={...JTe,...e},n=BTe(t,r);return XTe(n,r),rAe(n),e?.idleTimeout&&e.idleTimeout>0&&tAe(n,e.idleTimeout),n},Ddt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},XTe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Za.env.NETLIFY_LOCAL_QUIET==="true")return;if(Za.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Nb).pipe(Za.stdout),t.stderr?.pipe(new Nb).pipe(Za.stderr);return}t.stdout?.pipe(Za.stdout),t.stderr?.pipe(Za.stderr)},u9=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Za.kill(-t.pid,e),z_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return z_.error("Error killing process:",r),!1}},eAe=t=>u9(t,"SIGKILL"),tAe=(t,e)=>{let r=null,n=()=>{z_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),u9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(z_.log(`Force killing idle process ${t.pid}`),eAe(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)},rAe=t=>{c9.add(t);let e=YTe();if(e){let r=e.onTimesUp(()=>{z_.log(`Global timer expired, killing process ${t.pid}`),u9(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(z_.log(`Force killing process ${t.pid} after timeout`),eAe(t))},5e3)});t.on("exit",()=>{c9.delete(t),r()}),t.on("error",()=>{c9.delete(t),r()})}};function iM(t,e){return!!Jo(t,e)}function Jo(t,e){if(!Za.env.NETLIFY_LOCAL_MODE)try{let i=Ndt.resolve(ZTe.name),s=du.dirname(i);for(;s!==du.dirname(s);){let o=du.dirname(s);if(du.basename(o)==="node_modules"){let a=du.join(o,".bin",e);if(nM.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Za.env.NODE_PATH){let i=du.join(Za.env.NODE_PATH,".bin",e);if(nM.existsSync(i))return i}let r=du.join(t,"node_modules",".bin",e);if(nM.existsSync(r))return r;let n=du.join(kdt,"..","node_modules",".bin",e);if(nM.existsSync(n))return n}var nAe=re("repo"),cAe="runner-diffs-",l9=t=>`${cAe}${t}-`,uAe=async t=>{let e=oM.tmpdir(),r;try{r=await si.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(cAe)&&!n.startsWith(l9(t))).map(n=>si.rm(Fs.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},iAe=async t=>{let e=Mdt("sha256");for await(let r of $dt(t))e.update(r);return e.digest("hex")},sAe=async(t,e)=>t.size===e.size&&await iAe(t.path)===await iAe(e.path),lAe=/.. (.+)?\.log$/,Ldt=[lAe],Udt=1,oAe=t=>{let e=t.split(`
389
389
  `).reduce((r,n)=>{if(!n)return r;let[i,s,,...o]=n,a=o.join(""),c=i.trim(),u=s.trim();return r[a]?r[a].change=u:r[a]={filePath:a,stage:c,change:u},r},{});return Object.values(e)},Fdt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),zdt=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return bi(r?`${e}: ${r}`:e)},aAe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},sM=500,GT=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},$n=class{constructor(e=process.cwd()){this.cwd=e}getRoot(){return this.root??=this.run(["rev-parse","--show-toplevel"],{stdout:"pipe"}).then(({stdout:e})=>String(e).trim()),this.root}async restorePausedWork(e){let r="restore";try{let n=await this.restorePausedFiles(e);r="stage",await this.stageBuildSetup();let i=await this.getRoot(),s=new Set(n.changedFiles),o=(await this.listIndexEntries(n.deletedFiles,{cwd:i})).filter(({filePath:a})=>!s.has(a));return await this.unstageFiles(n.changedFiles,{cwd:i}),o.length>0&&await si.writeFile(await this.getSetupMetadataPath(),JSON.stringify(o)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new GT(r,n)}}run(e,r={}){return _t("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){nAe.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!r){let u=oAe(s);await this.discardSetupOnlyChanges(u)}nAe.info("Changes after processing"),await this.getStatus();let o=await this.getIgnoredPathspecs(s);if(await this.stageFiles(o),await this.excludeUnchangedSetupDescendants(),i=await this.hasStagedChanges(),!i)return{hasChanges:!1,ignored:o};await this.run(["commit","-m","Agent runner [skip ci]"]);let a=await si.mkdtemp(Fs.join(oM.tmpdir(),l9(e.sessionId))),c=await this.writeDiffFiles({config:e,diffDir:a,target:{commit:"HEAD"},ignored:o});return await this.rollbackIfLocal(),c.hasChanges&&Y.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c}async getStatus(){let e=await this.run(["-c","status.relativePaths=true","status","-s"]);return String(e.stdout??"")}async hasAgentChanges(){let e=await this.getStatus();return{hasChanges:(e.trim().length===0?[]:e.split(`
390
390
  `).filter(i=>Ldt.some(o=>o instanceof RegExp?o.test(i):i===o)?!1:i[1]?.trim()!=="")).length!==0,status:e}}async getCurrentCommitSha(){let{stdout:e}=await this.run(["rev-parse","HEAD"]);return String(e??"").trim()}async reset(){await this.run(["reset","--hard","HEAD"]),await si.rm(await this.getSetupMetadataPath(),{force:!0})}async discardSetupOnlyChanges(e){let r=e.filter(n=>n.stage&&!n.change).map(n=>n.filePath);r.length!==0&&await this.run(["restore","--staged","--worktree","--pathspec-from-file=-"],{input:r.join(`
391
391
  `)})}async stageBuildSetup(){await si.rm(await this.getSetupMetadataPath(),{force:!0});let e=await this.getIgnoredPathspecs();await this.stageFiles(e)}getSetupMetadataPath(){return this.setupMetadataPath??=this.getRoot().then(async e=>{let{stdout:r}=await this.run(["rev-parse","--git-path","netlify-agent-runner-setup.json"],{cwd:e,stdout:"pipe"});return Fs.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=sM){let s=e.slice(i,i+sM).map(a=>`:(literal)${a}`),{stdout:o}=await this.run(["ls-files","--stage","-z","--",...s],{...aAe,...r});for(let a of String(o??"").split("\0").filter(Boolean))n.push({filePath:a.slice(a.indexOf(" ")+1),entry:a})}return n}async excludeUnchangedSetupDescendants(e){let r;try{r=JSON.parse(await si.readFile(await this.getSetupMetadataPath(),"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}let i={cwd:await this.getRoot(),env:e},s=new Map((await this.listIndexEntries(r.map(({filePath:a})=>a),i)).map(({filePath:a,entry:c})=>[a,c])),o=r.filter(({filePath:a,entry:c})=>s.get(a)===c);o.length!==0&&await this.run(["update-index","--force-remove","-z","--stdin"],{...i,input:o.map(({filePath:a})=>a).join("\0")})}async getIgnoredPathspecs(e){e||=await this.getStatus();let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return e.split(`
package/dist/bin.js CHANGED
@@ -597,7 +597,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
597
597
  `,LF:`
598
598
  `,concatBytes:YJ},s$t=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},o$t={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:s$t};import{Buffer as a$t}from"buffer";var xNe=(t,e)=>t?void 0:c$t.bind(void 0,e),c$t=function*(t,e){if(typeof e!="string"&&!En(e)&&!a$t.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},ONe=(t,e)=>t?u$t.bind(void 0,e):l$t.bind(void 0,e),u$t=function*(t,e){PNe(t,e),yield e},l$t=function*(t,e){if(PNe(t,e),typeof e!="string"&&!En(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},PNe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
599
599
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
600
- if (condition) { yield value; }`)};import{Buffer as d$t}from"buffer";import{StringDecoder as f$t}from"string_decoder";var K$=(t,e,r)=>{if(r)return;if(t)return{transform:p$t.bind(void 0,new TextEncoder)};let n=new f$t(e);return{transform:h$t.bind(void 0,n),final:m$t.bind(void 0,n)}},p$t=function*(t,e){d$t.isBuffer(e)?yield cl(e):typeof e=="string"?yield t.encode(e):yield e},h$t=function*(t,e){yield En(e)?t.write(e):e},m$t=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as INe}from"util";var ZJ=INe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Y$=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_$t}=e[r];for await(let i of n(t))yield*Y$(i,e,r+1)},CNe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*g$t(r,Number(e),t)},g$t=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Y$(n,r,e+1)},NNe=INe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),_$t=function*(t){yield t};var XJ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},kNe=(t,e)=>[...e.flatMap(r=>[...Xh(r,t,0)]),...VA(t)],Xh=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=S$t}=e[r];for(let i of n(t))yield*Xh(i,e,r+1)},VA=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*y$t(r,Number(e),t)},y$t=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Xh(n,r,e+1)},S$t=function*(t){yield t};var QJ=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=LNe(t,o,s),u=Zh(e),l=Zh(r),d=u?ZJ.bind(void 0,Y$,a):XJ.bind(void 0,Xh),f=u||l?ZJ.bind(void 0,CNe,a):XJ.bind(void 0,VA),p=u||l?NNe.bind(void 0,a):void 0;return{stream:new E$t({writableObjectMode:n,writableHighWaterMark:DNe(n),readableObjectMode:i,readableHighWaterMark:DNe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},J$=(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=LNe(o,r,a);t=kNe(c,t)}return t},LNe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:xNe(n,a)},K$(r,o,n),W$(r,s,n,c),{transform:t,final:e},{transform:ONe(i,a)},ANe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var $Ne=(t,e)=>{for(let r of v$t(t))b$t(t,r,e)},v$t=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),b$t=(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 ${af[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>w$t(a,n));r.input=LA(o)},w$t=(t,e)=>{let r=J$(t,e,"utf8",!0);return T$t(r),LA(r)},T$t=t=>{let e=t.find(r=>typeof r!="string"&&!En(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 O$t,appendFileSync as P$t}from"fs";var Z$=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&cS(r,n)&&!qs.has(e)&&R$t(n)&&(t.some(({type:i,value:s})=>i==="native"&&A$t.has(s))||t.every(({type:i})=>Uo.has(i))),R$t=t=>t===1||t===2,A$t=new Set(["pipe","overlapped"]),MNe=async(t,e,r,n)=>{for await(let i of t)x$t(e)||FNe(i,r,n)},UNe=(t,e,r)=>{for(let n of t)FNe(n,e,r)},x$t=t=>t._readableState.pipes.length>0,FNe=(t,e,r)=>{let n=d$(t);jc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var jNe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>I$t({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},I$t=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=zCe(t,s,d),p=cl(f),{stdioItems:h,objectMode:m}=e[r],_=C$t([p],h,c,n),{serializedResult:y,finalResult:v=y}=N$t({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});k$t({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&&D$t(y,h,i),S}catch(g){return n.error=g,S}},C$t=(t,e,r,n)=>{try{return J$(t,e,r,!1)}catch(i){return n.error=i,t}},N$t=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:LA(t)};let o=tPe(t,r);return n[s]?{serializedResult:o,finalResult:JJ(o,!i[s],e)}:{serializedResult:o}},k$t=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!Z$({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=JJ(t,!1,o);try{UNe(a,e,n)}catch(c){r.error??=c}},D$t=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>V$.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?P$t(n,t):(r.add(s),O$t(n,t))}};var zNe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,dl(e,r,"all")]:Array.isArray(e)?[dl(t,r,"all"),...e]:En(t)&&En(e)?sJ([t,e]):`${t}${e}`};import{once as eZ}from"events";var qNe=async(t,e)=>{let[r,n]=await L$t(t);return e.isForcefullyTerminated??=!1,[r,n]},L$t=async t=>{let[e,r]=await Promise.allSettled([eZ(t,"spawn"),eZ(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?BNe(t):r.value},BNe=async t=>{try{return await eZ(t,"exit")}catch{return BNe(t)}},HNe=async t=>{let[e,r]=await t;if(!$$t(e,r)&&tZ(e,r))throw new Ca;return[e,r]},$$t=(t,e)=>t===void 0&&e===void 0,tZ=(t,e)=>t!==0||e!==null;var VNe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=M$t(t,e,r),o=s?.code==="ETIMEDOUT",a=jCe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},M$t=(t,e,r)=>t!==void 0?t:tZ(e,r)?new Ca:void 0;var GNe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=F$t(t,e,r),d=q$t({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return yS(d,c,u)},F$t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=p$(t,e,r),a=j$t(r),{file:c,commandArguments:u,options:l}=k$(t,e,a);z$t(l);let d=bNe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},j$t=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,z$t=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&X$("ipcInput"),t&&X$("ipc: true"),r&&X$("detached: true"),n&&X$("cancelSignal")},X$=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},q$t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=B$t({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=VNe(c,r),{output:h,error:m=u}=jNe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>dl(v,r,S)),y=dl(zNe(h,r),r,"all");return V$t({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},B$t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{$Ne(s,r);let a=H$t(r);return U$t(...D$(t,e,a))}catch(a){return _S({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},H$t=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:z$(e)}),V$t=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?q$({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):HA({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as N1t}from"events";import{spawn as k1t}from"child_process";import ZNe from"process";import{once as rZ,on as G$t}from"events";var WNe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(dS({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:x$(t)}),W$t({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),W$t=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{w$(e,i);let s=of(t,e,r),o=new AbortController;try{return await Promise.race([K$t(s,n,o),Y$t(s,r,o),J$t(s,r,o)])}catch(a){throw fS(t),a}finally{o.abort(),T$(e,i)}},K$t=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await rZ(t,"message",{signal:r});return n}for await(let[n]of G$t(t,"message",{signal:r}))if(e(n))return n},Y$t=async(t,e,{signal:r})=>{await rZ(t,"disconnect",{signal:r}),kIe(e)},J$t=async(t,e,{signal:r})=>{let[n]=await rZ(t,"strict:error",{signal:r});throw E$(n,e)};import{once as YNe,on as Z$t}from"events";var JNe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>nZ({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),nZ=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{dS({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:x$(t)}),w$(e,s);let o=of(t,e,r),a=new AbortController,c={};return X$t(t,o,a),Q$t({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),eMt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},X$t=async(t,e,r)=>{try{await YNe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Q$t=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await YNe(t,"strict:error",{signal:r.signal});n.error=E$(i,e),r.abort()}catch{}},eMt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Z$t(r,"message",{signal:s.signal}))KNe(o),yield c}catch{KNe(o)}finally{s.abort(),T$(e,a),n||fS(t),i&&await t}},KNe=({error:t})=>{if(t)throw t};var XNe=(t,{ipc:e})=>{Object.assign(t,eke(t,!1,e))},QNe=()=>{let t=ZNe,e=!0,r=ZNe.channel!==void 0;return{...eke(t,e,r),getCancelSignal:oCe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},eke=(t,e,r)=>({sendMessage:C$.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:WNe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:JNe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as tMt}from"child_process";import{PassThrough as rMt,Readable as nMt,Writable as iMt,Duplex as sMt}from"stream";var tke=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{WJ(n);let a=new tMt;oMt(a,n),Object.assign(a,{readable:aMt,writable:cMt,duplex:uMt});let c=_S({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=lMt(c,o,i);return{subprocess:a,promise:u}},oMt=(t,e)=>{let r=GA(),n=GA(),i=GA(),s=Array.from({length:e.length-3},GA),o=GA(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},GA=()=>{let t=new rMt;return t.end(),t},aMt=()=>new nMt({read(){}}),cMt=()=>new iMt({write(){}}),uMt=()=>new sMt({read(){},write(){}}),lMt=async(t,e,r)=>yS(t,e,r);import{createReadStream as rke,createWriteStream as nke}from"fs";import{Buffer as dMt}from"buffer";import{Readable as WA,Writable as fMt,Duplex as pMt}from"stream";var ske=(t,e)=>G$(hMt,t,e,!1),KA=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${af[t]}.`)},ike={fileNumber:KA,generator:QJ,asyncGenerator:QJ,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:pMt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},hMt={input:{...ike,fileUrl:({value:t})=>({stream:rke(t)}),filePath:({value:{file:t}})=>({stream:rke(t)}),webStream:({value:t})=>({stream:WA.fromWeb(t)}),iterable:({value:t})=>({stream:WA.from(t)}),asyncIterable:({value:t})=>({stream:WA.from(t)}),string:({value:t})=>({stream:WA.from(t)}),uint8Array:({value:t})=>({stream:WA.from(dMt.from(t))})},output:{...ike,fileUrl:({value:t})=>({stream:nke(t)}),filePath:({value:{file:t,append:e}})=>({stream:nke(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:fMt.fromWeb(t)}),iterable:KA,asyncIterable:KA,string:KA,uint8Array:KA}};import{on as mMt,once as oke}from"events";import{PassThrough as gMt,getDefaultHighWaterMark as _Mt}from"stream";import{finished as uke}from"stream/promises";function Qh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)sZ(i);let e=t.some(({readableObjectMode:i})=>i),r=yMt(t,e),n=new iZ({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var yMt=(t,e)=>{if(t.length===0)return _Mt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},iZ=class extends gMt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(sZ(e),this.#e.has(e))return;this.#e.add(e),this.#n??=SMt(this,this.#e,this.#s);let r=bMt({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(sZ(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)}},SMt=async(t,e,r)=>{Q$(t,ake);let n=new AbortController;try{await Promise.race([EMt(t,n),vMt(t,e,r,n)])}finally{n.abort(),Q$(t,-ake)}},EMt=async(t,{signal:e})=>{try{await uke(t,{signal:e,cleanup:!0})}catch(r){throw lke(t,r),r}},vMt=async(t,e,r,{signal:n})=>{for await(let[i]of mMt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},sZ=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},bMt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{Q$(t,cke);let a=new AbortController;try{await Promise.race([wMt(s,e,a),TMt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),RMt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),Q$(t,-cke)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?oZ(t):AMt(t))},wMt=async(t,e,{signal:r})=>{try{await t,r.aborted||oZ(e)}catch(n){r.aborted||lke(e,n)}},TMt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await uke(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;dke(o)?i.add(e):fke(t,o)}},RMt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await oke(t,i,{signal:s}),!t.readable)return oke(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},AMt=t=>{t.writable&&t.end()},lke=(t,e)=>{dke(e)?oZ(t):fke(t,e)},dke=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oZ=t=>{(t.readable||t.writable)&&t.destroy()},fke=(t,e)=>{t.destroyed||(t.once("error",xMt),t.destroy(e))},xMt=()=>{},Q$=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ake=2,cke=1;import{finished as pke}from"stream/promises";var ES=(t,e)=>{t.pipe(e),OMt(t,e),PMt(t,e)},OMt=async(t,e)=>{if(!(Ia(t)||Ia(e))){try{await pke(t,{cleanup:!0,readable:!0,writable:!1})}catch{}aZ(e)}},aZ=t=>{t.writable&&t.end()},PMt=async(t,e)=>{if(!(Ia(t)||Ia(e))){try{await pke(e,{cleanup:!0,readable:!1,writable:!0})}catch{}cZ(t)}},cZ=t=>{t.readable&&t.destroy()};var hke=(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})=>Uo.has(c)))IMt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Uo.has(c)))NMt({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]:Qh(s);ES(o,i)}},IMt=(t,e,r,n)=>{r==="output"?ES(t.stdio[n],e):ES(e,t.stdio[n]);let i=CMt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},CMt=["stdin","stdout","stderr"],NMt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;kMt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},kMt=(t,{signal:e})=>{Ia(t)&&Yh(t,DMt,e)},DMt=2;import{addAbortListener as MMt}from"events";var em=[];em.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&em.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&em.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var eM=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",uZ=Symbol.for("signal-exit emitter"),lZ=globalThis,LMt=Object.defineProperty.bind(Object),dZ=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(lZ[uZ])return lZ[uZ];LMt(lZ,uZ,{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}},tM=class{},$Mt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),fZ=class extends tM{onExit(){return()=>{}}load(){}unload(){}},pZ=class extends tM{#e=hZ.platform==="win32"?"SIGINT":"SIGHUP";#r=new dZ;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of em)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(!eM(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 em)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,em.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 eM(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"&&eM(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)}},hZ=globalThis.process,{onExit:mke,load:vLr,unload:bLr}=$Mt(eM(hZ)?new pZ(hZ):new fZ);var gke=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=mke(()=>{t.kill()});MMt(n,()=>{i()})};var yke=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=f$(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=UMt(r,n,i),{sourceStream:d,sourceError:f}=jMt(t,u),{options:p,fileDescriptors:h}=qc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},UMt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=FMt(t,e,...r),a=b$(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},FMt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(_ke,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||nJ(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]=r$(r,...n);return{destination:e(_ke)(i,s,o),pipeOptions:o}}if(qc.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}`)},_ke=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),jMt=(t,e)=>{try{return{sourceStream:pS(t,e)}}catch(r){return{sourceError:r}}};var Eke=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=zMt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw mZ({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},zMt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return cZ(t),n;if(e!==void 0)return aZ(r),e},mZ=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>_S({error:t,command:Ske,escapedCommand:Ske,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Ske="source.pipe(destination)";var vke=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 qMt}from"stream/promises";var bke=(t,e,r)=>{let n=rM.has(e)?HMt(t,e):BMt(t,e);return Yh(t,GMt,r.signal),Yh(e,WMt,r.signal),VMt(e),n},BMt=(t,e)=>{let r=Qh([t]);return ES(r,e),rM.set(e,r),r},HMt=(t,e)=>{let r=rM.get(e);return r.add(t),r},VMt=async t=>{try{await qMt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rM.delete(t)},rM=new WeakMap,GMt=2,WMt=1;import{aborted as KMt}from"util";var wke=(t,e)=>t===void 0?[]:[YMt(t,e)],YMt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await KMt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw mZ({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var nM=(t,...e)=>{if(Yr(e[0]))return nM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=yke(t,...e),i=JMt({...n,destination:r});return i.pipe=nM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},JMt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=ZMt(t,i);Eke({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=bke(e,s,d);return await Promise.race([vke(l),...wke(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},ZMt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as i1t}from"timers/promises";import{on as XMt}from"events";import{getDefaultHighWaterMark as QMt}from"stream";var iM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return e1t(e,o),Rke({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},e1t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},gZ=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;t1t(e,o,t);let a=t.readableObjectMode&&!s;return Rke({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},t1t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Rke=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=XMt(t,"data",{signal:e.signal,highWaterMark:Tke,highWatermark:Tke});return r1t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},_Z=QMt(!0),Tke=_Z,r1t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=n1t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Xh(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*VA(a)}},n1t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[K$(t,r,!e),W$(t,i,!n,{})].filter(Boolean);var Ake=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=s1t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([o1t(t),d]);return}let f=KJ(c,r),p=gZ({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([a1t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},s1t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!Z$({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=gZ({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await MNe(a,t,r,s)},o1t=async t=>{await i1t(),t.readableFlowing===null&&t.resume()},a1t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await U$(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await F$(r,{maxBuffer:s})):await gS(r,{maxBuffer:s})}catch(a){return xke(MCe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},yZ=async t=>{try{return await t}catch(e){return xke(e)}},xke=({bufferedData:t})=>QOe(t)?new Uint8Array(t):t;import{finished as c1t}from"stream/promises";var YA=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=u1t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],c1t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||f1t(a,e,r,n)}finally{o.abort()}},u1t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&l1t(t,r,n),n},l1t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{d1t(e,r),n.call(t,...i)}},d1t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},f1t=(t,e,r,n)=>{if(!p1t(t,e,r,n))throw t},p1t=(t,e,r,n=!0)=>r.propagating?Oke(t)||sM(t):(r.propagating=!0,SZ(r,e)===n?Oke(t):sM(t)),SZ=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",sM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Oke=t=>t?.code==="EPIPE";var Pke=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>EZ({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),EZ=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=YA(t,e,u);if(SZ(u,e)){await l;return}let[d]=await Promise.all([Ake({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var Ike=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Qh([t,e].filter(Boolean)):void 0,Cke=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>EZ({...h1t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:m1t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),h1t=({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}},m1t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as g1t}from"events";var Nke=t=>cS(t,"ipc"),kke=(t,e)=>{let r=d$(t);jc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Dke=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Nke(s),a=ul(e,"ipc"),c=ul(r,"ipc");for await(let u of nZ({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(UCe(t,i,c),i.push(u)),o&&kke(u,s);return i},Lke=async(t,e)=>(await Promise.allSettled([t]),e);var $ke=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=qNe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Pke({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=Cke({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),R=[],A=Dke({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:R,verboseInfo:p}),T=_1t(m,t,S),P=y1t(h,S);try{return await Promise.race([Promise.all([{},HNe(v),Promise.all(g),b,A,gCe(t,d),...T,...P]),_,S1t(t,y),...dCe(t,s,f,y),...NIe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...uCe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(I){return f.terminationReason??="other",Promise.all([{error:I},v,Promise.all(g.map(O=>yZ(O))),yZ(b),Lke(A,R),Promise.allSettled(T),Promise.allSettled(P)])}},_1t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:YA(n,i,r)),y1t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>ka(s,{checkOpen:!1})&&!Ia(s)).map(({type:i,value:s,stream:o=s})=>YA(o,n,e,{isSameDirection:Uo.has(i),stopOnExit:i==="native"}))),S1t=async(t,{signal:e})=>{let[r]=await g1t(t,"error",{signal:e});throw r};var Mke=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),JA=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=zc();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},vS=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 E1t}from"stream";import{callbackify as v1t}from"util";import{finished as Uke}from"stream/promises";var vZ=async t=>{if(t!==void 0)try{await bZ(t)}catch{}},Fke=async t=>{if(t!==void 0)try{await wZ(t)}catch{}},bZ=async t=>{await Uke(t,{cleanup:!0,readable:!1,writable:!0})},wZ=async t=>{await Uke(t,{cleanup:!0,readable:!0,writable:!1})},oM=async(t,e)=>{if(await t,e)throw e},aM=(t,e,r)=>{r&&!sM(r)?t.destroy(r):e&&t.destroy()};var jke=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||qs.has(r),{subprocessStdout:a,waitReadableDestroy:c}=TZ(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=RZ(a,o),{read:f,onStdoutDataDone:p}=AZ({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new E1t({read:f,destroy:v1t(OZ.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return xZ({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},TZ=(t,e,r)=>{let n=pS(t,e),i=JA(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},RZ=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:_Z},AZ=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=zc(),o=iM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){b1t(this,o,s)},onStdoutDataDone:s}},b1t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},xZ=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await wZ(t),await n,await vZ(i),await e,r.readable&&r.push(null)}catch(s){await vZ(i),zke(r,s)}},OZ=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await vS(r,e)&&(zke(t,n),await oM(e,n))},zke=(t,e)=>{aM(t,t.readable,e)};import{Writable as w1t}from"stream";import{callbackify as qke}from"util";var Bke=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=PZ(t,r,e),o=new w1t({...IZ(n,t,i),destroy:qke(NZ.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return CZ(n,o),o},PZ=(t,e,r)=>{let n=b$(t,e),i=JA(r,n,"writableFinal"),s=JA(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},IZ=(t,e,r)=>({write:T1t.bind(void 0,t),final:qke(R1t.bind(void 0,t,e,r))}),T1t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},R1t=async(t,e,r)=>{await vS(r,e)&&(t.writable&&t.end(),await e)},CZ=async(t,e,r)=>{try{await bZ(t),e.writable&&e.end()}catch(n){await Fke(r),Hke(e,n)}},NZ=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await vS(r,e),await vS(n,e)&&(Hke(t,i),await oM(e,i))},Hke=(t,e)=>{aM(t,t.writable,e)};import{Duplex as A1t}from"stream";import{callbackify as x1t}from"util";var Vke=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||qs.has(r),{subprocessStdout:c,waitReadableDestroy:u}=TZ(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=PZ(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=RZ(c,a),{read:_,onStdoutDataDone:y}=AZ({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new A1t({read:_,...IZ(l,t,d),destroy:x1t(O1t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return xZ({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),CZ(l,v,c),v},O1t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([OZ({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),NZ({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var kZ=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||qs.has(e),o=pS(t,r),a=iM({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return P1t(a,o,t)},P1t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Gke=(t,{encoding:e})=>{let r=Mke();t.readable=jke.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Bke.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Vke.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=kZ.bind(void 0,t,e),t[Symbol.asyncIterator]=kZ.bind(void 0,t,e,{})};var Wke=(t,e)=>{for(let[r,n]of C1t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},I1t=(async()=>{})().constructor.prototype,C1t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(I1t,t)]);var Kke=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=D1t(t,e,r),{subprocess:f,promise:p}=$1t({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=nM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Wke(f,p),qc.set(f,{options:l,fileDescriptors:d}),f},D1t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=p$(t,e,r),{file:a,commandArguments:c,options:u}=k$(t,e,r),l=L1t(u),d=ske(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},L1t=({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}},$1t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=k1t(...D$(t,e,r))}catch(h){return tke({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;N1t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];hke(c,a,u),gke(c,r,u);let d={},f=zc();c.kill=IIe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Ike(c,r),Gke(c,r),XNe(c,r);let p=M1t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},M1t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await $ke({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((g,b)=>dl(g,e,b)),v=dl(m,e,"all"),S=U1t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return yS(S,n,e)},U1t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?HA({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Bc,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):q$({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var cM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,F1t(n,t[n],i)]));return{...t,...r}},F1t=(t,e,r)=>j1t.has(t)&&Yr(e)&&Yr(r)?{...e,...r}:r,j1t=new Set(["env",...uJ]);var cf=(t,e,r,n)=>{let i=(o,a,c)=>cf(o,a,r,c),s=(...o)=>z1t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},z1t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Yr(s))return i(t,cM(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=q1t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?GNe(a,c,u):Kke(a,c,u,i)},q1t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=sPe(e)?oPe(e,r):[e,...r],[o,a,c]=r$(...s),u=cM(cM(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var Yke=({file:t,commandArguments:e})=>Zke(t,e),Jke=({file:t,commandArguments:e})=>({...Zke(t,e),isSync:!0}),Zke=(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]=B1t(t);return{file:r,commandArguments:n}},B1t=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(H1t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},H1t=/ +/g;var Xke=(t,e,r)=>{t.sync=e(V1t,r),t.s=t.sync},Qke=({options:t})=>eDe(t),V1t=({options:t})=>({...eDe(t),isSync:!0}),eDe=t=>({options:{...G1t(t),...t}}),G1t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},tDe={preferLocal:!0};var rDe=cf(()=>({})),d1r=cf(()=>({isSync:!0})),nDe=cf(Yke),f1r=cf(Jke),p1r=cf(pCe),h1r=cf(Qke,{},tDe,Xke),{sendMessage:m1r,getOneMessage:g1r,getEachMessage:_1r,getCancelSignal:y1r}=QNe();import{Transform as W1t}from"stream";var K1t=["NETLIFY_AI_GATEWAY_KEY"];function Y1t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...K1t])]}function J1t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function Z1t(){let e=Y1t().map(r=>process.env[r]).filter(r=>!(!r||J1t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ss(t){if(typeof t!="string")return t;let e=Z1t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(X1t(n),"g");r=r.replace(i,"******")}),r}function X1t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ZA=class extends W1t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ss(i);n(null,s)}},uM=Symbol("maskedWrite");function iDe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[uM]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ss(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[uM]=!0,process.stdout.write=r}if(!process.stderr.write[uM]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ss(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[uM]=!0,process.stderr.write=r}}}var sDe=!1,oDe,DZ=t=>{oDe??=t},aDe=t=>{sDe=!0,DZ(t)},an=()=>sDe,Da=()=>oDe,cDe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var XA=null,uDe=t=>(XA&&XA.destroy(),XA=new Fo({totalAllowedTime:t}),XA),lDe=()=>XA;var Fo=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&&an())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await Ok({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var dDe={name:"@netlify/agent-runner-cli",type:"module",version:"1.200.2-bug.6",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@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.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var rUt=eUt(import.meta.url),nUt=fl.dirname(rUt),iUt=tUt(import.meta.url),bS=de("shell"),LZ=new Set,fDe={preferLocal:!0},Dt=(t,e,r)=>{let[n,i]=sUt(e,r),s={...fDe,...i},o=rDe(t,n,s);hDe(o,s),_De(o);let a=r?.idleTimeout;return a&&a>0&&gDe(o,a),o},pDe=(t,e)=>{let r={...fDe,...e},n=nDe(t,r);return hDe(n,r),_De(n),e?.idleTimeout&&e.idleTimeout>0&&gDe(n,e.idleTimeout),n},sUt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},hDe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Vc.env.NETLIFY_LOCAL_QUIET==="true")return;if(Vc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new ZA).pipe(Vc.stdout),t.stderr?.pipe(new ZA).pipe(Vc.stderr);return}t.stdout?.pipe(Vc.stdout),t.stderr?.pipe(Vc.stderr)},$Z=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Vc.kill(-t.pid,e),bS.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return bS.error("Error killing process:",r),!1}},mDe=t=>$Z(t,"SIGKILL"),gDe=(t,e)=>{let r=null,n=()=>{bS.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),$Z(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(bS.log(`Force killing idle process ${t.pid}`),mDe(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)},_De=t=>{LZ.add(t);let e=lDe();if(e){let r=e.onTimesUp(()=>{bS.log(`Global timer expired, killing process ${t.pid}`),$Z(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(bS.log(`Force killing process ${t.pid} after timeout`),mDe(t))},5e3)});t.on("exit",()=>{LZ.delete(t),r()}),t.on("error",()=>{LZ.delete(t),r()})}};function Gc(t,e){if(!Vc.env.NETLIFY_LOCAL_MODE)try{let i=iUt.resolve(dDe.name),s=fl.dirname(i);for(;s!==fl.dirname(s);){let o=fl.dirname(s);if(fl.basename(o)==="node_modules"){let a=fl.join(o,".bin",e);if(lM.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Vc.env.NODE_PATH){let i=fl.join(Vc.env.NODE_PATH,".bin",e);if(lM.existsSync(i))return i}let r=fl.join(t,"node_modules",".bin",e);if(lM.existsSync(r))return r;let n=fl.join(nUt,"..","node_modules",".bin",e);if(lM.existsSync(n))return n}import kj from"process";import{fileURLToPath as DKt}from"url";import{createRequire as LKt}from"module";import Xx from"path";import{readFileSync as $Kt}from"fs";var oUt="__netlify__getTracer",aUt="__netlify__shutdownTracers",It=(t,e)=>globalThis[oUt]?.(t,e),yDe=async()=>globalThis[aUt]?.();function QA(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 xKt}from"timers/promises";Ue();import cjt from"process";Ue();var CUt=(t,e)=>{e.recordException(t),e.setStatus({code:xi.ERROR})};var ml=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}=dLe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>fLe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=dLe(r,n,i),c=this._tracer.startSpan(e,s,o);return fLe(c,s,a)}};function dLe(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??sr.active(),{opts:n,ctx:i,fn:s}}function fLe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:CUt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ue();var PS=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var gX=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=bLe(e),n._asyncAttributesPending=e.filter(([i,s])=>PS(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(PS(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=bLe(this._rawAttributes),this._schemaUrl=NUt(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,PS(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&pe.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(PS(n)){pe.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=kUt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function _X(t,e){return gX.FromAttributeList(Object.entries(t),e)}function bLe(t){return t.map(([e,r])=>PS(r)?[e,r.catch(n=>{pe.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function NUt(t){if(typeof t=="string"||t===void 0)return t;pe.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function kUt(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;pe.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ue();var d0=class{emit(e){}enabled(){return!1}},wLe=new d0;var f0=Symbol.for("io.opentelemetry.js.api.logs"),IS=globalThis;function TLe(t,e,r){return n=>n===t?e:r}var yX=1;var SX=class{getLogger(e,r,n){return new d0}},kM=new SX;var DM=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):wLe}};var p0=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new DM(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:kM}_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 LM=class t{constructor(){this._proxyLoggerProvider=new p0}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return IS[f0]?this.getLoggerProvider():(IS[f0]=TLe(yX,e,kM),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=IS[f0])===null||e===void 0?void 0:e.call(IS,yX))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete IS[f0],this._proxyLoggerProvider=new p0}};var RLe=LM.getInstance();function ALe(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 xLe(t){t.forEach(e=>e.disable())}function EX(t){let e=t.tracerProvider||zt.getTracerProvider(),r=t.meterProvider||l0.getMeterProvider(),n=t.loggerProvider||RLe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return ALe(i,e,r,n),()=>{xLe(i)}}Ue();var DUt=kn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function OLe(t){return t.getValue(DUt)===!0}var CS;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(CS||(CS={}));Ue();var vX="[_0-9a-z-*/]",LUt=`[a-z]${vX}{0,255}`,$Ut=`[a-z0-9]${vX}{0,240}@[a-z]${vX}{0,13}`,MUt=new RegExp(`^(?:${LUt}|${$Ut})$`),UUt=/^[ -~]{0,255}[!-~]$/,FUt=/,|=/;function bX(t){return MUt.test(t)}function wX(t){return UUt.test(t)&&!FUt.test(t)}var jUt=32,PLe=512,ILe=",",CLe="=",$M=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!bX(e)||!wX(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>PLe)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=ILe+e),e=`${n[0]}${CLe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(ILe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(CLe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!bX(a)||!wX(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>PLe)&&(r.set(a,c),n=u,r.size>=jUt))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 MM="traceparent",UM="tracestate",zUt="00",qUt="(?!ff)[\\da-f]{2}",BUt="(?![0]{32})[\\da-f]{32}",HUt="(?![0]{16})[\\da-f]{16}",VUt="[\\da-f]{2}",GUt=new RegExp(`^\\s?(${qUt})-(${BUt})-(${HUt})-(${VUt})(-.*)?\\s?$`);function NLe(t){let e=GUt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var df=class{inject(e,r,n){let i=zt.getSpanContext(e);if(!i||OLe(e)||!Es(i))return;let s=`${zUt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Ur.NONE).toString(16)}`;n.set(r,MM,s),i.traceState&&n.set(r,UM,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,MM);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=NLe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,UM);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new $M(typeof c=="string"?c:void 0)}return zt.setSpanContext(e,o)}fields(){return[MM,UM]}};var FM=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 h0=class{_isCalled=!1;_deferred=new FM;_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 I1=hn(cQ(),1);Ue();var h1e=t=>{throw TypeError(t)},fQ=(t,e,r)=>e.has(t)||h1e("Cannot "+r),P1=(t,e,r)=>(fQ(t,e,"read from private field"),r?r.call(t):e.get(t)),uQ=(t,e,r)=>e.has(t)?h1e("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),d1e=(t,e,r,n)=>(fQ(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),ajt=(t,e,r)=>(fQ(t,e,"access private method"),r),f1e="__netlify__getTracer",ujt="__netlify__shutdownTracers",ljt="__nfOTLPTrace",P0,I0,dQ,m1e,djt=class{constructor(){uQ(this,dQ),uQ(this,P0),uQ(this,I0),d1e(this,P0,new h0(ajt(this,dQ,m1e),this)),d1e(this,I0,pe.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(P1(this,I0).debug(`export ${t.length.toString()} spans`),P1(this,P0).isCalled){e({code:CS.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(ljt,JSON.stringify(fjt(t))),e({code:CS.SUCCESS})}shutdown(){return P1(this,P0).call()}};P0=new WeakMap;I0=new WeakMap;dQ=new WeakSet;m1e=function(){return P1(this,I0).debug("Shutting down"),Promise.resolve()};function fjt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:O1(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||La.SERVER,startTimeUnixNano:lQ(e.startTime),endTimeUnixNano:lQ(e.endTime),attributes:O1(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:lQ(n.time),attributes:O1(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:O1(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function O1(t){return Object.keys(t).map(e=>g1e(e,t[e]))}function g1e(t,e){return{key:t,value:_1e(e)}}function _1e(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(_1e)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>g1e(r,n))}}:{}}function lQ(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var p1e={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},y1e=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,f1e))return;let e=cjt.version.slice(1),r=_X({"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??[pjt()],i=new I1.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new df});let s=t.instrumentations??[];EX({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,f1e,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new ml(zt.getTracer(a,c)):new ml(zt.getTracer(p1e.name,p1e.version))}}),Object.defineProperty(globalThis,ujt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},pjt=()=>new I1.SimpleSpanProcessor(new djt);Ue();var C0=hn(cQ(),1);Ue();import*as C1 from"diagnostics_channel";var S1e=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?xi.ERROR:xi.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof ml?t:new ml(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){C1.subscribe(t,e);let r=()=>C1.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:La.CLIENT},sr.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:xi.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 BHe=hn(zHe(),1);var Cj=de("tracing"),qHe=8e3,OKt=5e3,Yx=async(t=OKt)=>{try{await Promise.race([yDe(),xKt(t)])}catch(e){Cj.warn("Failed to flush tracers on shutdown",e)}},HHe=async(t,e,r)=>{if(!It()){let n=[new C0.SimpleSpanProcessor(new pne),new C0.SimpleSpanProcessor(new BHe.OTLPTraceExporter({url:r.exporterUrl}))];await y1e({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new S1e({skipHeaders:!0})]})}return r.traceparent?(Gi.setGlobalPropagator(new df),Gi.extract(sr.active(),{traceparent:r.traceparent,isRemote:!0})):sr.active()};function cr(t,e,r){return Cj.log(`\u23F3 TRACE: ${e} starting...`),QA(t,e,r)}var pne=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(", ")}]`:"";Cj.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&Cj.log(` \u274C Error: ${e.status.message}`)}};function hne(){return Ge().captureLlmContentEnabled}function VHe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function Nj(t,e,r){let n={role:t,parts:[{type:"text",content:Ss(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var PKt=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 GHe(t,e,r,n){if(!t.length)return;let i=It();if(!i)return;let s=hne(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let u=Math.min(n,r+c*o),l=Math.min(n,u+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&PKt.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>qHe?`${a.message.slice(0,qHe)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:u,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":Ss(_)}:{"gen_ai.output.messages":Nj("assistant",_)}:{}}}).end(l)})}import{readdir as IKt,rm as CKt}from"fs/promises";import{join as NKt}from"path";async function WHe(t,e=[]){let n=(await IKt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>CKt(NKt(t,i),{recursive:!0,force:!0})))}var kKt=300,Jx=t=>Ge().budgetCreditThresholds[t.mode]?.[t.runner]??kKt,Zx=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var mne=t=>{let e=Jx(t);if(!Zx(t,e))return"default";let r=Ge();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},KHe=t=>{let e=mne(t),r=Jx(t);return{budget_eligible:Zx(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var MKt=Xx.dirname(DKt(import.meta.url)),YHe=LKt(import.meta.url),UKt=Xx.resolve(MKt,"scripts/scaffold.js"),FKt="scripts/scaffold.js",jKt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,gne=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},zKt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),qKt=t=>{let e=gne(t);return e==="node"||e.endsWith("/node")},Zs=t=>{if(typeof t!="string")return!1;let e=t.match(jKt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&zKt(gne(e[r]));)r+=1;if(r>=e.length||!qKt(e[r]))return!1;let n=e[r+1];return n?gne(n).includes(FKt):!1},jm=de("create_stage"),_ne="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.",BKt=`${_ne}
600
+ if (condition) { yield value; }`)};import{Buffer as d$t}from"buffer";import{StringDecoder as f$t}from"string_decoder";var K$=(t,e,r)=>{if(r)return;if(t)return{transform:p$t.bind(void 0,new TextEncoder)};let n=new f$t(e);return{transform:h$t.bind(void 0,n),final:m$t.bind(void 0,n)}},p$t=function*(t,e){d$t.isBuffer(e)?yield cl(e):typeof e=="string"?yield t.encode(e):yield e},h$t=function*(t,e){yield En(e)?t.write(e):e},m$t=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as INe}from"util";var ZJ=INe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Y$=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_$t}=e[r];for await(let i of n(t))yield*Y$(i,e,r+1)},CNe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*g$t(r,Number(e),t)},g$t=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Y$(n,r,e+1)},NNe=INe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),_$t=function*(t){yield t};var XJ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},kNe=(t,e)=>[...e.flatMap(r=>[...Xh(r,t,0)]),...VA(t)],Xh=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=S$t}=e[r];for(let i of n(t))yield*Xh(i,e,r+1)},VA=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*y$t(r,Number(e),t)},y$t=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Xh(n,r,e+1)},S$t=function*(t){yield t};var QJ=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=LNe(t,o,s),u=Zh(e),l=Zh(r),d=u?ZJ.bind(void 0,Y$,a):XJ.bind(void 0,Xh),f=u||l?ZJ.bind(void 0,CNe,a):XJ.bind(void 0,VA),p=u||l?NNe.bind(void 0,a):void 0;return{stream:new E$t({writableObjectMode:n,writableHighWaterMark:DNe(n),readableObjectMode:i,readableHighWaterMark:DNe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},J$=(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=LNe(o,r,a);t=kNe(c,t)}return t},LNe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:xNe(n,a)},K$(r,o,n),W$(r,s,n,c),{transform:t,final:e},{transform:ONe(i,a)},ANe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var $Ne=(t,e)=>{for(let r of v$t(t))b$t(t,r,e)},v$t=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),b$t=(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 ${af[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>w$t(a,n));r.input=LA(o)},w$t=(t,e)=>{let r=J$(t,e,"utf8",!0);return T$t(r),LA(r)},T$t=t=>{let e=t.find(r=>typeof r!="string"&&!En(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 O$t,appendFileSync as P$t}from"fs";var Z$=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&cS(r,n)&&!qs.has(e)&&R$t(n)&&(t.some(({type:i,value:s})=>i==="native"&&A$t.has(s))||t.every(({type:i})=>Uo.has(i))),R$t=t=>t===1||t===2,A$t=new Set(["pipe","overlapped"]),MNe=async(t,e,r,n)=>{for await(let i of t)x$t(e)||FNe(i,r,n)},UNe=(t,e,r)=>{for(let n of t)FNe(n,e,r)},x$t=t=>t._readableState.pipes.length>0,FNe=(t,e,r)=>{let n=d$(t);jc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var jNe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>I$t({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},I$t=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=zCe(t,s,d),p=cl(f),{stdioItems:h,objectMode:m}=e[r],_=C$t([p],h,c,n),{serializedResult:y,finalResult:v=y}=N$t({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});k$t({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&&D$t(y,h,i),S}catch(g){return n.error=g,S}},C$t=(t,e,r,n)=>{try{return J$(t,e,r,!1)}catch(i){return n.error=i,t}},N$t=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:LA(t)};let o=tPe(t,r);return n[s]?{serializedResult:o,finalResult:JJ(o,!i[s],e)}:{serializedResult:o}},k$t=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!Z$({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=JJ(t,!1,o);try{UNe(a,e,n)}catch(c){r.error??=c}},D$t=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>V$.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?P$t(n,t):(r.add(s),O$t(n,t))}};var zNe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,dl(e,r,"all")]:Array.isArray(e)?[dl(t,r,"all"),...e]:En(t)&&En(e)?sJ([t,e]):`${t}${e}`};import{once as eZ}from"events";var qNe=async(t,e)=>{let[r,n]=await L$t(t);return e.isForcefullyTerminated??=!1,[r,n]},L$t=async t=>{let[e,r]=await Promise.allSettled([eZ(t,"spawn"),eZ(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?BNe(t):r.value},BNe=async t=>{try{return await eZ(t,"exit")}catch{return BNe(t)}},HNe=async t=>{let[e,r]=await t;if(!$$t(e,r)&&tZ(e,r))throw new Ca;return[e,r]},$$t=(t,e)=>t===void 0&&e===void 0,tZ=(t,e)=>t!==0||e!==null;var VNe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=M$t(t,e,r),o=s?.code==="ETIMEDOUT",a=jCe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},M$t=(t,e,r)=>t!==void 0?t:tZ(e,r)?new Ca:void 0;var GNe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=F$t(t,e,r),d=q$t({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return yS(d,c,u)},F$t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=p$(t,e,r),a=j$t(r),{file:c,commandArguments:u,options:l}=k$(t,e,a);z$t(l);let d=bNe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},j$t=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,z$t=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&X$("ipcInput"),t&&X$("ipc: true"),r&&X$("detached: true"),n&&X$("cancelSignal")},X$=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},q$t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=B$t({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=VNe(c,r),{output:h,error:m=u}=jNe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>dl(v,r,S)),y=dl(zNe(h,r),r,"all");return V$t({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},B$t=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{$Ne(s,r);let a=H$t(r);return U$t(...D$(t,e,a))}catch(a){return _S({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},H$t=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:z$(e)}),V$t=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?q$({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):HA({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as N1t}from"events";import{spawn as k1t}from"child_process";import ZNe from"process";import{once as rZ,on as G$t}from"events";var WNe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(dS({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:x$(t)}),W$t({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),W$t=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{w$(e,i);let s=of(t,e,r),o=new AbortController;try{return await Promise.race([K$t(s,n,o),Y$t(s,r,o),J$t(s,r,o)])}catch(a){throw fS(t),a}finally{o.abort(),T$(e,i)}},K$t=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await rZ(t,"message",{signal:r});return n}for await(let[n]of G$t(t,"message",{signal:r}))if(e(n))return n},Y$t=async(t,e,{signal:r})=>{await rZ(t,"disconnect",{signal:r}),kIe(e)},J$t=async(t,e,{signal:r})=>{let[n]=await rZ(t,"strict:error",{signal:r});throw E$(n,e)};import{once as YNe,on as Z$t}from"events";var JNe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>nZ({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),nZ=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{dS({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:x$(t)}),w$(e,s);let o=of(t,e,r),a=new AbortController,c={};return X$t(t,o,a),Q$t({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),eMt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},X$t=async(t,e,r)=>{try{await YNe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Q$t=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await YNe(t,"strict:error",{signal:r.signal});n.error=E$(i,e),r.abort()}catch{}},eMt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Z$t(r,"message",{signal:s.signal}))KNe(o),yield c}catch{KNe(o)}finally{s.abort(),T$(e,a),n||fS(t),i&&await t}},KNe=({error:t})=>{if(t)throw t};var XNe=(t,{ipc:e})=>{Object.assign(t,eke(t,!1,e))},QNe=()=>{let t=ZNe,e=!0,r=ZNe.channel!==void 0;return{...eke(t,e,r),getCancelSignal:oCe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},eke=(t,e,r)=>({sendMessage:C$.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:WNe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:JNe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as tMt}from"child_process";import{PassThrough as rMt,Readable as nMt,Writable as iMt,Duplex as sMt}from"stream";var tke=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{WJ(n);let a=new tMt;oMt(a,n),Object.assign(a,{readable:aMt,writable:cMt,duplex:uMt});let c=_S({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=lMt(c,o,i);return{subprocess:a,promise:u}},oMt=(t,e)=>{let r=GA(),n=GA(),i=GA(),s=Array.from({length:e.length-3},GA),o=GA(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},GA=()=>{let t=new rMt;return t.end(),t},aMt=()=>new nMt({read(){}}),cMt=()=>new iMt({write(){}}),uMt=()=>new sMt({read(){},write(){}}),lMt=async(t,e,r)=>yS(t,e,r);import{createReadStream as rke,createWriteStream as nke}from"fs";import{Buffer as dMt}from"buffer";import{Readable as WA,Writable as fMt,Duplex as pMt}from"stream";var ske=(t,e)=>G$(hMt,t,e,!1),KA=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${af[t]}.`)},ike={fileNumber:KA,generator:QJ,asyncGenerator:QJ,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:pMt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},hMt={input:{...ike,fileUrl:({value:t})=>({stream:rke(t)}),filePath:({value:{file:t}})=>({stream:rke(t)}),webStream:({value:t})=>({stream:WA.fromWeb(t)}),iterable:({value:t})=>({stream:WA.from(t)}),asyncIterable:({value:t})=>({stream:WA.from(t)}),string:({value:t})=>({stream:WA.from(t)}),uint8Array:({value:t})=>({stream:WA.from(dMt.from(t))})},output:{...ike,fileUrl:({value:t})=>({stream:nke(t)}),filePath:({value:{file:t,append:e}})=>({stream:nke(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:fMt.fromWeb(t)}),iterable:KA,asyncIterable:KA,string:KA,uint8Array:KA}};import{on as mMt,once as oke}from"events";import{PassThrough as gMt,getDefaultHighWaterMark as _Mt}from"stream";import{finished as uke}from"stream/promises";function Qh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)sZ(i);let e=t.some(({readableObjectMode:i})=>i),r=yMt(t,e),n=new iZ({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var yMt=(t,e)=>{if(t.length===0)return _Mt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},iZ=class extends gMt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(sZ(e),this.#e.has(e))return;this.#e.add(e),this.#n??=SMt(this,this.#e,this.#s);let r=bMt({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(sZ(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)}},SMt=async(t,e,r)=>{Q$(t,ake);let n=new AbortController;try{await Promise.race([EMt(t,n),vMt(t,e,r,n)])}finally{n.abort(),Q$(t,-ake)}},EMt=async(t,{signal:e})=>{try{await uke(t,{signal:e,cleanup:!0})}catch(r){throw lke(t,r),r}},vMt=async(t,e,r,{signal:n})=>{for await(let[i]of mMt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},sZ=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},bMt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{Q$(t,cke);let a=new AbortController;try{await Promise.race([wMt(s,e,a),TMt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),RMt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),Q$(t,-cke)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?oZ(t):AMt(t))},wMt=async(t,e,{signal:r})=>{try{await t,r.aborted||oZ(e)}catch(n){r.aborted||lke(e,n)}},TMt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await uke(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;dke(o)?i.add(e):fke(t,o)}},RMt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await oke(t,i,{signal:s}),!t.readable)return oke(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},AMt=t=>{t.writable&&t.end()},lke=(t,e)=>{dke(e)?oZ(t):fke(t,e)},dke=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oZ=t=>{(t.readable||t.writable)&&t.destroy()},fke=(t,e)=>{t.destroyed||(t.once("error",xMt),t.destroy(e))},xMt=()=>{},Q$=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ake=2,cke=1;import{finished as pke}from"stream/promises";var ES=(t,e)=>{t.pipe(e),OMt(t,e),PMt(t,e)},OMt=async(t,e)=>{if(!(Ia(t)||Ia(e))){try{await pke(t,{cleanup:!0,readable:!0,writable:!1})}catch{}aZ(e)}},aZ=t=>{t.writable&&t.end()},PMt=async(t,e)=>{if(!(Ia(t)||Ia(e))){try{await pke(e,{cleanup:!0,readable:!1,writable:!0})}catch{}cZ(t)}},cZ=t=>{t.readable&&t.destroy()};var hke=(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})=>Uo.has(c)))IMt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Uo.has(c)))NMt({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]:Qh(s);ES(o,i)}},IMt=(t,e,r,n)=>{r==="output"?ES(t.stdio[n],e):ES(e,t.stdio[n]);let i=CMt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},CMt=["stdin","stdout","stderr"],NMt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;kMt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},kMt=(t,{signal:e})=>{Ia(t)&&Yh(t,DMt,e)},DMt=2;import{addAbortListener as MMt}from"events";var em=[];em.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&em.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&em.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var eM=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",uZ=Symbol.for("signal-exit emitter"),lZ=globalThis,LMt=Object.defineProperty.bind(Object),dZ=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(lZ[uZ])return lZ[uZ];LMt(lZ,uZ,{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}},tM=class{},$Mt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),fZ=class extends tM{onExit(){return()=>{}}load(){}unload(){}},pZ=class extends tM{#e=hZ.platform==="win32"?"SIGINT":"SIGHUP";#r=new dZ;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of em)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(!eM(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 em)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,em.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 eM(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"&&eM(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)}},hZ=globalThis.process,{onExit:mke,load:vLr,unload:bLr}=$Mt(eM(hZ)?new pZ(hZ):new fZ);var gke=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=mke(()=>{t.kill()});MMt(n,()=>{i()})};var yke=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=f$(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=UMt(r,n,i),{sourceStream:d,sourceError:f}=jMt(t,u),{options:p,fileDescriptors:h}=qc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},UMt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=FMt(t,e,...r),a=b$(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},FMt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(_ke,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||nJ(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]=r$(r,...n);return{destination:e(_ke)(i,s,o),pipeOptions:o}}if(qc.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}`)},_ke=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),jMt=(t,e)=>{try{return{sourceStream:pS(t,e)}}catch(r){return{sourceError:r}}};var Eke=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=zMt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw mZ({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},zMt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return cZ(t),n;if(e!==void 0)return aZ(r),e},mZ=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>_S({error:t,command:Ske,escapedCommand:Ske,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Ske="source.pipe(destination)";var vke=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 qMt}from"stream/promises";var bke=(t,e,r)=>{let n=rM.has(e)?HMt(t,e):BMt(t,e);return Yh(t,GMt,r.signal),Yh(e,WMt,r.signal),VMt(e),n},BMt=(t,e)=>{let r=Qh([t]);return ES(r,e),rM.set(e,r),r},HMt=(t,e)=>{let r=rM.get(e);return r.add(t),r},VMt=async t=>{try{await qMt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rM.delete(t)},rM=new WeakMap,GMt=2,WMt=1;import{aborted as KMt}from"util";var wke=(t,e)=>t===void 0?[]:[YMt(t,e)],YMt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await KMt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw mZ({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var nM=(t,...e)=>{if(Yr(e[0]))return nM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=yke(t,...e),i=JMt({...n,destination:r});return i.pipe=nM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},JMt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=ZMt(t,i);Eke({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=bke(e,s,d);return await Promise.race([vke(l),...wke(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},ZMt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as i1t}from"timers/promises";import{on as XMt}from"events";import{getDefaultHighWaterMark as QMt}from"stream";var iM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return e1t(e,o),Rke({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},e1t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},gZ=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;t1t(e,o,t);let a=t.readableObjectMode&&!s;return Rke({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},t1t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Rke=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=XMt(t,"data",{signal:e.signal,highWaterMark:Tke,highWatermark:Tke});return r1t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},_Z=QMt(!0),Tke=_Z,r1t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=n1t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Xh(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*VA(a)}},n1t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[K$(t,r,!e),W$(t,i,!n,{})].filter(Boolean);var Ake=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=s1t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([o1t(t),d]);return}let f=KJ(c,r),p=gZ({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([a1t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},s1t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!Z$({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=gZ({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await MNe(a,t,r,s)},o1t=async t=>{await i1t(),t.readableFlowing===null&&t.resume()},a1t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await U$(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await F$(r,{maxBuffer:s})):await gS(r,{maxBuffer:s})}catch(a){return xke(MCe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},yZ=async t=>{try{return await t}catch(e){return xke(e)}},xke=({bufferedData:t})=>QOe(t)?new Uint8Array(t):t;import{finished as c1t}from"stream/promises";var YA=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=u1t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],c1t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||f1t(a,e,r,n)}finally{o.abort()}},u1t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&l1t(t,r,n),n},l1t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{d1t(e,r),n.call(t,...i)}},d1t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},f1t=(t,e,r,n)=>{if(!p1t(t,e,r,n))throw t},p1t=(t,e,r,n=!0)=>r.propagating?Oke(t)||sM(t):(r.propagating=!0,SZ(r,e)===n?Oke(t):sM(t)),SZ=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",sM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Oke=t=>t?.code==="EPIPE";var Pke=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>EZ({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),EZ=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=YA(t,e,u);if(SZ(u,e)){await l;return}let[d]=await Promise.all([Ake({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var Ike=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Qh([t,e].filter(Boolean)):void 0,Cke=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>EZ({...h1t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:m1t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),h1t=({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}},m1t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as g1t}from"events";var Nke=t=>cS(t,"ipc"),kke=(t,e)=>{let r=d$(t);jc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Dke=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Nke(s),a=ul(e,"ipc"),c=ul(r,"ipc");for await(let u of nZ({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(UCe(t,i,c),i.push(u)),o&&kke(u,s);return i},Lke=async(t,e)=>(await Promise.allSettled([t]),e);var $ke=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=qNe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Pke({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=Cke({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),R=[],A=Dke({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:R,verboseInfo:p}),T=_1t(m,t,S),P=y1t(h,S);try{return await Promise.race([Promise.all([{},HNe(v),Promise.all(g),b,A,gCe(t,d),...T,...P]),_,S1t(t,y),...dCe(t,s,f,y),...NIe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...uCe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(I){return f.terminationReason??="other",Promise.all([{error:I},v,Promise.all(g.map(O=>yZ(O))),yZ(b),Lke(A,R),Promise.allSettled(T),Promise.allSettled(P)])}},_1t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:YA(n,i,r)),y1t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>ka(s,{checkOpen:!1})&&!Ia(s)).map(({type:i,value:s,stream:o=s})=>YA(o,n,e,{isSameDirection:Uo.has(i),stopOnExit:i==="native"}))),S1t=async(t,{signal:e})=>{let[r]=await g1t(t,"error",{signal:e});throw r};var Mke=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),JA=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=zc();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},vS=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 E1t}from"stream";import{callbackify as v1t}from"util";import{finished as Uke}from"stream/promises";var vZ=async t=>{if(t!==void 0)try{await bZ(t)}catch{}},Fke=async t=>{if(t!==void 0)try{await wZ(t)}catch{}},bZ=async t=>{await Uke(t,{cleanup:!0,readable:!1,writable:!0})},wZ=async t=>{await Uke(t,{cleanup:!0,readable:!0,writable:!1})},oM=async(t,e)=>{if(await t,e)throw e},aM=(t,e,r)=>{r&&!sM(r)?t.destroy(r):e&&t.destroy()};var jke=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||qs.has(r),{subprocessStdout:a,waitReadableDestroy:c}=TZ(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=RZ(a,o),{read:f,onStdoutDataDone:p}=AZ({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new E1t({read:f,destroy:v1t(OZ.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return xZ({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},TZ=(t,e,r)=>{let n=pS(t,e),i=JA(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},RZ=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:_Z},AZ=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=zc(),o=iM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){b1t(this,o,s)},onStdoutDataDone:s}},b1t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},xZ=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await wZ(t),await n,await vZ(i),await e,r.readable&&r.push(null)}catch(s){await vZ(i),zke(r,s)}},OZ=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await vS(r,e)&&(zke(t,n),await oM(e,n))},zke=(t,e)=>{aM(t,t.readable,e)};import{Writable as w1t}from"stream";import{callbackify as qke}from"util";var Bke=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=PZ(t,r,e),o=new w1t({...IZ(n,t,i),destroy:qke(NZ.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return CZ(n,o),o},PZ=(t,e,r)=>{let n=b$(t,e),i=JA(r,n,"writableFinal"),s=JA(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},IZ=(t,e,r)=>({write:T1t.bind(void 0,t),final:qke(R1t.bind(void 0,t,e,r))}),T1t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},R1t=async(t,e,r)=>{await vS(r,e)&&(t.writable&&t.end(),await e)},CZ=async(t,e,r)=>{try{await bZ(t),e.writable&&e.end()}catch(n){await Fke(r),Hke(e,n)}},NZ=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await vS(r,e),await vS(n,e)&&(Hke(t,i),await oM(e,i))},Hke=(t,e)=>{aM(t,t.writable,e)};import{Duplex as A1t}from"stream";import{callbackify as x1t}from"util";var Vke=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||qs.has(r),{subprocessStdout:c,waitReadableDestroy:u}=TZ(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=PZ(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=RZ(c,a),{read:_,onStdoutDataDone:y}=AZ({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new A1t({read:_,...IZ(l,t,d),destroy:x1t(O1t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return xZ({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),CZ(l,v,c),v},O1t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([OZ({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),NZ({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var kZ=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||qs.has(e),o=pS(t,r),a=iM({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return P1t(a,o,t)},P1t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Gke=(t,{encoding:e})=>{let r=Mke();t.readable=jke.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Bke.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Vke.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=kZ.bind(void 0,t,e),t[Symbol.asyncIterator]=kZ.bind(void 0,t,e,{})};var Wke=(t,e)=>{for(let[r,n]of C1t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},I1t=(async()=>{})().constructor.prototype,C1t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(I1t,t)]);var Kke=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=D1t(t,e,r),{subprocess:f,promise:p}=$1t({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=nM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Wke(f,p),qc.set(f,{options:l,fileDescriptors:d}),f},D1t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=p$(t,e,r),{file:a,commandArguments:c,options:u}=k$(t,e,r),l=L1t(u),d=ske(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},L1t=({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}},$1t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=k1t(...D$(t,e,r))}catch(h){return tke({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;N1t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];hke(c,a,u),gke(c,r,u);let d={},f=zc();c.kill=IIe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Ike(c,r),Gke(c,r),XNe(c,r);let p=M1t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},M1t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await $ke({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((g,b)=>dl(g,e,b)),v=dl(m,e,"all"),S=U1t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return yS(S,n,e)},U1t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?HA({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Bc,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):q$({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var cM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,F1t(n,t[n],i)]));return{...t,...r}},F1t=(t,e,r)=>j1t.has(t)&&Yr(e)&&Yr(r)?{...e,...r}:r,j1t=new Set(["env",...uJ]);var cf=(t,e,r,n)=>{let i=(o,a,c)=>cf(o,a,r,c),s=(...o)=>z1t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},z1t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Yr(s))return i(t,cM(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=q1t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?GNe(a,c,u):Kke(a,c,u,i)},q1t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=sPe(e)?oPe(e,r):[e,...r],[o,a,c]=r$(...s),u=cM(cM(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var Yke=({file:t,commandArguments:e})=>Zke(t,e),Jke=({file:t,commandArguments:e})=>({...Zke(t,e),isSync:!0}),Zke=(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]=B1t(t);return{file:r,commandArguments:n}},B1t=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(H1t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},H1t=/ +/g;var Xke=(t,e,r)=>{t.sync=e(V1t,r),t.s=t.sync},Qke=({options:t})=>eDe(t),V1t=({options:t})=>({...eDe(t),isSync:!0}),eDe=t=>({options:{...G1t(t),...t}}),G1t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},tDe={preferLocal:!0};var rDe=cf(()=>({})),d1r=cf(()=>({isSync:!0})),nDe=cf(Yke),f1r=cf(Jke),p1r=cf(pCe),h1r=cf(Qke,{},tDe,Xke),{sendMessage:m1r,getOneMessage:g1r,getEachMessage:_1r,getCancelSignal:y1r}=QNe();import{Transform as W1t}from"stream";var K1t=["NETLIFY_AI_GATEWAY_KEY"];function Y1t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...K1t])]}function J1t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function Z1t(){let e=Y1t().map(r=>process.env[r]).filter(r=>!(!r||J1t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ss(t){if(typeof t!="string")return t;let e=Z1t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(X1t(n),"g");r=r.replace(i,"******")}),r}function X1t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ZA=class extends W1t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ss(i);n(null,s)}},uM=Symbol("maskedWrite");function iDe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[uM]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ss(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[uM]=!0,process.stdout.write=r}if(!process.stderr.write[uM]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ss(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[uM]=!0,process.stderr.write=r}}}var sDe=!1,oDe,DZ=t=>{oDe??=t},aDe=t=>{sDe=!0,DZ(t)},an=()=>sDe,Da=()=>oDe,cDe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var XA=null,uDe=t=>(XA&&XA.destroy(),XA=new Fo({totalAllowedTime:t}),XA),lDe=()=>XA;var Fo=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&&an())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await Ok({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var dDe={name:"@netlify/agent-runner-cli",type:"module",version:"1.200.2-bug.7",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@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.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var rUt=eUt(import.meta.url),nUt=fl.dirname(rUt),iUt=tUt(import.meta.url),bS=de("shell"),LZ=new Set,fDe={preferLocal:!0},Dt=(t,e,r)=>{let[n,i]=sUt(e,r),s={...fDe,...i},o=rDe(t,n,s);hDe(o,s),_De(o);let a=r?.idleTimeout;return a&&a>0&&gDe(o,a),o},pDe=(t,e)=>{let r={...fDe,...e},n=nDe(t,r);return hDe(n,r),_De(n),e?.idleTimeout&&e.idleTimeout>0&&gDe(n,e.idleTimeout),n},sUt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},hDe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Vc.env.NETLIFY_LOCAL_QUIET==="true")return;if(Vc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new ZA).pipe(Vc.stdout),t.stderr?.pipe(new ZA).pipe(Vc.stderr);return}t.stdout?.pipe(Vc.stdout),t.stderr?.pipe(Vc.stderr)},$Z=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Vc.kill(-t.pid,e),bS.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return bS.error("Error killing process:",r),!1}},mDe=t=>$Z(t,"SIGKILL"),gDe=(t,e)=>{let r=null,n=()=>{bS.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),$Z(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(bS.log(`Force killing idle process ${t.pid}`),mDe(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)},_De=t=>{LZ.add(t);let e=lDe();if(e){let r=e.onTimesUp(()=>{bS.log(`Global timer expired, killing process ${t.pid}`),$Z(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(bS.log(`Force killing process ${t.pid} after timeout`),mDe(t))},5e3)});t.on("exit",()=>{LZ.delete(t),r()}),t.on("error",()=>{LZ.delete(t),r()})}};function Gc(t,e){if(!Vc.env.NETLIFY_LOCAL_MODE)try{let i=iUt.resolve(dDe.name),s=fl.dirname(i);for(;s!==fl.dirname(s);){let o=fl.dirname(s);if(fl.basename(o)==="node_modules"){let a=fl.join(o,".bin",e);if(lM.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Vc.env.NODE_PATH){let i=fl.join(Vc.env.NODE_PATH,".bin",e);if(lM.existsSync(i))return i}let r=fl.join(t,"node_modules",".bin",e);if(lM.existsSync(r))return r;let n=fl.join(nUt,"..","node_modules",".bin",e);if(lM.existsSync(n))return n}import kj from"process";import{fileURLToPath as DKt}from"url";import{createRequire as LKt}from"module";import Xx from"path";import{readFileSync as $Kt}from"fs";var oUt="__netlify__getTracer",aUt="__netlify__shutdownTracers",It=(t,e)=>globalThis[oUt]?.(t,e),yDe=async()=>globalThis[aUt]?.();function QA(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 xKt}from"timers/promises";Ue();import cjt from"process";Ue();var CUt=(t,e)=>{e.recordException(t),e.setStatus({code:xi.ERROR})};var ml=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}=dLe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>fLe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=dLe(r,n,i),c=this._tracer.startSpan(e,s,o);return fLe(c,s,a)}};function dLe(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??sr.active(),{opts:n,ctx:i,fn:s}}function fLe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:CUt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ue();var PS=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var gX=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=bLe(e),n._asyncAttributesPending=e.filter(([i,s])=>PS(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(PS(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=bLe(this._rawAttributes),this._schemaUrl=NUt(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,PS(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&pe.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(PS(n)){pe.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=kUt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function _X(t,e){return gX.FromAttributeList(Object.entries(t),e)}function bLe(t){return t.map(([e,r])=>PS(r)?[e,r.catch(n=>{pe.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function NUt(t){if(typeof t=="string"||t===void 0)return t;pe.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function kUt(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;pe.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ue();var d0=class{emit(e){}enabled(){return!1}},wLe=new d0;var f0=Symbol.for("io.opentelemetry.js.api.logs"),IS=globalThis;function TLe(t,e,r){return n=>n===t?e:r}var yX=1;var SX=class{getLogger(e,r,n){return new d0}},kM=new SX;var DM=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):wLe}};var p0=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new DM(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:kM}_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 LM=class t{constructor(){this._proxyLoggerProvider=new p0}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return IS[f0]?this.getLoggerProvider():(IS[f0]=TLe(yX,e,kM),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=IS[f0])===null||e===void 0?void 0:e.call(IS,yX))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete IS[f0],this._proxyLoggerProvider=new p0}};var RLe=LM.getInstance();function ALe(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 xLe(t){t.forEach(e=>e.disable())}function EX(t){let e=t.tracerProvider||zt.getTracerProvider(),r=t.meterProvider||l0.getMeterProvider(),n=t.loggerProvider||RLe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return ALe(i,e,r,n),()=>{xLe(i)}}Ue();var DUt=kn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function OLe(t){return t.getValue(DUt)===!0}var CS;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(CS||(CS={}));Ue();var vX="[_0-9a-z-*/]",LUt=`[a-z]${vX}{0,255}`,$Ut=`[a-z0-9]${vX}{0,240}@[a-z]${vX}{0,13}`,MUt=new RegExp(`^(?:${LUt}|${$Ut})$`),UUt=/^[ -~]{0,255}[!-~]$/,FUt=/,|=/;function bX(t){return MUt.test(t)}function wX(t){return UUt.test(t)&&!FUt.test(t)}var jUt=32,PLe=512,ILe=",",CLe="=",$M=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!bX(e)||!wX(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>PLe)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=ILe+e),e=`${n[0]}${CLe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(ILe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(CLe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!bX(a)||!wX(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>PLe)&&(r.set(a,c),n=u,r.size>=jUt))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 MM="traceparent",UM="tracestate",zUt="00",qUt="(?!ff)[\\da-f]{2}",BUt="(?![0]{32})[\\da-f]{32}",HUt="(?![0]{16})[\\da-f]{16}",VUt="[\\da-f]{2}",GUt=new RegExp(`^\\s?(${qUt})-(${BUt})-(${HUt})-(${VUt})(-.*)?\\s?$`);function NLe(t){let e=GUt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var df=class{inject(e,r,n){let i=zt.getSpanContext(e);if(!i||OLe(e)||!Es(i))return;let s=`${zUt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Ur.NONE).toString(16)}`;n.set(r,MM,s),i.traceState&&n.set(r,UM,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,MM);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=NLe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,UM);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new $M(typeof c=="string"?c:void 0)}return zt.setSpanContext(e,o)}fields(){return[MM,UM]}};var FM=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 h0=class{_isCalled=!1;_deferred=new FM;_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 I1=hn(cQ(),1);Ue();var h1e=t=>{throw TypeError(t)},fQ=(t,e,r)=>e.has(t)||h1e("Cannot "+r),P1=(t,e,r)=>(fQ(t,e,"read from private field"),r?r.call(t):e.get(t)),uQ=(t,e,r)=>e.has(t)?h1e("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),d1e=(t,e,r,n)=>(fQ(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),ajt=(t,e,r)=>(fQ(t,e,"access private method"),r),f1e="__netlify__getTracer",ujt="__netlify__shutdownTracers",ljt="__nfOTLPTrace",P0,I0,dQ,m1e,djt=class{constructor(){uQ(this,dQ),uQ(this,P0),uQ(this,I0),d1e(this,P0,new h0(ajt(this,dQ,m1e),this)),d1e(this,I0,pe.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(P1(this,I0).debug(`export ${t.length.toString()} spans`),P1(this,P0).isCalled){e({code:CS.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(ljt,JSON.stringify(fjt(t))),e({code:CS.SUCCESS})}shutdown(){return P1(this,P0).call()}};P0=new WeakMap;I0=new WeakMap;dQ=new WeakSet;m1e=function(){return P1(this,I0).debug("Shutting down"),Promise.resolve()};function fjt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:O1(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||La.SERVER,startTimeUnixNano:lQ(e.startTime),endTimeUnixNano:lQ(e.endTime),attributes:O1(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:lQ(n.time),attributes:O1(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:O1(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function O1(t){return Object.keys(t).map(e=>g1e(e,t[e]))}function g1e(t,e){return{key:t,value:_1e(e)}}function _1e(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(_1e)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>g1e(r,n))}}:{}}function lQ(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var p1e={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},y1e=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,f1e))return;let e=cjt.version.slice(1),r=_X({"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??[pjt()],i=new I1.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new df});let s=t.instrumentations??[];EX({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,f1e,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new ml(zt.getTracer(a,c)):new ml(zt.getTracer(p1e.name,p1e.version))}}),Object.defineProperty(globalThis,ujt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},pjt=()=>new I1.SimpleSpanProcessor(new djt);Ue();var C0=hn(cQ(),1);Ue();import*as C1 from"diagnostics_channel";var S1e=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?xi.ERROR:xi.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof ml?t:new ml(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){C1.subscribe(t,e);let r=()=>C1.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:La.CLIENT},sr.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:xi.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 BHe=hn(zHe(),1);var Cj=de("tracing"),qHe=8e3,OKt=5e3,Yx=async(t=OKt)=>{try{await Promise.race([yDe(),xKt(t)])}catch(e){Cj.warn("Failed to flush tracers on shutdown",e)}},HHe=async(t,e,r)=>{if(!It()){let n=[new C0.SimpleSpanProcessor(new pne),new C0.SimpleSpanProcessor(new BHe.OTLPTraceExporter({url:r.exporterUrl}))];await y1e({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new S1e({skipHeaders:!0})]})}return r.traceparent?(Gi.setGlobalPropagator(new df),Gi.extract(sr.active(),{traceparent:r.traceparent,isRemote:!0})):sr.active()};function cr(t,e,r){return Cj.log(`\u23F3 TRACE: ${e} starting...`),QA(t,e,r)}var pne=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(", ")}]`:"";Cj.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&Cj.log(` \u274C Error: ${e.status.message}`)}};function hne(){return Ge().captureLlmContentEnabled}function VHe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function Nj(t,e,r){let n={role:t,parts:[{type:"text",content:Ss(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var PKt=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 GHe(t,e,r,n){if(!t.length)return;let i=It();if(!i)return;let s=hne(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let u=Math.min(n,r+c*o),l=Math.min(n,u+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&PKt.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>qHe?`${a.message.slice(0,qHe)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:u,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":Ss(_)}:{"gen_ai.output.messages":Nj("assistant",_)}:{}}}).end(l)})}import{readdir as IKt,rm as CKt}from"fs/promises";import{join as NKt}from"path";async function WHe(t,e=[]){let n=(await IKt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>CKt(NKt(t,i),{recursive:!0,force:!0})))}var kKt=300,Jx=t=>Ge().budgetCreditThresholds[t.mode]?.[t.runner]??kKt,Zx=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var mne=t=>{let e=Jx(t);if(!Zx(t,e))return"default";let r=Ge();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},KHe=t=>{let e=mne(t),r=Jx(t);return{budget_eligible:Zx(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var MKt=Xx.dirname(DKt(import.meta.url)),YHe=LKt(import.meta.url),UKt=Xx.resolve(MKt,"scripts/scaffold.js"),FKt="scripts/scaffold.js",jKt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,gne=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},zKt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),qKt=t=>{let e=gne(t);return e==="node"||e.endsWith("/node")},Zs=t=>{if(typeof t!="string")return!1;let e=t.match(jKt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&zKt(gne(e[r]));)r+=1;if(r>=e.length||!qKt(e[r]))return!1;let n=e[r+1];return n?gne(n).includes(FKt):!1},jm=de("create_stage"),_ne="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.",BKt=`${_ne}
601
601
 
602
602
  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.`,HKt=`${_ne}
603
603
 
package/dist/index.js CHANGED
@@ -384,7 +384,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
384
384
  `,LF:`
385
385
  `,concatBytes:uY},fct=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},pct={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:fct};import{Buffer as hct}from"buffer";var Hbe=(t,e)=>t?void 0:mct.bind(void 0,e),mct=function*(t,e){if(typeof e!="string"&&!Fr(e)&&!hct.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Wbe=(t,e)=>t?gct.bind(void 0,e):_ct.bind(void 0,e),gct=function*(t,e){Kbe(t,e),yield e},_ct=function*(t,e){if(Kbe(t,e),typeof e!="string"&&!Fr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Kbe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
386
386
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
387
- if (condition) { yield value; }`)};import{Buffer as yct}from"buffer";import{StringDecoder as Sct}from"string_decoder";var ND=(t,e,r)=>{if(r)return;if(t)return{transform:vct.bind(void 0,new TextEncoder)};let n=new Sct(e);return{transform:Ect.bind(void 0,n),final:bct.bind(void 0,n)}},vct=function*(t,e){yct.isBuffer(e)?yield tu(e):typeof e=="string"?yield t.encode(e):yield e},Ect=function*(t,e){yield Fr(e)?t.write(e):e},bct=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Ybe}from"util";var dY=Ybe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),DD=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Tct}=e[r];for await(let i of n(t))yield*DD(i,e,r+1)},Zbe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wct(r,Number(e),t)},wct=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*DD(n,r,e+1)},Qbe=Ybe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Tct=function*(t){yield t};var fY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Jbe=(t,e)=>[...e.flatMap(r=>[...yp(r,t,0)]),...CT(t)],yp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Rct}=e[r];for(let i of n(t))yield*yp(i,e,r+1)},CT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Act(r,Number(e),t)},Act=function*(t,e,r){if(t!==void 0)for(let n of t())yield*yp(n,r,e+1)},Rct=function*(t){yield t};var pY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=ewe(t,o,s),u=_p(e),l=_p(r),d=u?dY.bind(void 0,DD,a):fY.bind(void 0,yp),f=u||l?dY.bind(void 0,Zbe,a):fY.bind(void 0,CT),p=u||l?Qbe.bind(void 0,a):void 0;return{stream:new xct({writableObjectMode:n,writableHighWaterMark:Xbe(n),readableObjectMode:i,readableHighWaterMark:Xbe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},MD=(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=ewe(o,r,a);t=Jbe(c,t)}return t},ewe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Hbe(n,a)},ND(r,o,n),kD(r,s,n,c),{transform:t,final:e},{transform:Wbe(i,a)},Gbe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var twe=(t,e)=>{for(let r of Oct(t))Pct(t,r,e)},Oct=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Pct=(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 ${Ul[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Ict(a,n));r.input=ET(o)},Ict=(t,e)=>{let r=MD(t,e,"utf8",!0);return Cct(r),ET(r)},Cct=t=>{let e=t.find(r=>typeof r!="string"&&!Fr(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 Mct,appendFileSync as $ct}from"fs";var $D=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&v_(r,n)&&!Ji.has(e)&&kct(n)&&(t.some(({type:i,value:s})=>i==="native"&&Nct.has(s))||t.every(({type:i})=>Ds.has(i))),kct=t=>t===1||t===2,Nct=new Set(["pipe","overlapped"]),rwe=async(t,e,r,n)=>{for await(let i of t)Dct(e)||iwe(i,r,n)},nwe=(t,e,r)=>{for(let n of t)iwe(n,e,r)},Dct=t=>t._readableState.pipes.length>0,iwe=(t,e,r)=>{let n=ZN(t);za({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var swe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>Lct({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Lct=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=obe(t,s,d),p=tu(f),{stdioItems:h,objectMode:m}=e[r],_=Uct([p],h,c,n),{serializedResult:S,finalResult:b=S}=Fct({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});zct({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?b:void 0;try{return n.error===void 0&&jct(S,h,i),x}catch(y){return n.error=y,x}},Uct=(t,e,r,n)=>{try{return MD(t,e,r,!1)}catch(i){return n.error=i,t}},Fct=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:ET(t)};let o=vSe(t,r);return n[s]?{serializedResult:o,finalResult:lY(o,!i[s],e)}:{serializedResult:o}},zct=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!$D({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=lY(t,!1,o);try{nwe(a,e,n)}catch(c){r.error??=c}},jct=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>ID.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?$ct(n,t):(r.add(s),Mct(n,t))}};var owe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,iu(e,r,"all")]:Array.isArray(e)?[iu(t,r,"all"),...e]:Fr(t)&&Fr(e)?SK([t,e]):`${t}${e}`};import{once as hY}from"events";var awe=async(t,e)=>{let[r,n]=await qct(t);return e.isForcefullyTerminated??=!1,[r,n]},qct=async t=>{let[e,r]=await Promise.allSettled([hY(t,"spawn"),hY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?cwe(t):r.value},cwe=async t=>{try{return await hY(t,"exit")}catch{return cwe(t)}},uwe=async t=>{let[e,r]=await t;if(!Bct(e,r)&&mY(e,r))throw new Vo;return[e,r]},Bct=(t,e)=>t===void 0&&e===void 0,mY=(t,e)=>t!==0||e!==null;var lwe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Vct(t,e,r),o=s?.code==="ETIMEDOUT",a=sbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Vct=(t,e,r)=>t!==void 0?t:mY(e,r)?new Vo:void 0;var dwe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Hct(t,e,r),d=Yct({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return I_(d,c,u)},Hct=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JN(t,e,r),a=Wct(r),{file:c,commandArguments:u,options:l}=yD(t,e,a);Kct(l);let d=jbe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},Wct=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Kct=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LD("ipcInput"),t&&LD("ipc: true"),r&&LD("detached: true"),n&&LD("cancelSignal")},LD=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Yct=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Zct({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=lwe(c,r),{output:h,error:m=u}=swe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((b,x)=>iu(b,r,x)),S=iu(owe(h,r),r,"all");return Jct({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},Zct=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{twe(s,r);let a=Qct(r);return Gct(...SD(t,e,a))}catch(a){return P_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Qct=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RD(e)}),Jct=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?xD({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):IT({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as Flt}from"events";import{spawn as zlt}from"child_process";import gwe from"process";import{once as gY,on as Xct}from"events";var fwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(w_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fD(t)}),eut({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),eut=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cD(e,i);let s=Ll(t,e,r),o=new AbortController;try{return await Promise.race([tut(s,n,o),rut(s,r,o),nut(s,r,o)])}catch(a){throw T_(t),a}finally{o.abort(),uD(e,i)}},tut=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await gY(t,"message",{signal:r});return n}for await(let[n]of Xct(t,"message",{signal:r}))if(e(n))return n},rut=async(t,e,{signal:r})=>{await gY(t,"disconnect",{signal:r}),Jve(e)},nut=async(t,e,{signal:r})=>{let[n]=await gY(t,"strict:error",{signal:r});throw sD(n,e)};import{once as hwe,on as iut}from"events";var mwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>_Y({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),_Y=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{w_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fD(t)}),cD(e,s);let o=Ll(t,e,r),a=new AbortController,c={};return sut(t,o,a),out({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),aut({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},sut=async(t,e,r)=>{try{await hwe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},out=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await hwe(t,"strict:error",{signal:r.signal});n.error=sD(i,e),r.abort()}catch{}},aut=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of iut(r,"message",{signal:s.signal}))pwe(o),yield c}catch{pwe(o)}finally{s.abort(),uD(e,a),n||T_(t),i&&await t}},pwe=({error:t})=>{if(t)throw t};var _we=(t,{ipc:e})=>{Object.assign(t,Swe(t,!1,e))},ywe=()=>{let t=gwe,e=!0,r=gwe.channel!==void 0;return{...Swe(t,e,r),getCancelSignal:AEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Swe=(t,e,r)=>({sendMessage:gD.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:fwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:mwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as cut}from"child_process";import{PassThrough as uut,Readable as lut,Writable as dut,Duplex as fut}from"stream";var vwe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{aY(n);let a=new cut;put(a,n),Object.assign(a,{readable:hut,writable:mut,duplex:gut});let c=P_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=_ut(c,o,i);return{subprocess:a,promise:u}},put=(t,e)=>{let r=kT(),n=kT(),i=kT(),s=Array.from({length:e.length-3},kT),o=kT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},kT=()=>{let t=new uut;return t.end(),t},hut=()=>new lut({read(){}}),mut=()=>new dut({write(){}}),gut=()=>new fut({read(){},write(){}}),_ut=async(t,e,r)=>I_(t,e,r);import{createReadStream as Ewe,createWriteStream as bwe}from"fs";import{Buffer as yut}from"buffer";import{Readable as NT,Writable as Sut,Duplex as vut}from"stream";var Twe=(t,e)=>CD(Eut,t,e,!1),DT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ul[t]}.`)},wwe={fileNumber:DT,generator:pY,asyncGenerator:pY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:vut.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Eut={input:{...wwe,fileUrl:({value:t})=>({stream:Ewe(t)}),filePath:({value:{file:t}})=>({stream:Ewe(t)}),webStream:({value:t})=>({stream:NT.fromWeb(t)}),iterable:({value:t})=>({stream:NT.from(t)}),asyncIterable:({value:t})=>({stream:NT.from(t)}),string:({value:t})=>({stream:NT.from(t)}),uint8Array:({value:t})=>({stream:NT.from(yut.from(t))})},output:{...wwe,fileUrl:({value:t})=>({stream:bwe(t)}),filePath:({value:{file:t,append:e}})=>({stream:bwe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Sut.fromWeb(t)}),iterable:DT,asyncIterable:DT,string:DT,uint8Array:DT}};import{on as but,once as Awe}from"events";import{PassThrough as wut,getDefaultHighWaterMark as Tut}from"stream";import{finished as Owe}from"stream/promises";function Sp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)SY(i);let e=t.some(({readableObjectMode:i})=>i),r=Aut(t,e),n=new yY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Aut=(t,e)=>{if(t.length===0)return Tut(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},yY=class extends wut{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(SY(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Rut(this,this.#e,this.#s);let r=Put({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(SY(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)}},Rut=async(t,e,r)=>{UD(t,Rwe);let n=new AbortController;try{await Promise.race([xut(t,n),Out(t,e,r,n)])}finally{n.abort(),UD(t,-Rwe)}},xut=async(t,{signal:e})=>{try{await Owe(t,{signal:e,cleanup:!0})}catch(r){throw Pwe(t,r),r}},Out=async(t,e,r,{signal:n})=>{for await(let[i]of but(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},SY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Put=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{UD(t,xwe);let a=new AbortController;try{await Promise.race([Iut(s,e,a),Cut({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),kut({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),UD(t,-xwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?vY(t):Nut(t))},Iut=async(t,e,{signal:r})=>{try{await t,r.aborted||vY(e)}catch(n){r.aborted||Pwe(e,n)}},Cut=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;Iwe(o)?i.add(e):Cwe(t,o)}},kut=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Awe(t,i,{signal:s}),!t.readable)return Awe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Nut=t=>{t.writable&&t.end()},Pwe=(t,e)=>{Iwe(e)?vY(t):Cwe(t,e)},Iwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",vY=t=>{(t.readable||t.writable)&&t.destroy()},Cwe=(t,e)=>{t.destroyed||(t.once("error",Dut),t.destroy(e))},Dut=()=>{},UD=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Rwe=2,xwe=1;import{finished as kwe}from"stream/promises";var k_=(t,e)=>{t.pipe(e),Mut(t,e),$ut(t,e)},Mut=async(t,e)=>{if(!(Bo(t)||Bo(e))){try{await kwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}EY(e)}},EY=t=>{t.writable&&t.end()},$ut=async(t,e)=>{if(!(Bo(t)||Bo(e))){try{await kwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}bY(t)}},bY=t=>{t.readable&&t.destroy()};var Nwe=(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})=>Ds.has(c)))Lut(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ds.has(c)))Fut({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]:Sp(s);k_(o,i)}},Lut=(t,e,r,n)=>{r==="output"?k_(t.stdio[n],e):k_(e,t.stdio[n]);let i=Uut[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Uut=["stdin","stdout","stderr"],Fut=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;zut(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},zut=(t,{signal:e})=>{Bo(t)&&mp(t,jut,e)},jut=2;import{addAbortListener as Vut}from"events";var vp=[];vp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&vp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&vp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FD=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",wY=Symbol.for("signal-exit emitter"),TY=globalThis,qut=Object.defineProperty.bind(Object),AY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(TY[wY])return TY[wY];qut(TY,wY,{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}},zD=class{},But=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),RY=class extends zD{onExit(){return()=>{}}load(){}unload(){}},xY=class extends zD{#e=OY.platform==="win32"?"SIGINT":"SIGHUP";#r=new AY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of vp)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(!FD(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 vp)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,vp.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 FD(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"&&FD(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)}},OY=globalThis.process,{onExit:Dwe,load:Eir,unload:bir}=But(FD(OY)?new xY(OY):new RY);var Mwe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Dwe(()=>{t.kill()});Vut(n,()=>{i()})};var Lwe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=QN(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=Gut(r,n,i),{sourceStream:d,sourceError:f}=Wut(t,u),{options:p,fileDescriptors:h}=qa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},Gut=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Hut(t,e,...r),a=aD(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Hut=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($we,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||_K(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]=jN(r,...n);return{destination:e($we)(i,s,o),pipeOptions:o}}if(qa.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}`)},$we=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Wut=(t,e)=>{try{return{sourceStream:A_(t,e)}}catch(r){return{sourceError:r}}};var Fwe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Kut({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw PY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Kut=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return bY(t),n;if(e!==void 0)return EY(r),e},PY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>P_({error:t,command:Uwe,escapedCommand:Uwe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Uwe="source.pipe(destination)";var zwe=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 Yut}from"stream/promises";var jwe=(t,e,r)=>{let n=jD.has(e)?Qut(t,e):Zut(t,e);return mp(t,Xut,r.signal),mp(e,elt,r.signal),Jut(e),n},Zut=(t,e)=>{let r=Sp([t]);return k_(r,e),jD.set(e,r),r},Qut=(t,e)=>{let r=jD.get(e);return r.add(t),r},Jut=async t=>{try{await Yut(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jD.delete(t)},jD=new WeakMap,Xut=2,elt=1;import{aborted as tlt}from"util";var qwe=(t,e)=>t===void 0?[]:[rlt(t,e)],rlt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await tlt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw PY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var qD=(t,...e)=>{if(yr(e[0]))return qD.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Lwe(t,...e),i=nlt({...n,destination:r});return i.pipe=qD.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},nlt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=ilt(t,i);Fwe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=jwe(e,s,d);return await Promise.race([zwe(l),...qwe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},ilt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as dlt}from"timers/promises";import{on as slt}from"events";import{getDefaultHighWaterMark as olt}from"stream";var BD=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return alt(e,o),Vwe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},alt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},IY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;clt(e,o,t);let a=t.readableObjectMode&&!s;return Vwe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},clt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Vwe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=slt(t,"data",{signal:e.signal,highWaterMark:Bwe,highWatermark:Bwe});return ult({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},CY=olt(!0),Bwe=CY,ult=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=llt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*yp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*CT(a)}},llt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[ND(t,r,!e),kD(t,i,!n,{})].filter(Boolean);var Gwe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=flt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([plt(t),d]);return}let f=cY(c,r),p=IY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([hlt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},flt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!$D({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=IY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await rwe(a,t,r,s)},plt=async t=>{await dlt(),t.readableFlowing===null&&t.resume()},hlt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await wD(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await TD(r,{maxBuffer:s})):await O_(r,{maxBuffer:s})}catch(a){return Hwe(rbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},kY=async t=>{try{return await t}catch(e){return Hwe(e)}},Hwe=({bufferedData:t})=>ySe(t)?new Uint8Array(t):t;import{finished as mlt}from"stream/promises";var MT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=glt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],mlt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Slt(a,e,r,n)}finally{o.abort()}},glt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&_lt(t,r,n),n},_lt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{ylt(e,r),n.call(t,...i)}},ylt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Slt=(t,e,r,n)=>{if(!vlt(t,e,r,n))throw t},vlt=(t,e,r,n=!0)=>r.propagating?Wwe(t)||VD(t):(r.propagating=!0,NY(r,e)===n?Wwe(t):VD(t)),NY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VD=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Wwe=t=>t?.code==="EPIPE";var Kwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>DY({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),DY=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=MT(t,e,u);if(NY(u,e)){await l;return}let[d]=await Promise.all([Gwe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var Ywe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Sp([t,e].filter(Boolean)):void 0,Zwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>DY({...Elt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:blt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Elt=({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}},blt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as wlt}from"events";var Qwe=t=>v_(t,"ipc"),Jwe=(t,e)=>{let r=ZN(t);za({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Xwe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Qwe(s),a=ru(e,"ipc"),c=ru(r,"ipc");for await(let u of _Y({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(nbe(t,i,c),i.push(u)),o&&Jwe(u,s);return i},eTe=async(t,e)=>(await Promise.allSettled([t]),e);var tTe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let b=awe(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=Kwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),v=Zwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),T=[],I=Xwe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:T,verboseInfo:p}),P=Tlt(m,t,x),C=Alt(h,x);try{return await Promise.race([Promise.all([{},uwe(b),Promise.all(y),v,I,MEe(t,d),...P,...C]),_,Rlt(t,S),...IEe(t,s,f,S),...Qve({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...OEe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},b,Promise.all(y.map(w=>kY(w))),kY(v),eTe(I,T),Promise.allSettled(P),Promise.allSettled(C)])}},Tlt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:MT(n,i,r)),Alt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ho(s,{checkOpen:!1})&&!Bo(s)).map(({type:i,value:s,stream:o=s})=>MT(o,n,e,{isSameDirection:Ds.has(i),stopOnExit:i==="native"}))),Rlt=async(t,{signal:e})=>{let[r]=await wlt(t,"error",{signal:e});throw r};var rTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),$T=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ja();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},N_=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 xlt}from"stream";import{callbackify as Olt}from"util";import{finished as nTe}from"stream/promises";var MY=async t=>{if(t!==void 0)try{await $Y(t)}catch{}},iTe=async t=>{if(t!==void 0)try{await LY(t)}catch{}},$Y=async t=>{await nTe(t,{cleanup:!0,readable:!1,writable:!0})},LY=async t=>{await nTe(t,{cleanup:!0,readable:!0,writable:!1})},GD=async(t,e)=>{if(await t,e)throw e},HD=(t,e,r)=>{r&&!VD(r)?t.destroy(r):e&&t.destroy()};var sTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Ji.has(r),{subprocessStdout:a,waitReadableDestroy:c}=UY(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=FY(a,o),{read:f,onStdoutDataDone:p}=zY({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new xlt({read:f,destroy:Olt(qY.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return jY({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},UY=(t,e,r)=>{let n=A_(t,e),i=$T(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},FY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:CY},zY=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ja(),o=BD({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Plt(this,o,s)},onStdoutDataDone:s}},Plt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},jY=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await LY(t),await n,await MY(i),await e,r.readable&&r.push(null)}catch(s){await MY(i),oTe(r,s)}},qY=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await N_(r,e)&&(oTe(t,n),await GD(e,n))},oTe=(t,e)=>{HD(t,t.readable,e)};import{Writable as Ilt}from"stream";import{callbackify as aTe}from"util";var cTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=BY(t,r,e),o=new Ilt({...VY(n,t,i),destroy:aTe(HY.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return GY(n,o),o},BY=(t,e,r)=>{let n=aD(t,e),i=$T(r,n,"writableFinal"),s=$T(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},VY=(t,e,r)=>({write:Clt.bind(void 0,t),final:aTe(klt.bind(void 0,t,e,r))}),Clt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},klt=async(t,e,r)=>{await N_(r,e)&&(t.writable&&t.end(),await e)},GY=async(t,e,r)=>{try{await $Y(t),e.writable&&e.end()}catch(n){await iTe(r),uTe(e,n)}},HY=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await N_(r,e),await N_(n,e)&&(uTe(t,i),await GD(e,i))},uTe=(t,e)=>{HD(t,t.writable,e)};import{Duplex as Nlt}from"stream";import{callbackify as Dlt}from"util";var lTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Ji.has(r),{subprocessStdout:c,waitReadableDestroy:u}=UY(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=BY(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=FY(c,a),{read:_,onStdoutDataDone:S}=zY({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new Nlt({read:_,...VY(l,t,d),destroy:Dlt(Mlt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return jY({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:l}),GY(l,b,c),b},Mlt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([qY({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),HY({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var WY=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Ji.has(e),o=A_(t,r),a=BD({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return $lt(a,o,t)},$lt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var dTe=(t,{encoding:e})=>{let r=rTe();t.readable=sTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=cTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=lTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=WY.bind(void 0,t,e),t[Symbol.asyncIterator]=WY.bind(void 0,t,e,{})};var fTe=(t,e)=>{for(let[r,n]of Ult){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Llt=(async()=>{})().constructor.prototype,Ult=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Llt,t)]);var pTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=jlt(t,e,r),{subprocess:f,promise:p}=Blt({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=qD.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),fTe(f,p),qa.set(f,{options:l,fileDescriptors:d}),f},jlt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JN(t,e,r),{file:a,commandArguments:c,options:u}=yD(t,e,r),l=qlt(u),d=Twe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},qlt=({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}},Blt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=zlt(...SD(t,e,r))}catch(h){return vwe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;Flt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Nwe(c,a,u),Mwe(c,r,u);let d={},f=ja();c.kill=Yve.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Ywe(c,r),dTe(c,r),_we(c,r);let p=Vlt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},Vlt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await tTe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let S=h.map((y,v)=>iu(y,e,v)),b=iu(m,e,"all"),x=Glt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:b,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return I_(x,n,e)},Glt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?IT({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Ba,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):xD({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var WD=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Hlt(n,t[n],i)]));return{...t,...r}},Hlt=(t,e,r)=>Wlt.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,Wlt=new Set(["env",...wK]);var Fl=(t,e,r,n)=>{let i=(o,a,c)=>Fl(o,a,r,c),s=(...o)=>Klt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},Klt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,WD(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=Ylt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?dwe(a,c,u):pTe(a,c,u,i)},Ylt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=TSe(e)?ASe(e,r):[e,...r],[o,a,c]=jN(...s),u=WD(WD(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var hTe=({file:t,commandArguments:e})=>gTe(t,e),mTe=({file:t,commandArguments:e})=>({...gTe(t,e),isSync:!0}),gTe=(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]=Zlt(t);return{file:r,commandArguments:n}},Zlt=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(Qlt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Qlt=/ +/g;var _Te=(t,e,r)=>{t.sync=e(Jlt,r),t.s=t.sync},yTe=({options:t})=>STe(t),Jlt=({options:t})=>({...STe(t),isSync:!0}),STe=t=>({options:{...Xlt(t),...t}}),Xlt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},vTe={preferLocal:!0};var ETe=Fl(()=>({})),far=Fl(()=>({isSync:!0})),bTe=Fl(hTe),par=Fl(mTe),har=Fl(kEe),mar=Fl(yTe,{},vTe,_Te),{sendMessage:gar,getOneMessage:_ar,getEachMessage:yar,getCancelSignal:Sar}=ywe();var wTe=!1,TTe,edt=t=>{TTe??=t},ATe=t=>{wTe=!0,edt(t)},kn=()=>wTe,su=()=>TTe,RTe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var LT=null,xTe=t=>(LT&&LT.destroy(),LT=new Ms({totalAllowedTime:t}),LT),OTe=()=>LT;var Ms=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&kn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await IC({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{Y.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var PTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.200.2-bug.6",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@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.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var idt=rdt(import.meta.url),sdt=ou.dirname(idt),odt=ndt(import.meta.url),D_=ne("shell"),KY=new Set,ITe={preferLocal:!0},yt=(t,e,r)=>{let[n,i]=adt(e,r),s={...ITe,...i},o=ETe(t,n,s);kTe(o,s),MTe(o);let a=r?.idleTimeout;return a&&a>0&&DTe(o,a),o},CTe=(t,e)=>{let r={...ITe,...e},n=bTe(t,r);return kTe(n,r),MTe(n),e?.idleTimeout&&e.idleTimeout>0&&DTe(n,e.idleTimeout),n},adt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},kTe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ga.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ga.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Rb).pipe(Ga.stdout),t.stderr?.pipe(new Rb).pipe(Ga.stderr);return}t.stdout?.pipe(Ga.stdout),t.stderr?.pipe(Ga.stderr)},YY=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ga.kill(-t.pid,e),D_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return D_.error("Error killing process:",r),!1}},NTe=t=>YY(t,"SIGKILL"),DTe=(t,e)=>{let r=null,n=()=>{D_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),YY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(D_.log(`Force killing idle process ${t.pid}`),NTe(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)},MTe=t=>{KY.add(t);let e=OTe();if(e){let r=e.onTimesUp(()=>{D_.log(`Global timer expired, killing process ${t.pid}`),YY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(D_.log(`Force killing process ${t.pid} after timeout`),NTe(t))},5e3)});t.on("exit",()=>{KY.delete(t),r()}),t.on("error",()=>{KY.delete(t),r()})}};function Ha(t,e){if(!Ga.env.NETLIFY_LOCAL_MODE)try{let i=odt.resolve(PTe.name),s=ou.dirname(i);for(;s!==ou.dirname(s);){let o=ou.dirname(s);if(ou.basename(o)==="node_modules"){let a=ou.join(o,".bin",e);if(KD.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ga.env.NODE_PATH){let i=ou.join(Ga.env.NODE_PATH,".bin",e);if(KD.existsSync(i))return i}let r=ou.join(t,"node_modules",".bin",e);if(KD.existsSync(r))return r;let n=ou.join(sdt,"..","node_modules",".bin",e);if(KD.existsSync(n))return n}var $Te=ne("repo"),jTe="runner-diffs-",ZY=t=>`${jTe}${t}-`,qTe=async t=>{let e=ZD.tmpdir(),r;try{r=await ti.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(jTe)&&!n.startsWith(ZY(t))).map(n=>ti.rm($s.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},LTe=async t=>{let e=cdt("sha256");for await(let r of udt(t))e.update(r);return e.digest("hex")},UTe=async(t,e)=>t.size===e.size&&await LTe(t.path)===await LTe(e.path),BTe=/.. (.+)?\.log$/,ldt=[BTe],ddt=1,FTe=t=>{let e=t.split(`
387
+ if (condition) { yield value; }`)};import{Buffer as yct}from"buffer";import{StringDecoder as Sct}from"string_decoder";var ND=(t,e,r)=>{if(r)return;if(t)return{transform:vct.bind(void 0,new TextEncoder)};let n=new Sct(e);return{transform:Ect.bind(void 0,n),final:bct.bind(void 0,n)}},vct=function*(t,e){yct.isBuffer(e)?yield tu(e):typeof e=="string"?yield t.encode(e):yield e},Ect=function*(t,e){yield Fr(e)?t.write(e):e},bct=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Ybe}from"util";var dY=Ybe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),DD=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Tct}=e[r];for await(let i of n(t))yield*DD(i,e,r+1)},Zbe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wct(r,Number(e),t)},wct=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*DD(n,r,e+1)},Qbe=Ybe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Tct=function*(t){yield t};var fY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Jbe=(t,e)=>[...e.flatMap(r=>[...yp(r,t,0)]),...CT(t)],yp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Rct}=e[r];for(let i of n(t))yield*yp(i,e,r+1)},CT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Act(r,Number(e),t)},Act=function*(t,e,r){if(t!==void 0)for(let n of t())yield*yp(n,r,e+1)},Rct=function*(t){yield t};var pY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=ewe(t,o,s),u=_p(e),l=_p(r),d=u?dY.bind(void 0,DD,a):fY.bind(void 0,yp),f=u||l?dY.bind(void 0,Zbe,a):fY.bind(void 0,CT),p=u||l?Qbe.bind(void 0,a):void 0;return{stream:new xct({writableObjectMode:n,writableHighWaterMark:Xbe(n),readableObjectMode:i,readableHighWaterMark:Xbe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},MD=(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=ewe(o,r,a);t=Jbe(c,t)}return t},ewe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Hbe(n,a)},ND(r,o,n),kD(r,s,n,c),{transform:t,final:e},{transform:Wbe(i,a)},Gbe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var twe=(t,e)=>{for(let r of Oct(t))Pct(t,r,e)},Oct=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Pct=(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 ${Ul[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Ict(a,n));r.input=ET(o)},Ict=(t,e)=>{let r=MD(t,e,"utf8",!0);return Cct(r),ET(r)},Cct=t=>{let e=t.find(r=>typeof r!="string"&&!Fr(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 Mct,appendFileSync as $ct}from"fs";var $D=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&v_(r,n)&&!Ji.has(e)&&kct(n)&&(t.some(({type:i,value:s})=>i==="native"&&Nct.has(s))||t.every(({type:i})=>Ds.has(i))),kct=t=>t===1||t===2,Nct=new Set(["pipe","overlapped"]),rwe=async(t,e,r,n)=>{for await(let i of t)Dct(e)||iwe(i,r,n)},nwe=(t,e,r)=>{for(let n of t)iwe(n,e,r)},Dct=t=>t._readableState.pipes.length>0,iwe=(t,e,r)=>{let n=ZN(t);za({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var swe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>Lct({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Lct=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=obe(t,s,d),p=tu(f),{stdioItems:h,objectMode:m}=e[r],_=Uct([p],h,c,n),{serializedResult:S,finalResult:b=S}=Fct({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});zct({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?b:void 0;try{return n.error===void 0&&jct(S,h,i),x}catch(y){return n.error=y,x}},Uct=(t,e,r,n)=>{try{return MD(t,e,r,!1)}catch(i){return n.error=i,t}},Fct=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:ET(t)};let o=vSe(t,r);return n[s]?{serializedResult:o,finalResult:lY(o,!i[s],e)}:{serializedResult:o}},zct=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!$D({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=lY(t,!1,o);try{nwe(a,e,n)}catch(c){r.error??=c}},jct=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>ID.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?$ct(n,t):(r.add(s),Mct(n,t))}};var owe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,iu(e,r,"all")]:Array.isArray(e)?[iu(t,r,"all"),...e]:Fr(t)&&Fr(e)?SK([t,e]):`${t}${e}`};import{once as hY}from"events";var awe=async(t,e)=>{let[r,n]=await qct(t);return e.isForcefullyTerminated??=!1,[r,n]},qct=async t=>{let[e,r]=await Promise.allSettled([hY(t,"spawn"),hY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?cwe(t):r.value},cwe=async t=>{try{return await hY(t,"exit")}catch{return cwe(t)}},uwe=async t=>{let[e,r]=await t;if(!Bct(e,r)&&mY(e,r))throw new Vo;return[e,r]},Bct=(t,e)=>t===void 0&&e===void 0,mY=(t,e)=>t!==0||e!==null;var lwe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Vct(t,e,r),o=s?.code==="ETIMEDOUT",a=sbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Vct=(t,e,r)=>t!==void 0?t:mY(e,r)?new Vo:void 0;var dwe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Hct(t,e,r),d=Yct({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return I_(d,c,u)},Hct=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JN(t,e,r),a=Wct(r),{file:c,commandArguments:u,options:l}=yD(t,e,a);Kct(l);let d=jbe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},Wct=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Kct=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LD("ipcInput"),t&&LD("ipc: true"),r&&LD("detached: true"),n&&LD("cancelSignal")},LD=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Yct=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Zct({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=lwe(c,r),{output:h,error:m=u}=swe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((b,x)=>iu(b,r,x)),S=iu(owe(h,r),r,"all");return Jct({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},Zct=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{twe(s,r);let a=Qct(r);return Gct(...SD(t,e,a))}catch(a){return P_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Qct=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RD(e)}),Jct=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?xD({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):IT({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as Flt}from"events";import{spawn as zlt}from"child_process";import gwe from"process";import{once as gY,on as Xct}from"events";var fwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(w_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fD(t)}),eut({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),eut=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cD(e,i);let s=Ll(t,e,r),o=new AbortController;try{return await Promise.race([tut(s,n,o),rut(s,r,o),nut(s,r,o)])}catch(a){throw T_(t),a}finally{o.abort(),uD(e,i)}},tut=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await gY(t,"message",{signal:r});return n}for await(let[n]of Xct(t,"message",{signal:r}))if(e(n))return n},rut=async(t,e,{signal:r})=>{await gY(t,"disconnect",{signal:r}),Jve(e)},nut=async(t,e,{signal:r})=>{let[n]=await gY(t,"strict:error",{signal:r});throw sD(n,e)};import{once as hwe,on as iut}from"events";var mwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>_Y({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),_Y=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{w_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fD(t)}),cD(e,s);let o=Ll(t,e,r),a=new AbortController,c={};return sut(t,o,a),out({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),aut({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},sut=async(t,e,r)=>{try{await hwe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},out=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await hwe(t,"strict:error",{signal:r.signal});n.error=sD(i,e),r.abort()}catch{}},aut=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of iut(r,"message",{signal:s.signal}))pwe(o),yield c}catch{pwe(o)}finally{s.abort(),uD(e,a),n||T_(t),i&&await t}},pwe=({error:t})=>{if(t)throw t};var _we=(t,{ipc:e})=>{Object.assign(t,Swe(t,!1,e))},ywe=()=>{let t=gwe,e=!0,r=gwe.channel!==void 0;return{...Swe(t,e,r),getCancelSignal:AEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Swe=(t,e,r)=>({sendMessage:gD.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:fwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:mwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as cut}from"child_process";import{PassThrough as uut,Readable as lut,Writable as dut,Duplex as fut}from"stream";var vwe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{aY(n);let a=new cut;put(a,n),Object.assign(a,{readable:hut,writable:mut,duplex:gut});let c=P_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=_ut(c,o,i);return{subprocess:a,promise:u}},put=(t,e)=>{let r=kT(),n=kT(),i=kT(),s=Array.from({length:e.length-3},kT),o=kT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},kT=()=>{let t=new uut;return t.end(),t},hut=()=>new lut({read(){}}),mut=()=>new dut({write(){}}),gut=()=>new fut({read(){},write(){}}),_ut=async(t,e,r)=>I_(t,e,r);import{createReadStream as Ewe,createWriteStream as bwe}from"fs";import{Buffer as yut}from"buffer";import{Readable as NT,Writable as Sut,Duplex as vut}from"stream";var Twe=(t,e)=>CD(Eut,t,e,!1),DT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ul[t]}.`)},wwe={fileNumber:DT,generator:pY,asyncGenerator:pY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:vut.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Eut={input:{...wwe,fileUrl:({value:t})=>({stream:Ewe(t)}),filePath:({value:{file:t}})=>({stream:Ewe(t)}),webStream:({value:t})=>({stream:NT.fromWeb(t)}),iterable:({value:t})=>({stream:NT.from(t)}),asyncIterable:({value:t})=>({stream:NT.from(t)}),string:({value:t})=>({stream:NT.from(t)}),uint8Array:({value:t})=>({stream:NT.from(yut.from(t))})},output:{...wwe,fileUrl:({value:t})=>({stream:bwe(t)}),filePath:({value:{file:t,append:e}})=>({stream:bwe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Sut.fromWeb(t)}),iterable:DT,asyncIterable:DT,string:DT,uint8Array:DT}};import{on as but,once as Awe}from"events";import{PassThrough as wut,getDefaultHighWaterMark as Tut}from"stream";import{finished as Owe}from"stream/promises";function Sp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)SY(i);let e=t.some(({readableObjectMode:i})=>i),r=Aut(t,e),n=new yY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Aut=(t,e)=>{if(t.length===0)return Tut(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},yY=class extends wut{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(SY(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Rut(this,this.#e,this.#s);let r=Put({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(SY(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)}},Rut=async(t,e,r)=>{UD(t,Rwe);let n=new AbortController;try{await Promise.race([xut(t,n),Out(t,e,r,n)])}finally{n.abort(),UD(t,-Rwe)}},xut=async(t,{signal:e})=>{try{await Owe(t,{signal:e,cleanup:!0})}catch(r){throw Pwe(t,r),r}},Out=async(t,e,r,{signal:n})=>{for await(let[i]of but(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},SY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Put=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{UD(t,xwe);let a=new AbortController;try{await Promise.race([Iut(s,e,a),Cut({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),kut({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),UD(t,-xwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?vY(t):Nut(t))},Iut=async(t,e,{signal:r})=>{try{await t,r.aborted||vY(e)}catch(n){r.aborted||Pwe(e,n)}},Cut=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;Iwe(o)?i.add(e):Cwe(t,o)}},kut=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Awe(t,i,{signal:s}),!t.readable)return Awe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Nut=t=>{t.writable&&t.end()},Pwe=(t,e)=>{Iwe(e)?vY(t):Cwe(t,e)},Iwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",vY=t=>{(t.readable||t.writable)&&t.destroy()},Cwe=(t,e)=>{t.destroyed||(t.once("error",Dut),t.destroy(e))},Dut=()=>{},UD=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Rwe=2,xwe=1;import{finished as kwe}from"stream/promises";var k_=(t,e)=>{t.pipe(e),Mut(t,e),$ut(t,e)},Mut=async(t,e)=>{if(!(Bo(t)||Bo(e))){try{await kwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}EY(e)}},EY=t=>{t.writable&&t.end()},$ut=async(t,e)=>{if(!(Bo(t)||Bo(e))){try{await kwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}bY(t)}},bY=t=>{t.readable&&t.destroy()};var Nwe=(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})=>Ds.has(c)))Lut(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ds.has(c)))Fut({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]:Sp(s);k_(o,i)}},Lut=(t,e,r,n)=>{r==="output"?k_(t.stdio[n],e):k_(e,t.stdio[n]);let i=Uut[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Uut=["stdin","stdout","stderr"],Fut=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;zut(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},zut=(t,{signal:e})=>{Bo(t)&&mp(t,jut,e)},jut=2;import{addAbortListener as Vut}from"events";var vp=[];vp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&vp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&vp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FD=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",wY=Symbol.for("signal-exit emitter"),TY=globalThis,qut=Object.defineProperty.bind(Object),AY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(TY[wY])return TY[wY];qut(TY,wY,{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}},zD=class{},But=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),RY=class extends zD{onExit(){return()=>{}}load(){}unload(){}},xY=class extends zD{#e=OY.platform==="win32"?"SIGINT":"SIGHUP";#r=new AY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of vp)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(!FD(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 vp)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,vp.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 FD(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"&&FD(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)}},OY=globalThis.process,{onExit:Dwe,load:Eir,unload:bir}=But(FD(OY)?new xY(OY):new RY);var Mwe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Dwe(()=>{t.kill()});Vut(n,()=>{i()})};var Lwe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=QN(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=Gut(r,n,i),{sourceStream:d,sourceError:f}=Wut(t,u),{options:p,fileDescriptors:h}=qa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},Gut=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Hut(t,e,...r),a=aD(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Hut=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($we,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||_K(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]=jN(r,...n);return{destination:e($we)(i,s,o),pipeOptions:o}}if(qa.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}`)},$we=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Wut=(t,e)=>{try{return{sourceStream:A_(t,e)}}catch(r){return{sourceError:r}}};var Fwe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Kut({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw PY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Kut=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return bY(t),n;if(e!==void 0)return EY(r),e},PY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>P_({error:t,command:Uwe,escapedCommand:Uwe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Uwe="source.pipe(destination)";var zwe=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 Yut}from"stream/promises";var jwe=(t,e,r)=>{let n=jD.has(e)?Qut(t,e):Zut(t,e);return mp(t,Xut,r.signal),mp(e,elt,r.signal),Jut(e),n},Zut=(t,e)=>{let r=Sp([t]);return k_(r,e),jD.set(e,r),r},Qut=(t,e)=>{let r=jD.get(e);return r.add(t),r},Jut=async t=>{try{await Yut(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jD.delete(t)},jD=new WeakMap,Xut=2,elt=1;import{aborted as tlt}from"util";var qwe=(t,e)=>t===void 0?[]:[rlt(t,e)],rlt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await tlt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw PY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var qD=(t,...e)=>{if(yr(e[0]))return qD.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Lwe(t,...e),i=nlt({...n,destination:r});return i.pipe=qD.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},nlt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=ilt(t,i);Fwe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=jwe(e,s,d);return await Promise.race([zwe(l),...qwe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},ilt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as dlt}from"timers/promises";import{on as slt}from"events";import{getDefaultHighWaterMark as olt}from"stream";var BD=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return alt(e,o),Vwe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},alt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},IY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;clt(e,o,t);let a=t.readableObjectMode&&!s;return Vwe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},clt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Vwe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=slt(t,"data",{signal:e.signal,highWaterMark:Bwe,highWatermark:Bwe});return ult({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},CY=olt(!0),Bwe=CY,ult=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=llt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*yp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*CT(a)}},llt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[ND(t,r,!e),kD(t,i,!n,{})].filter(Boolean);var Gwe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=flt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([plt(t),d]);return}let f=cY(c,r),p=IY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([hlt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},flt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!$D({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=IY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await rwe(a,t,r,s)},plt=async t=>{await dlt(),t.readableFlowing===null&&t.resume()},hlt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await wD(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await TD(r,{maxBuffer:s})):await O_(r,{maxBuffer:s})}catch(a){return Hwe(rbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},kY=async t=>{try{return await t}catch(e){return Hwe(e)}},Hwe=({bufferedData:t})=>ySe(t)?new Uint8Array(t):t;import{finished as mlt}from"stream/promises";var MT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=glt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],mlt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Slt(a,e,r,n)}finally{o.abort()}},glt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&_lt(t,r,n),n},_lt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{ylt(e,r),n.call(t,...i)}},ylt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Slt=(t,e,r,n)=>{if(!vlt(t,e,r,n))throw t},vlt=(t,e,r,n=!0)=>r.propagating?Wwe(t)||VD(t):(r.propagating=!0,NY(r,e)===n?Wwe(t):VD(t)),NY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VD=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Wwe=t=>t?.code==="EPIPE";var Kwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>DY({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),DY=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=MT(t,e,u);if(NY(u,e)){await l;return}let[d]=await Promise.all([Gwe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var Ywe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Sp([t,e].filter(Boolean)):void 0,Zwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>DY({...Elt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:blt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Elt=({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}},blt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as wlt}from"events";var Qwe=t=>v_(t,"ipc"),Jwe=(t,e)=>{let r=ZN(t);za({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Xwe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Qwe(s),a=ru(e,"ipc"),c=ru(r,"ipc");for await(let u of _Y({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(nbe(t,i,c),i.push(u)),o&&Jwe(u,s);return i},eTe=async(t,e)=>(await Promise.allSettled([t]),e);var tTe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let b=awe(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=Kwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),v=Zwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:x}),T=[],I=Xwe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:T,verboseInfo:p}),P=Tlt(m,t,x),C=Alt(h,x);try{return await Promise.race([Promise.all([{},uwe(b),Promise.all(y),v,I,MEe(t,d),...P,...C]),_,Rlt(t,S),...IEe(t,s,f,S),...Qve({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...OEe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},b,Promise.all(y.map(w=>kY(w))),kY(v),eTe(I,T),Promise.allSettled(P),Promise.allSettled(C)])}},Tlt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:MT(n,i,r)),Alt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ho(s,{checkOpen:!1})&&!Bo(s)).map(({type:i,value:s,stream:o=s})=>MT(o,n,e,{isSameDirection:Ds.has(i),stopOnExit:i==="native"}))),Rlt=async(t,{signal:e})=>{let[r]=await wlt(t,"error",{signal:e});throw r};var rTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),$T=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ja();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},N_=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 xlt}from"stream";import{callbackify as Olt}from"util";import{finished as nTe}from"stream/promises";var MY=async t=>{if(t!==void 0)try{await $Y(t)}catch{}},iTe=async t=>{if(t!==void 0)try{await LY(t)}catch{}},$Y=async t=>{await nTe(t,{cleanup:!0,readable:!1,writable:!0})},LY=async t=>{await nTe(t,{cleanup:!0,readable:!0,writable:!1})},GD=async(t,e)=>{if(await t,e)throw e},HD=(t,e,r)=>{r&&!VD(r)?t.destroy(r):e&&t.destroy()};var sTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Ji.has(r),{subprocessStdout:a,waitReadableDestroy:c}=UY(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=FY(a,o),{read:f,onStdoutDataDone:p}=zY({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new xlt({read:f,destroy:Olt(qY.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return jY({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},UY=(t,e,r)=>{let n=A_(t,e),i=$T(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},FY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:CY},zY=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ja(),o=BD({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Plt(this,o,s)},onStdoutDataDone:s}},Plt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},jY=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await LY(t),await n,await MY(i),await e,r.readable&&r.push(null)}catch(s){await MY(i),oTe(r,s)}},qY=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await N_(r,e)&&(oTe(t,n),await GD(e,n))},oTe=(t,e)=>{HD(t,t.readable,e)};import{Writable as Ilt}from"stream";import{callbackify as aTe}from"util";var cTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=BY(t,r,e),o=new Ilt({...VY(n,t,i),destroy:aTe(HY.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return GY(n,o),o},BY=(t,e,r)=>{let n=aD(t,e),i=$T(r,n,"writableFinal"),s=$T(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},VY=(t,e,r)=>({write:Clt.bind(void 0,t),final:aTe(klt.bind(void 0,t,e,r))}),Clt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},klt=async(t,e,r)=>{await N_(r,e)&&(t.writable&&t.end(),await e)},GY=async(t,e,r)=>{try{await $Y(t),e.writable&&e.end()}catch(n){await iTe(r),uTe(e,n)}},HY=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await N_(r,e),await N_(n,e)&&(uTe(t,i),await GD(e,i))},uTe=(t,e)=>{HD(t,t.writable,e)};import{Duplex as Nlt}from"stream";import{callbackify as Dlt}from"util";var lTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Ji.has(r),{subprocessStdout:c,waitReadableDestroy:u}=UY(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=BY(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=FY(c,a),{read:_,onStdoutDataDone:S}=zY({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new Nlt({read:_,...VY(l,t,d),destroy:Dlt(Mlt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return jY({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:l}),GY(l,b,c),b},Mlt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([qY({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),HY({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var WY=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Ji.has(e),o=A_(t,r),a=BD({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return $lt(a,o,t)},$lt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var dTe=(t,{encoding:e})=>{let r=rTe();t.readable=sTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=cTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=lTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=WY.bind(void 0,t,e),t[Symbol.asyncIterator]=WY.bind(void 0,t,e,{})};var fTe=(t,e)=>{for(let[r,n]of Ult){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Llt=(async()=>{})().constructor.prototype,Ult=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Llt,t)]);var pTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=jlt(t,e,r),{subprocess:f,promise:p}=Blt({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=qD.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),fTe(f,p),qa.set(f,{options:l,fileDescriptors:d}),f},jlt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JN(t,e,r),{file:a,commandArguments:c,options:u}=yD(t,e,r),l=qlt(u),d=Twe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},qlt=({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}},Blt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=zlt(...SD(t,e,r))}catch(h){return vwe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;Flt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Nwe(c,a,u),Mwe(c,r,u);let d={},f=ja();c.kill=Yve.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Ywe(c,r),dTe(c,r),_we(c,r);let p=Vlt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},Vlt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await tTe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let S=h.map((y,v)=>iu(y,e,v)),b=iu(m,e,"all"),x=Glt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:b,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return I_(x,n,e)},Glt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?IT({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof Ba,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):xD({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var WD=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Hlt(n,t[n],i)]));return{...t,...r}},Hlt=(t,e,r)=>Wlt.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,Wlt=new Set(["env",...wK]);var Fl=(t,e,r,n)=>{let i=(o,a,c)=>Fl(o,a,r,c),s=(...o)=>Klt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},Klt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,WD(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=Ylt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?dwe(a,c,u):pTe(a,c,u,i)},Ylt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=TSe(e)?ASe(e,r):[e,...r],[o,a,c]=jN(...s),u=WD(WD(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var hTe=({file:t,commandArguments:e})=>gTe(t,e),mTe=({file:t,commandArguments:e})=>({...gTe(t,e),isSync:!0}),gTe=(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]=Zlt(t);return{file:r,commandArguments:n}},Zlt=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(Qlt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Qlt=/ +/g;var _Te=(t,e,r)=>{t.sync=e(Jlt,r),t.s=t.sync},yTe=({options:t})=>STe(t),Jlt=({options:t})=>({...STe(t),isSync:!0}),STe=t=>({options:{...Xlt(t),...t}}),Xlt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},vTe={preferLocal:!0};var ETe=Fl(()=>({})),far=Fl(()=>({isSync:!0})),bTe=Fl(hTe),par=Fl(mTe),har=Fl(kEe),mar=Fl(yTe,{},vTe,_Te),{sendMessage:gar,getOneMessage:_ar,getEachMessage:yar,getCancelSignal:Sar}=ywe();var wTe=!1,TTe,edt=t=>{TTe??=t},ATe=t=>{wTe=!0,edt(t)},kn=()=>wTe,su=()=>TTe,RTe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var LT=null,xTe=t=>(LT&&LT.destroy(),LT=new Ms({totalAllowedTime:t}),LT),OTe=()=>LT;var Ms=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&kn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await IC({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{Y.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var PTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.200.2-bug.7",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.21.0","@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.295","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var idt=rdt(import.meta.url),sdt=ou.dirname(idt),odt=ndt(import.meta.url),D_=ne("shell"),KY=new Set,ITe={preferLocal:!0},yt=(t,e,r)=>{let[n,i]=adt(e,r),s={...ITe,...i},o=ETe(t,n,s);kTe(o,s),MTe(o);let a=r?.idleTimeout;return a&&a>0&&DTe(o,a),o},CTe=(t,e)=>{let r={...ITe,...e},n=bTe(t,r);return kTe(n,r),MTe(n),e?.idleTimeout&&e.idleTimeout>0&&DTe(n,e.idleTimeout),n},adt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},kTe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ga.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ga.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Rb).pipe(Ga.stdout),t.stderr?.pipe(new Rb).pipe(Ga.stderr);return}t.stdout?.pipe(Ga.stdout),t.stderr?.pipe(Ga.stderr)},YY=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ga.kill(-t.pid,e),D_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return D_.error("Error killing process:",r),!1}},NTe=t=>YY(t,"SIGKILL"),DTe=(t,e)=>{let r=null,n=()=>{D_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),YY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(D_.log(`Force killing idle process ${t.pid}`),NTe(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)},MTe=t=>{KY.add(t);let e=OTe();if(e){let r=e.onTimesUp(()=>{D_.log(`Global timer expired, killing process ${t.pid}`),YY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(D_.log(`Force killing process ${t.pid} after timeout`),NTe(t))},5e3)});t.on("exit",()=>{KY.delete(t),r()}),t.on("error",()=>{KY.delete(t),r()})}};function Ha(t,e){if(!Ga.env.NETLIFY_LOCAL_MODE)try{let i=odt.resolve(PTe.name),s=ou.dirname(i);for(;s!==ou.dirname(s);){let o=ou.dirname(s);if(ou.basename(o)==="node_modules"){let a=ou.join(o,".bin",e);if(KD.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ga.env.NODE_PATH){let i=ou.join(Ga.env.NODE_PATH,".bin",e);if(KD.existsSync(i))return i}let r=ou.join(t,"node_modules",".bin",e);if(KD.existsSync(r))return r;let n=ou.join(sdt,"..","node_modules",".bin",e);if(KD.existsSync(n))return n}var $Te=ne("repo"),jTe="runner-diffs-",ZY=t=>`${jTe}${t}-`,qTe=async t=>{let e=ZD.tmpdir(),r;try{r=await ti.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(jTe)&&!n.startsWith(ZY(t))).map(n=>ti.rm($s.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},LTe=async t=>{let e=cdt("sha256");for await(let r of udt(t))e.update(r);return e.digest("hex")},UTe=async(t,e)=>t.size===e.size&&await LTe(t.path)===await LTe(e.path),BTe=/.. (.+)?\.log$/,ldt=[BTe],ddt=1,FTe=t=>{let e=t.split(`
388
388
  `).reduce((r,n)=>{if(!n)return r;let[i,s,,...o]=n,a=o.join(""),c=i.trim(),u=s.trim();return r[a]?r[a].change=u:r[a]={filePath:a,stage:c,change:u},r},{});return Object.values(e)},fdt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),pdt=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return yi(r?`${e}: ${r}`:e)},zTe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},YD=500,UT=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},Oi=class{constructor(e=process.cwd()){this.cwd=e}getRoot(){return this.root??=this.run(["rev-parse","--show-toplevel"],{stdout:"pipe"}).then(({stdout:e})=>String(e).trim()),this.root}async restorePausedWork(e){let r="restore";try{let n=await this.restorePausedFiles(e);r="stage",await this.stageBuildSetup();let i=await this.getRoot(),s=new Set(n.changedFiles),o=(await this.listIndexEntries(n.deletedFiles,{cwd:i})).filter(({filePath:a})=>!s.has(a));return await this.unstageFiles(n.changedFiles,{cwd:i}),o.length>0&&await ti.writeFile(await this.getSetupMetadataPath(),JSON.stringify(o)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new UT(r,n)}}run(e,r={}){return yt("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){$Te.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!r){let u=FTe(s);await this.discardSetupOnlyChanges(u)}$Te.info("Changes after processing"),await this.getStatus();let o=await this.getIgnoredPathspecs(s);if(await this.stageFiles(o),await this.excludeUnchangedSetupDescendants(),i=await this.hasStagedChanges(),!i)return{hasChanges:!1,ignored:o};await this.run(["commit","-m","Agent runner [skip ci]"]);let a=await ti.mkdtemp($s.join(ZD.tmpdir(),ZY(e.sessionId))),c=await this.writeDiffFiles({config:e,diffDir:a,target:{commit:"HEAD"},ignored:o});return await this.rollbackIfLocal(),c.hasChanges&&Y.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c}async getStatus(){let e=await this.run(["-c","status.relativePaths=true","status","-s"]);return String(e.stdout??"")}async hasAgentChanges(){let e=await this.getStatus();return{hasChanges:(e.trim().length===0?[]:e.split(`
389
389
  `).filter(i=>ldt.some(o=>o instanceof RegExp?o.test(i):i===o)?!1:i[1]?.trim()!=="")).length!==0,status:e}}async getCurrentCommitSha(){let{stdout:e}=await this.run(["rev-parse","HEAD"]);return String(e??"").trim()}async reset(){await this.run(["reset","--hard","HEAD"]),await ti.rm(await this.getSetupMetadataPath(),{force:!0})}async discardSetupOnlyChanges(e){let r=e.filter(n=>n.stage&&!n.change).map(n=>n.filePath);r.length!==0&&await this.run(["restore","--staged","--worktree","--pathspec-from-file=-"],{input:r.join(`
390
390
  `)})}async stageBuildSetup(){await ti.rm(await this.getSetupMetadataPath(),{force:!0});let e=await this.getIgnoredPathspecs();await this.stageFiles(e)}getSetupMetadataPath(){return this.setupMetadataPath??=this.getRoot().then(async e=>{let{stdout:r}=await this.run(["rev-parse","--git-path","netlify-agent-runner-setup.json"],{cwd:e,stdout:"pipe"});return $s.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=YD){let s=e.slice(i,i+YD).map(a=>`:(literal)${a}`),{stdout:o}=await this.run(["ls-files","--stage","-z","--",...s],{...zTe,...r});for(let a of String(o??"").split("\0").filter(Boolean))n.push({filePath:a.slice(a.indexOf(" ")+1),entry:a})}return n}async excludeUnchangedSetupDescendants(e){let r;try{r=JSON.parse(await ti.readFile(await this.getSetupMetadataPath(),"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}let i={cwd:await this.getRoot(),env:e},s=new Map((await this.listIndexEntries(r.map(({filePath:a})=>a),i)).map(({filePath:a,entry:c})=>[a,c])),o=r.filter(({filePath:a,entry:c})=>s.get(a)===c);o.length!==0&&await this.run(["update-index","--force-remove","-z","--stdin"],{...i,input:o.map(({filePath:a})=>a).join("\0")})}async getIgnoredPathspecs(e){e||=await this.getStatus();let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return e.split(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/agent-runner-cli",
3
3
  "type": "module",
4
- "version": "1.200.2-bug.6",
4
+ "version": "1.200.2-bug.7",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",