@netlify/agent-runner-cli 1.182.0 → 1.183.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin-local.js CHANGED
@@ -141,7 +141,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
141
141
  `,LF:`
142
142
  `,concatBytes:BU},rVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},nVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:rVe};import{Buffer as iVe}from"buffer";var Fae=(t,e)=>t?void 0:oVe.bind(void 0,e),oVe=function*(t,e){if(typeof e!="string"&&!pr(e)&&!iVe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},zae=(t,e)=>t?sVe.bind(void 0,e):aVe.bind(void 0,e),sVe=function*(t,e){jae(t,e),yield e},aVe=function*(t,e){if(jae(t,e),typeof e!="string"&&!pr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},jae=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
143
143
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
144
- if (condition) { yield value; }`)};import{Buffer as cVe}from"buffer";import{StringDecoder as lVe}from"string_decoder";var LR=(t,e,r)=>{if(r)return;if(t)return{transform:uVe.bind(void 0,new TextEncoder)};let n=new lVe(e);return{transform:dVe.bind(void 0,n),final:fVe.bind(void 0,n)}},uVe=function*(t,e){cVe.isBuffer(e)?yield ya(e):typeof e=="string"?yield t.encode(e):yield e},dVe=function*(t,e){yield pr(e)?t.write(e):e},fVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Bae}from"util";var GU=Bae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),UR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=hVe}=e[r];for await(let i of n(t))yield*UR(i,e,r+1)},qae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*pVe(r,Number(e),t)},pVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*UR(n,r,e+1)},Gae=Bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),hVe=function*(t){yield t};var VU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Vae=(t,e)=>[...e.flatMap(r=>[...Bu(r,t,0)]),...eS(t)],Bu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=gVe}=e[r];for(let i of n(t))yield*Bu(i,e,r+1)},eS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*mVe(r,Number(e),t)},mVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Bu(n,r,e+1)},gVe=function*(t){yield t};var HU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Wae(t,s,o),l=ju(e),u=ju(r),d=l?GU.bind(void 0,UR,a):VU.bind(void 0,Bu),f=l||u?GU.bind(void 0,qae,a):VU.bind(void 0,eS),p=l||u?Gae.bind(void 0,a):void 0;return{stream:new _Ve({writableObjectMode:n,writableHighWaterMark:Hae(n),readableObjectMode:i,readableHighWaterMark:Hae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},FR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Wae(s,r,a);t=Vae(c,t)}return t},Wae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Fae(n,a)},LR(r,s,n),$R(r,o,n,c),{transform:t,final:e},{transform:zae(i,a)},Uae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Yae=(t,e)=>{for(let r of yVe(t))SVe(t,r,e)},yVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),SVe=(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 ${Lc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>EVe(a,n));r.input=Gy(s)},EVe=(t,e)=>{let r=FR(t,e,"utf8",!0);return vVe(r),Gy(r)},vVe=t=>{let e=t.find(r=>typeof r!="string"&&!pr(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 AVe,appendFileSync as xVe}from"fs";var zR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Mp(r,n)&&!ui.has(e)&&TVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&bVe.has(o))||t.every(({type:i})=>$i.has(i))),TVe=t=>t===1||t===2,bVe=new Set(["pipe","overlapped"]),Kae=async(t,e,r,n)=>{for await(let i of t)wVe(e)||Jae(i,r,n)},Zae=(t,e,r)=>{for(let n of t)Jae(n,e,r)},wVe=t=>t._readableState.pipes.length>0,Jae=(t,e,r)=>{let n=eR(t);fs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Xae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>RVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},RVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Qse(t,o,d),p=ya(f),{stdioItems:h,objectMode:m}=e[r],g=CVe([p],h,c,n),{serializedResult:_,finalResult:T=_}=IVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});PVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?T:void 0;try{return n.error===void 0&&OVe(_,h,i),w}catch(b){return n.error=b,w}},CVe=(t,e,r,n)=>{try{return FR(t,e,r,!1)}catch(i){return n.error=i,t}},IVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Gy(t)};let s=pie(t,r);return n[o]?{serializedResult:s,finalResult:qU(s,!i[o],e)}:{serializedResult:s}},PVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!zR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=qU(t,!1,s);try{Zae(a,e,n)}catch(c){r.error??=c}},OVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>MR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?xVe(n,t):(r.add(o),AVe(n,t))}};var Qae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,va(e,r,"all")]:Array.isArray(e)?[va(t,r,"all"),...e]:pr(t)&&pr(e)?X1([t,e]):`${t}${e}`};import{once as WU}from"events";var ece=async(t,e)=>{let[r,n]=await NVe(t);return e.isForcefullyTerminated??=!1,[r,n]},NVe=async t=>{let[e,r]=await Promise.allSettled([WU(t,"spawn"),WU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?tce(t):r.value},tce=async t=>{try{return await WU(t,"exit")}catch{return tce(t)}},rce=async t=>{let[e,r]=await t;if(!kVe(e,r)&&YU(e,r))throw new yo;return[e,r]},kVe=(t,e)=>t===void 0&&e===void 0,YU=(t,e)=>t!==0||e!==null;var nce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=MVe(t,e,r),s=o?.code==="ETIMEDOUT",a=Xse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},MVe=(t,e,r)=>t!==void 0?t:YU(e,r)?new yo:void 0;var ice=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=$Ve(t,e,r),d=FVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Gp(d,c,l)},$Ve=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=rR(t,e,r),a=LVe(r),{file:c,commandArguments:l,options:u}=TR(t,e,a);UVe(u);let d=Mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},LVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,UVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&jR("ipcInput"),t&&jR("ipc: true"),r&&jR("detached: true"),n&&jR("cancelSignal")},jR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},FVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=zVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=nce(c,r),{output:h,error:m=l}=Xae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((T,w)=>va(T,r,w)),_=va(Qae(h,r),r,"all");return BVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},zVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Yae(o,r);let a=jVe(r);return DVe(...bR(t,e,a))}catch(a){return qp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},jVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:PR(e)}),BVe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?OR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Qy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as IHe}from"events";import{spawn as PHe}from"child_process";import lce from"process";import{once as KU,on as qVe}from"events";var oce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Lp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:gR(t)}),GVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),GVe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{fR(e,i);let o=$c(t,e,r),s=new AbortController;try{return await Promise.race([VVe(o,n,s),HVe(o,r,s),WVe(o,r,s)])}catch(a){throw Up(t),a}finally{s.abort(),pR(e,i)}},VVe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await KU(t,"message",{signal:r});return n}for await(let[n]of qVe(t,"message",{signal:r}))if(e(n))return n},HVe=async(t,e,{signal:r})=>{await KU(t,"disconnect",{signal:r}),Voe(e)},WVe=async(t,e,{signal:r})=>{let[n]=await KU(t,"strict:error",{signal:r});throw lR(n,e)};import{once as ace,on as YVe}from"events";var cce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>ZU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),ZU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Lp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:gR(t)}),fR(e,o);let s=$c(t,e,r),a=new AbortController,c={};return KVe(t,s,a),ZVe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),JVe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},KVe=async(t,e,r)=>{try{await ace(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ZVe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ace(t,"strict:error",{signal:r.signal});n.error=lR(i,e),r.abort()}catch{}},JVe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of YVe(r,"message",{signal:o.signal}))sce(s),yield c}catch{sce(s)}finally{o.abort(),pR(e,a),n||Up(t),i&&await t}},sce=({error:t})=>{if(t)throw t};var uce=(t,{ipc:e})=>{Object.assign(t,fce(t,!1,e))},dce=()=>{let t=lce,e=!0,r=lce.channel!==void 0;return{...fce(t,e,r),getCancelSignal:yse.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},fce=(t,e,r)=>({sendMessage:ER.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:oce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:cce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as XVe}from"child_process";import{PassThrough as QVe,Readable as e4e,Writable as t4e,Duplex as r4e}from"stream";var pce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{zU(n);let a=new XVe;n4e(a,n),Object.assign(a,{readable:i4e,writable:o4e,duplex:s4e});let c=qp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=a4e(c,s,i);return{subprocess:a,promise:l}},n4e=(t,e)=>{let r=tS(),n=tS(),i=tS(),o=Array.from({length:e.length-3},tS),s=tS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},tS=()=>{let t=new QVe;return t.end(),t},i4e=()=>new e4e({read(){}}),o4e=()=>new t4e({write(){}}),s4e=()=>new r4e({read(){},write(){}}),a4e=async(t,e,r)=>Gp(t,e,r);import{createReadStream as hce,createWriteStream as mce}from"fs";import{Buffer as c4e}from"buffer";import{Readable as rS,Writable as l4e,Duplex as u4e}from"stream";var _ce=(t,e)=>DR(d4e,t,e,!1),nS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Lc[t]}.`)},gce={fileNumber:nS,generator:HU,asyncGenerator:HU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:u4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},d4e={input:{...gce,fileUrl:({value:t})=>({stream:hce(t)}),filePath:({value:{file:t}})=>({stream:hce(t)}),webStream:({value:t})=>({stream:rS.fromWeb(t)}),iterable:({value:t})=>({stream:rS.from(t)}),asyncIterable:({value:t})=>({stream:rS.from(t)}),string:({value:t})=>({stream:rS.from(t)}),uint8Array:({value:t})=>({stream:rS.from(c4e.from(t))})},output:{...gce,fileUrl:({value:t})=>({stream:mce(t)}),filePath:({value:{file:t,append:e}})=>({stream:mce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:l4e.fromWeb(t)}),iterable:nS,asyncIterable:nS,string:nS,uint8Array:nS}};import{on as f4e,once as yce}from"events";import{PassThrough as p4e,getDefaultHighWaterMark as h4e}from"stream";import{finished as vce}from"stream/promises";function qu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)XU(i);let e=t.some(({readableObjectMode:i})=>i),r=m4e(t,e),n=new JU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var m4e=(t,e)=>{if(t.length===0)return h4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},JU=class extends p4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(XU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=g4e(this,this.#e,this.#o);let r=S4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(XU(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)}},g4e=async(t,e,r)=>{BR(t,Sce);let n=new AbortController;try{await Promise.race([_4e(t,n),y4e(t,e,r,n)])}finally{n.abort(),BR(t,-Sce)}},_4e=async(t,{signal:e})=>{try{await vce(t,{signal:e,cleanup:!0})}catch(r){throw Tce(t,r),r}},y4e=async(t,e,r,{signal:n})=>{for await(let[i]of f4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},XU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},S4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{BR(t,Ece);let a=new AbortController;try{await Promise.race([E4e(o,e,a),v4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),T4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),BR(t,-Ece)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?QU(t):b4e(t))},E4e=async(t,e,{signal:r})=>{try{await t,r.aborted||QU(e)}catch(n){r.aborted||Tce(e,n)}},v4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await vce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;bce(s)?i.add(e):wce(t,s)}},T4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await yce(t,i,{signal:o}),!t.readable)return yce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},b4e=t=>{t.writable&&t.end()},Tce=(t,e)=>{bce(e)?QU(t):wce(t,e)},bce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",QU=t=>{(t.readable||t.writable)&&t.destroy()},wce=(t,e)=>{t.destroyed||(t.once("error",w4e),t.destroy(e))},w4e=()=>{},BR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Sce=2,Ece=1;import{finished as Ace}from"stream/promises";var Hp=(t,e)=>{t.pipe(e),A4e(t,e),x4e(t,e)},A4e=async(t,e)=>{if(!(_o(t)||_o(e))){try{await Ace(t,{cleanup:!0,readable:!0,writable:!1})}catch{}eF(e)}},eF=t=>{t.writable&&t.end()},x4e=async(t,e)=>{if(!(_o(t)||_o(e))){try{await Ace(e,{cleanup:!0,readable:!1,writable:!0})}catch{}tF(t)}},tF=t=>{t.readable&&t.destroy()};var xce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>$i.has(c)))R4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!$i.has(c)))I4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:qu(o);Hp(s,i)}},R4e=(t,e,r,n)=>{r==="output"?Hp(t.stdio[n],e):Hp(e,t.stdio[n]);let i=C4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},C4e=["stdin","stdout","stderr"],I4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;P4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},P4e=(t,{signal:e})=>{_o(t)&&Fu(t,O4e,e)},O4e=2;import{addAbortListener as M4e}from"events";var Gu=[];Gu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Gu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Gu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var qR=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",rF=Symbol.for("signal-exit emitter"),nF=globalThis,N4e=Object.defineProperty.bind(Object),iF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(nF[rF])return nF[rF];N4e(nF,rF,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},GR=class{},k4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),oF=class extends GR{onExit(){return()=>{}}load(){}unload(){}},sF=class extends GR{#e=aF.platform==="win32"?"SIGINT":"SIGHUP";#r=new iF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Gu)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!qR(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of Gu)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Gu.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return qR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&qR(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)}},aF=globalThis.process,{onExit:Rce,load:i1t,unload:o1t}=k4e(qR(aF)?new sF(aF):new oF);var Cce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Rce(()=>{t.kill()});M4e(n,()=>{i()})};var Pce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=tR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=D4e(r,n,i),{sourceStream:d,sourceError:f}=L4e(t,l),{options:p,fileDescriptors:h}=hs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},D4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=$4e(t,e,...r),a=dR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},$4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Ice,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||Z1(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=Vx(r,...n);return{destination:e(Ice)(i,o,s),pipeOptions:s}}if(hs.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}`)},Ice=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),L4e=(t,e)=>{try{return{sourceStream:Fp(t,e)}}catch(r){return{sourceError:r}}};var Nce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=U4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw cF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},U4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return tF(t),n;if(e!==void 0)return eF(r),e},cF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>qp({error:t,command:Oce,escapedCommand:Oce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Oce="source.pipe(destination)";var kce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as F4e}from"stream/promises";var Mce=(t,e,r)=>{let n=VR.has(e)?j4e(t,e):z4e(t,e);return Fu(t,q4e,r.signal),Fu(e,G4e,r.signal),B4e(e),n},z4e=(t,e)=>{let r=qu([t]);return Hp(r,e),VR.set(e,r),r},j4e=(t,e)=>{let r=VR.get(e);return r.add(t),r},B4e=async t=>{try{await F4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}VR.delete(t)},VR=new WeakMap,q4e=2,G4e=1;import{aborted as V4e}from"util";var Dce=(t,e)=>t===void 0?[]:[H4e(t,e)],H4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await V4e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw cF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var HR=(t,...e)=>{if(er(e[0]))return HR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Pce(t,...e),i=W4e({...n,destination:r});return i.pipe=HR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},W4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=Y4e(t,i);Nce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Mce(e,o,d);return await Promise.race([kce(u),...Dce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},Y4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as tHe}from"timers/promises";import{on as K4e}from"events";import{getDefaultHighWaterMark as Z4e}from"stream";var WR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return J4e(e,s),Lce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},J4e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},lF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;X4e(e,s,t);let a=t.readableObjectMode&&!o;return Lce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},X4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Lce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=K4e(t,"data",{signal:e.signal,highWaterMark:$ce,highWatermark:$ce});return Q4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},uF=Z4e(!0),$ce=uF,Q4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=eHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Bu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*eS(a)}},eHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[LR(t,r,!e),$R(t,i,!n,{})].filter(Boolean);var Uce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=rHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([nHe(t),d]);return}let f=jU(c,r),p=lF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([iHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},rHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!zR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=lF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Kae(a,t,r,o)},nHe=async t=>{await tHe(),t.readableFlowing===null&&t.resume()},iHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await RR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await CR(r,{maxBuffer:o})):await Bp(r,{maxBuffer:o})}catch(a){return Fce(Kse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},dF=async t=>{try{return await t}catch(e){return Fce(e)}},Fce=({bufferedData:t})=>die(t)?new Uint8Array(t):t;import{finished as oHe}from"stream/promises";var iS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=sHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],oHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||lHe(a,e,r,n)}finally{s.abort()}},sHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&aHe(t,r,n),n},aHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{cHe(e,r),n.call(t,...i)}},cHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},lHe=(t,e,r,n)=>{if(!uHe(t,e,r,n))throw t},uHe=(t,e,r,n=!0)=>r.propagating?zce(t)||YR(t):(r.propagating=!0,fF(r,e)===n?zce(t):YR(t)),fF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",YR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",zce=t=>t?.code==="EPIPE";var jce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>pF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),pF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=iS(t,e,l);if(fF(l,e)){await u;return}let[d]=await Promise.all([Uce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?qu([t,e].filter(Boolean)):void 0,qce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>pF({...dHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:fHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),dHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},fHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as pHe}from"events";var Gce=t=>Mp(t,"ipc"),Vce=(t,e)=>{let r=eR(t);fs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Hce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Gce(o),a=Sa(e,"ipc"),c=Sa(r,"ipc");for await(let l of ZU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Zse(t,i,c),i.push(l)),s&&Vce(l,o);return i},Wce=async(t,e)=>(await Promise.allSettled([t]),e);var Yce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let T=ece(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},b=jce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),v=qce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),A=[],C=Hce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),P=hHe(m,t,w),N=mHe(h,w);try{return await Promise.race([Promise.all([{},rce(T),Promise.all(b),v,C,Cse(t,d),...P,...N]),g,gHe(t,_),...bse(t,o,f,_),...Goe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...vse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},T,Promise.all(b.map(y=>dF(y))),dF(v),Wce(C,A),Promise.allSettled(P),Promise.allSettled(N)])}},hHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:iS(n,i,r)),mHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Eo(o,{checkOpen:!1})&&!_o(o)).map(({type:i,value:o,stream:s=o})=>iS(s,n,e,{isSameDirection:$i.has(i),stopOnExit:i==="native"}))),gHe=async(t,{signal:e})=>{let[r]=await pHe(t,"error",{signal:e});throw r};var Kce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),oS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ps();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Wp=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 _He}from"stream";import{callbackify as yHe}from"util";import{finished as Zce}from"stream/promises";var hF=async t=>{if(t!==void 0)try{await mF(t)}catch{}},Jce=async t=>{if(t!==void 0)try{await gF(t)}catch{}},mF=async t=>{await Zce(t,{cleanup:!0,readable:!1,writable:!0})},gF=async t=>{await Zce(t,{cleanup:!0,readable:!0,writable:!1})},KR=async(t,e)=>{if(await t,e)throw e},ZR=(t,e,r)=>{r&&!YR(r)?t.destroy(r):e&&t.destroy()};var Xce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ui.has(r),{subprocessStdout:a,waitReadableDestroy:c}=_F(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=yF(a,s),{read:f,onStdoutDataDone:p}=SF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new _He({read:f,destroy:yHe(vF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return EF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},_F=(t,e,r)=>{let n=Fp(t,e),i=oS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},yF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:uF},SF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ps(),s=WR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){SHe(this,s,o)},onStdoutDataDone:o}},SHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},EF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await gF(t),await n,await hF(i),await e,r.readable&&r.push(null)}catch(o){await hF(i),Qce(r,o)}},vF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Wp(r,e)&&(Qce(t,n),await KR(e,n))},Qce=(t,e)=>{ZR(t,t.readable,e)};import{Writable as EHe}from"stream";import{callbackify as ele}from"util";var tle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=TF(t,r,e),s=new EHe({...bF(n,t,i),destroy:ele(AF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return wF(n,s),s},TF=(t,e,r)=>{let n=dR(t,e),i=oS(r,n,"writableFinal"),o=oS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},bF=(t,e,r)=>({write:vHe.bind(void 0,t),final:ele(THe.bind(void 0,t,e,r))}),vHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},THe=async(t,e,r)=>{await Wp(r,e)&&(t.writable&&t.end(),await e)},wF=async(t,e,r)=>{try{await mF(t),e.writable&&e.end()}catch(n){await Jce(r),rle(e,n)}},AF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Wp(r,e),await Wp(n,e)&&(rle(t,i),await KR(e,i))},rle=(t,e)=>{ZR(t,t.writable,e)};import{Duplex as bHe}from"stream";import{callbackify as wHe}from"util";var nle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ui.has(r),{subprocessStdout:c,waitReadableDestroy:l}=_F(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=TF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=yF(c,a),{read:g,onStdoutDataDone:_}=SF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new bHe({read:g,...bF(u,t,d),destroy:wHe(AHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return EF({subprocessStdout:c,onStdoutDataDone:_,readable:T,subprocess:t,subprocessStdin:u}),wF(u,T,c),T},AHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([vF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),AF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var xF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ui.has(e),s=Fp(t,r),a=WR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return xHe(a,s,t)},xHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var ile=(t,{encoding:e})=>{let r=Kce();t.readable=Xce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=tle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=nle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=xF.bind(void 0,t,e),t[Symbol.asyncIterator]=xF.bind(void 0,t,e,{})};var ole=(t,e)=>{for(let[r,n]of CHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},RHe=(async()=>{})().constructor.prototype,CHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(RHe,t)]);var sle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=OHe(t,e,r),{subprocess:f,promise:p}=kHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=HR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ole(f,p),hs.set(f,{options:u,fileDescriptors:d}),f},OHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=rR(t,e,r),{file:a,commandArguments:c,options:l}=TR(t,e,r),u=NHe(l),d=_ce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},NHe=({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}},kHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=PHe(...bR(t,e,r))}catch(h){return pce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;IHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];xce(c,a,l),Cce(c,r,l);let d={},f=ps();c.kill=Boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Bce(c,r),ile(c,r),uce(c,r);let p=MHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},MHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Yce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((b,v)=>va(b,e,v)),T=va(m,e,"all"),w=DHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:T,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Gp(w,n,e)},DHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Qy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ms,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):OR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var JR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,$He(n,t[n],i)]));return{...t,...r}},$He=(t,e,r)=>LHe.has(t)&&er(e)&&er(r)?{...e,...r}:r,LHe=new Set(["env",...rU]);var Uc=(t,e,r,n)=>{let i=(s,a,c)=>Uc(s,a,r,c),o=(...s)=>UHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},UHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(er(o))return i(t,JR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=FHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?ice(a,c,l):sle(a,c,l,i)},FHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=_ie(e)?yie(e,r):[e,...r],[s,a,c]=Vx(...o),l=JR(JR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var ale=({file:t,commandArguments:e})=>lle(t,e),cle=({file:t,commandArguments:e})=>({...lle(t,e),isSync:!0}),lle=(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]=zHe(t);return{file:r,commandArguments:n}},zHe=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(jHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},jHe=/ +/g;var ule=(t,e,r)=>{t.sync=e(BHe,r),t.s=t.sync},dle=({options:t})=>fle(t),BHe=({options:t})=>({...fle(t),isSync:!0}),fle=t=>({options:{...qHe(t),...t}}),qHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},ple={preferLocal:!0};var hle=Uc(()=>({})),YFt=Uc(()=>({isSync:!0})),mle=Uc(ale),KFt=Uc(cle),ZFt=Uc(Ase),JFt=Uc(dle,{},ple,ule),{sendMessage:XFt,getOneMessage:QFt,getEachMessage:ezt,getCancelSignal:tzt}=dce();var gle=!1,_le,yle=t=>{gle=!0,_le??=t},Ta=()=>gle,Sle=()=>_le;var sS=null,Ele=t=>(sS&&sS.destroy(),sS=new vo({totalAllowedTime:t}),sS),vle=()=>sS;var vo=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&&Ta())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await kx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{H.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Tle={name:"@netlify/agent-runner-cli",type:"module",version:"1.182.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@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.280","@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.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@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:"6.34.0",zod:"^4.4.3"}};var WHe=VHe(import.meta.url),YHe=ba.dirname(WHe),KHe=HHe(import.meta.url),Yp=re("shell"),RF=new Set,ble={preferLocal:!0},Nt=(t,e,r)=>{let[n,i]=ZHe(e,r),o={...ble,...i},s=hle(t,n,o);Ale(s,o),Cle(s);let a=r?.idleTimeout;return a&&a>0&&Rle(s,a),s},wle=(t,e)=>{let r={...ble,...e},n=mle(t,r);return Ale(n,r),Cle(n),e?.idleTimeout&&e.idleTimeout>0&&Rle(n,e.idleTimeout),n},ZHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ale=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||_s.env.NETLIFY_LOCAL_QUIET==="true")return;if(_s.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Dy).pipe(_s.stdout),t.stderr?.pipe(new Dy).pipe(_s.stderr);return}t.stdout?.pipe(_s.stdout),t.stderr?.pipe(_s.stderr)},CF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_s.kill(-t.pid,e),Yp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Yp.error("Error killing process:",r),!1}},xle=t=>CF(t,"SIGKILL"),Rle=(t,e)=>{let r=null,n=()=>{Yp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),CF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yp.log(`Force killing idle process ${t.pid}`),xle(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Cle=t=>{RF.add(t);let e=vle();if(e){let r=e.onTimesUp(()=>{Yp.log(`Global timer expired, killing process ${t.pid}`),CF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yp.log(`Force killing process ${t.pid} after timeout`),xle(t))},5e3)});t.on("exit",()=>{RF.delete(t),r()}),t.on("error",()=>{RF.delete(t),r()})}};function QR(t,e){return!!To(t,e)}function To(t,e){if(!_s.env.NETLIFY_LOCAL_MODE)try{let i=KHe.resolve(Tle.name),o=ba.dirname(i);for(;o!==ba.dirname(o);){let s=ba.dirname(o);if(ba.basename(s)==="node_modules"){let a=ba.join(s,".bin",e);if(XR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(_s.env.NODE_PATH){let i=ba.join(_s.env.NODE_PATH,".bin",e);if(XR.existsSync(i))return i}let r=ba.join(t,"node_modules",".bin",e);if(XR.existsSync(r))return r;let n=ba.join(YHe,"..","node_modules",".bin",e);if(XR.existsSync(n))return n}var Ile=re("repo"),kle="runner-diffs-",rC=t=>`${kle}${t}-`,Mle=async t=>{let e=Nle.tmpdir(),r;try{r=await eC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(kle)&&!n.startsWith(rC(t))).map(n=>eC.rm(tC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},tr=(t,e={})=>Nt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),nC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Ile.info("Getting runner diffs");let n=await NF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=kF(o);await i6e(l,r)}Ile.info("Changes after processing"),await OF(r);let s=await cS(o,r);if(await PF(s,r),i=await t6e(r),!i)return{hasChanges:!1,ignored:s};await tr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await eC.mkdtemp(tC.join(Nle.tmpdir(),rC(t.sessionId))),c=await IF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await QHe(r),c.hasChanges&&H.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},IF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=tC.join(e,h);await tr([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:T}=await eC.stat(g);return{path:g,size:T}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Ole(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Ole(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Ple=async t=>{let e=JHe("sha256");for await(let r of XHe(t))e.update(r);return e.digest("hex")},Ole=async(t,e)=>t.size===e.size&&await Ple(t.path)===await Ple(e.path),QHe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await tr(["reset","--soft","HEAD~1"],{cwd:t})},PF=async(t=[],e=process.cwd())=>{await tr(["add",".",...t],{cwd:e})},OF=async(t=process.cwd())=>{let e=await tr(["status","-s"],{cwd:t});return String(e.stdout??"")},Dle=/.. (.+)?\.log$/,e6e=[Dle],NF=async(t=process.cwd())=>{let e=await OF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
144
+ if (condition) { yield value; }`)};import{Buffer as cVe}from"buffer";import{StringDecoder as lVe}from"string_decoder";var LR=(t,e,r)=>{if(r)return;if(t)return{transform:uVe.bind(void 0,new TextEncoder)};let n=new lVe(e);return{transform:dVe.bind(void 0,n),final:fVe.bind(void 0,n)}},uVe=function*(t,e){cVe.isBuffer(e)?yield ya(e):typeof e=="string"?yield t.encode(e):yield e},dVe=function*(t,e){yield pr(e)?t.write(e):e},fVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Bae}from"util";var GU=Bae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),UR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=hVe}=e[r];for await(let i of n(t))yield*UR(i,e,r+1)},qae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*pVe(r,Number(e),t)},pVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*UR(n,r,e+1)},Gae=Bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),hVe=function*(t){yield t};var VU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Vae=(t,e)=>[...e.flatMap(r=>[...Bu(r,t,0)]),...eS(t)],Bu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=gVe}=e[r];for(let i of n(t))yield*Bu(i,e,r+1)},eS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*mVe(r,Number(e),t)},mVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Bu(n,r,e+1)},gVe=function*(t){yield t};var HU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Wae(t,s,o),l=ju(e),u=ju(r),d=l?GU.bind(void 0,UR,a):VU.bind(void 0,Bu),f=l||u?GU.bind(void 0,qae,a):VU.bind(void 0,eS),p=l||u?Gae.bind(void 0,a):void 0;return{stream:new _Ve({writableObjectMode:n,writableHighWaterMark:Hae(n),readableObjectMode:i,readableHighWaterMark:Hae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},FR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Wae(s,r,a);t=Vae(c,t)}return t},Wae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Fae(n,a)},LR(r,s,n),$R(r,o,n,c),{transform:t,final:e},{transform:zae(i,a)},Uae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Yae=(t,e)=>{for(let r of yVe(t))SVe(t,r,e)},yVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),SVe=(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 ${Lc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>EVe(a,n));r.input=Gy(s)},EVe=(t,e)=>{let r=FR(t,e,"utf8",!0);return vVe(r),Gy(r)},vVe=t=>{let e=t.find(r=>typeof r!="string"&&!pr(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 AVe,appendFileSync as xVe}from"fs";var zR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Mp(r,n)&&!ui.has(e)&&TVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&bVe.has(o))||t.every(({type:i})=>$i.has(i))),TVe=t=>t===1||t===2,bVe=new Set(["pipe","overlapped"]),Kae=async(t,e,r,n)=>{for await(let i of t)wVe(e)||Jae(i,r,n)},Zae=(t,e,r)=>{for(let n of t)Jae(n,e,r)},wVe=t=>t._readableState.pipes.length>0,Jae=(t,e,r)=>{let n=eR(t);fs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Xae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>RVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},RVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Qse(t,o,d),p=ya(f),{stdioItems:h,objectMode:m}=e[r],g=CVe([p],h,c,n),{serializedResult:_,finalResult:T=_}=IVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});PVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?T:void 0;try{return n.error===void 0&&OVe(_,h,i),w}catch(b){return n.error=b,w}},CVe=(t,e,r,n)=>{try{return FR(t,e,r,!1)}catch(i){return n.error=i,t}},IVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Gy(t)};let s=pie(t,r);return n[o]?{serializedResult:s,finalResult:qU(s,!i[o],e)}:{serializedResult:s}},PVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!zR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=qU(t,!1,s);try{Zae(a,e,n)}catch(c){r.error??=c}},OVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>MR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?xVe(n,t):(r.add(o),AVe(n,t))}};var Qae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,va(e,r,"all")]:Array.isArray(e)?[va(t,r,"all"),...e]:pr(t)&&pr(e)?X1([t,e]):`${t}${e}`};import{once as WU}from"events";var ece=async(t,e)=>{let[r,n]=await NVe(t);return e.isForcefullyTerminated??=!1,[r,n]},NVe=async t=>{let[e,r]=await Promise.allSettled([WU(t,"spawn"),WU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?tce(t):r.value},tce=async t=>{try{return await WU(t,"exit")}catch{return tce(t)}},rce=async t=>{let[e,r]=await t;if(!kVe(e,r)&&YU(e,r))throw new yo;return[e,r]},kVe=(t,e)=>t===void 0&&e===void 0,YU=(t,e)=>t!==0||e!==null;var nce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=MVe(t,e,r),s=o?.code==="ETIMEDOUT",a=Xse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},MVe=(t,e,r)=>t!==void 0?t:YU(e,r)?new yo:void 0;var ice=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=$Ve(t,e,r),d=FVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Gp(d,c,l)},$Ve=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=rR(t,e,r),a=LVe(r),{file:c,commandArguments:l,options:u}=TR(t,e,a);UVe(u);let d=Mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},LVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,UVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&jR("ipcInput"),t&&jR("ipc: true"),r&&jR("detached: true"),n&&jR("cancelSignal")},jR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},FVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=zVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=nce(c,r),{output:h,error:m=l}=Xae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((T,w)=>va(T,r,w)),_=va(Qae(h,r),r,"all");return BVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},zVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Yae(o,r);let a=jVe(r);return DVe(...bR(t,e,a))}catch(a){return qp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},jVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:PR(e)}),BVe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?OR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Qy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as IHe}from"events";import{spawn as PHe}from"child_process";import lce from"process";import{once as KU,on as qVe}from"events";var oce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Lp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:gR(t)}),GVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),GVe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{fR(e,i);let o=$c(t,e,r),s=new AbortController;try{return await Promise.race([VVe(o,n,s),HVe(o,r,s),WVe(o,r,s)])}catch(a){throw Up(t),a}finally{s.abort(),pR(e,i)}},VVe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await KU(t,"message",{signal:r});return n}for await(let[n]of qVe(t,"message",{signal:r}))if(e(n))return n},HVe=async(t,e,{signal:r})=>{await KU(t,"disconnect",{signal:r}),Voe(e)},WVe=async(t,e,{signal:r})=>{let[n]=await KU(t,"strict:error",{signal:r});throw lR(n,e)};import{once as ace,on as YVe}from"events";var cce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>ZU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),ZU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Lp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:gR(t)}),fR(e,o);let s=$c(t,e,r),a=new AbortController,c={};return KVe(t,s,a),ZVe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),JVe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},KVe=async(t,e,r)=>{try{await ace(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ZVe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ace(t,"strict:error",{signal:r.signal});n.error=lR(i,e),r.abort()}catch{}},JVe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of YVe(r,"message",{signal:o.signal}))sce(s),yield c}catch{sce(s)}finally{o.abort(),pR(e,a),n||Up(t),i&&await t}},sce=({error:t})=>{if(t)throw t};var uce=(t,{ipc:e})=>{Object.assign(t,fce(t,!1,e))},dce=()=>{let t=lce,e=!0,r=lce.channel!==void 0;return{...fce(t,e,r),getCancelSignal:yse.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},fce=(t,e,r)=>({sendMessage:ER.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:oce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:cce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as XVe}from"child_process";import{PassThrough as QVe,Readable as e4e,Writable as t4e,Duplex as r4e}from"stream";var pce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{zU(n);let a=new XVe;n4e(a,n),Object.assign(a,{readable:i4e,writable:o4e,duplex:s4e});let c=qp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=a4e(c,s,i);return{subprocess:a,promise:l}},n4e=(t,e)=>{let r=tS(),n=tS(),i=tS(),o=Array.from({length:e.length-3},tS),s=tS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},tS=()=>{let t=new QVe;return t.end(),t},i4e=()=>new e4e({read(){}}),o4e=()=>new t4e({write(){}}),s4e=()=>new r4e({read(){},write(){}}),a4e=async(t,e,r)=>Gp(t,e,r);import{createReadStream as hce,createWriteStream as mce}from"fs";import{Buffer as c4e}from"buffer";import{Readable as rS,Writable as l4e,Duplex as u4e}from"stream";var _ce=(t,e)=>DR(d4e,t,e,!1),nS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Lc[t]}.`)},gce={fileNumber:nS,generator:HU,asyncGenerator:HU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:u4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},d4e={input:{...gce,fileUrl:({value:t})=>({stream:hce(t)}),filePath:({value:{file:t}})=>({stream:hce(t)}),webStream:({value:t})=>({stream:rS.fromWeb(t)}),iterable:({value:t})=>({stream:rS.from(t)}),asyncIterable:({value:t})=>({stream:rS.from(t)}),string:({value:t})=>({stream:rS.from(t)}),uint8Array:({value:t})=>({stream:rS.from(c4e.from(t))})},output:{...gce,fileUrl:({value:t})=>({stream:mce(t)}),filePath:({value:{file:t,append:e}})=>({stream:mce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:l4e.fromWeb(t)}),iterable:nS,asyncIterable:nS,string:nS,uint8Array:nS}};import{on as f4e,once as yce}from"events";import{PassThrough as p4e,getDefaultHighWaterMark as h4e}from"stream";import{finished as vce}from"stream/promises";function qu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)XU(i);let e=t.some(({readableObjectMode:i})=>i),r=m4e(t,e),n=new JU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var m4e=(t,e)=>{if(t.length===0)return h4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},JU=class extends p4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(XU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=g4e(this,this.#e,this.#o);let r=S4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(XU(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)}},g4e=async(t,e,r)=>{BR(t,Sce);let n=new AbortController;try{await Promise.race([_4e(t,n),y4e(t,e,r,n)])}finally{n.abort(),BR(t,-Sce)}},_4e=async(t,{signal:e})=>{try{await vce(t,{signal:e,cleanup:!0})}catch(r){throw Tce(t,r),r}},y4e=async(t,e,r,{signal:n})=>{for await(let[i]of f4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},XU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},S4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{BR(t,Ece);let a=new AbortController;try{await Promise.race([E4e(o,e,a),v4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),T4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),BR(t,-Ece)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?QU(t):b4e(t))},E4e=async(t,e,{signal:r})=>{try{await t,r.aborted||QU(e)}catch(n){r.aborted||Tce(e,n)}},v4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await vce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;bce(s)?i.add(e):wce(t,s)}},T4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await yce(t,i,{signal:o}),!t.readable)return yce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},b4e=t=>{t.writable&&t.end()},Tce=(t,e)=>{bce(e)?QU(t):wce(t,e)},bce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",QU=t=>{(t.readable||t.writable)&&t.destroy()},wce=(t,e)=>{t.destroyed||(t.once("error",w4e),t.destroy(e))},w4e=()=>{},BR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Sce=2,Ece=1;import{finished as Ace}from"stream/promises";var Hp=(t,e)=>{t.pipe(e),A4e(t,e),x4e(t,e)},A4e=async(t,e)=>{if(!(_o(t)||_o(e))){try{await Ace(t,{cleanup:!0,readable:!0,writable:!1})}catch{}eF(e)}},eF=t=>{t.writable&&t.end()},x4e=async(t,e)=>{if(!(_o(t)||_o(e))){try{await Ace(e,{cleanup:!0,readable:!1,writable:!0})}catch{}tF(t)}},tF=t=>{t.readable&&t.destroy()};var xce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>$i.has(c)))R4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!$i.has(c)))I4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:qu(o);Hp(s,i)}},R4e=(t,e,r,n)=>{r==="output"?Hp(t.stdio[n],e):Hp(e,t.stdio[n]);let i=C4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},C4e=["stdin","stdout","stderr"],I4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;P4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},P4e=(t,{signal:e})=>{_o(t)&&Fu(t,O4e,e)},O4e=2;import{addAbortListener as M4e}from"events";var Gu=[];Gu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Gu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Gu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var qR=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",rF=Symbol.for("signal-exit emitter"),nF=globalThis,N4e=Object.defineProperty.bind(Object),iF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(nF[rF])return nF[rF];N4e(nF,rF,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},GR=class{},k4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),oF=class extends GR{onExit(){return()=>{}}load(){}unload(){}},sF=class extends GR{#e=aF.platform==="win32"?"SIGINT":"SIGHUP";#r=new iF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Gu)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!qR(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of Gu)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Gu.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return qR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&qR(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)}},aF=globalThis.process,{onExit:Rce,load:i1t,unload:o1t}=k4e(qR(aF)?new sF(aF):new oF);var Cce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Rce(()=>{t.kill()});M4e(n,()=>{i()})};var Pce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=tR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=D4e(r,n,i),{sourceStream:d,sourceError:f}=L4e(t,l),{options:p,fileDescriptors:h}=hs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},D4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=$4e(t,e,...r),a=dR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},$4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Ice,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||Z1(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=Vx(r,...n);return{destination:e(Ice)(i,o,s),pipeOptions:s}}if(hs.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}`)},Ice=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),L4e=(t,e)=>{try{return{sourceStream:Fp(t,e)}}catch(r){return{sourceError:r}}};var Nce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=U4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw cF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},U4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return tF(t),n;if(e!==void 0)return eF(r),e},cF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>qp({error:t,command:Oce,escapedCommand:Oce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Oce="source.pipe(destination)";var kce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as F4e}from"stream/promises";var Mce=(t,e,r)=>{let n=VR.has(e)?j4e(t,e):z4e(t,e);return Fu(t,q4e,r.signal),Fu(e,G4e,r.signal),B4e(e),n},z4e=(t,e)=>{let r=qu([t]);return Hp(r,e),VR.set(e,r),r},j4e=(t,e)=>{let r=VR.get(e);return r.add(t),r},B4e=async t=>{try{await F4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}VR.delete(t)},VR=new WeakMap,q4e=2,G4e=1;import{aborted as V4e}from"util";var Dce=(t,e)=>t===void 0?[]:[H4e(t,e)],H4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await V4e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw cF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var HR=(t,...e)=>{if(er(e[0]))return HR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Pce(t,...e),i=W4e({...n,destination:r});return i.pipe=HR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},W4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=Y4e(t,i);Nce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Mce(e,o,d);return await Promise.race([kce(u),...Dce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},Y4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as tHe}from"timers/promises";import{on as K4e}from"events";import{getDefaultHighWaterMark as Z4e}from"stream";var WR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return J4e(e,s),Lce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},J4e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},lF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;X4e(e,s,t);let a=t.readableObjectMode&&!o;return Lce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},X4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Lce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=K4e(t,"data",{signal:e.signal,highWaterMark:$ce,highWatermark:$ce});return Q4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},uF=Z4e(!0),$ce=uF,Q4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=eHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Bu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*eS(a)}},eHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[LR(t,r,!e),$R(t,i,!n,{})].filter(Boolean);var Uce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=rHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([nHe(t),d]);return}let f=jU(c,r),p=lF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([iHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},rHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!zR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=lF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Kae(a,t,r,o)},nHe=async t=>{await tHe(),t.readableFlowing===null&&t.resume()},iHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await RR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await CR(r,{maxBuffer:o})):await Bp(r,{maxBuffer:o})}catch(a){return Fce(Kse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},dF=async t=>{try{return await t}catch(e){return Fce(e)}},Fce=({bufferedData:t})=>die(t)?new Uint8Array(t):t;import{finished as oHe}from"stream/promises";var iS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=sHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],oHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||lHe(a,e,r,n)}finally{s.abort()}},sHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&aHe(t,r,n),n},aHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{cHe(e,r),n.call(t,...i)}},cHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},lHe=(t,e,r,n)=>{if(!uHe(t,e,r,n))throw t},uHe=(t,e,r,n=!0)=>r.propagating?zce(t)||YR(t):(r.propagating=!0,fF(r,e)===n?zce(t):YR(t)),fF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",YR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",zce=t=>t?.code==="EPIPE";var jce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>pF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),pF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=iS(t,e,l);if(fF(l,e)){await u;return}let[d]=await Promise.all([Uce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?qu([t,e].filter(Boolean)):void 0,qce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>pF({...dHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:fHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),dHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},fHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as pHe}from"events";var Gce=t=>Mp(t,"ipc"),Vce=(t,e)=>{let r=eR(t);fs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Hce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Gce(o),a=Sa(e,"ipc"),c=Sa(r,"ipc");for await(let l of ZU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Zse(t,i,c),i.push(l)),s&&Vce(l,o);return i},Wce=async(t,e)=>(await Promise.allSettled([t]),e);var Yce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let T=ece(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},b=jce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),v=qce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),A=[],C=Hce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),P=hHe(m,t,w),N=mHe(h,w);try{return await Promise.race([Promise.all([{},rce(T),Promise.all(b),v,C,Cse(t,d),...P,...N]),g,gHe(t,_),...bse(t,o,f,_),...Goe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...vse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},T,Promise.all(b.map(y=>dF(y))),dF(v),Wce(C,A),Promise.allSettled(P),Promise.allSettled(N)])}},hHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:iS(n,i,r)),mHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Eo(o,{checkOpen:!1})&&!_o(o)).map(({type:i,value:o,stream:s=o})=>iS(s,n,e,{isSameDirection:$i.has(i),stopOnExit:i==="native"}))),gHe=async(t,{signal:e})=>{let[r]=await pHe(t,"error",{signal:e});throw r};var Kce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),oS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ps();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Wp=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 _He}from"stream";import{callbackify as yHe}from"util";import{finished as Zce}from"stream/promises";var hF=async t=>{if(t!==void 0)try{await mF(t)}catch{}},Jce=async t=>{if(t!==void 0)try{await gF(t)}catch{}},mF=async t=>{await Zce(t,{cleanup:!0,readable:!1,writable:!0})},gF=async t=>{await Zce(t,{cleanup:!0,readable:!0,writable:!1})},KR=async(t,e)=>{if(await t,e)throw e},ZR=(t,e,r)=>{r&&!YR(r)?t.destroy(r):e&&t.destroy()};var Xce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ui.has(r),{subprocessStdout:a,waitReadableDestroy:c}=_F(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=yF(a,s),{read:f,onStdoutDataDone:p}=SF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new _He({read:f,destroy:yHe(vF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return EF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},_F=(t,e,r)=>{let n=Fp(t,e),i=oS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},yF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:uF},SF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ps(),s=WR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){SHe(this,s,o)},onStdoutDataDone:o}},SHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},EF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await gF(t),await n,await hF(i),await e,r.readable&&r.push(null)}catch(o){await hF(i),Qce(r,o)}},vF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Wp(r,e)&&(Qce(t,n),await KR(e,n))},Qce=(t,e)=>{ZR(t,t.readable,e)};import{Writable as EHe}from"stream";import{callbackify as ele}from"util";var tle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=TF(t,r,e),s=new EHe({...bF(n,t,i),destroy:ele(AF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return wF(n,s),s},TF=(t,e,r)=>{let n=dR(t,e),i=oS(r,n,"writableFinal"),o=oS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},bF=(t,e,r)=>({write:vHe.bind(void 0,t),final:ele(THe.bind(void 0,t,e,r))}),vHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},THe=async(t,e,r)=>{await Wp(r,e)&&(t.writable&&t.end(),await e)},wF=async(t,e,r)=>{try{await mF(t),e.writable&&e.end()}catch(n){await Jce(r),rle(e,n)}},AF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Wp(r,e),await Wp(n,e)&&(rle(t,i),await KR(e,i))},rle=(t,e)=>{ZR(t,t.writable,e)};import{Duplex as bHe}from"stream";import{callbackify as wHe}from"util";var nle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ui.has(r),{subprocessStdout:c,waitReadableDestroy:l}=_F(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=TF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=yF(c,a),{read:g,onStdoutDataDone:_}=SF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new bHe({read:g,...bF(u,t,d),destroy:wHe(AHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return EF({subprocessStdout:c,onStdoutDataDone:_,readable:T,subprocess:t,subprocessStdin:u}),wF(u,T,c),T},AHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([vF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),AF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var xF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ui.has(e),s=Fp(t,r),a=WR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return xHe(a,s,t)},xHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var ile=(t,{encoding:e})=>{let r=Kce();t.readable=Xce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=tle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=nle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=xF.bind(void 0,t,e),t[Symbol.asyncIterator]=xF.bind(void 0,t,e,{})};var ole=(t,e)=>{for(let[r,n]of CHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},RHe=(async()=>{})().constructor.prototype,CHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(RHe,t)]);var sle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=OHe(t,e,r),{subprocess:f,promise:p}=kHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=HR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ole(f,p),hs.set(f,{options:u,fileDescriptors:d}),f},OHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=rR(t,e,r),{file:a,commandArguments:c,options:l}=TR(t,e,r),u=NHe(l),d=_ce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},NHe=({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}},kHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=PHe(...bR(t,e,r))}catch(h){return pce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;IHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];xce(c,a,l),Cce(c,r,l);let d={},f=ps();c.kill=Boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Bce(c,r),ile(c,r),uce(c,r);let p=MHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},MHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Yce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((b,v)=>va(b,e,v)),T=va(m,e,"all"),w=DHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:T,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Gp(w,n,e)},DHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Qy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ms,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):OR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var JR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,$He(n,t[n],i)]));return{...t,...r}},$He=(t,e,r)=>LHe.has(t)&&er(e)&&er(r)?{...e,...r}:r,LHe=new Set(["env",...rU]);var Uc=(t,e,r,n)=>{let i=(s,a,c)=>Uc(s,a,r,c),o=(...s)=>UHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},UHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(er(o))return i(t,JR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=FHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?ice(a,c,l):sle(a,c,l,i)},FHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=_ie(e)?yie(e,r):[e,...r],[s,a,c]=Vx(...o),l=JR(JR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var ale=({file:t,commandArguments:e})=>lle(t,e),cle=({file:t,commandArguments:e})=>({...lle(t,e),isSync:!0}),lle=(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]=zHe(t);return{file:r,commandArguments:n}},zHe=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(jHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},jHe=/ +/g;var ule=(t,e,r)=>{t.sync=e(BHe,r),t.s=t.sync},dle=({options:t})=>fle(t),BHe=({options:t})=>({...fle(t),isSync:!0}),fle=t=>({options:{...qHe(t),...t}}),qHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},ple={preferLocal:!0};var hle=Uc(()=>({})),YFt=Uc(()=>({isSync:!0})),mle=Uc(ale),KFt=Uc(cle),ZFt=Uc(Ase),JFt=Uc(dle,{},ple,ule),{sendMessage:XFt,getOneMessage:QFt,getEachMessage:ezt,getCancelSignal:tzt}=dce();var gle=!1,_le,yle=t=>{gle=!0,_le??=t},Ta=()=>gle,Sle=()=>_le;var sS=null,Ele=t=>(sS&&sS.destroy(),sS=new vo({totalAllowedTime:t}),sS),vle=()=>sS;var vo=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&&Ta())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await kx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{H.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Tle={name:"@netlify/agent-runner-cli",type:"module",version:"1.183.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@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.280","@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.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@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:"6.34.0",zod:"^4.4.3"}};var WHe=VHe(import.meta.url),YHe=ba.dirname(WHe),KHe=HHe(import.meta.url),Yp=re("shell"),RF=new Set,ble={preferLocal:!0},Nt=(t,e,r)=>{let[n,i]=ZHe(e,r),o={...ble,...i},s=hle(t,n,o);Ale(s,o),Cle(s);let a=r?.idleTimeout;return a&&a>0&&Rle(s,a),s},wle=(t,e)=>{let r={...ble,...e},n=mle(t,r);return Ale(n,r),Cle(n),e?.idleTimeout&&e.idleTimeout>0&&Rle(n,e.idleTimeout),n},ZHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ale=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||_s.env.NETLIFY_LOCAL_QUIET==="true")return;if(_s.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Dy).pipe(_s.stdout),t.stderr?.pipe(new Dy).pipe(_s.stderr);return}t.stdout?.pipe(_s.stdout),t.stderr?.pipe(_s.stderr)},CF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_s.kill(-t.pid,e),Yp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Yp.error("Error killing process:",r),!1}},xle=t=>CF(t,"SIGKILL"),Rle=(t,e)=>{let r=null,n=()=>{Yp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),CF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yp.log(`Force killing idle process ${t.pid}`),xle(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Cle=t=>{RF.add(t);let e=vle();if(e){let r=e.onTimesUp(()=>{Yp.log(`Global timer expired, killing process ${t.pid}`),CF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Yp.log(`Force killing process ${t.pid} after timeout`),xle(t))},5e3)});t.on("exit",()=>{RF.delete(t),r()}),t.on("error",()=>{RF.delete(t),r()})}};function QR(t,e){return!!To(t,e)}function To(t,e){if(!_s.env.NETLIFY_LOCAL_MODE)try{let i=KHe.resolve(Tle.name),o=ba.dirname(i);for(;o!==ba.dirname(o);){let s=ba.dirname(o);if(ba.basename(s)==="node_modules"){let a=ba.join(s,".bin",e);if(XR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(_s.env.NODE_PATH){let i=ba.join(_s.env.NODE_PATH,".bin",e);if(XR.existsSync(i))return i}let r=ba.join(t,"node_modules",".bin",e);if(XR.existsSync(r))return r;let n=ba.join(YHe,"..","node_modules",".bin",e);if(XR.existsSync(n))return n}var Ile=re("repo"),kle="runner-diffs-",rC=t=>`${kle}${t}-`,Mle=async t=>{let e=Nle.tmpdir(),r;try{r=await eC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(kle)&&!n.startsWith(rC(t))).map(n=>eC.rm(tC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},tr=(t,e={})=>Nt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),nC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Ile.info("Getting runner diffs");let n=await NF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=kF(o);await i6e(l,r)}Ile.info("Changes after processing"),await OF(r);let s=await cS(o,r);if(await PF(s,r),i=await t6e(r),!i)return{hasChanges:!1,ignored:s};await tr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await eC.mkdtemp(tC.join(Nle.tmpdir(),rC(t.sessionId))),c=await IF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await QHe(r),c.hasChanges&&H.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},IF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=tC.join(e,h);await tr([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:T}=await eC.stat(g);return{path:g,size:T}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Ole(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Ole(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Ple=async t=>{let e=JHe("sha256");for await(let r of XHe(t))e.update(r);return e.digest("hex")},Ole=async(t,e)=>t.size===e.size&&await Ple(t.path)===await Ple(e.path),QHe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await tr(["reset","--soft","HEAD~1"],{cwd:t})},PF=async(t=[],e=process.cwd())=>{await tr(["add",".",...t],{cwd:e})},OF=async(t=process.cwd())=>{let e=await tr(["status","-s"],{cwd:t});return String(e.stdout??"")},Dle=/.. (.+)?\.log$/,e6e=[Dle],NF=async(t=process.cwd())=>{let e=await OF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
145
145
  `).filter(i=>e6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},t6e=async(t=process.cwd())=>{try{return await tr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},aS=async(t=process.cwd())=>{let{stdout:e}=await tr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},r6e=1,n6e=async t=>{try{return await tr(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===r6e)return!1;throw e}},$le=async(t=process.cwd())=>{if(!await n6e(t))return!0;let{stdout:e}=await tr(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},Lle=async(t=process.cwd())=>{let{stdout:e}=await tr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},cS=async(t,e=process.cwd())=>{t||=await OF(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
146
146
  `).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${tC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Dle)?.[1];o&&n.push(`:!${o}.log`)}),n},Ule=async(t=process.cwd())=>{await tr(["reset","--hard","HEAD"],{cwd:t})},Fle=async(t=process.cwd())=>{let e=await tr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
147
147
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},kF=t=>{let e=t.split(`
@@ -343,7 +343,7 @@ NETLIFY_BUILD_BASE="\${NETLIFY_BUILD_BASE:-${QQe}}" ${e} ${r} <template-id> [--p
343
343
  Replace \`<template-id>\` with the matching template \`id\`. Include \`--package-manager\` only if the user specified one. The templates can include relevant agent skills. The \`NETLIFY_BUILD_BASE=\u2026\` prefix lets the scaffold use a local template mirror if the platform set one \u2014 leave it as-is. Follow the instructions printed by the scaffold command.`:"",a="You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",c=[a,s,JQe];return n?c=[a,XQe,s]:i&&(c=[a,KQe,s]),c.filter(Boolean).join(`
344
344
 
345
345
  `)},n7e=t=>{try{return JSON.parse(FQe(WE.join(t,".netlify","scaffold-result.json"),"utf8"))}catch{return}},n_e=async t=>{let e=n7e(t);await Ot(at(),"create-scaffold-telemetry",r=>{r?.setAttributes({"create.template":e?.template??"none","create.packageManager":e?.packageManager??"none"})})},i_e=async({config:t,cwd:e=ZI.cwd()})=>await Ot(at(),"create-stage",async r=>{let n=performance.now();r?.setAttributes({"create.runner":t.runner,"create.id":t.id,"create.sessionId":t.sessionId}),await e_e(e,[".netlify",".git","node_modules"]),Td.info("Cleaned cwd folder");let{nodeCmd:i,tsCliPath:o}=e7e({cwd:e}),s=[];if(o){let f=[o,"--list-addons-json"];Td.log(`Running ${i} ${f.join(" ")}`);let{stdout:p}=await Nt(i,f);s=t7e(p),Td.info("Retrieved add-ons")}else Td.warn("ts-cli binary not resolved; create-mode prompt will omit template section"),H.inc("context.degraded",1,{component:"templates"});let a=b4(t),c=a==="budget_constrained",l=a==="ask_first";l&&Td.log("Low budget create run - Instructing the agent to ask for clarity if necessary",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),H.inc("create.low_budget_limit_ask",1,{ask_first:l}),c&&Td.log("Budget-constrained create run \u2014 using plan + first-milestone instructions",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),H.inc("create.budget_constrained",1,{constrained:c});let u=r7e({templates:s,nodeCmd:i,scaffoldScriptPath:jQe,budgetConstrained:c,askUserClarity:l}),d=performance.now()-n;return r?.setAttributes({"create.duration.ms":d,"create.status":"success","create.budget_constrained":c,"create.ask_user_clarity":l}),{additionalContext:u}});var La={Task:{name:"Task",category:V.Task},Agent:{name:"Task",category:V.Task},SendMessage:{name:"Message agent",category:V.Task},TaskOutput:{name:"Get task output",category:V.Task},TaskStop:{name:"Stop task",category:V.Task},TaskCreate:{name:"Update task list",category:V.Todo},TaskUpdate:{name:"Update task list",category:V.Todo},TaskList:{name:"Read task list",category:V.Todo},TaskGet:{name:"Read task list",category:V.Todo},ToolSearch:{name:"Load tools",category:V.Explore},Skill:{name:"Use skill",category:V.Skill},EnterPlanMode:{name:"Start planning",category:V.Plan},ListMcpResources:{name:"List resources",category:V.Explore},ReadMcpResource:{name:"Read resource",category:V.Explore},Bash:{name:"Run command",category:V.RunCommand},Glob:{name:"Find files",category:V.Explore},Grep:{name:"Search files",category:V.Explore},LS:{name:"List directory",category:V.Explore},ExitPlanMode:{name:"Exit planning",category:V.Plan},Read:{name:"Read file",category:V.FileRead},Edit:{name:"Edit file",category:V.FileWrite},MultiEdit:{name:"Edit multiple files",category:V.FileWrite},Write:{name:"Edit file",category:V.FileWrite},NotebookEdit:{name:"Edit notebook",category:V.Notebook},WebFetch:{name:"Fetch web",category:V.Web},TodoWrite:{name:"Update task list",category:V.Todo},WebSearch:{name:"Search web",category:V.Web},BashOutput:{name:"Get command output",category:V.RunCommand},KillBash:{name:"Stop command",category:V.RunCommand}},YE=t=>{if(La[t])return La[t].name;let e=t.match(/^mcp__(.+?)__(.+)$/);return e?`${e[2].replace(/_/g," ")} (${e[1]})`:t},R4=t=>t==="Task"||t==="Agent",o_e=t=>{let[e=""]=t.split(`
346
- `,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},s_e=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var Kr=re("runner_claude"),KE="Claude Code",c_e="claude-opus-5",C4="claude-sonnet-5",o7e={[$1]:"claude-sonnet-5"};async function s7e({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else if(r)await t.isModelAvailableForProvider("anthropic",r)||(Kr.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),H.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0);else{let i=o7e[e.accountType],o=i||c_e;!!o&&await t.isModelAvailableForProvider("anthropic",o)?(Kr.log(`Using ${i?"account override":"default"} model: ${o}`),n=o):o&&Kr.log(`Model ${o} is not available, proceeding without model specification`)}return n}function a7e({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...om.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!om.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...om.env}}async function c7e(){let t=ZE.join(om.cwd(),"AGENTS.md");try{await im.access(t)}catch{return}let e=ZE.join(om.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await im.readFile(e,"utf-8")).includes(r))return;await im.appendFile(e,`
346
+ `,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},s_e=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var Kr=re("runner_claude"),KE="Claude Code",c_e="claude-opus-5-5",C4="claude-sonnet-5",o7e={[$1]:"claude-sonnet-5"};async function s7e({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else if(r)await t.isModelAvailableForProvider("anthropic",r)||(Kr.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),H.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0);else{let i=o7e[e.accountType],o=i||c_e;!!o&&await t.isModelAvailableForProvider("anthropic",o)?(Kr.log(`Using ${i?"account override":"default"} model: ${o}`),n=o):o&&Kr.log(`Model ${o} is not available, proceeding without model specification`)}return n}function a7e({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...om.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!om.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...om.env}}async function c7e(){let t=ZE.join(om.cwd(),"AGENTS.md");try{await im.access(t)}catch{return}let e=ZE.join(om.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await im.readFile(e,"utf-8")).includes(r))return;await im.appendFile(e,`
347
347
  ${r}
348
348
  `)}catch{await im.writeFile(e,`${r}
349
349
  `)}Kr.log("Added @AGENTS.md import to CLAUDE.local.md")}async function I4({config:t,persistSteps:e,aiGateway:r,continueSession:n,priorAgentSessionId:i,cwd:o=om.cwd(),cliPath:s="netlify",abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let u=t,{prompt:d}=u,{model:f}=t,p="";await c7e();let h=a7e({aiGateway:r}),m=await s7e({config:t,aiGateway:r,model:f});l&&m?.includes("fable")&&(!r||await r.isModelAvailableForProvider("anthropic",C4))&&(Kr.log(`Credit wrap-up: downgrading model ${m} to ${C4}`),m=C4);let g=[],_=[],T={},w=new Set,b=[],v=st=>st?.match(/task\s+#([\w-]+)\s+created/i)?.[1],A=st=>{if(typeof st=="string")return st;if(Array.isArray(st))return st.filter(Ze=>Ze?.type==="text"&&typeof Ze.text=="string").map(Ze=>Ze.text).join(`
package/dist/bin.js CHANGED
@@ -592,7 +592,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
592
592
  `,LF:`
593
593
  `,concatBytes:W3},Cbt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Obt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Cbt};import{Buffer as Ibt}from"buffer";var Uwe=(t,e)=>t?void 0:Pbt.bind(void 0,e),Pbt=function*(t,e){if(typeof e!="string"&&!Kr(e)&&!Ibt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Fwe=(t,e)=>t?Nbt.bind(void 0,e):kbt.bind(void 0,e),Nbt=function*(t,e){jwe(t,e),yield e},kbt=function*(t,e){if(jwe(t,e),typeof e!="string"&&!Kr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},jwe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
594
594
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
595
- if (condition) { yield value; }`)};import{Buffer as $bt}from"buffer";import{StringDecoder as Dbt}from"string_decoder";var NP=(t,e,r)=>{if(r)return;if(t)return{transform:Lbt.bind(void 0,new TextEncoder)};let n=new Dbt(e);return{transform:Mbt.bind(void 0,n),final:Ubt.bind(void 0,n)}},Lbt=function*(t,e){$bt.isBuffer(e)?yield $c(e):typeof e=="string"?yield t.encode(e):yield e},Mbt=function*(t,e){yield Kr(e)?t.write(e):e},Ubt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as zwe}from"util";var K3=zwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),kP=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=jbt}=e[r];for await(let i of n(t))yield*kP(i,e,r+1)},qwe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Fbt(r,Number(e),t)},Fbt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*kP(n,r,e+1)},Bwe=zwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),jbt=function*(t){yield t};var Z3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Vwe=(t,e)=>[...e.flatMap(r=>[...Kf(r,t,0)]),...KT(t)],Kf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=qbt}=e[r];for(let i of n(t))yield*Kf(i,e,r+1)},KT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zbt(r,Number(e),t)},zbt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Kf(n,r,e+1)},qbt=function*(t){yield t};var J3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Gwe(t,o,s),l=Yf(e),u=Yf(r),d=l?K3.bind(void 0,kP,a):Z3.bind(void 0,Kf),f=l||u?K3.bind(void 0,qwe,a):Z3.bind(void 0,KT),p=l||u?Bwe.bind(void 0,a):void 0;return{stream:new Bbt({writableObjectMode:n,writableHighWaterMark:Hwe(n),readableObjectMode:i,readableHighWaterMark:Hwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},$P=(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=Gwe(o,r,a);t=Vwe(c,t)}return t},Gwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Uwe(n,a)},NP(r,o,n),PP(r,s,n,c),{transform:t,final:e},{transform:Fwe(i,a)},Mwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Wwe=(t,e)=>{for(let r of Vbt(t))Hbt(t,r,e)},Vbt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Hbt=(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 ${Iu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Gbt(a,n));r.input=FT(o)},Gbt=(t,e)=>{let r=$P(t,e,"utf8",!0);return Wbt(r),FT(r)},Wbt=t=>{let e=t.find(r=>typeof r!="string"&&!Kr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as Jbt,appendFileSync as Xbt}from"fs";var DP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Og(r,n)&&!ts.has(e)&&Ybt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Kbt.has(s))||t.every(({type:i})=>Ds.has(i))),Ybt=t=>t===1||t===2,Kbt=new Set(["pipe","overlapped"]),Ywe=async(t,e,r,n)=>{for await(let i of t)Zbt(e)||Zwe(i,r,n)},Kwe=(t,e,r)=>{for(let n of t)Zwe(n,e,r)},Zbt=t=>t._readableState.pipes.length>0,Zwe=(t,e,r)=>{let n=KI(t);ha({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Jwe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>Qbt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Qbt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Xbe(t,s,d),p=$c(f),{stdioItems:h,objectMode:m}=e[r],_=ewt([p],h,c,n),{serializedResult:S,finalResult:v=S}=twt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});rwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?v:void 0;try{return n.error===void 0&&nwt(S,h,i),y}catch(g){return n.error=g,y}},ewt=(t,e,r,n)=>{try{return $P(t,e,r,!1)}catch(i){return n.error=i,t}},twt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:FT(t)};let o=fve(t,r);return n[s]?{serializedResult:o,finalResult:Y3(o,!i[s],e)}:{serializedResult:o}},rwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!DP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=Y3(t,!1,o);try{Kwe(a,e,n)}catch(c){r.error??=c}},nwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?Xbt(n,t):(r.add(s),Jbt(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,Mc(e,r,"all")]:Array.isArray(e)?[Mc(t,r,"all"),...e]:Kr(t)&&Kr(e)?n3([t,e]):`${t}${e}`};import{once as X3}from"events";var Qwe=async(t,e)=>{let[r,n]=await iwt(t);return e.isForcefullyTerminated??=!1,[r,n]},iwt=async t=>{let[e,r]=await Promise.allSettled([X3(t,"spawn"),X3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?eRe(t):r.value},eRe=async t=>{try{return await X3(t,"exit")}catch{return eRe(t)}},tRe=async t=>{let[e,r]=await t;if(!swt(e,r)&&Q3(e,r))throw new ho;return[e,r]},swt=(t,e)=>t===void 0&&e===void 0,Q3=(t,e)=>t!==0||e!==null;var rRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=owt(t,e,r),o=s?.code==="ETIMEDOUT",a=Jbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},owt=(t,e,r)=>t!==void 0?t:Q3(e,r)?new ho:void 0;var nRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=cwt(t,e,r),d=dwt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Fg(d,c,l)},cwt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JI(t,e,r),a=lwt(r),{file:c,commandArguments:l,options:u}=_P(t,e,a);uwt(u);let d=kwe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},lwt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,uwt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LP("ipcInput"),t&&LP("ipc: true"),r&&LP("detached: true"),n&&LP("cancelSignal")},LP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},dwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=fwt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=rRe(c,r),{output:h,error:m=l}=Jwe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,y)=>Mc(v,r,y)),S=Mc(Xwe(h,r),r,"all");return hwt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},fwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Wwe(s,r);let a=pwt(r);return awt(...yP(t,e,a))}catch(a){return Ug({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},pwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RP(e)}),hwt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?AP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):YT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as tAt}from"events";import{spawn as rAt}from"child_process";import cRe from"process";import{once as eW,on as mwt}from"events";var iRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Ng({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:dP(t)}),gwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),gwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{aP(e,i);let s=Ou(t,e,r),o=new AbortController;try{return await Promise.race([_wt(s,n,o),ywt(s,r,o),Swt(s,r,o)])}catch(a){throw kg(t),a}finally{o.abort(),cP(e,i)}},_wt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await eW(t,"message",{signal:r});return n}for await(let[n]of mwt(t,"message",{signal:r}))if(e(n))return n},ywt=async(t,e,{signal:r})=>{await eW(t,"disconnect",{signal:r}),VTe(e)},Swt=async(t,e,{signal:r})=>{let[n]=await eW(t,"strict:error",{signal:r});throw iP(n,e)};import{once as oRe,on as Ewt}from"events";var aRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>tW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),tW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Ng({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:dP(t)}),aP(e,s);let o=Ou(t,e,r),a=new AbortController,c={};return vwt(t,o,a),Twt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),bwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},vwt=async(t,e,r)=>{try{await oRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Twt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await oRe(t,"strict:error",{signal:r.signal});n.error=iP(i,e),r.abort()}catch{}},bwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Ewt(r,"message",{signal:s.signal}))sRe(o),yield c}catch{sRe(o)}finally{s.abort(),cP(e,a),n||kg(t),i&&await t}},sRe=({error:t})=>{if(t)throw t};var lRe=(t,{ipc:e})=>{Object.assign(t,dRe(t,!1,e))},uRe=()=>{let t=cRe,e=!0,r=cRe.channel!==void 0;return{...dRe(t,e,r),getCancelSignal:_be.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},dRe=(t,e,r)=>({sendMessage:mP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:iRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:aRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as wwt}from"child_process";import{PassThrough as Rwt,Readable as Awt,Writable as xwt,Duplex as Cwt}from"stream";var fRe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{H3(n);let a=new wwt;Owt(a,n),Object.assign(a,{readable:Iwt,writable:Pwt,duplex:Nwt});let c=Ug({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=kwt(c,o,i);return{subprocess:a,promise:l}},Owt=(t,e)=>{let r=ZT(),n=ZT(),i=ZT(),s=Array.from({length:e.length-3},ZT),o=ZT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},ZT=()=>{let t=new Rwt;return t.end(),t},Iwt=()=>new Awt({read(){}}),Pwt=()=>new xwt({write(){}}),Nwt=()=>new Cwt({read(){},write(){}}),kwt=async(t,e,r)=>Fg(t,e,r);import{createReadStream as pRe,createWriteStream as hRe}from"fs";import{Buffer as $wt}from"buffer";import{Readable as JT,Writable as Dwt,Duplex as Lwt}from"stream";var gRe=(t,e)=>IP(Mwt,t,e,!1),XT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Iu[t]}.`)},mRe={fileNumber:XT,generator:J3,asyncGenerator:J3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Lwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Mwt={input:{...mRe,fileUrl:({value:t})=>({stream:pRe(t)}),filePath:({value:{file:t}})=>({stream:pRe(t)}),webStream:({value:t})=>({stream:JT.fromWeb(t)}),iterable:({value:t})=>({stream:JT.from(t)}),asyncIterable:({value:t})=>({stream:JT.from(t)}),string:({value:t})=>({stream:JT.from(t)}),uint8Array:({value:t})=>({stream:JT.from($wt.from(t))})},output:{...mRe,fileUrl:({value:t})=>({stream:hRe(t)}),filePath:({value:{file:t,append:e}})=>({stream:hRe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Dwt.fromWeb(t)}),iterable:XT,asyncIterable:XT,string:XT,uint8Array:XT}};import{on as Uwt,once as _Re}from"events";import{PassThrough as Fwt,getDefaultHighWaterMark as jwt}from"stream";import{finished as ERe}from"stream/promises";function Zf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)nW(i);let e=t.some(({readableObjectMode:i})=>i),r=zwt(t,e),n=new rW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var zwt=(t,e)=>{if(t.length===0)return jwt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},rW=class extends Fwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(nW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=qwt(this,this.#e,this.#s);let r=Hwt({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(nW(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)}},qwt=async(t,e,r)=>{MP(t,yRe);let n=new AbortController;try{await Promise.race([Bwt(t,n),Vwt(t,e,r,n)])}finally{n.abort(),MP(t,-yRe)}},Bwt=async(t,{signal:e})=>{try{await ERe(t,{signal:e,cleanup:!0})}catch(r){throw vRe(t,r),r}},Vwt=async(t,e,r,{signal:n})=>{for await(let[i]of Uwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},nW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Hwt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{MP(t,SRe);let a=new AbortController;try{await Promise.race([Gwt(s,e,a),Wwt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Ywt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),MP(t,-SRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?iW(t):Kwt(t))},Gwt=async(t,e,{signal:r})=>{try{await t,r.aborted||iW(e)}catch(n){r.aborted||vRe(e,n)}},Wwt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await ERe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;TRe(o)?i.add(e):bRe(t,o)}},Ywt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await _Re(t,i,{signal:s}),!t.readable)return _Re(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Kwt=t=>{t.writable&&t.end()},vRe=(t,e)=>{TRe(e)?iW(t):bRe(t,e)},TRe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",iW=t=>{(t.readable||t.writable)&&t.destroy()},bRe=(t,e)=>{t.destroyed||(t.once("error",Zwt),t.destroy(e))},Zwt=()=>{},MP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},yRe=2,SRe=1;import{finished as wRe}from"stream/promises";var zg=(t,e)=>{t.pipe(e),Jwt(t,e),Xwt(t,e)},Jwt=async(t,e)=>{if(!(po(t)||po(e))){try{await wRe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}sW(e)}},sW=t=>{t.writable&&t.end()},Xwt=async(t,e)=>{if(!(po(t)||po(e))){try{await wRe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}oW(t)}},oW=t=>{t.readable&&t.destroy()};var RRe=(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)))Qwt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ds.has(c)))tRt({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]:Zf(s);zg(o,i)}},Qwt=(t,e,r,n)=>{r==="output"?zg(t.stdio[n],e):zg(e,t.stdio[n]);let i=eRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},eRt=["stdin","stdout","stderr"],tRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;rRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},rRt=(t,{signal:e})=>{po(t)&&Gf(t,nRt,e)},nRt=2;import{addAbortListener as oRt}from"events";var Jf=[];Jf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Jf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Jf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var UP=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",aW=Symbol.for("signal-exit emitter"),cW=globalThis,iRt=Object.defineProperty.bind(Object),lW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(cW[aW])return cW[aW];iRt(cW,aW,{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}},FP=class{},sRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),uW=class extends FP{onExit(){return()=>{}}load(){}unload(){}},dW=class extends FP{#e=fW.platform==="win32"?"SIGINT":"SIGHUP";#r=new lW;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Jf)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(!UP(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 Jf)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,Jf.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 UP(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"&&UP(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)}},fW=globalThis.process,{onExit:ARe,load:vmr,unload:Tmr}=sRt(UP(fW)?new dW(fW):new uW);var xRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ARe(()=>{t.kill()});oRt(n,()=>{i()})};var ORe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=ZI(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=aRt(r,n,i),{sourceStream:d,sourceError:f}=lRt(t,l),{options:p,fileDescriptors:h}=ga.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},aRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=cRt(t,e,...r),a=oP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},cRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(CRe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||t3(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]=jI(r,...n);return{destination:e(CRe)(i,s,o),pipeOptions:o}}if(ga.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}`)},CRe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),lRt=(t,e)=>{try{return{sourceStream:$g(t,e)}}catch(r){return{sourceError:r}}};var PRe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=uRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw pW({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},uRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return oW(t),n;if(e!==void 0)return sW(r),e},pW=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Ug({error:t,command:IRe,escapedCommand:IRe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),IRe="source.pipe(destination)";var NRe=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 dRt}from"stream/promises";var kRe=(t,e,r)=>{let n=jP.has(e)?pRt(t,e):fRt(t,e);return Gf(t,mRt,r.signal),Gf(e,gRt,r.signal),hRt(e),n},fRt=(t,e)=>{let r=Zf([t]);return zg(r,e),jP.set(e,r),r},pRt=(t,e)=>{let r=jP.get(e);return r.add(t),r},hRt=async t=>{try{await dRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jP.delete(t)},jP=new WeakMap,mRt=2,gRt=1;import{aborted as _Rt}from"util";var $Re=(t,e)=>t===void 0?[]:[yRt(t,e)],yRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await _Rt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw pW({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var zP=(t,...e)=>{if(Pr(e[0]))return zP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ORe(t,...e),i=SRt({...n,destination:r});return i.pipe=zP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},SRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=ERt(t,i);PRe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=kRe(e,s,d);return await Promise.race([NRe(u),...$Re(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},ERt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as xRt}from"timers/promises";import{on as vRt}from"events";import{getDefaultHighWaterMark as TRt}from"stream";var qP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return bRt(e,o),LRe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},bRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},hW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;wRt(e,o,t);let a=t.readableObjectMode&&!s;return LRe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},wRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},LRe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=vRt(t,"data",{signal:e.signal,highWaterMark:DRe,highWatermark:DRe});return RRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},mW=TRt(!0),DRe=mW,RRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=ARt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Kf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*KT(a)}},ARt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NP(t,r,!e),PP(t,i,!n,{})].filter(Boolean);var MRe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=CRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([ORt(t),d]);return}let f=G3(c,r),p=hW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([IRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},CRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!DP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=hW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Ywe(a,t,r,s)},ORt=async t=>{await xRt(),t.readableFlowing===null&&t.resume()},IRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await TP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await bP(r,{maxBuffer:s})):await Mg(r,{maxBuffer:s})}catch(a){return URe(Ybe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},gW=async t=>{try{return await t}catch(e){return URe(e)}},URe=({bufferedData:t})=>uve(t)?new Uint8Array(t):t;import{finished as PRt}from"stream/promises";var QT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=NRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],PRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||DRt(a,e,r,n)}finally{o.abort()}},NRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&kRt(t,r,n),n},kRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{$Rt(e,r),n.call(t,...i)}},$Rt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},DRt=(t,e,r,n)=>{if(!LRt(t,e,r,n))throw t},LRt=(t,e,r,n=!0)=>r.propagating?FRe(t)||BP(t):(r.propagating=!0,_W(r,e)===n?FRe(t):BP(t)),_W=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",BP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",FRe=t=>t?.code==="EPIPE";var jRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>yW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),yW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=QT(t,e,l);if(_W(l,e)){await u;return}let[d]=await Promise.all([MRe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var zRe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Zf([t,e].filter(Boolean)):void 0,qRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>yW({...MRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:URt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),MRt=({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}},URt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as FRt}from"events";var BRe=t=>Og(t,"ipc"),VRe=(t,e)=>{let r=KI(t);ha({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var HRe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=BRe(s),a=Dc(e,"ipc"),c=Dc(r,"ipc");for await(let l of tW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Kbe(t,i,c),i.push(l)),o&&VRe(l,s);return i},GRe=async(t,e)=>(await Promise.allSettled([t]),e);var WRe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let v=Qwe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=jRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=qRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],R=HRe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=jRt(m,t,y),C=zRt(h,y);try{return await Promise.race([Promise.all([{},tRe(v),Promise.all(g),T,R,xbe(t,d),...b,...C]),_,qRt(t,S),...Tbe(t,s,f,S),...BTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Ebe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(N){return f.terminationReason??="other",Promise.all([{error:N},v,Promise.all(g.map(A=>gW(A))),gW(T),GRe(R,w),Promise.allSettled(b),Promise.allSettled(C)])}},jRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:QT(n,i,r)),zRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>go(s,{checkOpen:!1})&&!po(s)).map(({type:i,value:s,stream:o=s})=>QT(o,n,e,{isSameDirection:Ds.has(i),stopOnExit:i==="native"}))),qRt=async(t,{signal:e})=>{let[r]=await FRt(t,"error",{signal:e});throw r};var YRe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),eb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ma();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},qg=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 BRt}from"stream";import{callbackify as VRt}from"util";import{finished as KRe}from"stream/promises";var SW=async t=>{if(t!==void 0)try{await EW(t)}catch{}},ZRe=async t=>{if(t!==void 0)try{await vW(t)}catch{}},EW=async t=>{await KRe(t,{cleanup:!0,readable:!1,writable:!0})},vW=async t=>{await KRe(t,{cleanup:!0,readable:!0,writable:!1})},VP=async(t,e)=>{if(await t,e)throw e},HP=(t,e,r)=>{r&&!BP(r)?t.destroy(r):e&&t.destroy()};var JRe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ts.has(r),{subprocessStdout:a,waitReadableDestroy:c}=TW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=bW(a,o),{read:f,onStdoutDataDone:p}=wW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new BRt({read:f,destroy:VRt(AW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return RW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},TW=(t,e,r)=>{let n=$g(t,e),i=eb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},bW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:mW},wW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ma(),o=qP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){HRt(this,o,s)},onStdoutDataDone:s}},HRt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},RW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await vW(t),await n,await SW(i),await e,r.readable&&r.push(null)}catch(s){await SW(i),XRe(r,s)}},AW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await qg(r,e)&&(XRe(t,n),await VP(e,n))},XRe=(t,e)=>{HP(t,t.readable,e)};import{Writable as GRt}from"stream";import{callbackify as QRe}from"util";var eAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=xW(t,r,e),o=new GRt({...CW(n,t,i),destroy:QRe(IW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return OW(n,o),o},xW=(t,e,r)=>{let n=oP(t,e),i=eb(r,n,"writableFinal"),s=eb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},CW=(t,e,r)=>({write:WRt.bind(void 0,t),final:QRe(YRt.bind(void 0,t,e,r))}),WRt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},YRt=async(t,e,r)=>{await qg(r,e)&&(t.writable&&t.end(),await e)},OW=async(t,e,r)=>{try{await EW(t),e.writable&&e.end()}catch(n){await ZRe(r),tAe(e,n)}},IW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await qg(r,e),await qg(n,e)&&(tAe(t,i),await VP(e,i))},tAe=(t,e)=>{HP(t,t.writable,e)};import{Duplex as KRt}from"stream";import{callbackify as ZRt}from"util";var rAe=({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:l}=TW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=xW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=bW(c,a),{read:_,onStdoutDataDone:S}=wW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new KRt({read:_,...CW(u,t,d),destroy:ZRt(JRt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return RW({subprocessStdout:c,onStdoutDataDone:S,readable:v,subprocess:t,subprocessStdin:u}),OW(u,v,c),v},JRt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([AW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),IW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var PW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ts.has(e),o=$g(t,r),a=qP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return XRt(a,o,t)},XRt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var nAe=(t,{encoding:e})=>{let r=YRe();t.readable=JRe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=eAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=rAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=PW.bind(void 0,t,e),t[Symbol.asyncIterator]=PW.bind(void 0,t,e,{})};var iAe=(t,e)=>{for(let[r,n]of eAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},QRt=(async()=>{})().constructor.prototype,eAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(QRt,t)]);var sAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=nAt(t,e,r),{subprocess:f,promise:p}=sAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=zP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),iAe(f,p),ga.set(f,{options:u,fileDescriptors:d}),f},nAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JI(t,e,r),{file:a,commandArguments:c,options:l}=_P(t,e,r),u=iAt(l),d=gRe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},iAt=({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}},sAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=rAt(...yP(t,e,r))}catch(h){return fRe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;tAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];RRe(c,a,l),xRe(c,r,l);let d={},f=ma();c.kill=zTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=zRe(c,r),nAe(c,r),lRe(c,r);let p=oAt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},oAt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await WRe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((g,T)=>Mc(g,e,T)),v=Mc(m,e,"all"),y=aAt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Fg(y,n,e)},aAt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?YT({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof _a,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):AP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var GP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,cAt(n,t[n],i)]));return{...t,...r}},cAt=(t,e,r)=>lAt.has(t)&&Pr(e)&&Pr(r)?{...e,...r}:r,lAt=new Set(["env",...a3]);var Pu=(t,e,r,n)=>{let i=(o,a,c)=>Pu(o,a,r,c),s=(...o)=>uAt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},uAt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Pr(s))return i(t,GP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=dAt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?nRe(a,c,l):sAe(a,c,l,i)},dAt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=gve(e)?_ve(e,r):[e,...r],[o,a,c]=jI(...s),l=GP(GP(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var oAe=({file:t,commandArguments:e})=>cAe(t,e),aAe=({file:t,commandArguments:e})=>({...cAe(t,e),isSync:!0}),cAe=(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]=fAt(t);return{file:r,commandArguments:n}},fAt=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(pAt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},pAt=/ +/g;var lAe=(t,e,r)=>{t.sync=e(hAt,r),t.s=t.sync},uAe=({options:t})=>dAe(t),hAt=({options:t})=>({...dAe(t),isSync:!0}),dAe=t=>({options:{...mAt(t),...t}}),mAt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},fAe={preferLocal:!0};var pAe=Pu(()=>({})),dyr=Pu(()=>({isSync:!0})),hAe=Pu(oAe),fyr=Pu(aAe),pyr=Pu(wbe),hyr=Pu(uAe,{},fAe,lAe),{sendMessage:myr,getOneMessage:gyr,getEachMessage:_yr,getCancelSignal:yyr}=uRe();import{Transform as gAt}from"stream";var _At=["NETLIFY_AI_GATEWAY_KEY"];function yAt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,..._At])]}function SAt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function EAt(){let e=yAt().map(r=>process.env[r]).filter(r=>!(!r||SAt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ui(t){if(typeof t!="string")return t;let e=EAt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(vAt(n),"g");r=r.replace(i,"******")}),r}function vAt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var tb=class extends gAt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ui(i);n(null,s)}},WP=Symbol("maskedWrite");function mAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[WP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ui(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WP]=!0,process.stdout.write=r}if(!process.stderr.write[WP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ui(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WP]=!0,process.stderr.write=r}}}var gAe=!1,_Ae,yAe=t=>{gAe=!0,_Ae??=t},rs=()=>gAe,SAe=()=>_Ae;var rb=null,EAe=t=>(rb&&rb.destroy(),rb=new _o({totalAllowedTime:t}),rb),vAe=()=>rb;var _o=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&&rs())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await DI({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Q.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var TAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.182.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@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.280","@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.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@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:"6.34.0",zod:"^4.4.3"}};var RAt=bAt(import.meta.url),AAt=Uc.dirname(RAt),xAt=wAt(import.meta.url),Bg=ue("shell"),NW=new Set,bAe={preferLocal:!0},ar=(t,e,r)=>{let[n,i]=CAt(e,r),s={...bAe,...i},o=pAe(t,n,s);RAe(o,s),CAe(o);let a=r?.idleTimeout;return a&&a>0&&xAe(o,a),o},wAe=(t,e)=>{let r={...bAe,...e},n=hAe(t,r);return RAe(n,r),CAe(n),e?.idleTimeout&&e.idleTimeout>0&&xAe(n,e.idleTimeout),n},CAt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},RAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Sa.env.NETLIFY_LOCAL_QUIET==="true")return;if(Sa.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new tb).pipe(Sa.stdout),t.stderr?.pipe(new tb).pipe(Sa.stderr);return}t.stdout?.pipe(Sa.stdout),t.stderr?.pipe(Sa.stderr)},kW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Sa.kill(-t.pid,e),Bg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bg.error("Error killing process:",r),!1}},AAe=t=>kW(t,"SIGKILL"),xAe=(t,e)=>{let r=null,n=()=>{Bg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),kW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing idle process ${t.pid}`),AAe(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)},CAe=t=>{NW.add(t);let e=vAe();if(e){let r=e.onTimesUp(()=>{Bg.log(`Global timer expired, killing process ${t.pid}`),kW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing process ${t.pid} after timeout`),AAe(t))},5e3)});t.on("exit",()=>{NW.delete(t),r()}),t.on("error",()=>{NW.delete(t),r()})}};function Ea(t,e){if(!Sa.env.NETLIFY_LOCAL_MODE)try{let i=xAt.resolve(TAe.name),s=Uc.dirname(i);for(;s!==Uc.dirname(s);){let o=Uc.dirname(s);if(Uc.basename(o)==="node_modules"){let a=Uc.join(o,".bin",e);if(YP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Sa.env.NODE_PATH){let i=Uc.join(Sa.env.NODE_PATH,".bin",e);if(YP.existsSync(i))return i}let r=Uc.join(t,"node_modules",".bin",e);if(YP.existsSync(r))return r;let n=Uc.join(AAt,"..","node_modules",".bin",e);if(YP.existsSync(n))return n}import _L from"process";import{fileURLToPath as nFt}from"url";import{createRequire as iFt}from"module";import eR from"path";import{readFileSync as sFt}from"fs";var OAt="__netlify__getTracer",IAt="__netlify__shutdownTracers",bt=(t,e)=>globalThis[OAt]?.(t,e),OAe=async()=>globalThis[IAt]?.();function nb(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 ZUt}from"timers/promises";Pe();import Pxt from"process";Pe();var e0t=(t,e)=>{e.recordException(t),e.setStatus({code:Zn.ERROR})};var zc=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}=T0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>b0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=T0e(r,n,i),c=this._tracer.startSpan(e,s,o);return b0e(c,s,a)}};function T0e(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??Yt.active(),{opts:n,ctx:i,fn:s}}function b0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:e0t,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)}}Pe();var Zg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var pY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=k0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Zg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Zg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=k0e(this._rawAttributes),this._schemaUrl=t0t(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,Zg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&oe.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Zg(n)){oe.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=r0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function hY(t,e){return pY.FromAttributeList(Object.entries(t),e)}function k0e(t){return t.map(([e,r])=>Zg(r)?[e,r.catch(n=>{oe.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function t0t(t){if(typeof t=="string"||t===void 0)return t;oe.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function r0t(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;oe.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Pe();var mb=class{emit(e){}enabled(){return!1}},$0e=new mb;var gb=Symbol.for("io.opentelemetry.js.api.logs"),Jg=globalThis;function D0e(t,e,r){return n=>n===t?e:r}var mY=1;var gY=class{getLogger(e,r,n){return new mb}},_N=new gY;var yN=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):$0e}};var _b=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new yN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:_N}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var SN=class t{constructor(){this._proxyLoggerProvider=new _b}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Jg[gb]?this.getLoggerProvider():(Jg[gb]=D0e(mY,e,_N),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Jg[gb])===null||e===void 0?void 0:e.call(Jg,mY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Jg[gb],this._proxyLoggerProvider=new _b}};var L0e=SN.getInstance();function M0e(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 U0e(t){t.forEach(e=>e.disable())}function _Y(t){let e=t.tracerProvider||kt.getTracerProvider(),r=t.meterProvider||hb.getMeterProvider(),n=t.loggerProvider||L0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return M0e(i,e,r,n),()=>{U0e(i)}}Pe();var n0t=an("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function F0e(t){return t.getValue(n0t)===!0}var Xg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Xg||(Xg={}));Pe();var yY="[_0-9a-z-*/]",i0t=`[a-z]${yY}{0,255}`,s0t=`[a-z0-9]${yY}{0,240}@[a-z]${yY}{0,13}`,o0t=new RegExp(`^(?:${i0t}|${s0t})$`),a0t=/^[ -~]{0,255}[!-~]$/,c0t=/,|=/;function SY(t){return o0t.test(t)}function EY(t){return a0t.test(t)&&!c0t.test(t)}var l0t=32,j0e=512,z0e=",",q0e="=",EN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!SY(e)||!EY(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>j0e)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=z0e+e),e=`${n[0]}${q0e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(z0e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(q0e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!SY(a)||!EY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>j0e)&&(r.set(a,c),n=l,r.size>=l0t))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 vN="traceparent",TN="tracestate",u0t="00",d0t="(?!ff)[\\da-f]{2}",f0t="(?![0]{32})[\\da-f]{32}",p0t="(?![0]{16})[\\da-f]{16}",h0t="[\\da-f]{2}",m0t=new RegExp(`^\\s?(${d0t})-(${f0t})-(${p0t})-(${h0t})(-.*)?\\s?$`);function B0e(t){let e=m0t.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var $u=class{inject(e,r,n){let i=kt.getSpanContext(e);if(!i||F0e(e)||!Fi(i))return;let s=`${u0t}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||vr.NONE).toString(16)}`;n.set(r,vN,s),i.traceState&&n.set(r,TN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,vN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=B0e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,TN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new EN(typeof c=="string"?c:void 0)}return kt.setSpanContext(e,o)}fields(){return[vN,TN]}};var bN=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 yb=class{_isCalled=!1;_deferred=new bN;_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 hk=Sn(sK(),1);Pe();var ROe=t=>{throw TypeError(t)},lK=(t,e,r)=>e.has(t)||ROe("Cannot "+r),pk=(t,e,r)=>(lK(t,e,"read from private field"),r?r.call(t):e.get(t)),oK=(t,e,r)=>e.has(t)?ROe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),TOe=(t,e,r,n)=>(lK(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Ixt=(t,e,r)=>(lK(t,e,"access private method"),r),bOe="__netlify__getTracer",Nxt="__netlify__shutdownTracers",kxt="__nfOTLPTrace",kb,$b,cK,AOe,$xt=class{constructor(){oK(this,cK),oK(this,kb),oK(this,$b),TOe(this,kb,new yb(Ixt(this,cK,AOe),this)),TOe(this,$b,oe.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(pk(this,$b).debug(`export ${t.length.toString()} spans`),pk(this,kb).isCalled){e({code:Xg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(kxt,JSON.stringify(Dxt(t))),e({code:Xg.SUCCESS})}shutdown(){return pk(this,kb).call()}};kb=new WeakMap;$b=new WeakMap;cK=new WeakSet;AOe=function(){return pk(this,$b).debug("Shutting down"),Promise.resolve()};function Dxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:fk(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||yo.SERVER,startTimeUnixNano:aK(e.startTime),endTimeUnixNano:aK(e.endTime),attributes:fk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:aK(n.time),attributes:fk(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:fk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function fk(t){return Object.keys(t).map(e=>xOe(e,t[e]))}function xOe(t,e){return{key:t,value:COe(e)}}function COe(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(COe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>xOe(r,n))}}:{}}function aK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var wOe={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"}},OOe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,bOe))return;let e=Pxt.version.slice(1),r=hY({"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??[Lxt()],i=new hk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new $u});let s=t.instrumentations??[];_Y({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,bOe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new zc(kt.getTracer(a,c)):new zc(kt.getTracer(wOe.name,wOe.version))}}),Object.defineProperty(globalThis,Nxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Lxt=()=>new hk.SimpleSpanProcessor(new $xt);Pe();var Db=Sn(sK(),1);Pe();import*as mk from"diagnostics_channel";var IOe=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?Zn.ERROR:Zn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof zc?t:new zc(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){mk.subscribe(t,e);let r=()=>mk.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:yo.CLIENT},Yt.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:Zn.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 e1e=Sn(XMe(),1);var mL=ue("tracing"),QMe=8e3,JUt=5e3,Qw=async(t=JUt)=>{try{await Promise.race([OAe(),ZUt(t)])}catch(e){mL.warn("Failed to flush tracers on shutdown",e)}},t1e=async(t,e,r)=>{if(!bt()){let n=[new Db.SimpleSpanProcessor(new uJ),new Db.SimpleSpanProcessor(new e1e.OTLPTraceExporter({url:r.exporterUrl}))];await OOe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new IOe({skipHeaders:!0})]})}return r.traceparent?(gi.setGlobalPropagator(new $u),gi.extract(Yt.active(),{traceparent:r.traceparent,isRemote:!0})):Yt.active()};function Jt(t,e,r){return mL.log(`\u23F3 TRACE: ${e} starting...`),nb(t,e,r)}var uJ=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(", ")}]`:"";mL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&mL.log(` \u274C Error: ${e.status.message}`)}};function dJ(){return He().captureLlmContentEnabled}function r1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function gL(t,e,r){let n={role:t,parts:[{type:"text",content:Ui(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var XUt=new Set([X.Task,X.RunCommand,X.Explore,X.FileRead,X.FileWrite,X.Notebook,X.Web,X.Todo,X.Skill,X.Tool,X.Memorize,X.Deployment,X.SiteGeneration]);function n1e(t,e,r,n){if(!t.length)return;let i=bt();if(!i)return;let s=dJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&XUt.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>QMe?`${a.message.slice(0,QMe)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Ui(_)}:{"gen_ai.output.messages":gL("assistant",_)}:{}}}).end(u)})}import{readdir as QUt,rm as eFt}from"fs/promises";import{join as tFt}from"path";async function i1e(t,e=[]){let n=(await QUt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>eFt(tFt(t,i),{recursive:!0,force:!0})))}var rFt=300,Mp=t=>He().budgetCreditThresholds[t.mode]?.[t.runner]??rFt,Up=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var fJ=t=>{let e=Mp(t);if(!Up(t,e))return"default";let r=He();return r.createAskFirstEnabled&&r.questionsEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},s1e=t=>{let e=fJ(t),r=Mp(t);return{budget_eligible:Up(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var oFt=eR.dirname(nFt(import.meta.url)),o1e=iFt(import.meta.url),aFt=eR.resolve(oFt,"scripts/scaffold.js"),cFt="scripts/scaffold.js",lFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,pJ=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},uFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),dFt=t=>{let e=pJ(t);return e==="node"||e.endsWith("/node")},dl=t=>{if(typeof t!="string")return!1;let e=t.match(lFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&uFt(pJ(e[r]));)r+=1;if(r>=e.length||!dFt(e[r]))return!1;let n=e[r+1];return n?pJ(n).includes(cFt):!1},Fp=ue("create_stage"),hJ="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.",fFt=`${hJ}
595
+ if (condition) { yield value; }`)};import{Buffer as $bt}from"buffer";import{StringDecoder as Dbt}from"string_decoder";var NP=(t,e,r)=>{if(r)return;if(t)return{transform:Lbt.bind(void 0,new TextEncoder)};let n=new Dbt(e);return{transform:Mbt.bind(void 0,n),final:Ubt.bind(void 0,n)}},Lbt=function*(t,e){$bt.isBuffer(e)?yield $c(e):typeof e=="string"?yield t.encode(e):yield e},Mbt=function*(t,e){yield Kr(e)?t.write(e):e},Ubt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as zwe}from"util";var K3=zwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),kP=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=jbt}=e[r];for await(let i of n(t))yield*kP(i,e,r+1)},qwe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Fbt(r,Number(e),t)},Fbt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*kP(n,r,e+1)},Bwe=zwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),jbt=function*(t){yield t};var Z3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Vwe=(t,e)=>[...e.flatMap(r=>[...Kf(r,t,0)]),...KT(t)],Kf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=qbt}=e[r];for(let i of n(t))yield*Kf(i,e,r+1)},KT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zbt(r,Number(e),t)},zbt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Kf(n,r,e+1)},qbt=function*(t){yield t};var J3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Gwe(t,o,s),l=Yf(e),u=Yf(r),d=l?K3.bind(void 0,kP,a):Z3.bind(void 0,Kf),f=l||u?K3.bind(void 0,qwe,a):Z3.bind(void 0,KT),p=l||u?Bwe.bind(void 0,a):void 0;return{stream:new Bbt({writableObjectMode:n,writableHighWaterMark:Hwe(n),readableObjectMode:i,readableHighWaterMark:Hwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},$P=(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=Gwe(o,r,a);t=Vwe(c,t)}return t},Gwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Uwe(n,a)},NP(r,o,n),PP(r,s,n,c),{transform:t,final:e},{transform:Fwe(i,a)},Mwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Wwe=(t,e)=>{for(let r of Vbt(t))Hbt(t,r,e)},Vbt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Hbt=(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 ${Iu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Gbt(a,n));r.input=FT(o)},Gbt=(t,e)=>{let r=$P(t,e,"utf8",!0);return Wbt(r),FT(r)},Wbt=t=>{let e=t.find(r=>typeof r!="string"&&!Kr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as Jbt,appendFileSync as Xbt}from"fs";var DP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Og(r,n)&&!ts.has(e)&&Ybt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Kbt.has(s))||t.every(({type:i})=>Ds.has(i))),Ybt=t=>t===1||t===2,Kbt=new Set(["pipe","overlapped"]),Ywe=async(t,e,r,n)=>{for await(let i of t)Zbt(e)||Zwe(i,r,n)},Kwe=(t,e,r)=>{for(let n of t)Zwe(n,e,r)},Zbt=t=>t._readableState.pipes.length>0,Zwe=(t,e,r)=>{let n=KI(t);ha({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Jwe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>Qbt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Qbt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Xbe(t,s,d),p=$c(f),{stdioItems:h,objectMode:m}=e[r],_=ewt([p],h,c,n),{serializedResult:S,finalResult:v=S}=twt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});rwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?v:void 0;try{return n.error===void 0&&nwt(S,h,i),y}catch(g){return n.error=g,y}},ewt=(t,e,r,n)=>{try{return $P(t,e,r,!1)}catch(i){return n.error=i,t}},twt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:FT(t)};let o=fve(t,r);return n[s]?{serializedResult:o,finalResult:Y3(o,!i[s],e)}:{serializedResult:o}},rwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!DP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=Y3(t,!1,o);try{Kwe(a,e,n)}catch(c){r.error??=c}},nwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?Xbt(n,t):(r.add(s),Jbt(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,Mc(e,r,"all")]:Array.isArray(e)?[Mc(t,r,"all"),...e]:Kr(t)&&Kr(e)?n3([t,e]):`${t}${e}`};import{once as X3}from"events";var Qwe=async(t,e)=>{let[r,n]=await iwt(t);return e.isForcefullyTerminated??=!1,[r,n]},iwt=async t=>{let[e,r]=await Promise.allSettled([X3(t,"spawn"),X3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?eRe(t):r.value},eRe=async t=>{try{return await X3(t,"exit")}catch{return eRe(t)}},tRe=async t=>{let[e,r]=await t;if(!swt(e,r)&&Q3(e,r))throw new ho;return[e,r]},swt=(t,e)=>t===void 0&&e===void 0,Q3=(t,e)=>t!==0||e!==null;var rRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=owt(t,e,r),o=s?.code==="ETIMEDOUT",a=Jbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},owt=(t,e,r)=>t!==void 0?t:Q3(e,r)?new ho:void 0;var nRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=cwt(t,e,r),d=dwt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Fg(d,c,l)},cwt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JI(t,e,r),a=lwt(r),{file:c,commandArguments:l,options:u}=_P(t,e,a);uwt(u);let d=kwe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},lwt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,uwt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LP("ipcInput"),t&&LP("ipc: true"),r&&LP("detached: true"),n&&LP("cancelSignal")},LP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},dwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=fwt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=rRe(c,r),{output:h,error:m=l}=Jwe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,y)=>Mc(v,r,y)),S=Mc(Xwe(h,r),r,"all");return hwt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},fwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Wwe(s,r);let a=pwt(r);return awt(...yP(t,e,a))}catch(a){return Ug({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},pwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RP(e)}),hwt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?AP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):YT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as tAt}from"events";import{spawn as rAt}from"child_process";import cRe from"process";import{once as eW,on as mwt}from"events";var iRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Ng({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:dP(t)}),gwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),gwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{aP(e,i);let s=Ou(t,e,r),o=new AbortController;try{return await Promise.race([_wt(s,n,o),ywt(s,r,o),Swt(s,r,o)])}catch(a){throw kg(t),a}finally{o.abort(),cP(e,i)}},_wt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await eW(t,"message",{signal:r});return n}for await(let[n]of mwt(t,"message",{signal:r}))if(e(n))return n},ywt=async(t,e,{signal:r})=>{await eW(t,"disconnect",{signal:r}),VTe(e)},Swt=async(t,e,{signal:r})=>{let[n]=await eW(t,"strict:error",{signal:r});throw iP(n,e)};import{once as oRe,on as Ewt}from"events";var aRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>tW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),tW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Ng({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:dP(t)}),aP(e,s);let o=Ou(t,e,r),a=new AbortController,c={};return vwt(t,o,a),Twt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),bwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},vwt=async(t,e,r)=>{try{await oRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Twt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await oRe(t,"strict:error",{signal:r.signal});n.error=iP(i,e),r.abort()}catch{}},bwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Ewt(r,"message",{signal:s.signal}))sRe(o),yield c}catch{sRe(o)}finally{s.abort(),cP(e,a),n||kg(t),i&&await t}},sRe=({error:t})=>{if(t)throw t};var lRe=(t,{ipc:e})=>{Object.assign(t,dRe(t,!1,e))},uRe=()=>{let t=cRe,e=!0,r=cRe.channel!==void 0;return{...dRe(t,e,r),getCancelSignal:_be.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},dRe=(t,e,r)=>({sendMessage:mP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:iRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:aRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as wwt}from"child_process";import{PassThrough as Rwt,Readable as Awt,Writable as xwt,Duplex as Cwt}from"stream";var fRe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{H3(n);let a=new wwt;Owt(a,n),Object.assign(a,{readable:Iwt,writable:Pwt,duplex:Nwt});let c=Ug({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=kwt(c,o,i);return{subprocess:a,promise:l}},Owt=(t,e)=>{let r=ZT(),n=ZT(),i=ZT(),s=Array.from({length:e.length-3},ZT),o=ZT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},ZT=()=>{let t=new Rwt;return t.end(),t},Iwt=()=>new Awt({read(){}}),Pwt=()=>new xwt({write(){}}),Nwt=()=>new Cwt({read(){},write(){}}),kwt=async(t,e,r)=>Fg(t,e,r);import{createReadStream as pRe,createWriteStream as hRe}from"fs";import{Buffer as $wt}from"buffer";import{Readable as JT,Writable as Dwt,Duplex as Lwt}from"stream";var gRe=(t,e)=>IP(Mwt,t,e,!1),XT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Iu[t]}.`)},mRe={fileNumber:XT,generator:J3,asyncGenerator:J3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Lwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Mwt={input:{...mRe,fileUrl:({value:t})=>({stream:pRe(t)}),filePath:({value:{file:t}})=>({stream:pRe(t)}),webStream:({value:t})=>({stream:JT.fromWeb(t)}),iterable:({value:t})=>({stream:JT.from(t)}),asyncIterable:({value:t})=>({stream:JT.from(t)}),string:({value:t})=>({stream:JT.from(t)}),uint8Array:({value:t})=>({stream:JT.from($wt.from(t))})},output:{...mRe,fileUrl:({value:t})=>({stream:hRe(t)}),filePath:({value:{file:t,append:e}})=>({stream:hRe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Dwt.fromWeb(t)}),iterable:XT,asyncIterable:XT,string:XT,uint8Array:XT}};import{on as Uwt,once as _Re}from"events";import{PassThrough as Fwt,getDefaultHighWaterMark as jwt}from"stream";import{finished as ERe}from"stream/promises";function Zf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)nW(i);let e=t.some(({readableObjectMode:i})=>i),r=zwt(t,e),n=new rW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var zwt=(t,e)=>{if(t.length===0)return jwt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},rW=class extends Fwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(nW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=qwt(this,this.#e,this.#s);let r=Hwt({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(nW(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)}},qwt=async(t,e,r)=>{MP(t,yRe);let n=new AbortController;try{await Promise.race([Bwt(t,n),Vwt(t,e,r,n)])}finally{n.abort(),MP(t,-yRe)}},Bwt=async(t,{signal:e})=>{try{await ERe(t,{signal:e,cleanup:!0})}catch(r){throw vRe(t,r),r}},Vwt=async(t,e,r,{signal:n})=>{for await(let[i]of Uwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},nW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Hwt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{MP(t,SRe);let a=new AbortController;try{await Promise.race([Gwt(s,e,a),Wwt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Ywt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),MP(t,-SRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?iW(t):Kwt(t))},Gwt=async(t,e,{signal:r})=>{try{await t,r.aborted||iW(e)}catch(n){r.aborted||vRe(e,n)}},Wwt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await ERe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;TRe(o)?i.add(e):bRe(t,o)}},Ywt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await _Re(t,i,{signal:s}),!t.readable)return _Re(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Kwt=t=>{t.writable&&t.end()},vRe=(t,e)=>{TRe(e)?iW(t):bRe(t,e)},TRe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",iW=t=>{(t.readable||t.writable)&&t.destroy()},bRe=(t,e)=>{t.destroyed||(t.once("error",Zwt),t.destroy(e))},Zwt=()=>{},MP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},yRe=2,SRe=1;import{finished as wRe}from"stream/promises";var zg=(t,e)=>{t.pipe(e),Jwt(t,e),Xwt(t,e)},Jwt=async(t,e)=>{if(!(po(t)||po(e))){try{await wRe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}sW(e)}},sW=t=>{t.writable&&t.end()},Xwt=async(t,e)=>{if(!(po(t)||po(e))){try{await wRe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}oW(t)}},oW=t=>{t.readable&&t.destroy()};var RRe=(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)))Qwt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ds.has(c)))tRt({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]:Zf(s);zg(o,i)}},Qwt=(t,e,r,n)=>{r==="output"?zg(t.stdio[n],e):zg(e,t.stdio[n]);let i=eRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},eRt=["stdin","stdout","stderr"],tRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;rRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},rRt=(t,{signal:e})=>{po(t)&&Gf(t,nRt,e)},nRt=2;import{addAbortListener as oRt}from"events";var Jf=[];Jf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Jf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Jf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var UP=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",aW=Symbol.for("signal-exit emitter"),cW=globalThis,iRt=Object.defineProperty.bind(Object),lW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(cW[aW])return cW[aW];iRt(cW,aW,{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}},FP=class{},sRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),uW=class extends FP{onExit(){return()=>{}}load(){}unload(){}},dW=class extends FP{#e=fW.platform==="win32"?"SIGINT":"SIGHUP";#r=new lW;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Jf)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(!UP(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 Jf)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,Jf.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 UP(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"&&UP(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)}},fW=globalThis.process,{onExit:ARe,load:vmr,unload:Tmr}=sRt(UP(fW)?new dW(fW):new uW);var xRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ARe(()=>{t.kill()});oRt(n,()=>{i()})};var ORe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=ZI(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=aRt(r,n,i),{sourceStream:d,sourceError:f}=lRt(t,l),{options:p,fileDescriptors:h}=ga.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},aRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=cRt(t,e,...r),a=oP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},cRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(CRe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||t3(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]=jI(r,...n);return{destination:e(CRe)(i,s,o),pipeOptions:o}}if(ga.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}`)},CRe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),lRt=(t,e)=>{try{return{sourceStream:$g(t,e)}}catch(r){return{sourceError:r}}};var PRe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=uRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw pW({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},uRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return oW(t),n;if(e!==void 0)return sW(r),e},pW=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Ug({error:t,command:IRe,escapedCommand:IRe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),IRe="source.pipe(destination)";var NRe=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 dRt}from"stream/promises";var kRe=(t,e,r)=>{let n=jP.has(e)?pRt(t,e):fRt(t,e);return Gf(t,mRt,r.signal),Gf(e,gRt,r.signal),hRt(e),n},fRt=(t,e)=>{let r=Zf([t]);return zg(r,e),jP.set(e,r),r},pRt=(t,e)=>{let r=jP.get(e);return r.add(t),r},hRt=async t=>{try{await dRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jP.delete(t)},jP=new WeakMap,mRt=2,gRt=1;import{aborted as _Rt}from"util";var $Re=(t,e)=>t===void 0?[]:[yRt(t,e)],yRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await _Rt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw pW({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var zP=(t,...e)=>{if(Pr(e[0]))return zP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ORe(t,...e),i=SRt({...n,destination:r});return i.pipe=zP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},SRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=ERt(t,i);PRe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=kRe(e,s,d);return await Promise.race([NRe(u),...$Re(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},ERt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as xRt}from"timers/promises";import{on as vRt}from"events";import{getDefaultHighWaterMark as TRt}from"stream";var qP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return bRt(e,o),LRe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},bRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},hW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;wRt(e,o,t);let a=t.readableObjectMode&&!s;return LRe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},wRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},LRe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=vRt(t,"data",{signal:e.signal,highWaterMark:DRe,highWatermark:DRe});return RRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},mW=TRt(!0),DRe=mW,RRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=ARt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Kf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*KT(a)}},ARt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NP(t,r,!e),PP(t,i,!n,{})].filter(Boolean);var MRe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=CRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([ORt(t),d]);return}let f=G3(c,r),p=hW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([IRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},CRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!DP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=hW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Ywe(a,t,r,s)},ORt=async t=>{await xRt(),t.readableFlowing===null&&t.resume()},IRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await TP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await bP(r,{maxBuffer:s})):await Mg(r,{maxBuffer:s})}catch(a){return URe(Ybe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},gW=async t=>{try{return await t}catch(e){return URe(e)}},URe=({bufferedData:t})=>uve(t)?new Uint8Array(t):t;import{finished as PRt}from"stream/promises";var QT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=NRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],PRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||DRt(a,e,r,n)}finally{o.abort()}},NRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&kRt(t,r,n),n},kRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{$Rt(e,r),n.call(t,...i)}},$Rt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},DRt=(t,e,r,n)=>{if(!LRt(t,e,r,n))throw t},LRt=(t,e,r,n=!0)=>r.propagating?FRe(t)||BP(t):(r.propagating=!0,_W(r,e)===n?FRe(t):BP(t)),_W=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",BP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",FRe=t=>t?.code==="EPIPE";var jRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>yW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),yW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=QT(t,e,l);if(_W(l,e)){await u;return}let[d]=await Promise.all([MRe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var zRe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Zf([t,e].filter(Boolean)):void 0,qRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>yW({...MRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:URt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),MRt=({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}},URt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as FRt}from"events";var BRe=t=>Og(t,"ipc"),VRe=(t,e)=>{let r=KI(t);ha({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var HRe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=BRe(s),a=Dc(e,"ipc"),c=Dc(r,"ipc");for await(let l of tW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Kbe(t,i,c),i.push(l)),o&&VRe(l,s);return i},GRe=async(t,e)=>(await Promise.allSettled([t]),e);var WRe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let v=Qwe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=jRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=qRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],R=HRe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=jRt(m,t,y),C=zRt(h,y);try{return await Promise.race([Promise.all([{},tRe(v),Promise.all(g),T,R,xbe(t,d),...b,...C]),_,qRt(t,S),...Tbe(t,s,f,S),...BTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Ebe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(N){return f.terminationReason??="other",Promise.all([{error:N},v,Promise.all(g.map(A=>gW(A))),gW(T),GRe(R,w),Promise.allSettled(b),Promise.allSettled(C)])}},jRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:QT(n,i,r)),zRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>go(s,{checkOpen:!1})&&!po(s)).map(({type:i,value:s,stream:o=s})=>QT(o,n,e,{isSameDirection:Ds.has(i),stopOnExit:i==="native"}))),qRt=async(t,{signal:e})=>{let[r]=await FRt(t,"error",{signal:e});throw r};var YRe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),eb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ma();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},qg=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 BRt}from"stream";import{callbackify as VRt}from"util";import{finished as KRe}from"stream/promises";var SW=async t=>{if(t!==void 0)try{await EW(t)}catch{}},ZRe=async t=>{if(t!==void 0)try{await vW(t)}catch{}},EW=async t=>{await KRe(t,{cleanup:!0,readable:!1,writable:!0})},vW=async t=>{await KRe(t,{cleanup:!0,readable:!0,writable:!1})},VP=async(t,e)=>{if(await t,e)throw e},HP=(t,e,r)=>{r&&!BP(r)?t.destroy(r):e&&t.destroy()};var JRe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ts.has(r),{subprocessStdout:a,waitReadableDestroy:c}=TW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=bW(a,o),{read:f,onStdoutDataDone:p}=wW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new BRt({read:f,destroy:VRt(AW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return RW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},TW=(t,e,r)=>{let n=$g(t,e),i=eb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},bW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:mW},wW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ma(),o=qP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){HRt(this,o,s)},onStdoutDataDone:s}},HRt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},RW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await vW(t),await n,await SW(i),await e,r.readable&&r.push(null)}catch(s){await SW(i),XRe(r,s)}},AW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await qg(r,e)&&(XRe(t,n),await VP(e,n))},XRe=(t,e)=>{HP(t,t.readable,e)};import{Writable as GRt}from"stream";import{callbackify as QRe}from"util";var eAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=xW(t,r,e),o=new GRt({...CW(n,t,i),destroy:QRe(IW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return OW(n,o),o},xW=(t,e,r)=>{let n=oP(t,e),i=eb(r,n,"writableFinal"),s=eb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},CW=(t,e,r)=>({write:WRt.bind(void 0,t),final:QRe(YRt.bind(void 0,t,e,r))}),WRt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},YRt=async(t,e,r)=>{await qg(r,e)&&(t.writable&&t.end(),await e)},OW=async(t,e,r)=>{try{await EW(t),e.writable&&e.end()}catch(n){await ZRe(r),tAe(e,n)}},IW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await qg(r,e),await qg(n,e)&&(tAe(t,i),await VP(e,i))},tAe=(t,e)=>{HP(t,t.writable,e)};import{Duplex as KRt}from"stream";import{callbackify as ZRt}from"util";var rAe=({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:l}=TW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=xW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=bW(c,a),{read:_,onStdoutDataDone:S}=wW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new KRt({read:_,...CW(u,t,d),destroy:ZRt(JRt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return RW({subprocessStdout:c,onStdoutDataDone:S,readable:v,subprocess:t,subprocessStdin:u}),OW(u,v,c),v},JRt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([AW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),IW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var PW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ts.has(e),o=$g(t,r),a=qP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return XRt(a,o,t)},XRt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var nAe=(t,{encoding:e})=>{let r=YRe();t.readable=JRe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=eAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=rAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=PW.bind(void 0,t,e),t[Symbol.asyncIterator]=PW.bind(void 0,t,e,{})};var iAe=(t,e)=>{for(let[r,n]of eAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},QRt=(async()=>{})().constructor.prototype,eAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(QRt,t)]);var sAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=nAt(t,e,r),{subprocess:f,promise:p}=sAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=zP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),iAe(f,p),ga.set(f,{options:u,fileDescriptors:d}),f},nAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=JI(t,e,r),{file:a,commandArguments:c,options:l}=_P(t,e,r),u=iAt(l),d=gRe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},iAt=({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}},sAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=rAt(...yP(t,e,r))}catch(h){return fRe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;tAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];RRe(c,a,l),xRe(c,r,l);let d={},f=ma();c.kill=zTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=zRe(c,r),nAe(c,r),lRe(c,r);let p=oAt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},oAt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await WRe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((g,T)=>Mc(g,e,T)),v=Mc(m,e,"all"),y=aAt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Fg(y,n,e)},aAt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?YT({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof _a,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):AP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var GP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,cAt(n,t[n],i)]));return{...t,...r}},cAt=(t,e,r)=>lAt.has(t)&&Pr(e)&&Pr(r)?{...e,...r}:r,lAt=new Set(["env",...a3]);var Pu=(t,e,r,n)=>{let i=(o,a,c)=>Pu(o,a,r,c),s=(...o)=>uAt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},uAt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Pr(s))return i(t,GP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=dAt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?nRe(a,c,l):sAe(a,c,l,i)},dAt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=gve(e)?_ve(e,r):[e,...r],[o,a,c]=jI(...s),l=GP(GP(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var oAe=({file:t,commandArguments:e})=>cAe(t,e),aAe=({file:t,commandArguments:e})=>({...cAe(t,e),isSync:!0}),cAe=(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]=fAt(t);return{file:r,commandArguments:n}},fAt=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(pAt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},pAt=/ +/g;var lAe=(t,e,r)=>{t.sync=e(hAt,r),t.s=t.sync},uAe=({options:t})=>dAe(t),hAt=({options:t})=>({...dAe(t),isSync:!0}),dAe=t=>({options:{...mAt(t),...t}}),mAt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},fAe={preferLocal:!0};var pAe=Pu(()=>({})),dyr=Pu(()=>({isSync:!0})),hAe=Pu(oAe),fyr=Pu(aAe),pyr=Pu(wbe),hyr=Pu(uAe,{},fAe,lAe),{sendMessage:myr,getOneMessage:gyr,getEachMessage:_yr,getCancelSignal:yyr}=uRe();import{Transform as gAt}from"stream";var _At=["NETLIFY_AI_GATEWAY_KEY"];function yAt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,..._At])]}function SAt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function EAt(){let e=yAt().map(r=>process.env[r]).filter(r=>!(!r||SAt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ui(t){if(typeof t!="string")return t;let e=EAt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(vAt(n),"g");r=r.replace(i,"******")}),r}function vAt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var tb=class extends gAt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ui(i);n(null,s)}},WP=Symbol("maskedWrite");function mAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[WP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ui(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WP]=!0,process.stdout.write=r}if(!process.stderr.write[WP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ui(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WP]=!0,process.stderr.write=r}}}var gAe=!1,_Ae,yAe=t=>{gAe=!0,_Ae??=t},rs=()=>gAe,SAe=()=>_Ae;var rb=null,EAe=t=>(rb&&rb.destroy(),rb=new _o({totalAllowedTime:t}),rb),vAe=()=>rb;var _o=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&&rs())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await DI({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Q.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var TAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.183.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@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.280","@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.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@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:"6.34.0",zod:"^4.4.3"}};var RAt=bAt(import.meta.url),AAt=Uc.dirname(RAt),xAt=wAt(import.meta.url),Bg=ue("shell"),NW=new Set,bAe={preferLocal:!0},ar=(t,e,r)=>{let[n,i]=CAt(e,r),s={...bAe,...i},o=pAe(t,n,s);RAe(o,s),CAe(o);let a=r?.idleTimeout;return a&&a>0&&xAe(o,a),o},wAe=(t,e)=>{let r={...bAe,...e},n=hAe(t,r);return RAe(n,r),CAe(n),e?.idleTimeout&&e.idleTimeout>0&&xAe(n,e.idleTimeout),n},CAt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},RAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Sa.env.NETLIFY_LOCAL_QUIET==="true")return;if(Sa.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new tb).pipe(Sa.stdout),t.stderr?.pipe(new tb).pipe(Sa.stderr);return}t.stdout?.pipe(Sa.stdout),t.stderr?.pipe(Sa.stderr)},kW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Sa.kill(-t.pid,e),Bg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bg.error("Error killing process:",r),!1}},AAe=t=>kW(t,"SIGKILL"),xAe=(t,e)=>{let r=null,n=()=>{Bg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),kW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing idle process ${t.pid}`),AAe(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)},CAe=t=>{NW.add(t);let e=vAe();if(e){let r=e.onTimesUp(()=>{Bg.log(`Global timer expired, killing process ${t.pid}`),kW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing process ${t.pid} after timeout`),AAe(t))},5e3)});t.on("exit",()=>{NW.delete(t),r()}),t.on("error",()=>{NW.delete(t),r()})}};function Ea(t,e){if(!Sa.env.NETLIFY_LOCAL_MODE)try{let i=xAt.resolve(TAe.name),s=Uc.dirname(i);for(;s!==Uc.dirname(s);){let o=Uc.dirname(s);if(Uc.basename(o)==="node_modules"){let a=Uc.join(o,".bin",e);if(YP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Sa.env.NODE_PATH){let i=Uc.join(Sa.env.NODE_PATH,".bin",e);if(YP.existsSync(i))return i}let r=Uc.join(t,"node_modules",".bin",e);if(YP.existsSync(r))return r;let n=Uc.join(AAt,"..","node_modules",".bin",e);if(YP.existsSync(n))return n}import _L from"process";import{fileURLToPath as nFt}from"url";import{createRequire as iFt}from"module";import eR from"path";import{readFileSync as sFt}from"fs";var OAt="__netlify__getTracer",IAt="__netlify__shutdownTracers",bt=(t,e)=>globalThis[OAt]?.(t,e),OAe=async()=>globalThis[IAt]?.();function nb(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 ZUt}from"timers/promises";Pe();import Pxt from"process";Pe();var e0t=(t,e)=>{e.recordException(t),e.setStatus({code:Zn.ERROR})};var zc=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}=T0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>b0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=T0e(r,n,i),c=this._tracer.startSpan(e,s,o);return b0e(c,s,a)}};function T0e(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??Yt.active(),{opts:n,ctx:i,fn:s}}function b0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:e0t,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)}}Pe();var Zg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var pY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=k0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Zg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Zg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=k0e(this._rawAttributes),this._schemaUrl=t0t(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,Zg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&oe.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Zg(n)){oe.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=r0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function hY(t,e){return pY.FromAttributeList(Object.entries(t),e)}function k0e(t){return t.map(([e,r])=>Zg(r)?[e,r.catch(n=>{oe.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function t0t(t){if(typeof t=="string"||t===void 0)return t;oe.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function r0t(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;oe.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Pe();var mb=class{emit(e){}enabled(){return!1}},$0e=new mb;var gb=Symbol.for("io.opentelemetry.js.api.logs"),Jg=globalThis;function D0e(t,e,r){return n=>n===t?e:r}var mY=1;var gY=class{getLogger(e,r,n){return new mb}},_N=new gY;var yN=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):$0e}};var _b=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new yN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:_N}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var SN=class t{constructor(){this._proxyLoggerProvider=new _b}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Jg[gb]?this.getLoggerProvider():(Jg[gb]=D0e(mY,e,_N),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Jg[gb])===null||e===void 0?void 0:e.call(Jg,mY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Jg[gb],this._proxyLoggerProvider=new _b}};var L0e=SN.getInstance();function M0e(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 U0e(t){t.forEach(e=>e.disable())}function _Y(t){let e=t.tracerProvider||kt.getTracerProvider(),r=t.meterProvider||hb.getMeterProvider(),n=t.loggerProvider||L0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return M0e(i,e,r,n),()=>{U0e(i)}}Pe();var n0t=an("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function F0e(t){return t.getValue(n0t)===!0}var Xg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Xg||(Xg={}));Pe();var yY="[_0-9a-z-*/]",i0t=`[a-z]${yY}{0,255}`,s0t=`[a-z0-9]${yY}{0,240}@[a-z]${yY}{0,13}`,o0t=new RegExp(`^(?:${i0t}|${s0t})$`),a0t=/^[ -~]{0,255}[!-~]$/,c0t=/,|=/;function SY(t){return o0t.test(t)}function EY(t){return a0t.test(t)&&!c0t.test(t)}var l0t=32,j0e=512,z0e=",",q0e="=",EN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!SY(e)||!EY(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>j0e)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=z0e+e),e=`${n[0]}${q0e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(z0e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(q0e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!SY(a)||!EY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>j0e)&&(r.set(a,c),n=l,r.size>=l0t))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 vN="traceparent",TN="tracestate",u0t="00",d0t="(?!ff)[\\da-f]{2}",f0t="(?![0]{32})[\\da-f]{32}",p0t="(?![0]{16})[\\da-f]{16}",h0t="[\\da-f]{2}",m0t=new RegExp(`^\\s?(${d0t})-(${f0t})-(${p0t})-(${h0t})(-.*)?\\s?$`);function B0e(t){let e=m0t.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var $u=class{inject(e,r,n){let i=kt.getSpanContext(e);if(!i||F0e(e)||!Fi(i))return;let s=`${u0t}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||vr.NONE).toString(16)}`;n.set(r,vN,s),i.traceState&&n.set(r,TN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,vN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=B0e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,TN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new EN(typeof c=="string"?c:void 0)}return kt.setSpanContext(e,o)}fields(){return[vN,TN]}};var bN=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 yb=class{_isCalled=!1;_deferred=new bN;_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 hk=Sn(sK(),1);Pe();var ROe=t=>{throw TypeError(t)},lK=(t,e,r)=>e.has(t)||ROe("Cannot "+r),pk=(t,e,r)=>(lK(t,e,"read from private field"),r?r.call(t):e.get(t)),oK=(t,e,r)=>e.has(t)?ROe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),TOe=(t,e,r,n)=>(lK(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Ixt=(t,e,r)=>(lK(t,e,"access private method"),r),bOe="__netlify__getTracer",Nxt="__netlify__shutdownTracers",kxt="__nfOTLPTrace",kb,$b,cK,AOe,$xt=class{constructor(){oK(this,cK),oK(this,kb),oK(this,$b),TOe(this,kb,new yb(Ixt(this,cK,AOe),this)),TOe(this,$b,oe.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(pk(this,$b).debug(`export ${t.length.toString()} spans`),pk(this,kb).isCalled){e({code:Xg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(kxt,JSON.stringify(Dxt(t))),e({code:Xg.SUCCESS})}shutdown(){return pk(this,kb).call()}};kb=new WeakMap;$b=new WeakMap;cK=new WeakSet;AOe=function(){return pk(this,$b).debug("Shutting down"),Promise.resolve()};function Dxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:fk(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||yo.SERVER,startTimeUnixNano:aK(e.startTime),endTimeUnixNano:aK(e.endTime),attributes:fk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:aK(n.time),attributes:fk(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:fk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function fk(t){return Object.keys(t).map(e=>xOe(e,t[e]))}function xOe(t,e){return{key:t,value:COe(e)}}function COe(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(COe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>xOe(r,n))}}:{}}function aK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var wOe={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"}},OOe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,bOe))return;let e=Pxt.version.slice(1),r=hY({"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??[Lxt()],i=new hk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new $u});let s=t.instrumentations??[];_Y({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,bOe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new zc(kt.getTracer(a,c)):new zc(kt.getTracer(wOe.name,wOe.version))}}),Object.defineProperty(globalThis,Nxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Lxt=()=>new hk.SimpleSpanProcessor(new $xt);Pe();var Db=Sn(sK(),1);Pe();import*as mk from"diagnostics_channel";var IOe=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?Zn.ERROR:Zn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof zc?t:new zc(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){mk.subscribe(t,e);let r=()=>mk.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:yo.CLIENT},Yt.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:Zn.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 e1e=Sn(XMe(),1);var mL=ue("tracing"),QMe=8e3,JUt=5e3,Qw=async(t=JUt)=>{try{await Promise.race([OAe(),ZUt(t)])}catch(e){mL.warn("Failed to flush tracers on shutdown",e)}},t1e=async(t,e,r)=>{if(!bt()){let n=[new Db.SimpleSpanProcessor(new uJ),new Db.SimpleSpanProcessor(new e1e.OTLPTraceExporter({url:r.exporterUrl}))];await OOe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new IOe({skipHeaders:!0})]})}return r.traceparent?(gi.setGlobalPropagator(new $u),gi.extract(Yt.active(),{traceparent:r.traceparent,isRemote:!0})):Yt.active()};function Jt(t,e,r){return mL.log(`\u23F3 TRACE: ${e} starting...`),nb(t,e,r)}var uJ=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(", ")}]`:"";mL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&mL.log(` \u274C Error: ${e.status.message}`)}};function dJ(){return He().captureLlmContentEnabled}function r1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function gL(t,e,r){let n={role:t,parts:[{type:"text",content:Ui(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var XUt=new Set([X.Task,X.RunCommand,X.Explore,X.FileRead,X.FileWrite,X.Notebook,X.Web,X.Todo,X.Skill,X.Tool,X.Memorize,X.Deployment,X.SiteGeneration]);function n1e(t,e,r,n){if(!t.length)return;let i=bt();if(!i)return;let s=dJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&XUt.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>QMe?`${a.message.slice(0,QMe)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Ui(_)}:{"gen_ai.output.messages":gL("assistant",_)}:{}}}).end(u)})}import{readdir as QUt,rm as eFt}from"fs/promises";import{join as tFt}from"path";async function i1e(t,e=[]){let n=(await QUt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>eFt(tFt(t,i),{recursive:!0,force:!0})))}var rFt=300,Mp=t=>He().budgetCreditThresholds[t.mode]?.[t.runner]??rFt,Up=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var fJ=t=>{let e=Mp(t);if(!Up(t,e))return"default";let r=He();return r.createAskFirstEnabled&&r.questionsEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},s1e=t=>{let e=fJ(t),r=Mp(t);return{budget_eligible:Up(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var oFt=eR.dirname(nFt(import.meta.url)),o1e=iFt(import.meta.url),aFt=eR.resolve(oFt,"scripts/scaffold.js"),cFt="scripts/scaffold.js",lFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,pJ=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},uFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),dFt=t=>{let e=pJ(t);return e==="node"||e.endsWith("/node")},dl=t=>{if(typeof t!="string")return!1;let e=t.match(lFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&uFt(pJ(e[r]));)r+=1;if(r>=e.length||!dFt(e[r]))return!1;let n=e[r+1];return n?pJ(n).includes(cFt):!1},Fp=ue("create_stage"),hJ="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.",fFt=`${hJ}
596
596
 
597
597
  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.`,pFt=`${hJ}
598
598
 
@@ -706,7 +706,7 @@ NETLIFY_BUILD_BASE="\${NETLIFY_BUILD_BASE:-${SFt}}" ${e} ${r} <template-id> [--p
706
706
  Replace \`<template-id>\` with the matching template \`id\`. Include \`--package-manager\` only if the user specified one. The templates can include relevant agent skills. The \`NETLIFY_BUILD_BASE=\u2026\` prefix lets the scaffold use a local template mirror if the platform set one \u2014 leave it as-is. Follow the instructions printed by the scaffold command.`:"",a="You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",c=[a,o,_Ft];return n?c=[a,yFt,o]:i&&(c=[a,mFt,o]),c.filter(Boolean).join(`
707
707
 
708
708
  `)},bFt=t=>{try{return JSON.parse(sFt(eR.join(t,".netlify","scaffold-result.json"),"utf8"))}catch{return}},a1e=async t=>{let e=bFt(t);await Jt(bt(),"create-scaffold-telemetry",r=>{r?.setAttributes({"create.template":e?.template??"none","create.packageManager":e?.packageManager??"none"})})},c1e=async({config:t,cwd:e=_L.cwd()})=>await Jt(bt(),"create-stage",async r=>{let n=performance.now();r?.setAttributes({"create.runner":t.runner,"create.id":t.id,"create.sessionId":t.sessionId}),await i1e(e,[".netlify",".git","node_modules"]),Fp.info("Cleaned cwd folder");let{nodeCmd:i,tsCliPath:s}=EFt({cwd:e}),o=[];if(s){let f=[s,"--list-addons-json"];Fp.log(`Running ${i} ${f.join(" ")}`);let{stdout:p}=await ar(i,f);o=vFt(p),Fp.info("Retrieved add-ons")}else Fp.warn("ts-cli binary not resolved; create-mode prompt will omit template section"),Q.inc("context.degraded",1,{component:"templates"});let a=fJ(t),c=a==="budget_constrained",l=a==="ask_first";l&&Fp.log("Low budget create run - Instructing the agent to ask for clarity if necessary",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),Q.inc("create.low_budget_limit_ask",1,{ask_first:l}),c&&Fp.log("Budget-constrained create run \u2014 using plan + first-milestone instructions",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),Q.inc("create.budget_constrained",1,{constrained:c});let u=TFt({templates:o,nodeCmd:i,scaffoldScriptPath:aFt,budgetConstrained:c,askUserClarity:l}),d=performance.now()-n;return r?.setAttributes({"create.duration.ms":d,"create.status":"success","create.budget_constrained":c,"create.ask_user_clarity":l}),{additionalContext:u}});var fl={Task:{name:"Task",category:X.Task},Agent:{name:"Task",category:X.Task},SendMessage:{name:"Message agent",category:X.Task},TaskOutput:{name:"Get task output",category:X.Task},TaskStop:{name:"Stop task",category:X.Task},TaskCreate:{name:"Update task list",category:X.Todo},TaskUpdate:{name:"Update task list",category:X.Todo},TaskList:{name:"Read task list",category:X.Todo},TaskGet:{name:"Read task list",category:X.Todo},ToolSearch:{name:"Load tools",category:X.Explore},Skill:{name:"Use skill",category:X.Skill},EnterPlanMode:{name:"Start planning",category:X.Plan},ListMcpResources:{name:"List resources",category:X.Explore},ReadMcpResource:{name:"Read resource",category:X.Explore},Bash:{name:"Run command",category:X.RunCommand},Glob:{name:"Find files",category:X.Explore},Grep:{name:"Search files",category:X.Explore},LS:{name:"List directory",category:X.Explore},ExitPlanMode:{name:"Exit planning",category:X.Plan},Read:{name:"Read file",category:X.FileRead},Edit:{name:"Edit file",category:X.FileWrite},MultiEdit:{name:"Edit multiple files",category:X.FileWrite},Write:{name:"Edit file",category:X.FileWrite},NotebookEdit:{name:"Edit notebook",category:X.Notebook},WebFetch:{name:"Fetch web",category:X.Web},TodoWrite:{name:"Update task list",category:X.Todo},WebSearch:{name:"Search web",category:X.Web},BashOutput:{name:"Get command output",category:X.RunCommand},KillBash:{name:"Stop command",category:X.RunCommand}},tR=t=>{if(fl[t])return fl[t].name;let e=t.match(/^mcp__(.+?)__(.+)$/);return e?`${e[2].replace(/_/g," ")} (${e[1]})`:t},gJ=t=>t==="Task"||t==="Agent",l1e=t=>{let[e=""]=t.split(`
709
- `,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},u1e=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var Un=ue("runner_claude"),rR="Claude Code",f1e="claude-opus-5",_J="claude-sonnet-5",RFt={[xh]:"claude-sonnet-5"};async function AFt({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else if(r)await t.isModelAvailableForProvider("anthropic",r)||(Un.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),Q.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0);else{let i=RFt[e.accountType],s=i||f1e;!!s&&await t.isModelAvailableForProvider("anthropic",s)?(Un.log(`Using ${i?"account override":"default"} model: ${s}`),n=s):s&&Un.log(`Model ${s} is not available, proceeding without model specification`)}return n}function xFt({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...uy.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!uy.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...uy.env}}async function CFt(){let t=nR.join(uy.cwd(),"AGENTS.md");try{await ly.access(t)}catch{return}let e=nR.join(uy.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await ly.readFile(e,"utf-8")).includes(r))return;await ly.appendFile(e,`
709
+ `,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},u1e=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var Un=ue("runner_claude"),rR="Claude Code",f1e="claude-opus-5-5",_J="claude-sonnet-5",RFt={[xh]:"claude-sonnet-5"};async function AFt({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else if(r)await t.isModelAvailableForProvider("anthropic",r)||(Un.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),Q.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0);else{let i=RFt[e.accountType],s=i||f1e;!!s&&await t.isModelAvailableForProvider("anthropic",s)?(Un.log(`Using ${i?"account override":"default"} model: ${s}`),n=s):s&&Un.log(`Model ${s} is not available, proceeding without model specification`)}return n}function xFt({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...uy.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!uy.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...uy.env}}async function CFt(){let t=nR.join(uy.cwd(),"AGENTS.md");try{await ly.access(t)}catch{return}let e=nR.join(uy.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await ly.readFile(e,"utf-8")).includes(r))return;await ly.appendFile(e,`
710
710
  ${r}
711
711
  `)}catch{await ly.writeFile(e,`${r}
712
712
  `)}Un.log("Added @AGENTS.md import to CLAUDE.local.md")}async function yJ({config:t,persistSteps:e,aiGateway:r,continueSession:n,priorAgentSessionId:i,cwd:s=uy.cwd(),cliPath:o="netlify",abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let u=t,{prompt:d}=u,{model:f}=t,p="";await CFt();let h=xFt({aiGateway:r}),m=await AFt({config:t,aiGateway:r,model:f});l&&m?.includes("fable")&&(!r||await r.isModelAvailableForProvider("anthropic",_J))&&(Un.log(`Credit wrap-up: downgrading model ${m} to ${_J}`),m=_J);let _=[],S=[],v={},y=new Set,g=[],T=nt=>nt?.match(/task\s+#([\w-]+)\s+created/i)?.[1],w=nt=>{if(typeof nt=="string")return nt;if(Array.isArray(nt))return nt.filter(ut=>ut?.type==="text"&&typeof ut.text=="string").map(ut=>ut.text).join(`
package/dist/index.js CHANGED
@@ -140,7 +140,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
140
140
  `,LF:`
141
141
  `,concatBytes:IU},IGe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},PGe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:IGe};import{Buffer as OGe}from"buffer";var Eae=(t,e)=>t?void 0:NGe.bind(void 0,e),NGe=function*(t,e){if(typeof e!="string"&&!pr(e)&&!OGe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},vae=(t,e)=>t?kGe.bind(void 0,e):MGe.bind(void 0,e),kGe=function*(t,e){Tae(t,e),yield e},MGe=function*(t,e){if(Tae(t,e),typeof e!="string"&&!pr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Tae=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
142
142
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
143
- if (condition) { yield value; }`)};import{Buffer as DGe}from"buffer";import{StringDecoder as $Ge}from"string_decoder";var CR=(t,e,r)=>{if(r)return;if(t)return{transform:LGe.bind(void 0,new TextEncoder)};let n=new $Ge(e);return{transform:UGe.bind(void 0,n),final:FGe.bind(void 0,n)}},LGe=function*(t,e){DGe.isBuffer(e)?yield pa(e):typeof e=="string"?yield t.encode(e):yield e},UGe=function*(t,e){yield pr(e)?t.write(e):e},FGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as bae}from"util";var OU=bae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),IR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=jGe}=e[r];for await(let i of n(t))yield*IR(i,e,r+1)},wae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zGe(r,Number(e),t)},zGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*IR(n,r,e+1)},Aae=bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),jGe=function*(t){yield t};var NU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},xae=(t,e)=>[...e.flatMap(r=>[...Lu(r,t,0)]),...Yy(t)],Lu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=qGe}=e[r];for(let i of n(t))yield*Lu(i,e,r+1)},Yy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*BGe(r,Number(e),t)},BGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Lu(n,r,e+1)},qGe=function*(t){yield t};var kU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Cae(t,s,o),l=$u(e),u=$u(r),d=l?OU.bind(void 0,IR,a):NU.bind(void 0,Lu),f=l||u?OU.bind(void 0,wae,a):NU.bind(void 0,Yy),p=l||u?Aae.bind(void 0,a):void 0;return{stream:new GGe({writableObjectMode:n,writableHighWaterMark:Rae(n),readableObjectMode:i,readableHighWaterMark:Rae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},PR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Cae(s,r,a);t=xae(c,t)}return t},Cae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Eae(n,a)},CR(r,s,n),RR(r,o,n,c),{transform:t,final:e},{transform:vae(i,a)},Sae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Iae=(t,e)=>{for(let r of VGe(t))HGe(t,r,e)},VGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),HGe=(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 ${Nc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>WGe(a,n));r.input=Uy(s)},WGe=(t,e)=>{let r=PR(t,e,"utf8",!0);return YGe(r),Uy(r)},YGe=t=>{let e=t.find(r=>typeof r!="string"&&!pr(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 XGe,appendFileSync as QGe}from"fs";var OR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cp(r,n)&&!ai.has(e)&&KGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&ZGe.has(o))||t.every(({type:i})=>ki.has(i))),KGe=t=>t===1||t===2,ZGe=new Set(["pipe","overlapped"]),Pae=async(t,e,r,n)=>{for await(let i of t)JGe(e)||Nae(i,r,n)},Oae=(t,e,r)=>{for(let n of t)Nae(n,e,r)},JGe=t=>t._readableState.pipes.length>0,Nae=(t,e,r)=>{let n=Vx(t);as({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var kae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>eVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},eVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Mse(t,o,d),p=pa(f),{stdioItems:h,objectMode:m}=e[r],g=tVe([p],h,c,n),{serializedResult:_,finalResult:v=_}=rVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});nVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let b=a[r]?v:void 0;try{return n.error===void 0&&iVe(_,h,i),b}catch(w){return n.error=w,b}},tVe=(t,e,r,n)=>{try{return PR(t,e,r,!1)}catch(i){return n.error=i,t}},rVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Uy(t)};let s=Yne(t,r);return n[o]?{serializedResult:s,finalResult:PU(s,!i[o],e)}:{serializedResult:s}},nVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!OR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=PU(t,!1,s);try{Oae(a,e,n)}catch(c){r.error??=c}},iVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>AR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?QGe(n,t):(r.add(o),XGe(n,t))}};var Mae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ga(e,r,"all")]:Array.isArray(e)?[ga(t,r,"all"),...e]:pr(t)&&pr(e)?F1([t,e]):`${t}${e}`};import{once as MU}from"events";var Dae=async(t,e)=>{let[r,n]=await oVe(t);return e.isForcefullyTerminated??=!1,[r,n]},oVe=async t=>{let[e,r]=await Promise.allSettled([MU(t,"spawn"),MU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$ae(t):r.value},$ae=async t=>{try{return await MU(t,"exit")}catch{return $ae(t)}},Lae=async t=>{let[e,r]=await t;if(!sVe(e,r)&&DU(e,r))throw new ho;return[e,r]},sVe=(t,e)=>t===void 0&&e===void 0,DU=(t,e)=>t!==0||e!==null;var Uae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=aVe(t,e,r),s=o?.code==="ETIMEDOUT",a=kse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},aVe=(t,e,r)=>t!==void 0?t:DU(e,r)?new ho:void 0;var Fae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=lVe(t,e,r),d=fVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Up(d,c,l)},lVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Wx(t,e,r),a=uVe(r),{file:c,commandArguments:l,options:u}=pR(t,e,a);dVe(u);let d=mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},uVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,dVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&NR("ipcInput"),t&&NR("ipc: true"),r&&NR("detached: true"),n&&NR("cancelSignal")},NR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},fVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=pVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Uae(c,r),{output:h,error:m=l}=kae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,b)=>ga(v,r,b)),_=ga(Mae(h,r),r,"all");return mVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},pVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Iae(o,r);let a=hVe(r);return cVe(...hR(t,e,a))}catch(a){return Lp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},hVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:vR(e)}),mVe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?TR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Wy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as rHe}from"events";import{spawn as nHe}from"child_process";import Gae from"process";import{once as $U,on as gVe}from"events";var zae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Op({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:aR(t)}),_Ve({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),_Ve=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{nR(e,i);let o=Oc(t,e,r),s=new AbortController;try{return await Promise.race([yVe(o,n,s),SVe(o,r,s),EVe(o,r,s)])}catch(a){throw Np(t),a}finally{s.abort(),iR(e,i)}},yVe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await $U(t,"message",{signal:r});return n}for await(let[n]of gVe(t,"message",{signal:r}))if(e(n))return n},SVe=async(t,e,{signal:r})=>{await $U(t,"disconnect",{signal:r}),xoe(e)},EVe=async(t,e,{signal:r})=>{let[n]=await $U(t,"strict:error",{signal:r});throw eR(n,e)};import{once as Bae,on as vVe}from"events";var qae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>LU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),LU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Op({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:aR(t)}),nR(e,o);let s=Oc(t,e,r),a=new AbortController,c={};return TVe(t,s,a),bVe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),wVe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},TVe=async(t,e,r)=>{try{await Bae(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},bVe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Bae(t,"strict:error",{signal:r.signal});n.error=eR(i,e),r.abort()}catch{}},wVe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of vVe(r,"message",{signal:o.signal}))jae(s),yield c}catch{jae(s)}finally{o.abort(),iR(e,a),n||Np(t),i&&await t}},jae=({error:t})=>{if(t)throw t};var Vae=(t,{ipc:e})=>{Object.assign(t,Wae(t,!1,e))},Hae=()=>{let t=Gae,e=!0,r=Gae.channel!==void 0;return{...Wae(t,e,r),getCancelSignal:Qoe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Wae=(t,e,r)=>({sendMessage:dR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:zae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:qae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as AVe}from"child_process";import{PassThrough as xVe,Readable as RVe,Writable as CVe,Duplex as IVe}from"stream";var Yae=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{RU(n);let a=new AVe;PVe(a,n),Object.assign(a,{readable:OVe,writable:NVe,duplex:kVe});let c=Lp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=MVe(c,s,i);return{subprocess:a,promise:l}},PVe=(t,e)=>{let r=Ky(),n=Ky(),i=Ky(),o=Array.from({length:e.length-3},Ky),s=Ky(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Ky=()=>{let t=new xVe;return t.end(),t},OVe=()=>new RVe({read(){}}),NVe=()=>new CVe({write(){}}),kVe=()=>new IVe({read(){},write(){}}),MVe=async(t,e,r)=>Up(t,e,r);import{createReadStream as Kae,createWriteStream as Zae}from"fs";import{Buffer as DVe}from"buffer";import{Readable as Zy,Writable as $Ve,Duplex as LVe}from"stream";var Xae=(t,e)=>xR(UVe,t,e,!1),Jy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Nc[t]}.`)},Jae={fileNumber:Jy,generator:kU,asyncGenerator:kU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:LVe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},UVe={input:{...Jae,fileUrl:({value:t})=>({stream:Kae(t)}),filePath:({value:{file:t}})=>({stream:Kae(t)}),webStream:({value:t})=>({stream:Zy.fromWeb(t)}),iterable:({value:t})=>({stream:Zy.from(t)}),asyncIterable:({value:t})=>({stream:Zy.from(t)}),string:({value:t})=>({stream:Zy.from(t)}),uint8Array:({value:t})=>({stream:Zy.from(DVe.from(t))})},output:{...Jae,fileUrl:({value:t})=>({stream:Zae(t)}),filePath:({value:{file:t,append:e}})=>({stream:Zae(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:$Ve.fromWeb(t)}),iterable:Jy,asyncIterable:Jy,string:Jy,uint8Array:Jy}};import{on as FVe,once as Qae}from"events";import{PassThrough as zVe,getDefaultHighWaterMark as jVe}from"stream";import{finished as rce}from"stream/promises";function Uu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)FU(i);let e=t.some(({readableObjectMode:i})=>i),r=BVe(t,e),n=new UU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var BVe=(t,e)=>{if(t.length===0)return jVe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},UU=class extends zVe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(FU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=qVe(this,this.#e,this.#o);let r=HVe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(FU(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)}},qVe=async(t,e,r)=>{kR(t,ece);let n=new AbortController;try{await Promise.race([GVe(t,n),VVe(t,e,r,n)])}finally{n.abort(),kR(t,-ece)}},GVe=async(t,{signal:e})=>{try{await rce(t,{signal:e,cleanup:!0})}catch(r){throw nce(t,r),r}},VVe=async(t,e,r,{signal:n})=>{for await(let[i]of FVe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},FU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},HVe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{kR(t,tce);let a=new AbortController;try{await Promise.race([WVe(o,e,a),YVe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),KVe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),kR(t,-tce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?zU(t):ZVe(t))},WVe=async(t,e,{signal:r})=>{try{await t,r.aborted||zU(e)}catch(n){r.aborted||nce(e,n)}},YVe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await rce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;ice(s)?i.add(e):oce(t,s)}},KVe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Qae(t,i,{signal:o}),!t.readable)return Qae(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},ZVe=t=>{t.writable&&t.end()},nce=(t,e)=>{ice(e)?zU(t):oce(t,e)},ice=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",zU=t=>{(t.readable||t.writable)&&t.destroy()},oce=(t,e)=>{t.destroyed||(t.once("error",JVe),t.destroy(e))},JVe=()=>{},kR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ece=2,tce=1;import{finished as sce}from"stream/promises";var zp=(t,e)=>{t.pipe(e),XVe(t,e),QVe(t,e)},XVe=async(t,e)=>{if(!(po(t)||po(e))){try{await sce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}jU(e)}},jU=t=>{t.writable&&t.end()},QVe=async(t,e)=>{if(!(po(t)||po(e))){try{await sce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}BU(t)}},BU=t=>{t.readable&&t.destroy()};var ace=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>ki.has(c)))e4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ki.has(c)))r4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Uu(o);zp(s,i)}},e4e=(t,e,r,n)=>{r==="output"?zp(t.stdio[n],e):zp(e,t.stdio[n]);let i=t4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},t4e=["stdin","stdout","stderr"],r4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;n4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},n4e=(t,{signal:e})=>{po(t)&&Mu(t,i4e,e)},i4e=2;import{addAbortListener as a4e}from"events";var Fu=[];Fu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Fu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Fu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var MR=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",qU=Symbol.for("signal-exit emitter"),GU=globalThis,o4e=Object.defineProperty.bind(Object),VU=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(GU[qU])return GU[qU];o4e(GU,qU,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},DR=class{},s4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),HU=class extends DR{onExit(){return()=>{}}load(){}unload(){}},WU=class extends DR{#e=YU.platform==="win32"?"SIGINT":"SIGHUP";#r=new VU;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Fu)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!MR(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of Fu)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Fu.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return MR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&MR(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)}},YU=globalThis.process,{onExit:cce,load:DLt,unload:$Lt}=s4e(MR(YU)?new WU(YU):new HU);var lce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=cce(()=>{t.kill()});a4e(n,()=>{i()})};var dce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Hx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=c4e(r,n,i),{sourceStream:d,sourceError:f}=u4e(t,l),{options:p,fileDescriptors:h}=ls.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},c4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=l4e(t,e,...r),a=rR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},l4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(uce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||L1(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=$x(r,...n);return{destination:e(uce)(i,o,s),pipeOptions:s}}if(ls.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}`)},uce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),u4e=(t,e)=>{try{return{sourceStream:kp(t,e)}}catch(r){return{sourceError:r}}};var pce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=d4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw KU({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},d4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return BU(t),n;if(e!==void 0)return jU(r),e},KU=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Lp({error:t,command:fce,escapedCommand:fce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),fce="source.pipe(destination)";var hce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as f4e}from"stream/promises";var mce=(t,e,r)=>{let n=$R.has(e)?h4e(t,e):p4e(t,e);return Mu(t,g4e,r.signal),Mu(e,_4e,r.signal),m4e(e),n},p4e=(t,e)=>{let r=Uu([t]);return zp(r,e),$R.set(e,r),r},h4e=(t,e)=>{let r=$R.get(e);return r.add(t),r},m4e=async t=>{try{await f4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}$R.delete(t)},$R=new WeakMap,g4e=2,_4e=1;import{aborted as y4e}from"util";var gce=(t,e)=>t===void 0?[]:[S4e(t,e)],S4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await y4e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw KU({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var LR=(t,...e)=>{if(er(e[0]))return LR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=dce(t,...e),i=E4e({...n,destination:r});return i.pipe=LR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},E4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=v4e(t,i);pce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=mce(e,o,d);return await Promise.race([hce(u),...gce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},v4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as C4e}from"timers/promises";import{on as T4e}from"events";import{getDefaultHighWaterMark as b4e}from"stream";var UR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return w4e(e,s),yce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},w4e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},ZU=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;A4e(e,s,t);let a=t.readableObjectMode&&!o;return yce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},A4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},yce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=T4e(t,"data",{signal:e.signal,highWaterMark:_ce,highWatermark:_ce});return x4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},JU=b4e(!0),_ce=JU,x4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=R4e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Lu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Yy(a)}},R4e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[CR(t,r,!e),RR(t,i,!n,{})].filter(Boolean);var Sce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=I4e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([P4e(t),d]);return}let f=CU(c,r),p=ZU({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([O4e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},I4e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!OR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=ZU({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Pae(a,t,r,o)},P4e=async t=>{await C4e(),t.readableFlowing===null&&t.resume()},O4e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await yR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await SR(r,{maxBuffer:o})):await $p(r,{maxBuffer:o})}catch(a){return Ece(Pse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},XU=async t=>{try{return await t}catch(e){return Ece(e)}},Ece=({bufferedData:t})=>Hne(t)?new Uint8Array(t):t;import{finished as N4e}from"stream/promises";var Xy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=k4e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],N4e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||$4e(a,e,r,n)}finally{s.abort()}},k4e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&M4e(t,r,n),n},M4e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{D4e(e,r),n.call(t,...i)}},D4e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},$4e=(t,e,r,n)=>{if(!L4e(t,e,r,n))throw t},L4e=(t,e,r,n=!0)=>r.propagating?vce(t)||FR(t):(r.propagating=!0,QU(r,e)===n?vce(t):FR(t)),QU=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",FR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",vce=t=>t?.code==="EPIPE";var Tce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>eF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),eF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Xy(t,e,l);if(QU(l,e)){await u;return}let[d]=await Promise.all([Sce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Uu([t,e].filter(Boolean)):void 0,wce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>eF({...U4e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:F4e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),U4e=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},F4e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as z4e}from"events";var Ace=t=>Cp(t,"ipc"),xce=(t,e)=>{let r=Vx(t);as({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Rce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ace(o),a=ha(e,"ipc"),c=ha(r,"ipc");for await(let l of LU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ose(t,i,c),i.push(l)),s&&xce(l,o);return i},Cce=async(t,e)=>(await Promise.allSettled([t]),e);var Ice=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let v=Dae(t,f),b={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},w=Tce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),T=wce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),A=[],I=Rce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),O=j4e(m,t,b),k=B4e(h,b);try{return await Promise.race([Promise.all([{},Lae(v),Promise.all(w),T,I,lse(t,d),...O,...k]),g,q4e(t,_),...ise(t,o,f,_),...Aoe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...rse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(z){return f.terminationReason??="other",Promise.all([{error:z},v,Promise.all(w.map(y=>XU(y))),XU(T),Cce(I,A),Promise.allSettled(O),Promise.allSettled(k)])}},j4e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Xy(n,i,r)),B4e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>go(o,{checkOpen:!1})&&!po(o)).map(({type:i,value:o,stream:s=o})=>Xy(s,n,e,{isSameDirection:ki.has(i),stopOnExit:i==="native"}))),q4e=async(t,{signal:e})=>{let[r]=await z4e(t,"error",{signal:e});throw r};var Pce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Qy=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=cs();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},jp=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 G4e}from"stream";import{callbackify as V4e}from"util";import{finished as Oce}from"stream/promises";var tF=async t=>{if(t!==void 0)try{await rF(t)}catch{}},Nce=async t=>{if(t!==void 0)try{await nF(t)}catch{}},rF=async t=>{await Oce(t,{cleanup:!0,readable:!1,writable:!0})},nF=async t=>{await Oce(t,{cleanup:!0,readable:!0,writable:!1})},zR=async(t,e)=>{if(await t,e)throw e},jR=(t,e,r)=>{r&&!FR(r)?t.destroy(r):e&&t.destroy()};var kce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ai.has(r),{subprocessStdout:a,waitReadableDestroy:c}=iF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=oF(a,s),{read:f,onStdoutDataDone:p}=sF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new G4e({read:f,destroy:V4e(cF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return aF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},iF=(t,e,r)=>{let n=kp(t,e),i=Qy(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},oF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:JU},sF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=cs(),s=UR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){H4e(this,s,o)},onStdoutDataDone:o}},H4e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},aF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await nF(t),await n,await tF(i),await e,r.readable&&r.push(null)}catch(o){await tF(i),Mce(r,o)}},cF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await jp(r,e)&&(Mce(t,n),await zR(e,n))},Mce=(t,e)=>{jR(t,t.readable,e)};import{Writable as W4e}from"stream";import{callbackify as Dce}from"util";var $ce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=lF(t,r,e),s=new W4e({...uF(n,t,i),destroy:Dce(fF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return dF(n,s),s},lF=(t,e,r)=>{let n=rR(t,e),i=Qy(r,n,"writableFinal"),o=Qy(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},uF=(t,e,r)=>({write:Y4e.bind(void 0,t),final:Dce(K4e.bind(void 0,t,e,r))}),Y4e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},K4e=async(t,e,r)=>{await jp(r,e)&&(t.writable&&t.end(),await e)},dF=async(t,e,r)=>{try{await rF(t),e.writable&&e.end()}catch(n){await Nce(r),Lce(e,n)}},fF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await jp(r,e),await jp(n,e)&&(Lce(t,i),await zR(e,i))},Lce=(t,e)=>{jR(t,t.writable,e)};import{Duplex as Z4e}from"stream";import{callbackify as J4e}from"util";var Uce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ai.has(r),{subprocessStdout:c,waitReadableDestroy:l}=iF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=lF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=oF(c,a),{read:g,onStdoutDataDone:_}=sF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new Z4e({read:g,...uF(u,t,d),destroy:J4e(X4e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return aF({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:t,subprocessStdin:u}),dF(u,v,c),v},X4e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([cF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),fF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var pF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ai.has(e),s=kp(t,r),a=UR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return Q4e(a,s,t)},Q4e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Fce=(t,{encoding:e})=>{let r=Pce();t.readable=kce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$ce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Uce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=pF.bind(void 0,t,e),t[Symbol.asyncIterator]=pF.bind(void 0,t,e,{})};var zce=(t,e)=>{for(let[r,n]of tHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},eHe=(async()=>{})().constructor.prototype,tHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(eHe,t)]);var jce=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=iHe(t,e,r),{subprocess:f,promise:p}=sHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=LR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),zce(f,p),ls.set(f,{options:u,fileDescriptors:d}),f},iHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Wx(t,e,r),{file:a,commandArguments:c,options:l}=pR(t,e,r),u=oHe(l),d=Xae(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},oHe=({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}},sHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=nHe(...hR(t,e,r))}catch(h){return Yae({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;rHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ace(c,a,l),lce(c,r,l);let d={},f=cs();c.kill=boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=bce(c,r),Fce(c,r),Vae(c,r);let p=aHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},aHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Ice({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((w,T)=>ga(w,e,T)),v=ga(m,e,"all"),b=cHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Up(b,n,e)},cHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Wy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof us,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):TR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var BR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,lHe(n,t[n],i)]));return{...t,...r}},lHe=(t,e,r)=>uHe.has(t)&&er(e)&&er(r)?{...e,...r}:r,uHe=new Set(["env",...q1]);var kc=(t,e,r,n)=>{let i=(s,a,c)=>kc(s,a,r,c),o=(...s)=>dHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},dHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(er(o))return i(t,BR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=fHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Fae(a,c,l):jce(a,c,l,i)},fHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Xne(e)?Qne(e,r):[e,...r],[s,a,c]=$x(...o),l=BR(BR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var Bce=({file:t,commandArguments:e})=>Gce(t,e),qce=({file:t,commandArguments:e})=>({...Gce(t,e),isSync:!0}),Gce=(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]=pHe(t);return{file:r,commandArguments:n}},pHe=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(hHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},hHe=/ +/g;var Vce=(t,e,r)=>{t.sync=e(mHe,r),t.s=t.sync},Hce=({options:t})=>Wce(t),mHe=({options:t})=>({...Wce(t),isSync:!0}),Wce=t=>({options:{...gHe(t),...t}}),gHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Yce={preferLocal:!0};var Kce=kc(()=>({})),AFt=kc(()=>({isSync:!0})),Zce=kc(Bce),xFt=kc(qce),RFt=kc(sse),CFt=kc(Hce,{},Yce,Vce),{sendMessage:IFt,getOneMessage:PFt,getEachMessage:OFt,getCancelSignal:NFt}=Hae();var Jce=!1,Xce,Qce=t=>{Jce=!0,Xce??=t},_a=()=>Jce,ele=()=>Xce;var eS=null,tle=t=>(eS&&eS.destroy(),eS=new _o({totalAllowedTime:t}),eS),rle=()=>eS;var _o=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&&_a())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await Ax({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{H.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var nle={name:"@netlify/agent-runner-cli",type:"module",version:"1.182.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@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.280","@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.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@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:"6.34.0",zod:"^4.4.3"}};var EHe=yHe(import.meta.url),vHe=ya.dirname(EHe),THe=SHe(import.meta.url),Bp=ne("shell"),hF=new Set,ile={preferLocal:!0},Lt=(t,e,r)=>{let[n,i]=bHe(e,r),o={...ile,...i},s=Kce(t,n,o);sle(s,o),lle(s);let a=r?.idleTimeout;return a&&a>0&&cle(s,a),s},ole=(t,e)=>{let r={...ile,...e},n=Zce(t,r);return sle(n,r),lle(n),e?.idleTimeout&&e.idleTimeout>0&&cle(n,e.idleTimeout),n},bHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},sle=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||fs.env.NETLIFY_LOCAL_QUIET==="true")return;if(fs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Iy).pipe(fs.stdout),t.stderr?.pipe(new Iy).pipe(fs.stderr);return}t.stdout?.pipe(fs.stdout),t.stderr?.pipe(fs.stderr)},mF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(fs.kill(-t.pid,e),Bp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bp.error("Error killing process:",r),!1}},ale=t=>mF(t,"SIGKILL"),cle=(t,e)=>{let r=null,n=()=>{Bp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),mF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bp.log(`Force killing idle process ${t.pid}`),ale(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},lle=t=>{hF.add(t);let e=rle();if(e){let r=e.onTimesUp(()=>{Bp.log(`Global timer expired, killing process ${t.pid}`),mF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bp.log(`Force killing process ${t.pid} after timeout`),ale(t))},5e3)});t.on("exit",()=>{hF.delete(t),r()}),t.on("error",()=>{hF.delete(t),r()})}};function ps(t,e){if(!fs.env.NETLIFY_LOCAL_MODE)try{let i=THe.resolve(nle.name),o=ya.dirname(i);for(;o!==ya.dirname(o);){let s=ya.dirname(o);if(ya.basename(s)==="node_modules"){let a=ya.join(s,".bin",e);if(qR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(fs.env.NODE_PATH){let i=ya.join(fs.env.NODE_PATH,".bin",e);if(qR.existsSync(i))return i}let r=ya.join(t,"node_modules",".bin",e);if(qR.existsSync(r))return r;let n=ya.join(vHe,"..","node_modules",".bin",e);if(qR.existsSync(n))return n}var ule=ne("repo"),hle="runner-diffs-",HR=t=>`${hle}${t}-`,mle=async t=>{let e=ple.tmpdir(),r;try{r=await GR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(hle)&&!n.startsWith(HR(t))).map(n=>GR.rm(VR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},tr=(t,e={})=>Lt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),WR=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{ule.info("Getting runner diffs");let n=await SF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=vF(o);await OHe(l,r)}ule.info("Changes after processing"),await yF(r);let s=await tS(o,r);if(await _F(s,r),i=await CHe(r),!i)return{hasChanges:!1,ignored:s};await tr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await GR.mkdtemp(VR.join(ple.tmpdir(),HR(t.sessionId))),c=await gF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await xHe(r),c.hasChanges&&H.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},gF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=VR.join(e,h);await tr([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:v}=await GR.stat(g);return{path:g,size:v}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await fle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await fle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},dle=async t=>{let e=wHe("sha256");for await(let r of AHe(t))e.update(r);return e.digest("hex")},fle=async(t,e)=>t.size===e.size&&await dle(t.path)===await dle(e.path),xHe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await tr(["reset","--soft","HEAD~1"],{cwd:t})},_F=async(t=[],e=process.cwd())=>{await tr(["add",".",...t],{cwd:e})},yF=async(t=process.cwd())=>{let e=await tr(["status","-s"],{cwd:t});return String(e.stdout??"")},gle=/.. (.+)?\.log$/,RHe=[gle],SF=async(t=process.cwd())=>{let e=await yF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
143
+ if (condition) { yield value; }`)};import{Buffer as DGe}from"buffer";import{StringDecoder as $Ge}from"string_decoder";var CR=(t,e,r)=>{if(r)return;if(t)return{transform:LGe.bind(void 0,new TextEncoder)};let n=new $Ge(e);return{transform:UGe.bind(void 0,n),final:FGe.bind(void 0,n)}},LGe=function*(t,e){DGe.isBuffer(e)?yield pa(e):typeof e=="string"?yield t.encode(e):yield e},UGe=function*(t,e){yield pr(e)?t.write(e):e},FGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as bae}from"util";var OU=bae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),IR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=jGe}=e[r];for await(let i of n(t))yield*IR(i,e,r+1)},wae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zGe(r,Number(e),t)},zGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*IR(n,r,e+1)},Aae=bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),jGe=function*(t){yield t};var NU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},xae=(t,e)=>[...e.flatMap(r=>[...Lu(r,t,0)]),...Yy(t)],Lu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=qGe}=e[r];for(let i of n(t))yield*Lu(i,e,r+1)},Yy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*BGe(r,Number(e),t)},BGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Lu(n,r,e+1)},qGe=function*(t){yield t};var kU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Cae(t,s,o),l=$u(e),u=$u(r),d=l?OU.bind(void 0,IR,a):NU.bind(void 0,Lu),f=l||u?OU.bind(void 0,wae,a):NU.bind(void 0,Yy),p=l||u?Aae.bind(void 0,a):void 0;return{stream:new GGe({writableObjectMode:n,writableHighWaterMark:Rae(n),readableObjectMode:i,readableHighWaterMark:Rae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},PR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Cae(s,r,a);t=xae(c,t)}return t},Cae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Eae(n,a)},CR(r,s,n),RR(r,o,n,c),{transform:t,final:e},{transform:vae(i,a)},Sae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Iae=(t,e)=>{for(let r of VGe(t))HGe(t,r,e)},VGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),HGe=(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 ${Nc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>WGe(a,n));r.input=Uy(s)},WGe=(t,e)=>{let r=PR(t,e,"utf8",!0);return YGe(r),Uy(r)},YGe=t=>{let e=t.find(r=>typeof r!="string"&&!pr(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 XGe,appendFileSync as QGe}from"fs";var OR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cp(r,n)&&!ai.has(e)&&KGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&ZGe.has(o))||t.every(({type:i})=>ki.has(i))),KGe=t=>t===1||t===2,ZGe=new Set(["pipe","overlapped"]),Pae=async(t,e,r,n)=>{for await(let i of t)JGe(e)||Nae(i,r,n)},Oae=(t,e,r)=>{for(let n of t)Nae(n,e,r)},JGe=t=>t._readableState.pipes.length>0,Nae=(t,e,r)=>{let n=Vx(t);as({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var kae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>eVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},eVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Mse(t,o,d),p=pa(f),{stdioItems:h,objectMode:m}=e[r],g=tVe([p],h,c,n),{serializedResult:_,finalResult:v=_}=rVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});nVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let b=a[r]?v:void 0;try{return n.error===void 0&&iVe(_,h,i),b}catch(w){return n.error=w,b}},tVe=(t,e,r,n)=>{try{return PR(t,e,r,!1)}catch(i){return n.error=i,t}},rVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Uy(t)};let s=Yne(t,r);return n[o]?{serializedResult:s,finalResult:PU(s,!i[o],e)}:{serializedResult:s}},nVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!OR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=PU(t,!1,s);try{Oae(a,e,n)}catch(c){r.error??=c}},iVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>AR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?QGe(n,t):(r.add(o),XGe(n,t))}};var Mae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ga(e,r,"all")]:Array.isArray(e)?[ga(t,r,"all"),...e]:pr(t)&&pr(e)?F1([t,e]):`${t}${e}`};import{once as MU}from"events";var Dae=async(t,e)=>{let[r,n]=await oVe(t);return e.isForcefullyTerminated??=!1,[r,n]},oVe=async t=>{let[e,r]=await Promise.allSettled([MU(t,"spawn"),MU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$ae(t):r.value},$ae=async t=>{try{return await MU(t,"exit")}catch{return $ae(t)}},Lae=async t=>{let[e,r]=await t;if(!sVe(e,r)&&DU(e,r))throw new ho;return[e,r]},sVe=(t,e)=>t===void 0&&e===void 0,DU=(t,e)=>t!==0||e!==null;var Uae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=aVe(t,e,r),s=o?.code==="ETIMEDOUT",a=kse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},aVe=(t,e,r)=>t!==void 0?t:DU(e,r)?new ho:void 0;var Fae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=lVe(t,e,r),d=fVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Up(d,c,l)},lVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Wx(t,e,r),a=uVe(r),{file:c,commandArguments:l,options:u}=pR(t,e,a);dVe(u);let d=mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},uVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,dVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&NR("ipcInput"),t&&NR("ipc: true"),r&&NR("detached: true"),n&&NR("cancelSignal")},NR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},fVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=pVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Uae(c,r),{output:h,error:m=l}=kae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((v,b)=>ga(v,r,b)),_=ga(Mae(h,r),r,"all");return mVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},pVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Iae(o,r);let a=hVe(r);return cVe(...hR(t,e,a))}catch(a){return Lp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},hVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:vR(e)}),mVe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?TR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Wy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as rHe}from"events";import{spawn as nHe}from"child_process";import Gae from"process";import{once as $U,on as gVe}from"events";var zae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Op({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:aR(t)}),_Ve({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),_Ve=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{nR(e,i);let o=Oc(t,e,r),s=new AbortController;try{return await Promise.race([yVe(o,n,s),SVe(o,r,s),EVe(o,r,s)])}catch(a){throw Np(t),a}finally{s.abort(),iR(e,i)}},yVe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await $U(t,"message",{signal:r});return n}for await(let[n]of gVe(t,"message",{signal:r}))if(e(n))return n},SVe=async(t,e,{signal:r})=>{await $U(t,"disconnect",{signal:r}),xoe(e)},EVe=async(t,e,{signal:r})=>{let[n]=await $U(t,"strict:error",{signal:r});throw eR(n,e)};import{once as Bae,on as vVe}from"events";var qae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>LU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),LU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Op({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:aR(t)}),nR(e,o);let s=Oc(t,e,r),a=new AbortController,c={};return TVe(t,s,a),bVe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),wVe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},TVe=async(t,e,r)=>{try{await Bae(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},bVe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Bae(t,"strict:error",{signal:r.signal});n.error=eR(i,e),r.abort()}catch{}},wVe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of vVe(r,"message",{signal:o.signal}))jae(s),yield c}catch{jae(s)}finally{o.abort(),iR(e,a),n||Np(t),i&&await t}},jae=({error:t})=>{if(t)throw t};var Vae=(t,{ipc:e})=>{Object.assign(t,Wae(t,!1,e))},Hae=()=>{let t=Gae,e=!0,r=Gae.channel!==void 0;return{...Wae(t,e,r),getCancelSignal:Qoe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Wae=(t,e,r)=>({sendMessage:dR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:zae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:qae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as AVe}from"child_process";import{PassThrough as xVe,Readable as RVe,Writable as CVe,Duplex as IVe}from"stream";var Yae=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{RU(n);let a=new AVe;PVe(a,n),Object.assign(a,{readable:OVe,writable:NVe,duplex:kVe});let c=Lp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=MVe(c,s,i);return{subprocess:a,promise:l}},PVe=(t,e)=>{let r=Ky(),n=Ky(),i=Ky(),o=Array.from({length:e.length-3},Ky),s=Ky(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Ky=()=>{let t=new xVe;return t.end(),t},OVe=()=>new RVe({read(){}}),NVe=()=>new CVe({write(){}}),kVe=()=>new IVe({read(){},write(){}}),MVe=async(t,e,r)=>Up(t,e,r);import{createReadStream as Kae,createWriteStream as Zae}from"fs";import{Buffer as DVe}from"buffer";import{Readable as Zy,Writable as $Ve,Duplex as LVe}from"stream";var Xae=(t,e)=>xR(UVe,t,e,!1),Jy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Nc[t]}.`)},Jae={fileNumber:Jy,generator:kU,asyncGenerator:kU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:LVe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},UVe={input:{...Jae,fileUrl:({value:t})=>({stream:Kae(t)}),filePath:({value:{file:t}})=>({stream:Kae(t)}),webStream:({value:t})=>({stream:Zy.fromWeb(t)}),iterable:({value:t})=>({stream:Zy.from(t)}),asyncIterable:({value:t})=>({stream:Zy.from(t)}),string:({value:t})=>({stream:Zy.from(t)}),uint8Array:({value:t})=>({stream:Zy.from(DVe.from(t))})},output:{...Jae,fileUrl:({value:t})=>({stream:Zae(t)}),filePath:({value:{file:t,append:e}})=>({stream:Zae(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:$Ve.fromWeb(t)}),iterable:Jy,asyncIterable:Jy,string:Jy,uint8Array:Jy}};import{on as FVe,once as Qae}from"events";import{PassThrough as zVe,getDefaultHighWaterMark as jVe}from"stream";import{finished as rce}from"stream/promises";function Uu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)FU(i);let e=t.some(({readableObjectMode:i})=>i),r=BVe(t,e),n=new UU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var BVe=(t,e)=>{if(t.length===0)return jVe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},UU=class extends zVe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(FU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=qVe(this,this.#e,this.#o);let r=HVe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(FU(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)}},qVe=async(t,e,r)=>{kR(t,ece);let n=new AbortController;try{await Promise.race([GVe(t,n),VVe(t,e,r,n)])}finally{n.abort(),kR(t,-ece)}},GVe=async(t,{signal:e})=>{try{await rce(t,{signal:e,cleanup:!0})}catch(r){throw nce(t,r),r}},VVe=async(t,e,r,{signal:n})=>{for await(let[i]of FVe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},FU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},HVe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{kR(t,tce);let a=new AbortController;try{await Promise.race([WVe(o,e,a),YVe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),KVe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),kR(t,-tce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?zU(t):ZVe(t))},WVe=async(t,e,{signal:r})=>{try{await t,r.aborted||zU(e)}catch(n){r.aborted||nce(e,n)}},YVe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await rce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;ice(s)?i.add(e):oce(t,s)}},KVe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Qae(t,i,{signal:o}),!t.readable)return Qae(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},ZVe=t=>{t.writable&&t.end()},nce=(t,e)=>{ice(e)?zU(t):oce(t,e)},ice=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",zU=t=>{(t.readable||t.writable)&&t.destroy()},oce=(t,e)=>{t.destroyed||(t.once("error",JVe),t.destroy(e))},JVe=()=>{},kR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ece=2,tce=1;import{finished as sce}from"stream/promises";var zp=(t,e)=>{t.pipe(e),XVe(t,e),QVe(t,e)},XVe=async(t,e)=>{if(!(po(t)||po(e))){try{await sce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}jU(e)}},jU=t=>{t.writable&&t.end()},QVe=async(t,e)=>{if(!(po(t)||po(e))){try{await sce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}BU(t)}},BU=t=>{t.readable&&t.destroy()};var ace=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>ki.has(c)))e4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ki.has(c)))r4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Uu(o);zp(s,i)}},e4e=(t,e,r,n)=>{r==="output"?zp(t.stdio[n],e):zp(e,t.stdio[n]);let i=t4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},t4e=["stdin","stdout","stderr"],r4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;n4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},n4e=(t,{signal:e})=>{po(t)&&Mu(t,i4e,e)},i4e=2;import{addAbortListener as a4e}from"events";var Fu=[];Fu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Fu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Fu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var MR=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",qU=Symbol.for("signal-exit emitter"),GU=globalThis,o4e=Object.defineProperty.bind(Object),VU=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(GU[qU])return GU[qU];o4e(GU,qU,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},DR=class{},s4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),HU=class extends DR{onExit(){return()=>{}}load(){}unload(){}},WU=class extends DR{#e=YU.platform==="win32"?"SIGINT":"SIGHUP";#r=new VU;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Fu)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!MR(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of Fu)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Fu.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return MR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&MR(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)}},YU=globalThis.process,{onExit:cce,load:DLt,unload:$Lt}=s4e(MR(YU)?new WU(YU):new HU);var lce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=cce(()=>{t.kill()});a4e(n,()=>{i()})};var dce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Hx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=c4e(r,n,i),{sourceStream:d,sourceError:f}=u4e(t,l),{options:p,fileDescriptors:h}=ls.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},c4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=l4e(t,e,...r),a=rR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},l4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(uce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||L1(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=$x(r,...n);return{destination:e(uce)(i,o,s),pipeOptions:s}}if(ls.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}`)},uce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),u4e=(t,e)=>{try{return{sourceStream:kp(t,e)}}catch(r){return{sourceError:r}}};var pce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=d4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw KU({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},d4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return BU(t),n;if(e!==void 0)return jU(r),e},KU=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Lp({error:t,command:fce,escapedCommand:fce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),fce="source.pipe(destination)";var hce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as f4e}from"stream/promises";var mce=(t,e,r)=>{let n=$R.has(e)?h4e(t,e):p4e(t,e);return Mu(t,g4e,r.signal),Mu(e,_4e,r.signal),m4e(e),n},p4e=(t,e)=>{let r=Uu([t]);return zp(r,e),$R.set(e,r),r},h4e=(t,e)=>{let r=$R.get(e);return r.add(t),r},m4e=async t=>{try{await f4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}$R.delete(t)},$R=new WeakMap,g4e=2,_4e=1;import{aborted as y4e}from"util";var gce=(t,e)=>t===void 0?[]:[S4e(t,e)],S4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await y4e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw KU({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var LR=(t,...e)=>{if(er(e[0]))return LR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=dce(t,...e),i=E4e({...n,destination:r});return i.pipe=LR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},E4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=v4e(t,i);pce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=mce(e,o,d);return await Promise.race([hce(u),...gce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},v4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as C4e}from"timers/promises";import{on as T4e}from"events";import{getDefaultHighWaterMark as b4e}from"stream";var UR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return w4e(e,s),yce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},w4e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},ZU=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;A4e(e,s,t);let a=t.readableObjectMode&&!o;return yce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},A4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},yce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=T4e(t,"data",{signal:e.signal,highWaterMark:_ce,highWatermark:_ce});return x4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},JU=b4e(!0),_ce=JU,x4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=R4e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Lu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Yy(a)}},R4e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[CR(t,r,!e),RR(t,i,!n,{})].filter(Boolean);var Sce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=I4e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([P4e(t),d]);return}let f=CU(c,r),p=ZU({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([O4e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},I4e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!OR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=ZU({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Pae(a,t,r,o)},P4e=async t=>{await C4e(),t.readableFlowing===null&&t.resume()},O4e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await yR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await SR(r,{maxBuffer:o})):await $p(r,{maxBuffer:o})}catch(a){return Ece(Pse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},XU=async t=>{try{return await t}catch(e){return Ece(e)}},Ece=({bufferedData:t})=>Hne(t)?new Uint8Array(t):t;import{finished as N4e}from"stream/promises";var Xy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=k4e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],N4e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||$4e(a,e,r,n)}finally{s.abort()}},k4e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&M4e(t,r,n),n},M4e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{D4e(e,r),n.call(t,...i)}},D4e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},$4e=(t,e,r,n)=>{if(!L4e(t,e,r,n))throw t},L4e=(t,e,r,n=!0)=>r.propagating?vce(t)||FR(t):(r.propagating=!0,QU(r,e)===n?vce(t):FR(t)),QU=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",FR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",vce=t=>t?.code==="EPIPE";var Tce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>eF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),eF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Xy(t,e,l);if(QU(l,e)){await u;return}let[d]=await Promise.all([Sce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Uu([t,e].filter(Boolean)):void 0,wce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>eF({...U4e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:F4e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),U4e=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},F4e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as z4e}from"events";var Ace=t=>Cp(t,"ipc"),xce=(t,e)=>{let r=Vx(t);as({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Rce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ace(o),a=ha(e,"ipc"),c=ha(r,"ipc");for await(let l of LU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ose(t,i,c),i.push(l)),s&&xce(l,o);return i},Cce=async(t,e)=>(await Promise.allSettled([t]),e);var Ice=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let v=Dae(t,f),b={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},w=Tce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),T=wce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:b}),A=[],I=Rce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),O=j4e(m,t,b),k=B4e(h,b);try{return await Promise.race([Promise.all([{},Lae(v),Promise.all(w),T,I,lse(t,d),...O,...k]),g,q4e(t,_),...ise(t,o,f,_),...Aoe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...rse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(z){return f.terminationReason??="other",Promise.all([{error:z},v,Promise.all(w.map(y=>XU(y))),XU(T),Cce(I,A),Promise.allSettled(O),Promise.allSettled(k)])}},j4e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Xy(n,i,r)),B4e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>go(o,{checkOpen:!1})&&!po(o)).map(({type:i,value:o,stream:s=o})=>Xy(s,n,e,{isSameDirection:ki.has(i),stopOnExit:i==="native"}))),q4e=async(t,{signal:e})=>{let[r]=await z4e(t,"error",{signal:e});throw r};var Pce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Qy=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=cs();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},jp=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 G4e}from"stream";import{callbackify as V4e}from"util";import{finished as Oce}from"stream/promises";var tF=async t=>{if(t!==void 0)try{await rF(t)}catch{}},Nce=async t=>{if(t!==void 0)try{await nF(t)}catch{}},rF=async t=>{await Oce(t,{cleanup:!0,readable:!1,writable:!0})},nF=async t=>{await Oce(t,{cleanup:!0,readable:!0,writable:!1})},zR=async(t,e)=>{if(await t,e)throw e},jR=(t,e,r)=>{r&&!FR(r)?t.destroy(r):e&&t.destroy()};var kce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ai.has(r),{subprocessStdout:a,waitReadableDestroy:c}=iF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=oF(a,s),{read:f,onStdoutDataDone:p}=sF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new G4e({read:f,destroy:V4e(cF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return aF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},iF=(t,e,r)=>{let n=kp(t,e),i=Qy(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},oF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:JU},sF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=cs(),s=UR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){H4e(this,s,o)},onStdoutDataDone:o}},H4e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},aF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await nF(t),await n,await tF(i),await e,r.readable&&r.push(null)}catch(o){await tF(i),Mce(r,o)}},cF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await jp(r,e)&&(Mce(t,n),await zR(e,n))},Mce=(t,e)=>{jR(t,t.readable,e)};import{Writable as W4e}from"stream";import{callbackify as Dce}from"util";var $ce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=lF(t,r,e),s=new W4e({...uF(n,t,i),destroy:Dce(fF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return dF(n,s),s},lF=(t,e,r)=>{let n=rR(t,e),i=Qy(r,n,"writableFinal"),o=Qy(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},uF=(t,e,r)=>({write:Y4e.bind(void 0,t),final:Dce(K4e.bind(void 0,t,e,r))}),Y4e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},K4e=async(t,e,r)=>{await jp(r,e)&&(t.writable&&t.end(),await e)},dF=async(t,e,r)=>{try{await rF(t),e.writable&&e.end()}catch(n){await Nce(r),Lce(e,n)}},fF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await jp(r,e),await jp(n,e)&&(Lce(t,i),await zR(e,i))},Lce=(t,e)=>{jR(t,t.writable,e)};import{Duplex as Z4e}from"stream";import{callbackify as J4e}from"util";var Uce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ai.has(r),{subprocessStdout:c,waitReadableDestroy:l}=iF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=lF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=oF(c,a),{read:g,onStdoutDataDone:_}=sF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new Z4e({read:g,...uF(u,t,d),destroy:J4e(X4e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return aF({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:t,subprocessStdin:u}),dF(u,v,c),v},X4e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([cF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),fF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var pF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ai.has(e),s=kp(t,r),a=UR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return Q4e(a,s,t)},Q4e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Fce=(t,{encoding:e})=>{let r=Pce();t.readable=kce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$ce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Uce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=pF.bind(void 0,t,e),t[Symbol.asyncIterator]=pF.bind(void 0,t,e,{})};var zce=(t,e)=>{for(let[r,n]of tHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},eHe=(async()=>{})().constructor.prototype,tHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(eHe,t)]);var jce=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=iHe(t,e,r),{subprocess:f,promise:p}=sHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=LR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),zce(f,p),ls.set(f,{options:u,fileDescriptors:d}),f},iHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Wx(t,e,r),{file:a,commandArguments:c,options:l}=pR(t,e,r),u=oHe(l),d=Xae(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},oHe=({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}},sHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=nHe(...hR(t,e,r))}catch(h){return Yae({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;rHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ace(c,a,l),lce(c,r,l);let d={},f=cs();c.kill=boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=bce(c,r),Fce(c,r),Vae(c,r);let p=aHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},aHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Ice({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((w,T)=>ga(w,e,T)),v=ga(m,e,"all"),b=cHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Up(b,n,e)},cHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Wy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof us,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):TR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var BR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,lHe(n,t[n],i)]));return{...t,...r}},lHe=(t,e,r)=>uHe.has(t)&&er(e)&&er(r)?{...e,...r}:r,uHe=new Set(["env",...q1]);var kc=(t,e,r,n)=>{let i=(s,a,c)=>kc(s,a,r,c),o=(...s)=>dHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},dHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(er(o))return i(t,BR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=fHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Fae(a,c,l):jce(a,c,l,i)},fHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Xne(e)?Qne(e,r):[e,...r],[s,a,c]=$x(...o),l=BR(BR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var Bce=({file:t,commandArguments:e})=>Gce(t,e),qce=({file:t,commandArguments:e})=>({...Gce(t,e),isSync:!0}),Gce=(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]=pHe(t);return{file:r,commandArguments:n}},pHe=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(hHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},hHe=/ +/g;var Vce=(t,e,r)=>{t.sync=e(mHe,r),t.s=t.sync},Hce=({options:t})=>Wce(t),mHe=({options:t})=>({...Wce(t),isSync:!0}),Wce=t=>({options:{...gHe(t),...t}}),gHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Yce={preferLocal:!0};var Kce=kc(()=>({})),AFt=kc(()=>({isSync:!0})),Zce=kc(Bce),xFt=kc(qce),RFt=kc(sse),CFt=kc(Hce,{},Yce,Vce),{sendMessage:IFt,getOneMessage:PFt,getEachMessage:OFt,getCancelSignal:NFt}=Hae();var Jce=!1,Xce,Qce=t=>{Jce=!0,Xce??=t},_a=()=>Jce,ele=()=>Xce;var eS=null,tle=t=>(eS&&eS.destroy(),eS=new _o({totalAllowedTime:t}),eS),rle=()=>eS;var _o=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&&_a())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await Ax({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{H.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var nle={name:"@netlify/agent-runner-cli",type:"module",version:"1.183.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"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:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@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.280","@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.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@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:"6.34.0",zod:"^4.4.3"}};var EHe=yHe(import.meta.url),vHe=ya.dirname(EHe),THe=SHe(import.meta.url),Bp=ne("shell"),hF=new Set,ile={preferLocal:!0},Lt=(t,e,r)=>{let[n,i]=bHe(e,r),o={...ile,...i},s=Kce(t,n,o);sle(s,o),lle(s);let a=r?.idleTimeout;return a&&a>0&&cle(s,a),s},ole=(t,e)=>{let r={...ile,...e},n=Zce(t,r);return sle(n,r),lle(n),e?.idleTimeout&&e.idleTimeout>0&&cle(n,e.idleTimeout),n},bHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},sle=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||fs.env.NETLIFY_LOCAL_QUIET==="true")return;if(fs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Iy).pipe(fs.stdout),t.stderr?.pipe(new Iy).pipe(fs.stderr);return}t.stdout?.pipe(fs.stdout),t.stderr?.pipe(fs.stderr)},mF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(fs.kill(-t.pid,e),Bp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bp.error("Error killing process:",r),!1}},ale=t=>mF(t,"SIGKILL"),cle=(t,e)=>{let r=null,n=()=>{Bp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),mF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bp.log(`Force killing idle process ${t.pid}`),ale(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},lle=t=>{hF.add(t);let e=rle();if(e){let r=e.onTimesUp(()=>{Bp.log(`Global timer expired, killing process ${t.pid}`),mF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bp.log(`Force killing process ${t.pid} after timeout`),ale(t))},5e3)});t.on("exit",()=>{hF.delete(t),r()}),t.on("error",()=>{hF.delete(t),r()})}};function ps(t,e){if(!fs.env.NETLIFY_LOCAL_MODE)try{let i=THe.resolve(nle.name),o=ya.dirname(i);for(;o!==ya.dirname(o);){let s=ya.dirname(o);if(ya.basename(s)==="node_modules"){let a=ya.join(s,".bin",e);if(qR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(fs.env.NODE_PATH){let i=ya.join(fs.env.NODE_PATH,".bin",e);if(qR.existsSync(i))return i}let r=ya.join(t,"node_modules",".bin",e);if(qR.existsSync(r))return r;let n=ya.join(vHe,"..","node_modules",".bin",e);if(qR.existsSync(n))return n}var ule=ne("repo"),hle="runner-diffs-",HR=t=>`${hle}${t}-`,mle=async t=>{let e=ple.tmpdir(),r;try{r=await GR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(hle)&&!n.startsWith(HR(t))).map(n=>GR.rm(VR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},tr=(t,e={})=>Lt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),WR=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{ule.info("Getting runner diffs");let n=await SF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=vF(o);await OHe(l,r)}ule.info("Changes after processing"),await yF(r);let s=await tS(o,r);if(await _F(s,r),i=await CHe(r),!i)return{hasChanges:!1,ignored:s};await tr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await GR.mkdtemp(VR.join(ple.tmpdir(),HR(t.sessionId))),c=await gF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await xHe(r),c.hasChanges&&H.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},gF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=VR.join(e,h);await tr([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:v}=await GR.stat(g);return{path:g,size:v}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await fle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await fle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},dle=async t=>{let e=wHe("sha256");for await(let r of AHe(t))e.update(r);return e.digest("hex")},fle=async(t,e)=>t.size===e.size&&await dle(t.path)===await dle(e.path),xHe=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await tr(["reset","--soft","HEAD~1"],{cwd:t})},_F=async(t=[],e=process.cwd())=>{await tr(["add",".",...t],{cwd:e})},yF=async(t=process.cwd())=>{let e=await tr(["status","-s"],{cwd:t});return String(e.stdout??"")},gle=/.. (.+)?\.log$/,RHe=[gle],SF=async(t=process.cwd())=>{let e=await yF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
144
144
  `).filter(i=>RHe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},CHe=async(t=process.cwd())=>{try{return await tr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},EF=async(t=process.cwd())=>{let{stdout:e}=await tr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},IHe=1,PHe=async t=>{try{return await tr(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===IHe)return!1;throw e}},_le=async(t=process.cwd())=>{if(!await PHe(t))return!0;let{stdout:e}=await tr(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},yle=async(t=process.cwd())=>{let{stdout:e}=await tr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},tS=async(t,e=process.cwd())=>{t||=await yF(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
145
145
  `).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${VR.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(gle)?.[1];o&&n.push(`:!${o}.log`)}),n},Sle=async(t=process.cwd())=>{await tr(["reset","--hard","HEAD"],{cwd:t})},Ele=async(t=process.cwd())=>{let e=await tr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
146
146
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},vF=t=>{let e=t.split(`
@@ -342,7 +342,7 @@ NETLIFY_BUILD_BASE="\${NETLIFY_BUILD_BASE:-${xQe}}" ${e} ${r} <template-id> [--p
342
342
  Replace \`<template-id>\` with the matching template \`id\`. Include \`--package-manager\` only if the user specified one. The templates can include relevant agent skills. The \`NETLIFY_BUILD_BASE=\u2026\` prefix lets the scaffold use a local template mirror if the platform set one \u2014 leave it as-is. Follow the instructions printed by the scaffold command.`:"",a="You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",c=[a,s,wQe];return n?c=[a,AQe,s]:i&&(c=[a,TQe,s]),c.filter(Boolean).join(`
343
343
 
344
344
  `)},PQe=t=>{try{return JSON.parse(fQe(zE.join(t,".netlify","scaffold-result.json"),"utf8"))}catch{return}},Uge=async t=>{let e=PQe(t);await Ot(at(),"create-scaffold-telemetry",r=>{r?.setAttributes({"create.template":e?.template??"none","create.packageManager":e?.packageManager??"none"})})},Fge=async({config:t,cwd:e=zI.cwd()})=>await Ot(at(),"create-stage",async r=>{let n=performance.now();r?.setAttributes({"create.runner":t.runner,"create.id":t.id,"create.sessionId":t.sessionId}),await Dge(e,[".netlify",".git","node_modules"]),_d.info("Cleaned cwd folder");let{nodeCmd:i,tsCliPath:o}=RQe({cwd:e}),s=[];if(o){let f=[o,"--list-addons-json"];_d.log(`Running ${i} ${f.join(" ")}`);let{stdout:p}=await Lt(i,f);s=CQe(p),_d.info("Retrieved add-ons")}else _d.warn("ts-cli binary not resolved; create-mode prompt will omit template section"),H.inc("context.degraded",1,{component:"templates"});let a=d4(t),c=a==="budget_constrained",l=a==="ask_first";l&&_d.log("Low budget create run - Instructing the agent to ask for clarity if necessary",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),H.inc("create.low_budget_limit_ask",1,{ask_first:l}),c&&_d.log("Budget-constrained create run \u2014 using plan + first-milestone instructions",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),H.inc("create.budget_constrained",1,{constrained:c});let u=IQe({templates:s,nodeCmd:i,scaffoldScriptPath:hQe,budgetConstrained:c,askUserClarity:l}),d=performance.now()-n;return r?.setAttributes({"create.duration.ms":d,"create.status":"success","create.budget_constrained":c,"create.ask_user_clarity":l}),{additionalContext:u}});var Na={Task:{name:"Task",category:V.Task},Agent:{name:"Task",category:V.Task},SendMessage:{name:"Message agent",category:V.Task},TaskOutput:{name:"Get task output",category:V.Task},TaskStop:{name:"Stop task",category:V.Task},TaskCreate:{name:"Update task list",category:V.Todo},TaskUpdate:{name:"Update task list",category:V.Todo},TaskList:{name:"Read task list",category:V.Todo},TaskGet:{name:"Read task list",category:V.Todo},ToolSearch:{name:"Load tools",category:V.Explore},Skill:{name:"Use skill",category:V.Skill},EnterPlanMode:{name:"Start planning",category:V.Plan},ListMcpResources:{name:"List resources",category:V.Explore},ReadMcpResource:{name:"Read resource",category:V.Explore},Bash:{name:"Run command",category:V.RunCommand},Glob:{name:"Find files",category:V.Explore},Grep:{name:"Search files",category:V.Explore},LS:{name:"List directory",category:V.Explore},ExitPlanMode:{name:"Exit planning",category:V.Plan},Read:{name:"Read file",category:V.FileRead},Edit:{name:"Edit file",category:V.FileWrite},MultiEdit:{name:"Edit multiple files",category:V.FileWrite},Write:{name:"Edit file",category:V.FileWrite},NotebookEdit:{name:"Edit notebook",category:V.Notebook},WebFetch:{name:"Fetch web",category:V.Web},TodoWrite:{name:"Update task list",category:V.Todo},WebSearch:{name:"Search web",category:V.Web},BashOutput:{name:"Get command output",category:V.RunCommand},KillBash:{name:"Stop command",category:V.RunCommand}},jE=t=>{if(Na[t])return Na[t].name;let e=t.match(/^mcp__(.+?)__(.+)$/);return e?`${e[2].replace(/_/g," ")} (${e[1]})`:t},m4=t=>t==="Task"||t==="Agent",zge=t=>{let[e=""]=t.split(`
345
- `,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},jge=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var Yr=ne("runner_claude"),BE="Claude Code",qge="claude-opus-5",g4="claude-sonnet-5",NQe={[x1]:"claude-sonnet-5"};async function kQe({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else if(r)await t.isModelAvailableForProvider("anthropic",r)||(Yr.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),H.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0);else{let i=NQe[e.accountType],o=i||qge;!!o&&await t.isModelAvailableForProvider("anthropic",o)?(Yr.log(`Using ${i?"account override":"default"} model: ${o}`),n=o):o&&Yr.log(`Model ${o} is not available, proceeding without model specification`)}return n}function MQe({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...Qh.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!Qh.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...Qh.env}}async function DQe(){let t=qE.join(Qh.cwd(),"AGENTS.md");try{await Xh.access(t)}catch{return}let e=qE.join(Qh.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await Xh.readFile(e,"utf-8")).includes(r))return;await Xh.appendFile(e,`
345
+ `,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},jge=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var Yr=ne("runner_claude"),BE="Claude Code",qge="claude-opus-5-5",g4="claude-sonnet-5",NQe={[x1]:"claude-sonnet-5"};async function kQe({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else if(r)await t.isModelAvailableForProvider("anthropic",r)||(Yr.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),H.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0);else{let i=NQe[e.accountType],o=i||qge;!!o&&await t.isModelAvailableForProvider("anthropic",o)?(Yr.log(`Using ${i?"account override":"default"} model: ${o}`),n=o):o&&Yr.log(`Model ${o} is not available, proceeding without model specification`)}return n}function MQe({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...Qh.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!Qh.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...Qh.env}}async function DQe(){let t=qE.join(Qh.cwd(),"AGENTS.md");try{await Xh.access(t)}catch{return}let e=qE.join(Qh.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await Xh.readFile(e,"utf-8")).includes(r))return;await Xh.appendFile(e,`
346
346
  ${r}
347
347
  `)}catch{await Xh.writeFile(e,`${r}
348
348
  `)}Yr.log("Added @AGENTS.md import to CLAUDE.local.md")}async function _4({config:t,persistSteps:e,aiGateway:r,continueSession:n,priorAgentSessionId:i,cwd:o=Qh.cwd(),cliPath:s="netlify",abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let u=t,{prompt:d}=u,{model:f}=t,p="";await DQe();let h=MQe({aiGateway:r}),m=await kQe({config:t,aiGateway:r,model:f});l&&m?.includes("fable")&&(!r||await r.isModelAvailableForProvider("anthropic",g4))&&(Yr.log(`Credit wrap-up: downgrading model ${m} to ${g4}`),m=g4);let g=[],_=[],v={},b=new Set,w=[],T=st=>st?.match(/task\s+#([\w-]+)\s+created/i)?.[1],A=st=>{if(typeof st=="string")return st;if(Array.isArray(st))return st.filter(Ze=>Ze?.type==="text"&&typeof Ze.text=="string").map(Ze=>Ze.text).join(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/agent-runner-cli",
3
3
  "type": "module",
4
- "version": "1.182.0",
4
+ "version": "1.183.0",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",