@netlify/agent-runner-cli 1.169.0 → 1.169.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -621,7 +621,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
621
621
  `,LF:`
622
622
  `,concatBytes:aY},FTt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},jTt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:FTt};import{Buffer as zTt}from"buffer";var WRe=(t,e)=>t?void 0:qTt.bind(void 0,e),qTt=function*(t,e){if(typeof e!="string"&&!Zr(e)&&!zTt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},YRe=(t,e)=>t?BTt.bind(void 0,e):HTt.bind(void 0,e),BTt=function*(t,e){KRe(t,e),yield e},HTt=function*(t,e){if(KRe(t,e),typeof e!="string"&&!Zr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},KRe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
623
623
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
624
- if (condition) { yield value; }`)};import{Buffer as VTt}from"buffer";import{StringDecoder as GTt}from"string_decoder";var QN=(t,e,r)=>{if(r)return;if(t)return{transform:WTt.bind(void 0,new TextEncoder)};let n=new GTt(e);return{transform:YTt.bind(void 0,n),final:KTt.bind(void 0,n)}},WTt=function*(t,e){VTt.isBuffer(e)?yield Xc(e):typeof e=="string"?yield t.encode(e):yield e},YTt=function*(t,e){yield Zr(e)?t.write(e):e},KTt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as JRe}from"util";var lY=JRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),ek=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=ZTt}=e[r];for await(let i of n(t))yield*ek(i,e,r+1)},ZRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*JTt(r,Number(e),t)},JTt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*ek(n,r,e+1)},XRe=JRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),ZTt=function*(t){yield t};var uY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},QRe=(t,e)=>[...e.flatMap(r=>[...Ep(r,t,0)]),...HT(t)],Ep=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QTt}=e[r];for(let i of n(t))yield*Ep(i,e,r+1)},HT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XTt(r,Number(e),t)},XTt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Ep(n,r,e+1)},QTt=function*(t){yield t};var dY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=t0e(t,o,s),l=Sp(e),u=Sp(r),d=l?lY.bind(void 0,ek,a):uY.bind(void 0,Ep),f=l||u?lY.bind(void 0,ZRe,a):uY.bind(void 0,HT),p=l||u?XRe.bind(void 0,a):void 0;return{stream:new ewt({writableObjectMode:n,writableHighWaterMark:e0e(n),readableObjectMode:i,readableHighWaterMark:e0e(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},tk=(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=t0e(o,r,a);t=QRe(c,t)}return t},t0e=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:WRe(n,a)},QN(r,o,n),XN(r,s,n,c),{transform:t,final:e},{transform:YRe(i,a)},GRe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var r0e=(t,e)=>{for(let r of twt(t))rwt(t,r,e)},twt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),rwt=(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 ${rd[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>nwt(a,n));r.input=$T(o)},nwt=(t,e)=>{let r=tk(t,e,"utf8",!0);return iwt(r),$T(r)},iwt=t=>{let e=t.find(r=>typeof r!="string"&&!Zr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as cwt,appendFileSync as lwt}from"fs";var rk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&b_(r,n)&&!us.has(e)&&swt(n)&&(t.some(({type:i,value:s})=>i==="native"&&owt.has(s))||t.every(({type:i})=>Ws.has(i))),swt=t=>t===1||t===2,owt=new Set(["pipe","overlapped"]),n0e=async(t,e,r,n)=>{for await(let i of t)awt(e)||s0e(i,r,n)},i0e=(t,e,r)=>{for(let n of t)s0e(n,e,r)},awt=t=>t._readableState.pipes.length>0,s0e=(t,e,r)=>{let n=gN(t);Ia({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var o0e=({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)=>uwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},uwt=({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=aRe(t,s,d),p=Xc(f),{stdioItems:h,objectMode:m}=e[r],_=dwt([p],h,c,n),{serializedResult:y,finalResult:v=y}=fwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});pwt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&hwt(y,h,i),S}catch(g){return n.error=g,S}},dwt=(t,e,r,n)=>{try{return tk(t,e,r,!1)}catch(i){return n.error=i,t}},fwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:$T(t)};let o=vbe(t,r);return n[s]?{serializedResult:o,finalResult:cY(o,!i[s],e)}:{serializedResult:o}},pwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!rk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=cY(t,!1,o);try{i0e(a,e,n)}catch(c){r.error??=c}},hwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>JN.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?lwt(n,t):(r.add(s),cwt(n,t))}};var a0e=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,tl(e,r,"all")]:Array.isArray(e)?[tl(t,r,"all"),...e]:Zr(t)&&Zr(e)?_W([t,e]):`${t}${e}`};import{once as fY}from"events";var c0e=async(t,e)=>{let[r,n]=await mwt(t);return e.isForcefullyTerminated??=!1,[r,n]},mwt=async t=>{let[e,r]=await Promise.allSettled([fY(t,"spawn"),fY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?l0e(t):r.value},l0e=async t=>{try{return await fY(t,"exit")}catch{return l0e(t)}},u0e=async t=>{let[e,r]=await t;if(!gwt(e,r)&&pY(e,r))throw new xo;return[e,r]},gwt=(t,e)=>t===void 0&&e===void 0,pY=(t,e)=>t!==0||e!==null;var d0e=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=_wt(t,e,r),o=s?.code==="ETIMEDOUT",a=oRe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},_wt=(t,e,r)=>t!==void 0?t:pY(e,r)?new xo:void 0;var f0e=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Swt(t,e,r),d=bwt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return N_(d,c,l)},Swt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=yN(t,e,r),a=Ewt(r),{file:c,commandArguments:l,options:u}=UN(t,e,a);vwt(u);let d=qRe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Ewt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vwt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&nk("ipcInput"),t&&nk("ipc: true"),r&&nk("detached: true"),n&&nk("cancelSignal")},nk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},bwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Twt({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}=d0e(c,r),{output:h,error:m=l}=o0e({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>tl(v,r,S)),y=tl(a0e(h,r),r,"all");return Rwt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Twt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{r0e(s,r);let a=wwt(r);return ywt(...FN(t,e,a))}catch(a){return O_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},wwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:GN(e)}),Rwt=({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?WN({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):BT({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 f0t}from"events";import{spawn as p0t}from"child_process";import _0e from"process";import{once as hY,on as Awt}from"events";var p0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(R_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:NN(t)}),xwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),xwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{PN(e,i);let s=td(t,e,r),o=new AbortController;try{return await Promise.race([Pwt(s,n,o),Cwt(s,r,o),Iwt(s,r,o)])}catch(a){throw A_(t),a}finally{o.abort(),CN(e,i)}},Pwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await hY(t,"message",{signal:r});return n}for await(let[n]of Awt(t,"message",{signal:r}))if(e(n))return n},Cwt=async(t,e,{signal:r})=>{await hY(t,"disconnect",{signal:r}),QTe(e)},Iwt=async(t,e,{signal:r})=>{let[n]=await hY(t,"strict:error",{signal:r});throw RN(n,e)};import{once as m0e,on as Owt}from"events";var g0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>mY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),mY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{R_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:NN(t)}),PN(e,s);let o=td(t,e,r),a=new AbortController,c={};return Nwt(t,o,a),kwt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),$wt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Nwt=async(t,e,r)=>{try{await m0e(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kwt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await m0e(t,"strict:error",{signal:r.signal});n.error=RN(i,e),r.abort()}catch{}},$wt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Owt(r,"message",{signal:s.signal}))h0e(o),yield c}catch{h0e(o)}finally{s.abort(),CN(e,a),n||A_(t),i&&await t}},h0e=({error:t})=>{if(t)throw t};var y0e=(t,{ipc:e})=>{Object.assign(t,E0e(t,!1,e))},S0e=()=>{let t=_0e,e=!0,r=_0e.channel!==void 0;return{...E0e(t,e,r),getCancelSignal:Awe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},E0e=(t,e,r)=>({sendMessage:DN.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:p0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:g0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Lwt}from"child_process";import{PassThrough as Dwt,Readable as Mwt,Writable as Uwt,Duplex as Fwt}from"stream";var v0e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{sY(n);let a=new Lwt;jwt(a,n),Object.assign(a,{readable:zwt,writable:qwt,duplex:Bwt});let c=O_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Hwt(c,o,i);return{subprocess:a,promise:l}},jwt=(t,e)=>{let r=VT(),n=VT(),i=VT(),s=Array.from({length:e.length-3},VT),o=VT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},VT=()=>{let t=new Dwt;return t.end(),t},zwt=()=>new Mwt({read(){}}),qwt=()=>new Uwt({write(){}}),Bwt=()=>new Fwt({read(){},write(){}}),Hwt=async(t,e,r)=>N_(t,e,r);import{createReadStream as b0e,createWriteStream as T0e}from"fs";import{Buffer as Vwt}from"buffer";import{Readable as GT,Writable as Gwt,Duplex as Wwt}from"stream";var R0e=(t,e)=>ZN(Ywt,t,e,!1),WT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${rd[t]}.`)},w0e={fileNumber:WT,generator:dY,asyncGenerator:dY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Wwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Ywt={input:{...w0e,fileUrl:({value:t})=>({stream:b0e(t)}),filePath:({value:{file:t}})=>({stream:b0e(t)}),webStream:({value:t})=>({stream:GT.fromWeb(t)}),iterable:({value:t})=>({stream:GT.from(t)}),asyncIterable:({value:t})=>({stream:GT.from(t)}),string:({value:t})=>({stream:GT.from(t)}),uint8Array:({value:t})=>({stream:GT.from(Vwt.from(t))})},output:{...w0e,fileUrl:({value:t})=>({stream:T0e(t)}),filePath:({value:{file:t,append:e}})=>({stream:T0e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Gwt.fromWeb(t)}),iterable:WT,asyncIterable:WT,string:WT,uint8Array:WT}};import{on as Kwt,once as A0e}from"events";import{PassThrough as Jwt,getDefaultHighWaterMark as Zwt}from"stream";import{finished as C0e}from"stream/promises";function vp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)_Y(i);let e=t.some(({readableObjectMode:i})=>i),r=Xwt(t,e),n=new gY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Xwt=(t,e)=>{if(t.length===0)return Zwt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},gY=class extends Jwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(_Y(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Qwt(this,this.#e,this.#s);let r=rRt({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(_Y(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)=>{ik(t,x0e);let n=new AbortController;try{await Promise.race([eRt(t,n),tRt(t,e,r,n)])}finally{n.abort(),ik(t,-x0e)}},eRt=async(t,{signal:e})=>{try{await C0e(t,{signal:e,cleanup:!0})}catch(r){throw I0e(t,r),r}},tRt=async(t,e,r,{signal:n})=>{for await(let[i]of Kwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},_Y=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},rRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{ik(t,P0e);let a=new AbortController;try{await Promise.race([nRt(s,e,a),iRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),sRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),ik(t,-P0e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?yY(t):oRt(t))},nRt=async(t,e,{signal:r})=>{try{await t,r.aborted||yY(e)}catch(n){r.aborted||I0e(e,n)}},iRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await C0e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;O0e(o)?i.add(e):N0e(t,o)}},sRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await A0e(t,i,{signal:s}),!t.readable)return A0e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},oRt=t=>{t.writable&&t.end()},I0e=(t,e)=>{O0e(e)?yY(t):N0e(t,e)},O0e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yY=t=>{(t.readable||t.writable)&&t.destroy()},N0e=(t,e)=>{t.destroyed||(t.once("error",aRt),t.destroy(e))},aRt=()=>{},ik=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},x0e=2,P0e=1;import{finished as k0e}from"stream/promises";var $_=(t,e)=>{t.pipe(e),cRt(t,e),lRt(t,e)},cRt=async(t,e)=>{if(!(Ao(t)||Ao(e))){try{await k0e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}SY(e)}},SY=t=>{t.writable&&t.end()},lRt=async(t,e)=>{if(!(Ao(t)||Ao(e))){try{await k0e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}EY(t)}},EY=t=>{t.readable&&t.destroy()};var $0e=(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})=>Ws.has(c)))uRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ws.has(c)))fRt({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]:vp(s);$_(o,i)}},uRt=(t,e,r,n)=>{r==="output"?$_(t.stdio[n],e):$_(e,t.stdio[n]);let i=dRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},dRt=["stdin","stdout","stderr"],fRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;pRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},pRt=(t,{signal:e})=>{Ao(t)&&_p(t,hRt,e)},hRt=2;import{addAbortListener as _Rt}from"events";var bp=[];bp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&bp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&bp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var sk=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",vY=Symbol.for("signal-exit emitter"),bY=globalThis,mRt=Object.defineProperty.bind(Object),TY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(bY[vY])return bY[vY];mRt(bY,vY,{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}},ok=class{},gRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),wY=class extends ok{onExit(){return()=>{}}load(){}unload(){}},RY=class extends ok{#e=AY.platform==="win32"?"SIGINT":"SIGHUP";#r=new TY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of bp)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(!sk(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 bp)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,bp.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 sk(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"&&sk(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)}},AY=globalThis.process,{onExit:L0e,load:Jgr,unload:Zgr}=gRt(sk(AY)?new RY(AY):new wY);var D0e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=L0e(()=>{t.kill()});_Rt(n,()=>{i()})};var U0e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=_N(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=yRt(r,n,i),{sourceStream:d,sourceError:f}=ERt(t,l),{options:p,fileDescriptors:h}=Na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},yRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=SRt(t,e,...r),a=xN(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},SRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(M0e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||mW(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]=aN(r,...n);return{destination:e(M0e)(i,s,o),pipeOptions:o}}if(Na.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}`)},M0e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),ERt=(t,e)=>{try{return{sourceStream:x_(t,e)}}catch(r){return{sourceError:r}}};var j0e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=vRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw xY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},vRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return EY(t),n;if(e!==void 0)return SY(r),e},xY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>O_({error:t,command:F0e,escapedCommand:F0e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),F0e="source.pipe(destination)";var z0e=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 bRt}from"stream/promises";var q0e=(t,e,r)=>{let n=ak.has(e)?wRt(t,e):TRt(t,e);return _p(t,ARt,r.signal),_p(e,xRt,r.signal),RRt(e),n},TRt=(t,e)=>{let r=vp([t]);return $_(r,e),ak.set(e,r),r},wRt=(t,e)=>{let r=ak.get(e);return r.add(t),r},RRt=async t=>{try{await bRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ak.delete(t)},ak=new WeakMap,ARt=2,xRt=1;import{aborted as PRt}from"util";var B0e=(t,e)=>t===void 0?[]:[CRt(t,e)],CRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await PRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw xY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ck=(t,...e)=>{if(Dr(e[0]))return ck.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=U0e(t,...e),i=IRt({...n,destination:r});return i.pipe=ck.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},IRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=ORt(t,i);j0e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=q0e(e,s,d);return await Promise.race([z0e(u),...B0e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},ORt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as URt}from"timers/promises";import{on as NRt}from"events";import{getDefaultHighWaterMark as kRt}from"stream";var lk=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return $Rt(e,o),V0e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},$Rt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},PY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;LRt(e,o,t);let a=t.readableObjectMode&&!s;return V0e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},LRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},V0e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=NRt(t,"data",{signal:e.signal,highWaterMark:H0e,highWatermark:H0e});return DRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},CY=kRt(!0),H0e=CY,DRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=MRt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Ep(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*HT(a)}},MRt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[QN(t,r,!e),XN(t,i,!n,{})].filter(Boolean);var G0e=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=FRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([jRt(t),d]);return}let f=oY(c,r),p=PY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},FRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!rk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=PY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await n0e(a,t,r,s)},jRt=async t=>{await URt(),t.readableFlowing===null&&t.resume()},zRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await BN(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await HN(r,{maxBuffer:s})):await I_(r,{maxBuffer:s})}catch(a){return W0e(nRe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},IY=async t=>{try{return await t}catch(e){return W0e(e)}},W0e=({bufferedData:t})=>Sbe(t)?new Uint8Array(t):t;import{finished as qRt}from"stream/promises";var YT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=BRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],qRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||GRt(a,e,r,n)}finally{o.abort()}},BRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&HRt(t,r,n),n},HRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{VRt(e,r),n.call(t,...i)}},VRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},GRt=(t,e,r,n)=>{if(!WRt(t,e,r,n))throw t},WRt=(t,e,r,n=!0)=>r.propagating?Y0e(t)||uk(t):(r.propagating=!0,OY(r,e)===n?Y0e(t):uk(t)),OY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",uk=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y0e=t=>t?.code==="EPIPE";var K0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>NY({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),NY=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=YT(t,e,l);if(OY(l,e)){await u;return}let[d]=await Promise.all([G0e({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 J0e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?vp([t,e].filter(Boolean)):void 0,Z0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>NY({...YRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:KRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),YRt=({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}},KRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as JRt}from"events";var X0e=t=>b_(t,"ipc"),Q0e=(t,e)=>{let r=gN(t);Ia({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var eAe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=X0e(s),a=Qc(e,"ipc"),c=Qc(r,"ipc");for await(let l of mY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(iRe(t,i,c),i.push(l)),o&&Q0e(l,s);return i},tAe=async(t,e)=>(await Promise.allSettled([t]),e);var rAe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=c0e(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=K0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=Z0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),x=[],R=eAe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),b=ZRt(m,t,S),P=XRt(h,S);try{return await Promise.race([Promise.all([{},u0e(v),Promise.all(g),w,R,Dwe(t,d),...b,...P]),_,QRt(t,y),...Owe(t,s,f,y),...XTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Cwe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(O){return f.terminationReason??="other",Promise.all([{error:O},v,Promise.all(g.map(A=>IY(A))),IY(w),tAe(R,x),Promise.allSettled(b),Promise.allSettled(P)])}},ZRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:YT(n,i,r)),XRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Co(s,{checkOpen:!1})&&!Ao(s)).map(({type:i,value:s,stream:o=s})=>YT(o,n,e,{isSameDirection:Ws.has(i),stopOnExit:i==="native"}))),QRt=async(t,{signal:e})=>{let[r]=await JRt(t,"error",{signal:e});throw r};var nAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),KT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Oa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},L_=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 e0t}from"stream";import{callbackify as t0t}from"util";import{finished as iAe}from"stream/promises";var kY=async t=>{if(t!==void 0)try{await $Y(t)}catch{}},sAe=async t=>{if(t!==void 0)try{await LY(t)}catch{}},$Y=async t=>{await iAe(t,{cleanup:!0,readable:!1,writable:!0})},LY=async t=>{await iAe(t,{cleanup:!0,readable:!0,writable:!1})},dk=async(t,e)=>{if(await t,e)throw e},fk=(t,e,r)=>{r&&!uk(r)?t.destroy(r):e&&t.destroy()};var oAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||us.has(r),{subprocessStdout:a,waitReadableDestroy:c}=DY(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=MY(a,o),{read:f,onStdoutDataDone:p}=UY({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new e0t({read:f,destroy:t0t(jY.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return FY({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},DY=(t,e,r)=>{let n=x_(t,e),i=KT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},MY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:CY},UY=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Oa(),o=lk({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){r0t(this,o,s)},onStdoutDataDone:s}},r0t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},FY=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await LY(t),await n,await kY(i),await e,r.readable&&r.push(null)}catch(s){await kY(i),aAe(r,s)}},jY=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await L_(r,e)&&(aAe(t,n),await dk(e,n))},aAe=(t,e)=>{fk(t,t.readable,e)};import{Writable as n0t}from"stream";import{callbackify as cAe}from"util";var lAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=zY(t,r,e),o=new n0t({...qY(n,t,i),destroy:cAe(HY.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return BY(n,o),o},zY=(t,e,r)=>{let n=xN(t,e),i=KT(r,n,"writableFinal"),s=KT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},qY=(t,e,r)=>({write:i0t.bind(void 0,t),final:cAe(s0t.bind(void 0,t,e,r))}),i0t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},s0t=async(t,e,r)=>{await L_(r,e)&&(t.writable&&t.end(),await e)},BY=async(t,e,r)=>{try{await $Y(t),e.writable&&e.end()}catch(n){await sAe(r),uAe(e,n)}},HY=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await L_(r,e),await L_(n,e)&&(uAe(t,i),await dk(e,i))},uAe=(t,e)=>{fk(t,t.writable,e)};import{Duplex as o0t}from"stream";import{callbackify as a0t}from"util";var dAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||us.has(r),{subprocessStdout:c,waitReadableDestroy:l}=DY(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=zY(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=MY(c,a),{read:_,onStdoutDataDone:y}=UY({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new o0t({read:_,...qY(u,t,d),destroy:a0t(c0t.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 FY({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),BY(u,v,c),v},c0t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([jY({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),HY({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var VY=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||us.has(e),o=x_(t,r),a=lk({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return l0t(a,o,t)},l0t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var fAe=(t,{encoding:e})=>{let r=nAe();t.readable=oAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=lAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=dAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=VY.bind(void 0,t,e),t[Symbol.asyncIterator]=VY.bind(void 0,t,e,{})};var pAe=(t,e)=>{for(let[r,n]of d0t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},u0t=(async()=>{})().constructor.prototype,d0t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(u0t,t)]);var hAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=h0t(t,e,r),{subprocess:f,promise:p}=g0t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ck.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),pAe(f,p),Na.set(f,{options:u,fileDescriptors:d}),f},h0t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=yN(t,e,r),{file:a,commandArguments:c,options:l}=UN(t,e,r),u=m0t(l),d=R0e(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},m0t=({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}},g0t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=p0t(...FN(t,e,r))}catch(h){return v0e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;f0t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];$0e(c,a,l),D0e(c,r,l);let d={},f=Oa();c.kill=JTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=J0e(c,r),fAe(c,r),y0e(c,r);let p=_0t({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}},_0t=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 rAe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,w)=>tl(g,e,w)),v=tl(m,e,"all"),S=y0t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return N_(S,n,e)},y0t=({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?BT({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 ka,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):WN({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var pk=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,S0t(n,t[n],i)]));return{...t,...r}},S0t=(t,e,r)=>E0t.has(t)&&Dr(e)&&Dr(r)?{...e,...r}:r,E0t=new Set(["env",...vW]);var nd=(t,e,r,n)=>{let i=(o,a,c)=>nd(o,a,r,c),s=(...o)=>v0t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},v0t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Dr(s))return i(t,pk(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=b0t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?f0e(a,c,l):hAe(a,c,l,i)},b0t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Rbe(e)?Abe(e,r):[e,...r],[o,a,c]=aN(...s),l=pk(pk(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 mAe=({file:t,commandArguments:e})=>_Ae(t,e),gAe=({file:t,commandArguments:e})=>({..._Ae(t,e),isSync:!0}),_Ae=(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]=T0t(t);return{file:r,commandArguments:n}},T0t=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(w0t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},w0t=/ +/g;var yAe=(t,e,r)=>{t.sync=e(R0t,r),t.s=t.sync},SAe=({options:t})=>EAe(t),R0t=({options:t})=>({...EAe(t),isSync:!0}),EAe=t=>({options:{...A0t(t),...t}}),A0t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},vAe={preferLocal:!0};var bAe=nd(()=>({})),jSr=nd(()=>({isSync:!0})),TAe=nd(mAe),zSr=nd(gAe),qSr=nd(kwe),BSr=nd(SAe,{},vAe,yAe),{sendMessage:HSr,getOneMessage:VSr,getEachMessage:GSr,getCancelSignal:WSr}=S0e();import{Transform as x0t}from"stream";var P0t=["NETLIFY_AI_GATEWAY_KEY"];function C0t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...P0t])]}function I0t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function O0t(){let e=C0t().map(r=>process.env[r]).filter(r=>!(!r||I0t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Hi(t){if(typeof t!="string")return t;let e=O0t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(N0t(n),"g");r=r.replace(i,"******")}),r}function N0t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var JT=class extends x0t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Hi(i);n(null,s)}},hk=Symbol("maskedWrite");function wAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[hk]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Hi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[hk]=!0,process.stdout.write=r}if(!process.stderr.write[hk]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Hi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[hk]=!0,process.stderr.write=r}}}var RAe=!1,AAe=()=>{RAe=!0},Vi=()=>RAe;var ZT=null,xAe=t=>(ZT&&ZT.destroy(),ZT=new Io({totalAllowedTime:t}),ZT),PAe=()=>ZT;var Io=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&&Vi())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 rN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{fe.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 CAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.169.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.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var D0t=$0t(import.meta.url),M0t=rl.dirname(D0t),U0t=L0t(import.meta.url),D_=he("shell"),GY=new Set,IAe={preferLocal:!0},$n=(t,e,r)=>{let[n,i]=F0t(e,r),s={...IAe,...i},o=bAe(t,n,s);NAe(o,s),LAe(o);let a=r?.idleTimeout;return a&&a>0&&$Ae(o,a),o},OAe=(t,e)=>{let r={...IAe,...e},n=TAe(t,r);return NAe(n,r),LAe(n),e?.idleTimeout&&e.idleTimeout>0&&$Ae(n,e.idleTimeout),n},F0t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},NAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||La.env.NETLIFY_LOCAL_QUIET==="true")return;if(La.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new JT).pipe(La.stdout),t.stderr?.pipe(new JT).pipe(La.stderr);return}t.stdout?.pipe(La.stdout),t.stderr?.pipe(La.stderr)},WY=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(La.kill(-t.pid,e),D_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return D_.error("Error killing process:",r),!1}},kAe=t=>WY(t,"SIGKILL"),$Ae=(t,e)=>{let r=null,n=()=>{D_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),WY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(D_.log(`Force killing idle process ${t.pid}`),kAe(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)},LAe=t=>{GY.add(t);let e=PAe();if(e){let r=e.onTimesUp(()=>{D_.log(`Global timer expired, killing process ${t.pid}`),WY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(D_.log(`Force killing process ${t.pid} after timeout`),kAe(t))},5e3)});t.on("exit",()=>{GY.delete(t),r()}),t.on("error",()=>{GY.delete(t),r()})}};function Da(t,e){if(!La.env.NETLIFY_LOCAL_MODE)try{let i=U0t.resolve(CAe.name),s=rl.dirname(i);for(;s!==rl.dirname(s);){let o=rl.dirname(s);if(rl.basename(o)==="node_modules"){let a=rl.join(o,".bin",e);if(mk.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(La.env.NODE_PATH){let i=rl.join(La.env.NODE_PATH,".bin",e);if(mk.existsSync(i))return i}let r=rl.join(t,"node_modules",".bin",e);if(mk.existsSync(r))return r;let n=rl.join(M0t,"..","node_modules",".bin",e);if(mk.existsSync(n))return n}import UM from"process";import{fileURLToPath as pFt}from"url";import{createRequire as hFt}from"module";import KR from"path";import{readFileSync as mFt}from"fs";var j0t="__netlify__getTracer",z0t="__netlify__shutdownTracers",Ct=(t,e)=>globalThis[j0t]?.(t,e),DAe=async()=>globalThis[z0t]?.();function XT(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 aFt}from"timers/promises";Ne();import qxt from"process";Ne();var dAt=(t,e)=>{e.recordException(t),e.setStatus({code:ni.ERROR})};var sl=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}=Cxe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>Ixe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Cxe(r,n,i),c=this._tracer.startSpan(e,s,o);return Ixe(c,s,a)}};function Cxe(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??rr.active(),{opts:n,ctx:i,fn:s}}function Ixe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:dAt,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)}}Ne();var B_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var xK=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=jxe(e),n._asyncAttributesPending=e.filter(([i,s])=>B_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(B_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=jxe(this._rawAttributes),this._schemaUrl=fAt(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,B_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ae.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(B_(n)){ae.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=pAt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function PK(t,e){return xK.FromAttributeList(Object.entries(t),e)}function jxe(t){return t.map(([e,r])=>B_(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function fAt(t){if(typeof t=="string"||t===void 0)return t;ae.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function pAt(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;ae.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var uw=class{emit(e){}enabled(){return!1}},zxe=new uw;var dw=Symbol.for("io.opentelemetry.js.api.logs"),H_=globalThis;function qxe(t,e,r){return n=>n===t?e:r}var CK=1;var IK=class{getLogger(e,r,n){return new uw}},Uk=new IK;var Fk=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):zxe}};var fw=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new Fk(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Uk}_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 jk=class t{constructor(){this._proxyLoggerProvider=new fw}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return H_[dw]?this.getLoggerProvider():(H_[dw]=qxe(CK,e,Uk),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=H_[dw])===null||e===void 0?void 0:e.call(H_,CK))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete H_[dw],this._proxyLoggerProvider=new fw}};var Bxe=jk.getInstance();function Hxe(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 Vxe(t){t.forEach(e=>e.disable())}function OK(t){let e=t.tracerProvider||jt.getTracerProvider(),r=t.meterProvider||lw.getMeterProvider(),n=t.loggerProvider||Bxe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Hxe(i,e,r,n),()=>{Vxe(i)}}Ne();var hAt=ln("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Gxe(t){return t.getValue(hAt)===!0}var V_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(V_||(V_={}));Ne();var NK="[_0-9a-z-*/]",mAt=`[a-z]${NK}{0,255}`,gAt=`[a-z0-9]${NK}{0,240}@[a-z]${NK}{0,13}`,_At=new RegExp(`^(?:${mAt}|${gAt})$`),yAt=/^[ -~]{0,255}[!-~]$/,SAt=/,|=/;function kK(t){return _At.test(t)}function $K(t){return yAt.test(t)&&!SAt.test(t)}var EAt=32,Wxe=512,Yxe=",",Kxe="=",zk=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!kK(e)||!$K(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>Wxe)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=Yxe+e),e=`${n[0]}${Kxe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(Yxe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Kxe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!kK(a)||!$K(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>Wxe)&&(r.set(a,c),n=l,r.size>=EAt))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 qk="traceparent",Bk="tracestate",vAt="00",bAt="(?!ff)[\\da-f]{2}",TAt="(?![0]{32})[\\da-f]{32}",wAt="(?![0]{16})[\\da-f]{16}",RAt="[\\da-f]{2}",AAt=new RegExp(`^\\s?(${bAt})-(${TAt})-(${wAt})-(${RAt})(-.*)?\\s?$`);function Jxe(t){let e=AAt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var od=class{inject(e,r,n){let i=jt.getSpanContext(e);if(!i||Gxe(e)||!Gi(i))return;let s=`${vAt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Cr.NONE).toString(16)}`;n.set(r,qk,s),i.traceState&&n.set(r,Bk,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,qk);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=Jxe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,Bk);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new zk(typeof c=="string"?c:void 0)}return jt.setSpanContext(e,o)}fields(){return[qk,Bk]}};var Hk=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 pw=class{_isCalled=!1;_deferred=new Hk;_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 L$=Yn(S5(),1);Ne();var NIe=t=>{throw TypeError(t)},T5=(t,e,r)=>e.has(t)||NIe("Cannot "+r),$$=(t,e,r)=>(T5(t,e,"read from private field"),r?r.call(t):e.get(t)),E5=(t,e,r)=>e.has(t)?NIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),CIe=(t,e,r,n)=>(T5(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),zxt=(t,e,r)=>(T5(t,e,"access private method"),r),IIe="__netlify__getTracer",Bxt="__netlify__shutdownTracers",Hxt="__nfOTLPTrace",Pw,Cw,b5,kIe,Vxt=class{constructor(){E5(this,b5),E5(this,Pw),E5(this,Cw),CIe(this,Pw,new pw(zxt(this,b5,kIe),this)),CIe(this,Cw,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if($$(this,Cw).debug(`export ${t.length.toString()} spans`),$$(this,Pw).isCalled){e({code:V_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Hxt,JSON.stringify(Gxt(t))),e({code:V_.SUCCESS})}shutdown(){return $$(this,Pw).call()}};Pw=new WeakMap;Cw=new WeakMap;b5=new WeakSet;kIe=function(){return $$(this,Cw).debug("Shutting down"),Promise.resolve()};function Gxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:k$(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||Oo.SERVER,startTimeUnixNano:v5(e.startTime),endTimeUnixNano:v5(e.endTime),attributes:k$(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:v5(n.time),attributes:k$(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:k$(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function k$(t){return Object.keys(t).map(e=>$Ie(e,t[e]))}function $Ie(t,e){return{key:t,value:LIe(e)}}function LIe(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(LIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>$Ie(r,n))}}:{}}function v5(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var OIe={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"}},DIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,IIe))return;let e=qxt.version.slice(1),r=PK({"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??[Wxt()],i=new L$.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new od});let s=t.instrumentations??[];OK({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,IIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new sl(jt.getTracer(a,c)):new sl(jt.getTracer(OIe.name,OIe.version))}}),Object.defineProperty(globalThis,Bxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Wxt=()=>new L$.SimpleSpanProcessor(new Vxt);Ne();var Iw=Yn(S5(),1);Ne();import*as D$ from"diagnostics_channel";var MIe=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?ni.ERROR:ni.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 sl?t:new sl(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){D$.subscribe(t,e);let r=()=>D$.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:Oo.CLIENT},rr.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:ni.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 aUe=Yn(sUe(),1);var DM=he("tracing"),oUe=8e3,cFt=5e3,YR=async(t=cFt)=>{try{await Promise.race([DAe(),aFt(t)])}catch(e){DM.warn("Failed to flush tracers on shutdown",e)}},cUe=async(t,e,r)=>{if(!Ct()){let n=[new Iw.SimpleSpanProcessor(new wX),new Iw.SimpleSpanProcessor(new aUe.OTLPTraceExporter({url:r.exporterUrl}))];await DIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new MIe({skipHeaders:!0})]})}return r.traceparent?(bi.setGlobalPropagator(new od),bi.extract(rr.active(),{traceparent:r.traceparent,isRemote:!0})):rr.active()};function sr(t,e,r){return DM.log(`\u23F3 TRACE: ${e} starting...`),XT(t,e,r)}var wX=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(", ")}]`:"";DM.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&DM.log(` \u274C Error: ${e.status.message}`)}};function RX(){return Je().captureLlmContentEnabled}function lUe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function MM(t,e,r){let n={role:t,parts:[{type:"text",content:Hi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var lFt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]);function uUe(t,e,r,n){if(!t.length)return;let i=Ct();if(!i)return;let s=RX(),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&&lFt.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>oUe?`${a.message.slice(0,oUe)}\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":Hi(_)}:{"gen_ai.output.messages":MM("assistant",_)}:{}}}).end(u)})}import{readdir as uFt,rm as dFt}from"fs/promises";import{join as fFt}from"path";async function dUe(t,e=[]){let n=(await uFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>dFt(fFt(t,i),{recursive:!0,force:!0})))}var ch=({mode:t,sessionCreditLimit:e})=>t==="create"&&e!=null&&e<=300;var AX=t=>{if(!ch(t))return"default";let e=Je();return e.createAskFirstEnabled&&e.questionsEnabled?"ask_first":e.creditWrapUpEnabled?"budget_constrained":"default"},fUe=t=>{let e=AX(t);return{budget_eligible:ch(t),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var gFt=KR.dirname(pFt(import.meta.url)),pUe=hFt(import.meta.url),_Ft=KR.resolve(gFt,"scripts/scaffold.js"),yFt="scripts/scaffold.js",SFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,xX=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},EFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),vFt=t=>{let e=xX(t);return e==="node"||e.endsWith("/node")},Cl=t=>{if(typeof t!="string")return!1;let e=t.match(SFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&EFt(xX(e[r]));)r+=1;if(r>=e.length||!vFt(e[r]))return!1;let n=e[r+1];return n?xX(n).includes(yFt):!1},lh=he("create_stage"),PX="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.",bFt=`${PX}
624
+ if (condition) { yield value; }`)};import{Buffer as VTt}from"buffer";import{StringDecoder as GTt}from"string_decoder";var QN=(t,e,r)=>{if(r)return;if(t)return{transform:WTt.bind(void 0,new TextEncoder)};let n=new GTt(e);return{transform:YTt.bind(void 0,n),final:KTt.bind(void 0,n)}},WTt=function*(t,e){VTt.isBuffer(e)?yield Xc(e):typeof e=="string"?yield t.encode(e):yield e},YTt=function*(t,e){yield Zr(e)?t.write(e):e},KTt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as JRe}from"util";var lY=JRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),ek=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=ZTt}=e[r];for await(let i of n(t))yield*ek(i,e,r+1)},ZRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*JTt(r,Number(e),t)},JTt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*ek(n,r,e+1)},XRe=JRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),ZTt=function*(t){yield t};var uY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},QRe=(t,e)=>[...e.flatMap(r=>[...Ep(r,t,0)]),...HT(t)],Ep=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QTt}=e[r];for(let i of n(t))yield*Ep(i,e,r+1)},HT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XTt(r,Number(e),t)},XTt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Ep(n,r,e+1)},QTt=function*(t){yield t};var dY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=t0e(t,o,s),l=Sp(e),u=Sp(r),d=l?lY.bind(void 0,ek,a):uY.bind(void 0,Ep),f=l||u?lY.bind(void 0,ZRe,a):uY.bind(void 0,HT),p=l||u?XRe.bind(void 0,a):void 0;return{stream:new ewt({writableObjectMode:n,writableHighWaterMark:e0e(n),readableObjectMode:i,readableHighWaterMark:e0e(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},tk=(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=t0e(o,r,a);t=QRe(c,t)}return t},t0e=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:WRe(n,a)},QN(r,o,n),XN(r,s,n,c),{transform:t,final:e},{transform:YRe(i,a)},GRe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var r0e=(t,e)=>{for(let r of twt(t))rwt(t,r,e)},twt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),rwt=(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 ${rd[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>nwt(a,n));r.input=$T(o)},nwt=(t,e)=>{let r=tk(t,e,"utf8",!0);return iwt(r),$T(r)},iwt=t=>{let e=t.find(r=>typeof r!="string"&&!Zr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as cwt,appendFileSync as lwt}from"fs";var rk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&b_(r,n)&&!us.has(e)&&swt(n)&&(t.some(({type:i,value:s})=>i==="native"&&owt.has(s))||t.every(({type:i})=>Ws.has(i))),swt=t=>t===1||t===2,owt=new Set(["pipe","overlapped"]),n0e=async(t,e,r,n)=>{for await(let i of t)awt(e)||s0e(i,r,n)},i0e=(t,e,r)=>{for(let n of t)s0e(n,e,r)},awt=t=>t._readableState.pipes.length>0,s0e=(t,e,r)=>{let n=gN(t);Ia({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var o0e=({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)=>uwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},uwt=({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=aRe(t,s,d),p=Xc(f),{stdioItems:h,objectMode:m}=e[r],_=dwt([p],h,c,n),{serializedResult:y,finalResult:v=y}=fwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});pwt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&hwt(y,h,i),S}catch(g){return n.error=g,S}},dwt=(t,e,r,n)=>{try{return tk(t,e,r,!1)}catch(i){return n.error=i,t}},fwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:$T(t)};let o=vbe(t,r);return n[s]?{serializedResult:o,finalResult:cY(o,!i[s],e)}:{serializedResult:o}},pwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!rk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=cY(t,!1,o);try{i0e(a,e,n)}catch(c){r.error??=c}},hwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>JN.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?lwt(n,t):(r.add(s),cwt(n,t))}};var a0e=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,tl(e,r,"all")]:Array.isArray(e)?[tl(t,r,"all"),...e]:Zr(t)&&Zr(e)?_W([t,e]):`${t}${e}`};import{once as fY}from"events";var c0e=async(t,e)=>{let[r,n]=await mwt(t);return e.isForcefullyTerminated??=!1,[r,n]},mwt=async t=>{let[e,r]=await Promise.allSettled([fY(t,"spawn"),fY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?l0e(t):r.value},l0e=async t=>{try{return await fY(t,"exit")}catch{return l0e(t)}},u0e=async t=>{let[e,r]=await t;if(!gwt(e,r)&&pY(e,r))throw new xo;return[e,r]},gwt=(t,e)=>t===void 0&&e===void 0,pY=(t,e)=>t!==0||e!==null;var d0e=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=_wt(t,e,r),o=s?.code==="ETIMEDOUT",a=oRe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},_wt=(t,e,r)=>t!==void 0?t:pY(e,r)?new xo:void 0;var f0e=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Swt(t,e,r),d=bwt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return N_(d,c,l)},Swt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=yN(t,e,r),a=Ewt(r),{file:c,commandArguments:l,options:u}=UN(t,e,a);vwt(u);let d=qRe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Ewt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vwt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&nk("ipcInput"),t&&nk("ipc: true"),r&&nk("detached: true"),n&&nk("cancelSignal")},nk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},bwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Twt({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}=d0e(c,r),{output:h,error:m=l}=o0e({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>tl(v,r,S)),y=tl(a0e(h,r),r,"all");return Rwt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Twt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{r0e(s,r);let a=wwt(r);return ywt(...FN(t,e,a))}catch(a){return O_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},wwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:GN(e)}),Rwt=({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?WN({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):BT({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 f0t}from"events";import{spawn as p0t}from"child_process";import _0e from"process";import{once as hY,on as Awt}from"events";var p0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(R_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:NN(t)}),xwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),xwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{PN(e,i);let s=td(t,e,r),o=new AbortController;try{return await Promise.race([Pwt(s,n,o),Cwt(s,r,o),Iwt(s,r,o)])}catch(a){throw A_(t),a}finally{o.abort(),CN(e,i)}},Pwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await hY(t,"message",{signal:r});return n}for await(let[n]of Awt(t,"message",{signal:r}))if(e(n))return n},Cwt=async(t,e,{signal:r})=>{await hY(t,"disconnect",{signal:r}),QTe(e)},Iwt=async(t,e,{signal:r})=>{let[n]=await hY(t,"strict:error",{signal:r});throw RN(n,e)};import{once as m0e,on as Owt}from"events";var g0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>mY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),mY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{R_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:NN(t)}),PN(e,s);let o=td(t,e,r),a=new AbortController,c={};return Nwt(t,o,a),kwt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),$wt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Nwt=async(t,e,r)=>{try{await m0e(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kwt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await m0e(t,"strict:error",{signal:r.signal});n.error=RN(i,e),r.abort()}catch{}},$wt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Owt(r,"message",{signal:s.signal}))h0e(o),yield c}catch{h0e(o)}finally{s.abort(),CN(e,a),n||A_(t),i&&await t}},h0e=({error:t})=>{if(t)throw t};var y0e=(t,{ipc:e})=>{Object.assign(t,E0e(t,!1,e))},S0e=()=>{let t=_0e,e=!0,r=_0e.channel!==void 0;return{...E0e(t,e,r),getCancelSignal:Awe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},E0e=(t,e,r)=>({sendMessage:DN.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:p0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:g0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Lwt}from"child_process";import{PassThrough as Dwt,Readable as Mwt,Writable as Uwt,Duplex as Fwt}from"stream";var v0e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{sY(n);let a=new Lwt;jwt(a,n),Object.assign(a,{readable:zwt,writable:qwt,duplex:Bwt});let c=O_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Hwt(c,o,i);return{subprocess:a,promise:l}},jwt=(t,e)=>{let r=VT(),n=VT(),i=VT(),s=Array.from({length:e.length-3},VT),o=VT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},VT=()=>{let t=new Dwt;return t.end(),t},zwt=()=>new Mwt({read(){}}),qwt=()=>new Uwt({write(){}}),Bwt=()=>new Fwt({read(){},write(){}}),Hwt=async(t,e,r)=>N_(t,e,r);import{createReadStream as b0e,createWriteStream as T0e}from"fs";import{Buffer as Vwt}from"buffer";import{Readable as GT,Writable as Gwt,Duplex as Wwt}from"stream";var R0e=(t,e)=>ZN(Ywt,t,e,!1),WT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${rd[t]}.`)},w0e={fileNumber:WT,generator:dY,asyncGenerator:dY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Wwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Ywt={input:{...w0e,fileUrl:({value:t})=>({stream:b0e(t)}),filePath:({value:{file:t}})=>({stream:b0e(t)}),webStream:({value:t})=>({stream:GT.fromWeb(t)}),iterable:({value:t})=>({stream:GT.from(t)}),asyncIterable:({value:t})=>({stream:GT.from(t)}),string:({value:t})=>({stream:GT.from(t)}),uint8Array:({value:t})=>({stream:GT.from(Vwt.from(t))})},output:{...w0e,fileUrl:({value:t})=>({stream:T0e(t)}),filePath:({value:{file:t,append:e}})=>({stream:T0e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Gwt.fromWeb(t)}),iterable:WT,asyncIterable:WT,string:WT,uint8Array:WT}};import{on as Kwt,once as A0e}from"events";import{PassThrough as Jwt,getDefaultHighWaterMark as Zwt}from"stream";import{finished as C0e}from"stream/promises";function vp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)_Y(i);let e=t.some(({readableObjectMode:i})=>i),r=Xwt(t,e),n=new gY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Xwt=(t,e)=>{if(t.length===0)return Zwt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},gY=class extends Jwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(_Y(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Qwt(this,this.#e,this.#s);let r=rRt({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(_Y(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)=>{ik(t,x0e);let n=new AbortController;try{await Promise.race([eRt(t,n),tRt(t,e,r,n)])}finally{n.abort(),ik(t,-x0e)}},eRt=async(t,{signal:e})=>{try{await C0e(t,{signal:e,cleanup:!0})}catch(r){throw I0e(t,r),r}},tRt=async(t,e,r,{signal:n})=>{for await(let[i]of Kwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},_Y=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},rRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{ik(t,P0e);let a=new AbortController;try{await Promise.race([nRt(s,e,a),iRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),sRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),ik(t,-P0e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?yY(t):oRt(t))},nRt=async(t,e,{signal:r})=>{try{await t,r.aborted||yY(e)}catch(n){r.aborted||I0e(e,n)}},iRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await C0e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;O0e(o)?i.add(e):N0e(t,o)}},sRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await A0e(t,i,{signal:s}),!t.readable)return A0e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},oRt=t=>{t.writable&&t.end()},I0e=(t,e)=>{O0e(e)?yY(t):N0e(t,e)},O0e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yY=t=>{(t.readable||t.writable)&&t.destroy()},N0e=(t,e)=>{t.destroyed||(t.once("error",aRt),t.destroy(e))},aRt=()=>{},ik=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},x0e=2,P0e=1;import{finished as k0e}from"stream/promises";var $_=(t,e)=>{t.pipe(e),cRt(t,e),lRt(t,e)},cRt=async(t,e)=>{if(!(Ao(t)||Ao(e))){try{await k0e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}SY(e)}},SY=t=>{t.writable&&t.end()},lRt=async(t,e)=>{if(!(Ao(t)||Ao(e))){try{await k0e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}EY(t)}},EY=t=>{t.readable&&t.destroy()};var $0e=(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})=>Ws.has(c)))uRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ws.has(c)))fRt({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]:vp(s);$_(o,i)}},uRt=(t,e,r,n)=>{r==="output"?$_(t.stdio[n],e):$_(e,t.stdio[n]);let i=dRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},dRt=["stdin","stdout","stderr"],fRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;pRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},pRt=(t,{signal:e})=>{Ao(t)&&_p(t,hRt,e)},hRt=2;import{addAbortListener as _Rt}from"events";var bp=[];bp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&bp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&bp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var sk=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",vY=Symbol.for("signal-exit emitter"),bY=globalThis,mRt=Object.defineProperty.bind(Object),TY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(bY[vY])return bY[vY];mRt(bY,vY,{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}},ok=class{},gRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),wY=class extends ok{onExit(){return()=>{}}load(){}unload(){}},RY=class extends ok{#e=AY.platform==="win32"?"SIGINT":"SIGHUP";#r=new TY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of bp)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(!sk(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 bp)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,bp.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 sk(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"&&sk(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)}},AY=globalThis.process,{onExit:L0e,load:Jgr,unload:Zgr}=gRt(sk(AY)?new RY(AY):new wY);var D0e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=L0e(()=>{t.kill()});_Rt(n,()=>{i()})};var U0e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=_N(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=yRt(r,n,i),{sourceStream:d,sourceError:f}=ERt(t,l),{options:p,fileDescriptors:h}=Na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},yRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=SRt(t,e,...r),a=xN(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},SRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(M0e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||mW(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]=aN(r,...n);return{destination:e(M0e)(i,s,o),pipeOptions:o}}if(Na.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}`)},M0e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),ERt=(t,e)=>{try{return{sourceStream:x_(t,e)}}catch(r){return{sourceError:r}}};var j0e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=vRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw xY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},vRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return EY(t),n;if(e!==void 0)return SY(r),e},xY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>O_({error:t,command:F0e,escapedCommand:F0e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),F0e="source.pipe(destination)";var z0e=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 bRt}from"stream/promises";var q0e=(t,e,r)=>{let n=ak.has(e)?wRt(t,e):TRt(t,e);return _p(t,ARt,r.signal),_p(e,xRt,r.signal),RRt(e),n},TRt=(t,e)=>{let r=vp([t]);return $_(r,e),ak.set(e,r),r},wRt=(t,e)=>{let r=ak.get(e);return r.add(t),r},RRt=async t=>{try{await bRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ak.delete(t)},ak=new WeakMap,ARt=2,xRt=1;import{aborted as PRt}from"util";var B0e=(t,e)=>t===void 0?[]:[CRt(t,e)],CRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await PRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw xY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ck=(t,...e)=>{if(Dr(e[0]))return ck.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=U0e(t,...e),i=IRt({...n,destination:r});return i.pipe=ck.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},IRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=ORt(t,i);j0e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=q0e(e,s,d);return await Promise.race([z0e(u),...B0e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},ORt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as URt}from"timers/promises";import{on as NRt}from"events";import{getDefaultHighWaterMark as kRt}from"stream";var lk=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return $Rt(e,o),V0e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},$Rt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},PY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;LRt(e,o,t);let a=t.readableObjectMode&&!s;return V0e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},LRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},V0e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=NRt(t,"data",{signal:e.signal,highWaterMark:H0e,highWatermark:H0e});return DRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},CY=kRt(!0),H0e=CY,DRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=MRt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Ep(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*HT(a)}},MRt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[QN(t,r,!e),XN(t,i,!n,{})].filter(Boolean);var G0e=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=FRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([jRt(t),d]);return}let f=oY(c,r),p=PY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},FRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!rk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=PY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await n0e(a,t,r,s)},jRt=async t=>{await URt(),t.readableFlowing===null&&t.resume()},zRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await BN(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await HN(r,{maxBuffer:s})):await I_(r,{maxBuffer:s})}catch(a){return W0e(nRe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},IY=async t=>{try{return await t}catch(e){return W0e(e)}},W0e=({bufferedData:t})=>Sbe(t)?new Uint8Array(t):t;import{finished as qRt}from"stream/promises";var YT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=BRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],qRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||GRt(a,e,r,n)}finally{o.abort()}},BRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&HRt(t,r,n),n},HRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{VRt(e,r),n.call(t,...i)}},VRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},GRt=(t,e,r,n)=>{if(!WRt(t,e,r,n))throw t},WRt=(t,e,r,n=!0)=>r.propagating?Y0e(t)||uk(t):(r.propagating=!0,OY(r,e)===n?Y0e(t):uk(t)),OY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",uk=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y0e=t=>t?.code==="EPIPE";var K0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>NY({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),NY=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=YT(t,e,l);if(OY(l,e)){await u;return}let[d]=await Promise.all([G0e({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 J0e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?vp([t,e].filter(Boolean)):void 0,Z0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>NY({...YRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:KRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),YRt=({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}},KRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as JRt}from"events";var X0e=t=>b_(t,"ipc"),Q0e=(t,e)=>{let r=gN(t);Ia({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var eAe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=X0e(s),a=Qc(e,"ipc"),c=Qc(r,"ipc");for await(let l of mY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(iRe(t,i,c),i.push(l)),o&&Q0e(l,s);return i},tAe=async(t,e)=>(await Promise.allSettled([t]),e);var rAe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=c0e(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=K0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=Z0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),x=[],R=eAe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),b=ZRt(m,t,S),P=XRt(h,S);try{return await Promise.race([Promise.all([{},u0e(v),Promise.all(g),w,R,Dwe(t,d),...b,...P]),_,QRt(t,y),...Owe(t,s,f,y),...XTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Cwe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(O){return f.terminationReason??="other",Promise.all([{error:O},v,Promise.all(g.map(A=>IY(A))),IY(w),tAe(R,x),Promise.allSettled(b),Promise.allSettled(P)])}},ZRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:YT(n,i,r)),XRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Co(s,{checkOpen:!1})&&!Ao(s)).map(({type:i,value:s,stream:o=s})=>YT(o,n,e,{isSameDirection:Ws.has(i),stopOnExit:i==="native"}))),QRt=async(t,{signal:e})=>{let[r]=await JRt(t,"error",{signal:e});throw r};var nAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),KT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Oa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},L_=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 e0t}from"stream";import{callbackify as t0t}from"util";import{finished as iAe}from"stream/promises";var kY=async t=>{if(t!==void 0)try{await $Y(t)}catch{}},sAe=async t=>{if(t!==void 0)try{await LY(t)}catch{}},$Y=async t=>{await iAe(t,{cleanup:!0,readable:!1,writable:!0})},LY=async t=>{await iAe(t,{cleanup:!0,readable:!0,writable:!1})},dk=async(t,e)=>{if(await t,e)throw e},fk=(t,e,r)=>{r&&!uk(r)?t.destroy(r):e&&t.destroy()};var oAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||us.has(r),{subprocessStdout:a,waitReadableDestroy:c}=DY(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=MY(a,o),{read:f,onStdoutDataDone:p}=UY({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new e0t({read:f,destroy:t0t(jY.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return FY({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},DY=(t,e,r)=>{let n=x_(t,e),i=KT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},MY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:CY},UY=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Oa(),o=lk({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){r0t(this,o,s)},onStdoutDataDone:s}},r0t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},FY=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await LY(t),await n,await kY(i),await e,r.readable&&r.push(null)}catch(s){await kY(i),aAe(r,s)}},jY=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await L_(r,e)&&(aAe(t,n),await dk(e,n))},aAe=(t,e)=>{fk(t,t.readable,e)};import{Writable as n0t}from"stream";import{callbackify as cAe}from"util";var lAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=zY(t,r,e),o=new n0t({...qY(n,t,i),destroy:cAe(HY.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return BY(n,o),o},zY=(t,e,r)=>{let n=xN(t,e),i=KT(r,n,"writableFinal"),s=KT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},qY=(t,e,r)=>({write:i0t.bind(void 0,t),final:cAe(s0t.bind(void 0,t,e,r))}),i0t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},s0t=async(t,e,r)=>{await L_(r,e)&&(t.writable&&t.end(),await e)},BY=async(t,e,r)=>{try{await $Y(t),e.writable&&e.end()}catch(n){await sAe(r),uAe(e,n)}},HY=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await L_(r,e),await L_(n,e)&&(uAe(t,i),await dk(e,i))},uAe=(t,e)=>{fk(t,t.writable,e)};import{Duplex as o0t}from"stream";import{callbackify as a0t}from"util";var dAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||us.has(r),{subprocessStdout:c,waitReadableDestroy:l}=DY(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=zY(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=MY(c,a),{read:_,onStdoutDataDone:y}=UY({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new o0t({read:_,...qY(u,t,d),destroy:a0t(c0t.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 FY({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),BY(u,v,c),v},c0t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([jY({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),HY({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var VY=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||us.has(e),o=x_(t,r),a=lk({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return l0t(a,o,t)},l0t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var fAe=(t,{encoding:e})=>{let r=nAe();t.readable=oAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=lAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=dAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=VY.bind(void 0,t,e),t[Symbol.asyncIterator]=VY.bind(void 0,t,e,{})};var pAe=(t,e)=>{for(let[r,n]of d0t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},u0t=(async()=>{})().constructor.prototype,d0t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(u0t,t)]);var hAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=h0t(t,e,r),{subprocess:f,promise:p}=g0t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ck.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),pAe(f,p),Na.set(f,{options:u,fileDescriptors:d}),f},h0t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=yN(t,e,r),{file:a,commandArguments:c,options:l}=UN(t,e,r),u=m0t(l),d=R0e(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},m0t=({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}},g0t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=p0t(...FN(t,e,r))}catch(h){return v0e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;f0t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];$0e(c,a,l),D0e(c,r,l);let d={},f=Oa();c.kill=JTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=J0e(c,r),fAe(c,r),y0e(c,r);let p=_0t({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}},_0t=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 rAe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,w)=>tl(g,e,w)),v=tl(m,e,"all"),S=y0t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return N_(S,n,e)},y0t=({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?BT({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 ka,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):WN({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var pk=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,S0t(n,t[n],i)]));return{...t,...r}},S0t=(t,e,r)=>E0t.has(t)&&Dr(e)&&Dr(r)?{...e,...r}:r,E0t=new Set(["env",...vW]);var nd=(t,e,r,n)=>{let i=(o,a,c)=>nd(o,a,r,c),s=(...o)=>v0t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},v0t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Dr(s))return i(t,pk(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=b0t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?f0e(a,c,l):hAe(a,c,l,i)},b0t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Rbe(e)?Abe(e,r):[e,...r],[o,a,c]=aN(...s),l=pk(pk(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 mAe=({file:t,commandArguments:e})=>_Ae(t,e),gAe=({file:t,commandArguments:e})=>({..._Ae(t,e),isSync:!0}),_Ae=(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]=T0t(t);return{file:r,commandArguments:n}},T0t=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(w0t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},w0t=/ +/g;var yAe=(t,e,r)=>{t.sync=e(R0t,r),t.s=t.sync},SAe=({options:t})=>EAe(t),R0t=({options:t})=>({...EAe(t),isSync:!0}),EAe=t=>({options:{...A0t(t),...t}}),A0t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},vAe={preferLocal:!0};var bAe=nd(()=>({})),jSr=nd(()=>({isSync:!0})),TAe=nd(mAe),zSr=nd(gAe),qSr=nd(kwe),BSr=nd(SAe,{},vAe,yAe),{sendMessage:HSr,getOneMessage:VSr,getEachMessage:GSr,getCancelSignal:WSr}=S0e();import{Transform as x0t}from"stream";var P0t=["NETLIFY_AI_GATEWAY_KEY"];function C0t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...P0t])]}function I0t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function O0t(){let e=C0t().map(r=>process.env[r]).filter(r=>!(!r||I0t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Hi(t){if(typeof t!="string")return t;let e=O0t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(N0t(n),"g");r=r.replace(i,"******")}),r}function N0t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var JT=class extends x0t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Hi(i);n(null,s)}},hk=Symbol("maskedWrite");function wAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[hk]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Hi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[hk]=!0,process.stdout.write=r}if(!process.stderr.write[hk]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Hi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[hk]=!0,process.stderr.write=r}}}var RAe=!1,AAe=()=>{RAe=!0},Vi=()=>RAe;var ZT=null,xAe=t=>(ZT&&ZT.destroy(),ZT=new Io({totalAllowedTime:t}),ZT),PAe=()=>ZT;var Io=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&&Vi())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 rN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{fe.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 CAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.169.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{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.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var D0t=$0t(import.meta.url),M0t=rl.dirname(D0t),U0t=L0t(import.meta.url),D_=he("shell"),GY=new Set,IAe={preferLocal:!0},$n=(t,e,r)=>{let[n,i]=F0t(e,r),s={...IAe,...i},o=bAe(t,n,s);NAe(o,s),LAe(o);let a=r?.idleTimeout;return a&&a>0&&$Ae(o,a),o},OAe=(t,e)=>{let r={...IAe,...e},n=TAe(t,r);return NAe(n,r),LAe(n),e?.idleTimeout&&e.idleTimeout>0&&$Ae(n,e.idleTimeout),n},F0t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},NAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||La.env.NETLIFY_LOCAL_QUIET==="true")return;if(La.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new JT).pipe(La.stdout),t.stderr?.pipe(new JT).pipe(La.stderr);return}t.stdout?.pipe(La.stdout),t.stderr?.pipe(La.stderr)},WY=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(La.kill(-t.pid,e),D_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return D_.error("Error killing process:",r),!1}},kAe=t=>WY(t,"SIGKILL"),$Ae=(t,e)=>{let r=null,n=()=>{D_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),WY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(D_.log(`Force killing idle process ${t.pid}`),kAe(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)},LAe=t=>{GY.add(t);let e=PAe();if(e){let r=e.onTimesUp(()=>{D_.log(`Global timer expired, killing process ${t.pid}`),WY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(D_.log(`Force killing process ${t.pid} after timeout`),kAe(t))},5e3)});t.on("exit",()=>{GY.delete(t),r()}),t.on("error",()=>{GY.delete(t),r()})}};function Da(t,e){if(!La.env.NETLIFY_LOCAL_MODE)try{let i=U0t.resolve(CAe.name),s=rl.dirname(i);for(;s!==rl.dirname(s);){let o=rl.dirname(s);if(rl.basename(o)==="node_modules"){let a=rl.join(o,".bin",e);if(mk.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(La.env.NODE_PATH){let i=rl.join(La.env.NODE_PATH,".bin",e);if(mk.existsSync(i))return i}let r=rl.join(t,"node_modules",".bin",e);if(mk.existsSync(r))return r;let n=rl.join(M0t,"..","node_modules",".bin",e);if(mk.existsSync(n))return n}import UM from"process";import{fileURLToPath as pFt}from"url";import{createRequire as hFt}from"module";import KR from"path";import{readFileSync as mFt}from"fs";var j0t="__netlify__getTracer",z0t="__netlify__shutdownTracers",Ct=(t,e)=>globalThis[j0t]?.(t,e),DAe=async()=>globalThis[z0t]?.();function XT(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 aFt}from"timers/promises";Ne();import qxt from"process";Ne();var dAt=(t,e)=>{e.recordException(t),e.setStatus({code:ni.ERROR})};var sl=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}=Cxe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>Ixe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Cxe(r,n,i),c=this._tracer.startSpan(e,s,o);return Ixe(c,s,a)}};function Cxe(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??rr.active(),{opts:n,ctx:i,fn:s}}function Ixe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:dAt,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)}}Ne();var B_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var xK=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=jxe(e),n._asyncAttributesPending=e.filter(([i,s])=>B_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(B_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=jxe(this._rawAttributes),this._schemaUrl=fAt(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,B_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ae.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(B_(n)){ae.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=pAt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function PK(t,e){return xK.FromAttributeList(Object.entries(t),e)}function jxe(t){return t.map(([e,r])=>B_(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function fAt(t){if(typeof t=="string"||t===void 0)return t;ae.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function pAt(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;ae.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var uw=class{emit(e){}enabled(){return!1}},zxe=new uw;var dw=Symbol.for("io.opentelemetry.js.api.logs"),H_=globalThis;function qxe(t,e,r){return n=>n===t?e:r}var CK=1;var IK=class{getLogger(e,r,n){return new uw}},Uk=new IK;var Fk=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):zxe}};var fw=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new Fk(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Uk}_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 jk=class t{constructor(){this._proxyLoggerProvider=new fw}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return H_[dw]?this.getLoggerProvider():(H_[dw]=qxe(CK,e,Uk),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=H_[dw])===null||e===void 0?void 0:e.call(H_,CK))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete H_[dw],this._proxyLoggerProvider=new fw}};var Bxe=jk.getInstance();function Hxe(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 Vxe(t){t.forEach(e=>e.disable())}function OK(t){let e=t.tracerProvider||jt.getTracerProvider(),r=t.meterProvider||lw.getMeterProvider(),n=t.loggerProvider||Bxe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Hxe(i,e,r,n),()=>{Vxe(i)}}Ne();var hAt=ln("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Gxe(t){return t.getValue(hAt)===!0}var V_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(V_||(V_={}));Ne();var NK="[_0-9a-z-*/]",mAt=`[a-z]${NK}{0,255}`,gAt=`[a-z0-9]${NK}{0,240}@[a-z]${NK}{0,13}`,_At=new RegExp(`^(?:${mAt}|${gAt})$`),yAt=/^[ -~]{0,255}[!-~]$/,SAt=/,|=/;function kK(t){return _At.test(t)}function $K(t){return yAt.test(t)&&!SAt.test(t)}var EAt=32,Wxe=512,Yxe=",",Kxe="=",zk=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!kK(e)||!$K(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>Wxe)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=Yxe+e),e=`${n[0]}${Kxe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(Yxe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Kxe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!kK(a)||!$K(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>Wxe)&&(r.set(a,c),n=l,r.size>=EAt))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 qk="traceparent",Bk="tracestate",vAt="00",bAt="(?!ff)[\\da-f]{2}",TAt="(?![0]{32})[\\da-f]{32}",wAt="(?![0]{16})[\\da-f]{16}",RAt="[\\da-f]{2}",AAt=new RegExp(`^\\s?(${bAt})-(${TAt})-(${wAt})-(${RAt})(-.*)?\\s?$`);function Jxe(t){let e=AAt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var od=class{inject(e,r,n){let i=jt.getSpanContext(e);if(!i||Gxe(e)||!Gi(i))return;let s=`${vAt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Cr.NONE).toString(16)}`;n.set(r,qk,s),i.traceState&&n.set(r,Bk,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,qk);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=Jxe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,Bk);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new zk(typeof c=="string"?c:void 0)}return jt.setSpanContext(e,o)}fields(){return[qk,Bk]}};var Hk=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 pw=class{_isCalled=!1;_deferred=new Hk;_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 L$=Yn(S5(),1);Ne();var NIe=t=>{throw TypeError(t)},T5=(t,e,r)=>e.has(t)||NIe("Cannot "+r),$$=(t,e,r)=>(T5(t,e,"read from private field"),r?r.call(t):e.get(t)),E5=(t,e,r)=>e.has(t)?NIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),CIe=(t,e,r,n)=>(T5(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),zxt=(t,e,r)=>(T5(t,e,"access private method"),r),IIe="__netlify__getTracer",Bxt="__netlify__shutdownTracers",Hxt="__nfOTLPTrace",Pw,Cw,b5,kIe,Vxt=class{constructor(){E5(this,b5),E5(this,Pw),E5(this,Cw),CIe(this,Pw,new pw(zxt(this,b5,kIe),this)),CIe(this,Cw,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if($$(this,Cw).debug(`export ${t.length.toString()} spans`),$$(this,Pw).isCalled){e({code:V_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Hxt,JSON.stringify(Gxt(t))),e({code:V_.SUCCESS})}shutdown(){return $$(this,Pw).call()}};Pw=new WeakMap;Cw=new WeakMap;b5=new WeakSet;kIe=function(){return $$(this,Cw).debug("Shutting down"),Promise.resolve()};function Gxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:k$(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||Oo.SERVER,startTimeUnixNano:v5(e.startTime),endTimeUnixNano:v5(e.endTime),attributes:k$(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:v5(n.time),attributes:k$(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:k$(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function k$(t){return Object.keys(t).map(e=>$Ie(e,t[e]))}function $Ie(t,e){return{key:t,value:LIe(e)}}function LIe(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(LIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>$Ie(r,n))}}:{}}function v5(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var OIe={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"}},DIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,IIe))return;let e=qxt.version.slice(1),r=PK({"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??[Wxt()],i=new L$.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new od});let s=t.instrumentations??[];OK({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,IIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new sl(jt.getTracer(a,c)):new sl(jt.getTracer(OIe.name,OIe.version))}}),Object.defineProperty(globalThis,Bxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Wxt=()=>new L$.SimpleSpanProcessor(new Vxt);Ne();var Iw=Yn(S5(),1);Ne();import*as D$ from"diagnostics_channel";var MIe=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?ni.ERROR:ni.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 sl?t:new sl(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){D$.subscribe(t,e);let r=()=>D$.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:Oo.CLIENT},rr.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:ni.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 aUe=Yn(sUe(),1);var DM=he("tracing"),oUe=8e3,cFt=5e3,YR=async(t=cFt)=>{try{await Promise.race([DAe(),aFt(t)])}catch(e){DM.warn("Failed to flush tracers on shutdown",e)}},cUe=async(t,e,r)=>{if(!Ct()){let n=[new Iw.SimpleSpanProcessor(new wX),new Iw.SimpleSpanProcessor(new aUe.OTLPTraceExporter({url:r.exporterUrl}))];await DIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new MIe({skipHeaders:!0})]})}return r.traceparent?(bi.setGlobalPropagator(new od),bi.extract(rr.active(),{traceparent:r.traceparent,isRemote:!0})):rr.active()};function sr(t,e,r){return DM.log(`\u23F3 TRACE: ${e} starting...`),XT(t,e,r)}var wX=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(", ")}]`:"";DM.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&DM.log(` \u274C Error: ${e.status.message}`)}};function RX(){return Je().captureLlmContentEnabled}function lUe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function MM(t,e,r){let n={role:t,parts:[{type:"text",content:Hi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var lFt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]);function uUe(t,e,r,n){if(!t.length)return;let i=Ct();if(!i)return;let s=RX(),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&&lFt.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>oUe?`${a.message.slice(0,oUe)}\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":Hi(_)}:{"gen_ai.output.messages":MM("assistant",_)}:{}}}).end(u)})}import{readdir as uFt,rm as dFt}from"fs/promises";import{join as fFt}from"path";async function dUe(t,e=[]){let n=(await uFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>dFt(fFt(t,i),{recursive:!0,force:!0})))}var ch=({mode:t,sessionCreditLimit:e})=>t==="create"&&e!=null&&e<=300;var AX=t=>{if(!ch(t))return"default";let e=Je();return e.createAskFirstEnabled&&e.questionsEnabled?"ask_first":e.creditWrapUpEnabled?"budget_constrained":"default"},fUe=t=>{let e=AX(t);return{budget_eligible:ch(t),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var gFt=KR.dirname(pFt(import.meta.url)),pUe=hFt(import.meta.url),_Ft=KR.resolve(gFt,"scripts/scaffold.js"),yFt="scripts/scaffold.js",SFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,xX=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},EFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),vFt=t=>{let e=xX(t);return e==="node"||e.endsWith("/node")},Cl=t=>{if(typeof t!="string")return!1;let e=t.match(SFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&EFt(xX(e[r]));)r+=1;if(r>=e.length||!vFt(e[r]))return!1;let n=e[r+1];return n?xX(n).includes(yFt):!1},lh=he("create_stage"),PX="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.",bFt=`${PX}
625
625
 
626
626
  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.`,TFt=`${PX}
627
627
 
@@ -994,10 +994,10 @@ Use the following file for the complete context of the ask, the environment, and
994
994
 
995
995
  `)},vHt=t=>{let e=t.map(r=>r.authorization).filter(r=>!!r).map(r=>r.granted?`- ${r.service} is now authorized. Its tools are available to you.`:`- The user declined to authorize ${r.service}. Continue without it and do not request authorization for ${r.service} again in this run.`);return e.length?["## Service authorization","",...e].join(`
996
996
  `):""};import Gl from"fs/promises";import MVe from"os";import Wl from"path";import{rm as jte}from"fs/promises";import{resolve as bHt}from"path";var THt=".netlify/cache/",Uh=function({cacheDir:t=THt,cwd:e="."}={}){return bHt(e,t)};import{promises as PWt}from"fs";import{basename as cVe,dirname as lVe,join as CWt}from"path";import H3t from"process";import V3t from"events";import zt from"path";import G3t from"os";async function eA(t,e,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:n=!0,signal:i}={}){return new Promise((s,o)=>{if(t[Symbol.iterator]===void 0&&t[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(r)&&r>=1||r===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let a=[],c=[],l=new Map,u=!1,d=!1,f=!1,p=0,h=0,m=t[Symbol.iterator]===void 0?t[Symbol.asyncIterator]():t[Symbol.iterator](),_=()=>{S(i.reason)},y=()=>{i?.removeEventListener("abort",_)},v=w=>{s(w),y()},S=w=>{u=!0,d=!0,o(w),y()};i&&(i.aborted&&S(i.reason),i.addEventListener("abort",_,{once:!0}));let g=async()=>{if(d)return;let w=await m.next(),x=h;if(h++,w.done){if(f=!0,p===0&&!d){if(!n&&c.length>0){S(new AggregateError(c));return}if(d=!0,l.size===0){v(a);return}let R=[];for(let[b,P]of a.entries())l.get(b)!==Dze&&R.push(P);v(R)}return}p++,(async()=>{try{let R=await w.value;if(d)return;let b=await e(R,x);b===Dze&&l.set(x,b),a[x]=b,p--,await g()}catch(R){if(n)S(R);else{c.push(R),p--;try{await g()}catch(b){S(b)}}}})()};(async()=>{for(let w=0;w<r;w++){try{await g()}catch(x){S(x);break}if(f||u)break}})()})}var Dze=Symbol("skip");import jh from"path";import UWr,{constants as gQ}from"fs";import _Q from"fs/promises";var cQ=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},lQ=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Mze=t=>globalThis.DOMException===void 0?new lQ(t):new DOMException(t),Uze=t=>{let e=t.reason===void 0?Mze("This operation was aborted."):t.reason;return e instanceof Error?e:Mze(e)};function uQ(t,e){let{milliseconds:r,fallback:n,message:i,customTimers:s={setTimeout,clearTimeout}}=e,o,a,l=new Promise((u,d)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:p}=e;p.aborted&&d(Uze(p)),a=()=>{d(Uze(p))},p.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let f=new cQ;o=s.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(p){d(p)}return}typeof t.cancel=="function"&&t.cancel(),i===!1?u():i instanceof Error?d(i):(f.message=i??`Promise timed out after ${r} milliseconds`,d(f))},r),(async()=>{try{u(await t)}catch(p){d(p)}})()}).finally(()=>{l.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return l.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},l}var wHt=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function RHt(t,e,r){let n,i=new Promise((s,o)=>{if(r={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:l,removeListener:u}=wHt(t),d=(...p)=>{let h=r.multiArgs?p:p[0];r.filter&&!r.filter(h)||(c.push(h),r.count===c.length&&(n(),s(c)))},f=p=>{n(),o(p)};n=()=>{for(let p of a)u(p,d);for(let p of r.rejectionEvents)u(p,f)};for(let p of a)l(p,d);for(let p of r.rejectionEvents)l(p,f);r.signal&&r.signal.addEventListener("abort",()=>{f(r.signal.reason)},{once:!0}),r.resolveImmediately&&s(c)});if(i.cancel=n,typeof r.timeout=="number"){let s=uQ(i,{milliseconds:r.timeout});return s.cancel=n,s}return i}function F1(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=RHt(t,e,r),i=n.then(s=>s[0]);return i.cancel=n.cancel,i}var Ci=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CopyFileError"}};var ta=Yn(Kze(),1);import{promisify as tA}from"util";var OWr=tA(ta.default.stat),DHt=tA(ta.default.lstat),MHt=tA(ta.default.utimes),UHt=tA(ta.default.chmod),FHt=tA(ta.default.mkdir),NWr=ta.default.closeSync.bind(ta.default),Jze=ta.default.createWriteStream.bind(ta.default);async function Zze(t,e){let r=ta.default.createReadStream(t,e);try{await F1(r,["readable","end"])}catch(n){throw new Ci(`Cannot read from \`${t}\`: ${n.message}`,{cause:n})}return r}var mQ=t=>DHt(t).catch(e=>{throw new Ci(`lstat \`${t}\` failed: ${e.message}`,{cause:e})}),Xze=(t,e,r)=>MHt(t,e,r).catch(n=>{throw new Ci(`utimes \`${t}\` failed: ${n.message}`,{cause:n})}),Qze=(t,e)=>UHt(t,e).catch(r=>{throw new Ci(`chmod \`${t}\` failed: ${r.message}`,{cause:r})});var eqe=(t,e)=>FHt(t,{...e,recursive:!0}).catch(r=>{throw new Ci(`Cannot create directory \`${t}\`: ${r.message}`,{cause:r})});var zHt=(t,e,r)=>({sourcePath:jh.resolve(t,e),destinationPath:jh.resolve(t,r)}),qHt=(t,e)=>{if(!t.isFile())throw Object.assign(new Ci(`EISDIR: illegal operation on a directory '${e}'`),{errno:-21,code:"EISDIR",source:e})};async function tqe(t,e,r={}){if(!t||!e)throw new Ci("`source` and `destination` required");r.cwd&&({sourcePath:t,destinationPath:e}=zHt(r.cwd,t,e)),r={overwrite:!0,...r};let n=await mQ(t),{size:i}=n;qHt(n,t);let s=jh.dirname(e);if(jh.parse(s).root===s||await eqe(jh.dirname(e),{mode:r.directoryMode}),typeof r.onProgress=="function"){let a=await Zze(t),c=Jze(e,{flags:r.overwrite?"w":"wx"}),l=p=>{r.onProgress({sourcePath:jh.resolve(t),destinationPath:jh.resolve(e),size:i,writtenBytes:p,percent:p===i?1:p/i})},u=-1;a.on("data",()=>{let p=c.bytesWritten,h=p===i?1:p/i;(h===1||h-u>=.01)&&(u=h,l(p))});let d;a.once("error",p=>{d=new Ci(`Cannot read from \`${t}\`: ${p.message}`,{cause:p})});let f=!1;try{let p=F1(c,"close");a.pipe(c),await p,l(i),f=!0}catch(p){throw new Ci(`Cannot write to \`${e}\`: ${p.message}`,{cause:p})}if(d)throw d;if(f){let p=await mQ(t);return Promise.all([Xze(e,p.atime,p.mtime).catch(h=>{if(h.code!=="EPERM")throw h}),Qze(e,p.mode)])}}else{let a=r.overwrite?gQ.COPYFILE_FICLONE:gQ.COPYFILE_FICLONE|gQ.COPYFILE_EXCL;try{await _Q.copyFile(t,e,a),await Promise.all([_Q.utimes(e,n.atime,n.mtime).catch(c=>{if(c.code!=="EPERM")throw c}),_Q.chmod(e,n.mode)])}catch(c){throw new Ci(c.message,{cause:c})}}}async function yQ(t,e,r){return(await eA(t,(i,s)=>Promise.all([e(i,s),i]),r)).filter(i=>!!i[0]).map(i=>i[1])}import hHe from"process";import M3t from"fs";import vE from"path";import{on as BHt,once as HHt}from"events";import{PassThrough as VHt}from"stream";import{finished as iqe}from"stream/promises";function bQ(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)EQ(i);let e=t.some(({readableObjectMode:i})=>i),r=GHt(t,e),n=new SQ({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&aqe(n),n}var GHt=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},SQ=class extends VHt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){EQ(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=WHt(this,this.#e),JHt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return EQ(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},WHt=async(t,e)=>{H1(t,rqe);let r=new AbortController;try{await Promise.race([YHt(t,r),KHt(t,e,r)])}finally{r.abort(),H1(t,-rqe)}},YHt=async(t,{signal:e})=>{await iqe(t,{signal:e,cleanup:!0})},KHt=async(t,e,{signal:r})=>{for await(let[n]of BHt(t,"unpipe",{signal:r}))e.has(n)&&n.emit(oqe)},EQ=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},JHt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s})=>{H1(t,nqe);let o=new AbortController;try{await Promise.race([ZHt(s,e),XHt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:o}),QHt({stream:e,streams:r,ended:n,aborted:i,controller:o})])}finally{o.abort(),H1(t,-nqe)}r.size===n.size+i.size&&(n.size===0&&i.size>0?vQ(t):aqe(t))},sqe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",ZHt=async(t,e)=>{try{await t,vQ(e)}catch(r){sqe(r)?vQ(e):cqe(e,r)}},XHt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await iqe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;sqe(o)?i.add(e):cqe(t,o)}},QHt=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await HHt(t,oqe,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},oqe=Symbol("unpipe"),aqe=t=>{t.writable&&t.end()},vQ=t=>{(t.readable||t.writable)&&t.destroy()},cqe=(t,e)=>{t.destroyed||(t.once("error",eVt),t.destroy(e))},eVt=()=>{},H1=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},rqe=2,nqe=1;var bE=Yn(cA(),1);import c3t from"fs";import l3t from"fs/promises";async function ate(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await l3t[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function cte(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return c3t[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var mKr=ate.bind(void 0,"stat","isFile"),KBe=ate.bind(void 0,"stat","isDirectory"),gKr=ate.bind(void 0,"lstat","isSymbolicLink"),_Kr=cte.bind(void 0,"statSync","isFile"),JBe=cte.bind(void 0,"statSync","isDirectory"),yKr=cte.bind(void 0,"lstatSync","isSymbolicLink");var gte=Yn(cA(),1),sHe=Yn(mte(),1);import I3t from"process";import O3t from"fs";import N3t from"fs/promises";import EE from"path";function SE(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var uA=t=>t[0]==="!";var k3t=["**/node_modules","**/flow-typed","**/coverage","**/.git"],oHe={absolute:!0,dot:!0},aHe="**/.gitignore",$3t=(t,e)=>uA(t)?"!"+EE.posix.join(e,t.slice(1)):EE.posix.join(e,t),L3t=(t,e)=>{let r=SE(EE.relative(e,EE.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>$3t(n,r))},D3t=(t,e)=>{if(e=SE(e),EE.isAbsolute(t)){if(SE(t).startsWith(e))return EE.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},cHe=(t,e)=>{let r=t.flatMap(i=>L3t(i,e)),n=(0,sHe.default)().add(r);return i=>(i=Bi(i),i=D3t(i,e),i?n.ignores(SE(i)):!1)},lHe=(t={})=>({cwd:Bi(t.cwd)??I3t.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...k3t]}),uHe=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:s}=lHe(e),o=await(0,gte.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:s,...oHe}),a=await Promise.all(o.map(async c=>({filePath:c,content:await N3t.readFile(c,"utf8")})));return cHe(a,r)},dHe=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:s}=lHe(e),a=gte.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:s,...oHe}).map(c=>({filePath:c,content:O3t.readFileSync(c,"utf8")}));return cHe(a,r)};var U3t=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},mHe=(t,e)=>{let r=uA(t)?t.slice(1):t;return vE.isAbsolute(r)?r:vE.join(e,r)},gHe=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>vE.posix.join(t,`**/${vE.extname(i)?i:`${i}${n}`}`)):[vE.posix.join(t,`**${n?`/*${n}`:""}`)]},fHe=async(t,{cwd:e=hHe.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async s=>await KBe(mHe(s,e))?gHe({directoryPath:s,files:r,extensions:n}):s))).flat(),pHe=(t,{cwd:e=hHe.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>JBe(mHe(i,e))?gHe({directoryPath:i,files:r,extensions:n}):i),_te=t=>(t=[...new Set([t].flat())],U3t(t),t),F3t=t=>{if(!t)return;let e;try{e=M3t.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},_He=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Bi(t.cwd)},F3t(t.cwd),t),yHe=t=>async(e,r)=>t(_te(e),_He(r)),bU=t=>(e,r)=>t(_te(e),_He(r)),SHe=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?_te(e):[];return r&&n.push(aHe),n},j3t=async t=>{let e=SHe(t);return vHe(e.length>0&&await uHe(e,t))},EHe=t=>{let e=SHe(t);return vHe(e.length>0&&dHe(e,t))},vHe=t=>{let e=new Set;return r=>{let n=vE.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},bHe=(t,e)=>t.flat().filter(r=>e(r)),THe=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(s=>uA(s));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let s of r)s.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},wHe=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),RHe=async(t,e)=>{let r=THe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let s=wHe(i,n);return Promise.all(r.map(async o=>{let{patterns:a,options:c}=o;return[a,c.ignore]=await Promise.all([fHe(a,s),fHe(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},yte=(t,e)=>{let r=THe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let s=wHe(i,n);return r.map(o=>{let{patterns:a,options:c}=o;return a=pHe(a,s),c.ignore=pHe(c.ignore,{cwd:n}),{patterns:a,options:c}})},FKr=yHe(async(t,e)=>{let[r,n]=await Promise.all([RHe(t,e),j3t(e)]),i=await Promise.all(r.map(s=>(0,bE.default)(s.patterns,s.options)));return bHe(i,n)}),AHe=bU((t,e)=>{let r=yte(t,e),n=EHe(e),i=r.map(s=>bE.default.sync(s.patterns,s.options));return bHe(i,n)}),jKr=bU((t,e)=>{let r=yte(t,e),n=EHe(e),i=r.map(o=>bE.default.stream(o.patterns,o.options));return bQ(i).filter(o=>n(o))}),Hh=bU((t,e)=>t.some(r=>bE.default.isDynamicPattern(r,e))),zKr=yHe(RHe),qKr=bU(yte),{convertPathToPattern:BKr}=bE.default;var PHe=Yn(HQ(),1);var lf=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CpyError"}};import wU from"path";import xHe from"fs";var z3t=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],q3t=new RegExp(z3t.join("|"));function B3t(t){return q3t.test(t)}function TU(t){return!B3t(t)}var dA=class{constructor(e,r,n){this.path=e,this.originalPath=e,this.destination=r,this.options=n,this.isDirectory=!1,!Hh(e)&&xHe.existsSync(e)&&xHe.lstatSync(e).isDirectory()&&(this.path=[e,"**"].join("/"),this.isDirectory=!0)}get name(){return wU.basename(this.originalPath)}get normalizedPath(){let e=this.originalPath.split("/"),r=e.findIndex(i=>i?Hh(i):!1),n=e.slice(0,r).join("/");return n?wU.isAbsolute(n)?n:wU.join(this.options.cwd,n):this.destination}hasMagic(){return Hh(this.options.flat?this.path:this.originalPath)}getMatches(){let e=AHe(this.path,{...this.options,dot:!0,absolute:!0,onlyFiles:!0});return this.options.ignoreJunk&&(e=e.filter(r=>TU(wU.basename(r)))),e}};var W3t={ignoreJunk:!0,flat:!1,cwd:H3t.cwd()},Ste=class{constructor(e,r,n){this.path=e.split("/").join(zt.sep),this.relativePath=r.split("/").join(zt.sep),this.pattern=n,Object.freeze(this)}get name(){return zt.basename(this.path)}get nameWithoutExtension(){return zt.basename(this.path,zt.extname(this.path))}get extension(){return zt.extname(this.path).slice(1)}},Y3t=t=>t.flatMap(e=>PHe.default.braces(e,{expand:!0,nodupes:!0})),K3t=({entry:t,destination:e,options:r})=>t.pattern.hasMagic()?r.flat?zt.isAbsolute(e)?zt.join(e,t.name):zt.join(r.cwd,e,t.name):zt.join(e,zt.relative(t.pattern.normalizedPath,t.path)):zt.isAbsolute(e)?zt.join(e,t.name):t.pattern.isDirectory&&zt.relative(r.cwd,t.path).startsWith("..")?zt.join(r.cwd,e,zt.basename(t.pattern.originalPath),zt.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&t.path===t.relativePath?zt.join(r.cwd,e,zt.basename(t.pattern.originalPath),zt.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&r.flat?zt.join(r.cwd,e,zt.basename(t.pattern.originalPath)):zt.join(r.cwd,e,zt.relative(r.cwd,t.path)),J3t=(t,e)=>{let r=zt.dirname(t);if(typeof e=="string")return zt.join(r,e);if(typeof e=="function"){let n=zt.basename(t);return zt.join(r,e(n))}return t};function Ete(t,e,{concurrency:r=G3t.availableParallelism(),...n}={}){let i=new Map,s=new V3t;n={...W3t,...n};let o=(async()=>{let a=[],c=0,l=0,u=Y3t([t??[]].flat()).map(h=>h.replaceAll("\\","/")),d=u.filter(h=>!h.startsWith("!")),f=u.filter(h=>h.startsWith("!"));if(d.length===0||!e)throw new lf("`source` and `destination` required");u=u.map(h=>new dA(h,e,{...n,ignore:f}));for(let h of u){let m=[];try{m=h.getMatches()}catch(_){throw new lf(`Cannot glob \`${h.originalPath}\`: ${_.message}`,{cause:_})}if(m.length===0&&!Hh(h.originalPath)&&!Hh(f))throw new lf(`Cannot copy \`${h.originalPath}\`: the file doesn't exist`);a=[...a,...m.map(_=>new Ste(_,zt.relative(n.cwd,_),h))]}n.filter!==void 0&&(a=await yQ(a,n.filter,{concurrency:1024})),a.length===0&&s.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0});let p=h=>{let m=i.get(h.sourcePath)||{writtenBytes:0,percent:0};(m.writtenBytes!==h.writtenBytes||m.percent!==h.percent)&&(l-=m.writtenBytes,l+=h.writtenBytes,h.percent===1&&m.percent!==1&&c++,i.set(h.sourcePath,{writtenBytes:h.writtenBytes,percent:h.percent}),s.emit("progress",{totalFiles:a.length,percent:c/a.length,completedFiles:c,completedSize:l,sourcePath:h.sourcePath,destinationPath:h.destinationPath}))};return eA(a,async h=>{let m=J3t(K3t({entry:h,destination:e,options:n}),n.rename);try{await tqe(h.path,m,{...n,onProgress:p})}catch(_){throw new lf(`Cannot copy from \`${h.relativePath}\` to \`${m}\`: ${_.message}`,{cause:_})}return m},{concurrency:r})})();return o.on=(...a)=>(s.on(...a),o),o}import WHe from"process";import yWt from"fs";import RE from"path";import{on as Z3t,once as X3t}from"events";import{PassThrough as Q3t}from"stream";import{finished as OHe}from"stream/promises";function wte(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)bte(i);let e=t.some(({readableObjectMode:i})=>i),r=eWt(t,e),n=new vte({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&$He(n),n}var eWt=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},vte=class extends Q3t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){bte(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=tWt(this,this.#e),iWt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return bte(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},tWt=async(t,e)=>{RU(t,CHe);let r=new AbortController;try{await Promise.race([rWt(t,r),nWt(t,e,r)])}finally{r.abort(),RU(t,-CHe)}},rWt=async(t,{signal:e})=>{await OHe(t,{signal:e,cleanup:!0})},nWt=async(t,e,{signal:r})=>{for await(let[n]of Z3t(t,"unpipe",{signal:r}))e.has(n)&&n.emit(kHe)},bte=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},iWt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s})=>{RU(t,IHe);let o=new AbortController;try{await Promise.race([sWt(s,e),oWt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:o}),aWt({stream:e,streams:r,ended:n,aborted:i,controller:o})])}finally{o.abort(),RU(t,-IHe)}r.size===n.size+i.size&&(n.size===0&&i.size>0?Tte(t):$He(t))},NHe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",sWt=async(t,e)=>{try{await t,Tte(e)}catch(r){NHe(r)?Tte(e):LHe(e,r)}},oWt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await OHe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;NHe(o)?i.add(e):LHe(t,o)}},aWt=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await X3t(t,kHe,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},kHe=Symbol("unpipe"),$He=t=>{t.writable&&t.end()},Tte=t=>{(t.readable||t.writable)&&t.destroy()},LHe=(t,e)=>{t.destroyed||(t.once("error",cWt),t.destroy(e))},cWt=()=>{},RU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},CHe=2,IHe=1;var AE=Yn(cA(),1);import lWt from"fs";import uWt from"fs/promises";async function Rte(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await uWt[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function Ate(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return lWt[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var m5r=Rte.bind(void 0,"stat","isFile"),DHe=Rte.bind(void 0,"stat","isDirectory"),g5r=Rte.bind(void 0,"lstat","isSymbolicLink"),_5r=Ate.bind(void 0,"statSync","isFile"),MHe=Ate.bind(void 0,"statSync","isDirectory"),y5r=Ate.bind(void 0,"lstatSync","isSymbolicLink");var xte=Yn(cA(),1),UHe=Yn(mte(),1);import dWt from"process";import fWt from"fs";import pWt from"fs/promises";import wE from"path";function TE(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var fA=t=>t[0]==="!";var hWt=["**/node_modules","**/flow-typed","**/coverage","**/.git"],FHe={absolute:!0,dot:!0},jHe="**/.gitignore",mWt=(t,e)=>fA(t)?"!"+wE.posix.join(e,t.slice(1)):wE.posix.join(e,t),gWt=(t,e)=>{let r=TE(wE.relative(e,wE.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>mWt(n,r))},_Wt=(t,e)=>{if(e=TE(e),wE.isAbsolute(t)){if(TE(t).startsWith(e))return wE.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},zHe=(t,e)=>{let r=t.flatMap(i=>gWt(i,e)),n=(0,UHe.default)().add(r);return i=>(i=Bi(i),i=_Wt(i,e),i?n.ignores(TE(i)):!1)},qHe=(t={})=>({cwd:Bi(t.cwd)??dWt.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...hWt]}),BHe=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:s}=qHe(e),o=await(0,xte.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:s,...FHe}),a=await Promise.all(o.map(async c=>({filePath:c,content:await pWt.readFile(c,"utf8")})));return zHe(a,r)},HHe=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:s}=qHe(e),a=xte.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:s,...FHe}).map(c=>({filePath:c,content:fWt.readFileSync(c,"utf8")}));return zHe(a,r)};var SWt=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},YHe=(t,e)=>{let r=fA(t)?t.slice(1):t;return RE.isAbsolute(r)?r:RE.join(e,r)},KHe=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>RE.posix.join(t,`**/${RE.extname(i)?i:`${i}${n}`}`)):[RE.posix.join(t,`**${n?`/*${n}`:""}`)]},VHe=async(t,{cwd:e=WHe.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async s=>await DHe(YHe(s,e))?KHe({directoryPath:s,files:r,extensions:n}):s))).flat(),GHe=(t,{cwd:e=WHe.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>MHe(YHe(i,e))?KHe({directoryPath:i,files:r,extensions:n}):i),Pte=t=>(t=[...new Set([t].flat())],SWt(t),t),EWt=t=>{if(!t)return;let e;try{e=yWt.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},JHe=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Bi(t.cwd)},EWt(t.cwd),t),ZHe=t=>async(e,r)=>t(Pte(e),JHe(r)),AU=t=>(e,r)=>t(Pte(e),JHe(r)),XHe=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?Pte(e):[];return r&&n.push(jHe),n},vWt=async t=>{let e=XHe(t);return eVe(e.length>0&&await BHe(e,t))},QHe=t=>{let e=XHe(t);return eVe(e.length>0&&HHe(e,t))},eVe=t=>{let e=new Set;return r=>{let n=RE.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},tVe=(t,e)=>t.flat().filter(r=>e(r)),rVe=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(s=>fA(s));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let s of r)s.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},nVe=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),iVe=async(t,e)=>{let r=rVe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let s=nVe(i,n);return Promise.all(r.map(async o=>{let{patterns:a,options:c}=o;return[a,c.ignore]=await Promise.all([VHe(a,s),VHe(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},Cte=(t,e)=>{let r=rVe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let s=nVe(i,n);return r.map(o=>{let{patterns:a,options:c}=o;return a=GHe(a,s),c.ignore=GHe(c.ignore,{cwd:n}),{patterns:a,options:c}})},sVe=ZHe(async(t,e)=>{let[r,n]=await Promise.all([iVe(t,e),vWt(e)]),i=await Promise.all(r.map(s=>(0,AE.default)(s.patterns,s.options)));return tVe(i,n)}),U5r=AU((t,e)=>{let r=Cte(t,e),n=QHe(e),i=r.map(s=>AE.default.sync(s.patterns,s.options));return tVe(i,n)}),F5r=AU((t,e)=>{let r=Cte(t,e),n=QHe(e),i=r.map(o=>AE.default.stream(o.patterns,o.options));return wte(i).filter(o=>n(o))}),j5r=AU((t,e)=>t.some(r=>AE.default.isDynamicPattern(r,e))),z5r=ZHe(iVe),q5r=AU(Cte),{convertPathToPattern:B5r}=AE.default;import TWt from"process";import pA from"path";import Z5r,{promises as xU}from"fs";import G5r,{promises as bWt}from"fs";async function oVe(t){try{return await bWt.access(t),!0}catch{return!1}}var wWt=(t,e,r)=>(e=pA.resolve(t,e),r=pA.resolve(t,r),{sourcePath:e,destinationPath:r}),RWt=(t,e,r="Path")=>{if(!t||!e)throw new TypeError(`\`source${r}\` and \`destination${r}\` required`)},AWt=(t,e)=>{if(pA.dirname(t)!==pA.dirname(e))throw new Error("`source` and `destination` must be in the same directory")},xWt=async(t,e,{overwrite:r=!0,cwd:n=TWt.cwd(),directoryMode:i,validateDirectory:s=!1}={})=>{if(n&&({sourcePath:t,destinationPath:e}=wWt(n,t,e)),s&&AWt(t,e),!r&&await oVe(e))throw new Error(`The destination file exists: ${e}`);await xU.mkdir(pA.dirname(e),{recursive:!0,mode:i});try{await xU.rename(t,e)}catch(o){if(o.code==="EXDEV")await xU.copyFile(t,e),await xU.unlink(t);else throw o}};async function aVe(t,e,r){return RWt(t,e),xWt(t,e,r)}var Ite=async function(t,e,r=!1){if(r)return aVe(t,e,{overwrite:!1});let{srcGlob:n,dest:i,...s}=await uVe(t,lVe(e));if(n&&i)return Ete(n,i,{...s,overwrite:!1})},hA=async function(t){let{srcGlob:e,isDir:r,dest:n,...i}=await uVe(t,"");return e!==void 0&&!await IWt(e,r,i)},IWt=async function(t,e,r){return e?(await sVe(t,r)).filter(s=>TU(cVe(s))).length===0:!1},uVe=async function(t,e){let r=await OWt(t);if(r===void 0)return{srcGlob:void 0,isDir:!1,cwd:""};let n=r.isDirectory(),i=cVe(t),s=lVe(t),o={srcGlob:i,dest:e,isDir:n,cwd:s,dot:!0};return n?{...o,srcGlob:`${i}/**`,dest:CWt(e,i)}:o},OWt=async t=>{try{return await PWt.stat(t)}catch{return}};import{join as AYt}from"path";import{stat as NWt,lstat as dVe,readdir as kWt,realpath as $Wt}from"fs/promises";import{Readable as LWt}from"stream";import{resolve as fVe,relative as DWt,join as MWt,sep as UWt}from"path";var Rs={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Ote={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:Rs.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Ote);var gVe="READDIRP_RECURSIVE_ERROR",FWt=new Set(["ENOENT","EPERM","EACCES","ELOOP",gVe]),pVe=[Rs.DIR_TYPE,Rs.EVERYTHING_TYPE,Rs.FILE_DIR_TYPE,Rs.FILE_TYPE],jWt=new Set([Rs.DIR_TYPE,Rs.EVERYTHING_TYPE,Rs.FILE_DIR_TYPE]),zWt=new Set([Rs.EVERYTHING_TYPE,Rs.FILE_DIR_TYPE,Rs.FILE_TYPE]),qWt=t=>FWt.has(t.code),BWt=process.platform==="win32",hVe=t=>!0,mVe=t=>{if(t===void 0)return hVe;if(typeof t=="function")return t;if(typeof t=="string"){let e=t.trim();return r=>r.basename===e}if(Array.isArray(t)){let e=t.map(r=>r.trim());return r=>e.some(n=>r.basename===n)}return hVe},Nte=class extends LWt{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...Ote,...e},{root:n,type:i}=r;this._fileFilter=mVe(r.fileFilter),this._directoryFilter=mVe(r.directoryFilter);let s=r.lstat?dVe:NWt;BWt?this._stat=o=>s(o,{bigint:!0}):this._stat=s,this._maxDepth=r.depth??Ote.depth,this._wantsDir=i?jWt.has(i):!1,this._wantsFile=i?zWt.has(i):!1,this._wantsEverything=i===Rs.EVERYTHING_TYPE,this._root=fVe(n),this._isDirent=!r.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let r=this.parent,n=r&&r.files;if(n&&n.length>0){let{path:i,depth:s}=r,o=n.splice(0,e).map(c=>this._formatEntry(c,i)),a=await Promise.all(o);for(let c of a){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(s<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,s+1)),this._wantsDir&&(this.push(c),e--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let i=this.parents.pop();if(!i){this.push(null);break}if(this.parent=await i,this.destroyed)return}}}catch(r){this.destroy(r)}finally{this.reading=!1}}}async _exploreDir(e,r){let n;try{n=await kWt(e,this._rdOptions)}catch(i){this._onError(i)}return{files:n,depth:r,path:e}}async _formatEntry(e,r){let n,i=this._isDirent?e.name:e;try{let s=fVe(MWt(r,i));n={path:DWt(this._root,s),fullPath:s,basename:i},n[this._statsProp]=this._isDirent?e:await this._stat(s)}catch(s){this._onError(s);return}return n}_onError(e){qWt(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let r=e[this._statsProp];if(r.isFile())return"file";if(r.isDirectory())return"directory";if(r&&r.isSymbolicLink()){let n=e.fullPath;try{let i=await $Wt(n),s=await dVe(i);if(s.isFile())return"file";if(s.isDirectory()){let o=i.length;if(n.startsWith(i)&&n.substr(o,1)===UWt){let a=new Error(`Circular symlink detected: "${n}" points to "${i}"`);return a.code=gVe,this._onError(a)}return"directory"}}catch(i){return this._onError(i),""}}}_includeAsFile(e){let r=e&&e[this._statsProp];return r&&this._wantsEverything&&!r.isDirectory()}};function HWt(t,e={}){let r=e.entryType||e.type;if(r==="both"&&(r=Rs.FILE_DIR_TYPE),r&&(e.type=r),t){if(typeof t!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(r&&!pVe.includes(r))throw new Error(`readdirp: Invalid type passed. Use one of ${pVe.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new Nte(e)}function _Ve(t,e={}){return new Promise((r,n)=>{let i=[];HWt(t,e).on("data",s=>i.push(s)).on("end",()=>r(i)).on("error",s=>n(s))})}import{mkdir as nYt,readFile as wVe,rm as iYt,writeFile as sYt}from"fs/promises";import{existsSync as RVe}from"fs";import{dirname as oYt}from"path";var yVe=t=>{if(!(!Number.isInteger(t)||t<1))return Date.now()+t*1e3},SVe=t=>t!==void 0&&Date.now()>t;import{createHash as QWt}from"crypto";import{createReadStream as eYt}from"fs";import WWt from"process";import YWt from"path";import E9r,{promises as EVe}from"fs";import{fileURLToPath as KWt}from"url";var kte=class{value;next;constructor(e){this.value=e}},mA=class{#e;#r;#t;constructor(){this.clear()}enqueue(e){let r=new kte(e);this.#e?(this.#r.next=r,this.#r=r):(this.#e=r,this.#r=r),this.#t++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#t--,this.#e||(this.#r=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#r=void 0,this.#t=0}get size(){return this.#t}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}};function PU(t){if(!((Number.isInteger(t)||t===Number.POSITIVE_INFINITY)&&t>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new mA,r=0,n=()=>{r--,e.size>0&&e.dequeue()()},i=async(a,c,l)=>{r++;let u=(async()=>a(...l))();c(u);try{await u}catch{}n()},s=(a,c,l)=>{e.enqueue(i.bind(void 0,a,c,l)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.dequeue()()))()},o=(a,...c)=>new Promise(l=>{s(a,l,c)});return Object.defineProperties(o,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}var CU=class extends Error{constructor(e){super(),this.value=e}},VWt=async(t,e)=>e(await t),GWt=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new CU(e[0]);return!1};async function $te(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let i=PU(r),s=[...t].map(a=>[a,i(VWt,a,e)]),o=PU(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(s.map(a=>o(GWt,a)))}catch(a){if(a instanceof CU)return a.value;throw a}}var vVe={directory:"isDirectory",file:"isFile"};function JWt(t){if(!Object.hasOwnProperty.call(vVe,t))throw new Error(`Invalid type specified: ${t}`)}var ZWt=(t,e)=>e[vVe[t]](),XWt=t=>t instanceof URL?KWt(t):t;async function bVe(t,{cwd:e=WWt.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:i,preserveOrder:s}={}){JWt(r),e=XWt(e);let o=n?EVe.stat:EVe.lstat;return $te(t,async a=>{try{let c=await o(YWt.resolve(e,a));return ZWt(r,c)}catch{return!1}},{concurrency:i,preserveOrder:s})}var tYt="sha1",TVe=async function(t,e){if(e||t.length===0)return;let r=await bVe(t);return r===void 0?void 0:await rYt(r)},rYt=async function(t){let e=eYt(t,"utf8"),r=QWt(tYt,{encoding:"hex"});return e.pipe(r),await I_(r)};var AVe=async function({cachePath:t,move:e,ttl:r,digests:n}){let i=IU(t),s=yVe(r),o=await TVe(n,e),c=`${JSON.stringify({expires:s,hash:o},null,2)}
997
- `,l=await aYt({hash:o,manifestPath:i,manifestString:c});return{manifestInfo:{manifestPath:i,manifestString:c},identical:l}},aYt=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!RVe(e)?!1:await wVe(e,"utf8")===r},xVe=async function({manifestPath:t,manifestString:e}){await nYt(oYt(t),{recursive:!0}),await sYt(t,e)},PVe=async function(t){let e=IU(t);await iYt(e,{force:!0,recursive:!0,maxRetries:3})},IU=function(t){return`${t}${IVe}`},CVe=function(t){return t.endsWith(IVe)},IVe=".netlify.cache.json",Lte=async function(t){let e=IU(t);if(!RVe(e))return!1;let{expires:r}=await cYt(t);return SVe(r)},cYt=async function(t){let e=IU(t),r=await wVe(e,"utf-8");return JSON.parse(r)};import{homedir as pYt}from"os";import{resolve as OVe,isAbsolute as hYt,join as mYt,sep as Mte}from"path";import{normalize as lYt}from"path";import{existsSync as uYt}from"fs";import dYt from"process";var Dte=function(t){try{let e=fYt(t);return uYt(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},fYt=function(t=dYt.cwd()){return lYt(t)};var gA=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await gYt(t,r),i=await EYt({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:i}},gYt=async function(t,e){let r=await Dte(e),n=_Yt(t,r);return yYt(n,r),n},_Yt=function(t,e){if(hYt(t))return OVe(t);if(e!=="")return OVe(e,t);throw new Error(`Current directory does not exist: ${e}`)},yYt=function(t,e){if(e!==""&&SYt(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},SYt=function(t,e){return`${e}${Mte}`.startsWith(`${t}${Mte}`)},EYt=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Uh({cacheDir:e,cwd:r}),{name:i,relPath:s}=await vYt(t,r);return mYt(n,i,s)},vYt=async function(t,e){let r=await Ute(e),n=bYt(t);return r.map(({name:i,base:s})=>wYt(i,s,n)).find(Boolean)},bYt=function(t){return t.replace(TYt,"\\")},TYt=/^[a-zA-Z]:\\/,wYt=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},Ute=async function(t){return[...await RYt(t),{name:"home",base:pYt()},{name:"root",base:Mte}]},RYt=async function(t){let e=await Dte(t);return e===""?[]:[{name:"cwd",base:e}]};var xYt=1,Fte=async function({cacheDir:t,cwd:e,depth:r=xYt}={}){let n=await Ute(e),i=Uh({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>PYt({name:a,base:c,cacheDir:i,depth:r})))).flat()},PYt=async function({name:t,base:e,cacheDir:r,depth:n}){return(await _Ve(`${r}/${t}`,{fileFilter:CYt,depth:n,type:"files_directories"})).map(({path:o})=>AYt(e,o))},CYt=function({basename:t}){return!CVe(t)};var IYt=async function(t,{move:e=NVe,ttl:r=$Yt,digests:n=[],cacheDir:i,cwd:s}={}){let{srcPath:o,cachePath:a}=await gA({path:t,cacheDir:i,cwdOpt:s});if(!await hA(o))return!1;let{manifestInfo:c,identical:l}=await AVe({cachePath:a,move:e,ttl:r,digests:n});return l||(await jte(a,{force:!0,recursive:!0,maxRetries:3}),await Ite(o,a,e),await xVe(c)),!0},OYt=async function(t,{move:e=NVe,cacheDir:r,cwd:n}={}){let{srcPath:i,cachePath:s}=await gA({path:t,cacheDir:r,cwdOpt:n});return!await hA(s)||await Lte(s)?!1:(await jte(i,{force:!0,recursive:!0,maxRetries:3}),await Ite(s,i,e),!0)},NYt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await gA({path:t,cacheDir:e,cwdOpt:r});return await hA(n)?(await jte(n,{force:!0,recursive:!0,maxRetries:3}),await PVe(n),!0):!1},kYt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await gA({path:t,cacheDir:e,cwdOpt:r});return await hA(n)&&!await Lte(n)},NVe=!1,$Yt=void 0,OU=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(i=>t(i,...r)))).some(Boolean):t(e,...r)},LYt=OU.bind(null,IYt),DYt=OU.bind(null,OYt),MYt=OU.bind(null,NYt),UYt=OU.bind(null,kYt),kVe=function(t){return{save:(e,r)=>LYt(e,{...t,...r}),restore:(e,r)=>DYt(e,{...t,...r}),remove:(e,r)=>MYt(e,{...t,...r}),has:(e,r)=>UYt(e,{...t,...r}),list:e=>Fte({...t,...e}),getCacheDir:e=>Uh({...t,...e})}};var FYt=he("opencode_session"),jYt=async t=>{try{let e=await y1(t),{stdout:r}=await $n(e,["session","list","--format","json"],{cwd:t,env:{...process.env,OPENCODE_DISABLE_AUTOUPDATE:"1"}}),n=String(r??"").trim();if(!n)return[];let i=JSON.parse(n);return Array.isArray(i)?i:[]}catch(e){return FYt.warn("Could not list opencode sessions",{error:e?.message}),[]}},zte=new Map,$Ve=t=>{let e=zte.get(t);if(e)return e;let r=jYt(t).finally(()=>zte.delete(t));return zte.set(t,r),r},LVe=async t=>(await $Ve(t)).length>0,DVe=async(t,e)=>e?(await $Ve(t)).some(r=>r.id===e):!1;var _n=he("native_session"),qte=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await Gl.stat(Wl.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),Vh=async({runnerId:t,sessionId:e,archive:r,nativeSessionId:n})=>{if(!r)return _n.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:i,include:s}=r,o=!1;try{o=(await Gl.stat(i)).isDirectory()}catch{}if(!o)return _n.log(`Native session base dir ${i} not found, skipping`),null;let a=await qte(i,s);if(a.length===0)return _n.log(`No native session history found under ${i}, skipping`),null;let c=Wl.join(MVe.tmpdir(),`native-session-${e}.zip`);try{await $n("zip",["-r","-q","-X",c,...a],{cwd:i});let l=await Gl.readFile(c);_n.log(`Zipped native session (${l.length} bytes) from ${a.join(", ")}`,{nativeSessionId:n});let{upload_url:u,s3_key:d}=await QFe(t,e);return await aje(u,l,{contentType:"application/zip"}),_n.log("Successfully uploaded native session to S3"),d}catch(l){return _n.error("Failed to archive/upload native session, continuing without it:",l),null}finally{await Gl.rm(c,{force:!0}).catch(()=>{})}},UVe=async(t,e,r=process.cwd())=>{if(e==="opencode")return LVe(r);if(!t)return!1;let{baseDir:n,include:i}=t,s=await qte(n,i);for(let o of s)if((await Gl.readdir(Wl.join(n,o)).catch(()=>[])).length>0)return!0;return!1},zYt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),FVe=async(t,e)=>{let r=await Gl.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await FVe(Wl.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},jVe=async(t,e,r,n=process.cwd())=>{if(r==="opencode")return DVe(n,e);if(!t||!e)return!1;let i=new RegExp(`(^|[^a-zA-Z0-9])${zYt(e)}([^a-zA-Z0-9]|$)`),{baseDir:s,include:o}=t,a=await qte(s,o);for(let c of a)if(await FVe(Wl.join(s,c),i))return!0;return!1},zVe=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return _n.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,i=Wl.join(MVe.tmpdir(),`native-session-restore-${e}.zip`);try{let s=await eje(t,e);if(!s?.download_url)return _n.log("No native session available to restore, skipping"),!1;let o=await oje(s.download_url);return await Gl.writeFile(i,o),_n.log(`Downloaded native session (${o.length} bytes) to ${i}`),await Gl.mkdir(n,{recursive:!0}),await $n("unzip",["-o","-q",i,"-d",n]),_n.log(`Restored native session into ${n}`),!0}catch(s){return _n.error("Failed to fetch/restore native session, continuing without it:",s),!1}finally{await Gl.rm(i,{force:!0}).catch(()=>{})}},qYt="native-sessions",qVe=(t,e)=>kVe({cacheDir:Wl.join(e.dir,qYt),cwd:t}),BVe=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await qVe(r,e).restore(n.map(s=>Wl.join(r,s)),{})?(_n.log(`Restored native session from buildbot cache into ${r}`),!0):(_n.log("No native session in buildbot cache, skipping restore"),!1)}catch(i){return _n.error("Failed to restore native session from buildbot cache, continuing without it:",i),!1}},_A=async({archive:t,cache:e,nativeSessionId:r})=>{if(!e?.dir||!t)return _n.log("No buildbot cache configured for the native session, skipping cache seed",{nativeSessionId:r}),!1;let{baseDir:n,include:i}=t;try{return await qVe(n,e).save(i.map(o=>Wl.join(n,o)),{})?(_n.log(`Saved native session to buildbot cache under ${e.dir}`,{nativeSessionId:r}),!0):(_n.log("No native session history to save to buildbot cache, skipping"),!1)}catch(s){return _n.error("Failed to save native session to buildbot cache, continuing:",s),!1}};var xE=he("inference_stage"),HVe=5,uf=async t=>{let{additionalContext:e,cliPath:r,config:n,context:i,buildErrors:s,runner:o,persistSteps:a,aiGateway:c,attempt:l,contextPrefix:u,priorAgentSessionId:d,cwd:f,abortSignal:p,onSessionId:h,resumeForCreditWrapUp:m,forceLowEffortForCreditWrapUp:_,answerFold:y}=t;if(Vi())throw new Error("Shutdown in progress, aborting inference stage");xE.log(`Running inference stage, attempt ${l} of ${HVe}`);let v=!1,S=await sr(Ct(),"inference-stage",async g=>{g?.setAttributes({"inference.attempt":l||1}),wAe();let w=!!(l&&l>1),x=await BYt(n,w,f),R=!!m&&!!d;R&&n.runner==="gemini"&&!await w0(d)&&(R=!1);let b=x.viable||R;v=b,x.outcome!=="not_eligible"&&fe.inc("inference.native_resume",1,{outcome:x.outcome,...x.source?{source:x.source}:{}});let P=n;if("prompt"in n&&n.answeredInteraction&&Je().questionsEnabled){let C=n.answeredInteraction,N=b||w&&!!d,z=[C];if(!N){y.allAnswered??=Nze(n);let Y=await y.allAnswered;Y===null&&(y.allAnswered=void 0),Y&&Y.length>0&&(z=Y.some(ue=>ue.refId===C.refId)?Y:[...Y,C])}P={...n,prompt:Lze(n.prompt,z)},!w&&!y.counted&&(y.counted=!0,xE.log("Resuming session with answered questions",{sessionId:n.sessionId,interactionCount:z.length}),fe.inc("inference.answer_resume",1,{fold:N?"latest":"all"}),$ze(C))}let{prompt:O}=await sr(Ct(),"compose-prompt",async()=>await Aze({cliPath:r,config:P,buildErrorContext:HYt(s),netlify:i,additionalContext:e,resumePrompt:b,preserveResultsFile:!!m})),A=`
997
+ `,l=await aYt({hash:o,manifestPath:i,manifestString:c});return{manifestInfo:{manifestPath:i,manifestString:c},identical:l}},aYt=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!RVe(e)?!1:await wVe(e,"utf8")===r},xVe=async function({manifestPath:t,manifestString:e}){await nYt(oYt(t),{recursive:!0}),await sYt(t,e)},PVe=async function(t){let e=IU(t);await iYt(e,{force:!0,recursive:!0,maxRetries:3})},IU=function(t){return`${t}${IVe}`},CVe=function(t){return t.endsWith(IVe)},IVe=".netlify.cache.json",Lte=async function(t){let e=IU(t);if(!RVe(e))return!1;let{expires:r}=await cYt(t);return SVe(r)},cYt=async function(t){let e=IU(t),r=await wVe(e,"utf-8");return JSON.parse(r)};import{homedir as pYt}from"os";import{resolve as OVe,isAbsolute as hYt,join as mYt,sep as Mte}from"path";import{normalize as lYt}from"path";import{existsSync as uYt}from"fs";import dYt from"process";var Dte=function(t){try{let e=fYt(t);return uYt(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},fYt=function(t=dYt.cwd()){return lYt(t)};var gA=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await gYt(t,r),i=await EYt({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:i}},gYt=async function(t,e){let r=await Dte(e),n=_Yt(t,r);return yYt(n,r),n},_Yt=function(t,e){if(hYt(t))return OVe(t);if(e!=="")return OVe(e,t);throw new Error(`Current directory does not exist: ${e}`)},yYt=function(t,e){if(e!==""&&SYt(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},SYt=function(t,e){return`${e}${Mte}`.startsWith(`${t}${Mte}`)},EYt=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Uh({cacheDir:e,cwd:r}),{name:i,relPath:s}=await vYt(t,r);return mYt(n,i,s)},vYt=async function(t,e){let r=await Ute(e),n=bYt(t);return r.map(({name:i,base:s})=>wYt(i,s,n)).find(Boolean)},bYt=function(t){return t.replace(TYt,"\\")},TYt=/^[a-zA-Z]:\\/,wYt=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},Ute=async function(t){return[...await RYt(t),{name:"home",base:pYt()},{name:"root",base:Mte}]},RYt=async function(t){let e=await Dte(t);return e===""?[]:[{name:"cwd",base:e}]};var xYt=1,Fte=async function({cacheDir:t,cwd:e,depth:r=xYt}={}){let n=await Ute(e),i=Uh({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>PYt({name:a,base:c,cacheDir:i,depth:r})))).flat()},PYt=async function({name:t,base:e,cacheDir:r,depth:n}){return(await _Ve(`${r}/${t}`,{fileFilter:CYt,depth:n,type:"files_directories"})).map(({path:o})=>AYt(e,o))},CYt=function({basename:t}){return!CVe(t)};var IYt=async function(t,{move:e=NVe,ttl:r=$Yt,digests:n=[],cacheDir:i,cwd:s}={}){let{srcPath:o,cachePath:a}=await gA({path:t,cacheDir:i,cwdOpt:s});if(!await hA(o))return!1;let{manifestInfo:c,identical:l}=await AVe({cachePath:a,move:e,ttl:r,digests:n});return l||(await jte(a,{force:!0,recursive:!0,maxRetries:3}),await Ite(o,a,e),await xVe(c)),!0},OYt=async function(t,{move:e=NVe,cacheDir:r,cwd:n}={}){let{srcPath:i,cachePath:s}=await gA({path:t,cacheDir:r,cwdOpt:n});return!await hA(s)||await Lte(s)?!1:(await jte(i,{force:!0,recursive:!0,maxRetries:3}),await Ite(s,i,e),!0)},NYt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await gA({path:t,cacheDir:e,cwdOpt:r});return await hA(n)?(await jte(n,{force:!0,recursive:!0,maxRetries:3}),await PVe(n),!0):!1},kYt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await gA({path:t,cacheDir:e,cwdOpt:r});return await hA(n)&&!await Lte(n)},NVe=!1,$Yt=void 0,OU=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(i=>t(i,...r)))).some(Boolean):t(e,...r)},LYt=OU.bind(null,IYt),DYt=OU.bind(null,OYt),MYt=OU.bind(null,NYt),UYt=OU.bind(null,kYt),kVe=function(t){return{save:(e,r)=>LYt(e,{...t,...r}),restore:(e,r)=>DYt(e,{...t,...r}),remove:(e,r)=>MYt(e,{...t,...r}),has:(e,r)=>UYt(e,{...t,...r}),list:e=>Fte({...t,...e}),getCacheDir:e=>Uh({...t,...e})}};var FYt=he("opencode_session"),jYt=async t=>{try{let e=await y1(t),{stdout:r}=await $n(e,["session","list","--format","json"],{cwd:t,env:{...process.env,OPENCODE_DISABLE_AUTOUPDATE:"1"}}),n=String(r??"").trim();if(!n)return[];let i=JSON.parse(n);return Array.isArray(i)?i:[]}catch(e){return FYt.warn("Could not list opencode sessions",{error:e?.message}),[]}},zte=new Map,$Ve=t=>{let e=zte.get(t);if(e)return e;let r=jYt(t).finally(()=>zte.delete(t));return zte.set(t,r),r},LVe=async t=>(await $Ve(t)).length>0,DVe=async(t,e)=>e?(await $Ve(t)).some(r=>r.id===e):!1;var _n=he("native_session"),qte=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await Gl.stat(Wl.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),Vh=async({runnerId:t,sessionId:e,archive:r,nativeSessionId:n})=>{if(!r)return _n.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:i,include:s}=r,o=!1;try{o=(await Gl.stat(i)).isDirectory()}catch{}if(!o)return _n.log(`Native session base dir ${i} not found, skipping`),null;let a=await qte(i,s);if(a.length===0)return _n.log(`No native session history found under ${i}, skipping`),null;let c=Wl.join(MVe.tmpdir(),`native-session-${e}.zip`);try{await $n("zip",["-r","-q","-X",c,...a],{cwd:i});let l=await Gl.readFile(c);_n.log(`Zipped native session (${l.length} bytes) from ${a.join(", ")}`,{nativeSessionId:n});let{upload_url:u,s3_key:d}=await QFe(t,e);return await aje(u,l,{contentType:"application/zip"}),_n.log("Successfully uploaded native session to S3"),d}catch(l){return _n.error("Failed to archive/upload native session, continuing without it:",l),null}finally{await Gl.rm(c,{force:!0}).catch(()=>{})}},UVe=async(t,e,r=process.cwd())=>{if(e==="opencode")return LVe(r);if(!t)return!1;let{baseDir:n,include:i}=t,s=await qte(n,i);for(let o of s)if((await Gl.readdir(Wl.join(n,o)).catch(()=>[])).length>0)return!0;return!1},zYt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),FVe=async(t,e)=>{let r=await Gl.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await FVe(Wl.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},jVe=async(t,e,r,n=process.cwd())=>{if(r==="opencode")return DVe(n,e);if(!t||!e)return!1;let i=new RegExp(`(^|[^a-zA-Z0-9])${zYt(e)}([^a-zA-Z0-9]|$)`),{baseDir:s,include:o}=t,a=await qte(s,o);for(let c of a)if(await FVe(Wl.join(s,c),i))return!0;return!1},zVe=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return _n.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,i=Wl.join(MVe.tmpdir(),`native-session-restore-${e}.zip`);try{let s=await eje(t,e);if(!s?.download_url)return _n.log("No native session available to restore, skipping"),!1;let o=await oje(s.download_url);return await Gl.writeFile(i,o),_n.log(`Downloaded native session (${o.length} bytes) to ${i}`),await Gl.mkdir(n,{recursive:!0}),await $n("unzip",["-o","-q",i,"-d",n]),_n.log(`Restored native session into ${n}`),!0}catch(s){return _n.error("Failed to fetch/restore native session, continuing without it:",s),!1}finally{await Gl.rm(i,{force:!0}).catch(()=>{})}},qYt="native-sessions",qVe=(t,e)=>kVe({cacheDir:Wl.join(e.dir,qYt),cwd:t}),BVe=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await qVe(r,e).restore(n.map(s=>Wl.join(r,s)),{})?(_n.log(`Restored native session from buildbot cache into ${r}`),!0):(_n.log("No native session in buildbot cache, skipping restore"),!1)}catch(i){return _n.error("Failed to restore native session from buildbot cache, continuing without it:",i),!1}},_A=async({archive:t,cache:e,nativeSessionId:r})=>{if(!e?.dir||!t)return _n.log("No buildbot cache configured for the native session, skipping cache seed",{nativeSessionId:r}),!1;let{baseDir:n,include:i}=t;try{return await qVe(n,e).save(i.map(o=>Wl.join(n,o)),{})?(_n.log(`Saved native session to buildbot cache under ${e.dir}`,{nativeSessionId:r}),!0):(_n.log("No native session history to save to buildbot cache, skipping"),!1)}catch(s){return _n.error("Failed to save native session to buildbot cache, continuing:",s),!1}};var xE=he("inference_stage"),HVe=5,uf=async t=>{let{additionalContext:e,cliPath:r,config:n,context:i,buildErrors:s,runner:o,persistSteps:a,aiGateway:c,attempt:l,contextPrefix:u,priorAgentSessionId:d,cwd:f,abortSignal:p,onSessionId:h,resumeForCreditWrapUp:m,forceLowEffortForCreditWrapUp:_,answerFold:y}=t;if(Vi())throw new Error("Shutdown in progress, aborting inference stage");xE.log(`Running inference stage, attempt ${l} of ${HVe}`);let v=!1,S=await sr(Ct(),"inference-stage",async g=>{g?.setAttributes({"inference.attempt":l||1}),wAe();let w=!!(l&&l>1),x=await BYt({config:n,isRetry:w,cwd:f,resumeForCreditWrapUp:m}),R=!!m&&!!d;R&&n.runner==="gemini"&&!await w0(d)&&(R=!1);let b=x.viable||R;v=b,x.outcome!=="not_eligible"&&fe.inc("inference.native_resume",1,{outcome:x.outcome,...x.source?{source:x.source}:{}});let P=n;if("prompt"in n&&n.answeredInteraction&&Je().questionsEnabled){let C=n.answeredInteraction,N=b||w&&!!d,z=[C];if(!N){y.allAnswered??=Nze(n);let Y=await y.allAnswered;Y===null&&(y.allAnswered=void 0),Y&&Y.length>0&&(z=Y.some(ue=>ue.refId===C.refId)?Y:[...Y,C])}P={...n,prompt:Lze(n.prompt,z)},!w&&!y.counted&&(y.counted=!0,xE.log("Resuming session with answered questions",{sessionId:n.sessionId,interactionCount:z.length}),fe.inc("inference.answer_resume",1,{fold:N?"latest":"all"}),$ze(C))}let{prompt:O}=await sr(Ct(),"compose-prompt",async()=>await Aze({cliPath:r,config:P,buildErrorContext:HYt(s),netlify:i,additionalContext:e,resumePrompt:b,preserveResultsFile:!!m})),A=`
998
998
  ${u||""}
999
999
  ${O}
1000
- `.trim(),F={...n,prompt:A},I=d??(b?x.sessionId:void 0),T=await sr(Ct(),`run-${n.runner}`,async C=>{let N=RX();C?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":lUe(n.runner),"gen_ai.system":n.runner,...N?{"gen_ai.input.messages":MM("user",A)}:{}});let z=Date.now(),Y=await o({aiGateway:c,config:F,netlify:i,persistSteps:a,continueSession:w||b,priorAgentSessionId:I,cwd:f,cliPath:r,abortSignal:p,onSessionId:h,..._?{forceLowEffortForCreditWrapUp:_}:{}}),ue=Date.now(),xe=Y.resolvedModel||n.model||"unknown",Me=Y.error?"error":"stop";return C?.setAttributes({...N?{"gen_ai.output.messages":MM("assistant",Y.result??Y.error??"",Me)}:{},"gen_ai.response.finish_reasons":[Me],"gen_ai.request.model":xe,"gen_ai.response.model":xe,"gen_ai.request.effort":Y.effort??"auto",...Y.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":Y.usage.input_tokens}:{},...Y.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":Y.usage.output_tokens}:{},...Y.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":Y.usage.cache_creation_input_tokens}:{},...Y.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":Y.usage.cache_read_input_tokens}:{},...Y.usage?.reasoning_output_tokens!=null?{"gen_ai.usage.reasoning.output_tokens":Y.usage.reasoning_output_tokens}:{}}),uUe(Y.steps??[],n.mode,z,ue),Y});return T.result&&(T.result=Hi(T.result)),T.error&&(T.error=Hi(T.error)),await a.flush(),T});if(S.aborted)return xE.log("Inference turn was interrupted (credit wrap-up); skipping retry/error handling",{agentSessionId:S.agentSessionId}),{runnerResult:S,nativeResume:v};if(S.error){if(Vi()){let R=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(R,{agentSessionId:S.agentSessionId}),R}let g=S.providerFailure,w=sN(g);xE.error("Runner failed",{stepsCount:S.steps.length,duration:S.duration,error:S.error,isRetryableError:S.isRetryableError,attempt:l||1,agentSessionId:S.agentSessionId,...g?{providerFailure:g,failureClass:w?.failureClass}:{}}),fe.inc("inference.failed",1,{attempt:l||1,is_retryable:!!S.isRetryableError,is_provider_unavailable:!!S.isProviderUnavailableError,is_answer_resume:!!n.answeredInteraction,upstream_status:g?.status??"none",failure_class:w?.failureClass??"unclassified"});let x=w?.maxAttempts??HVe;if(S.isRetryableError&&(!l||l<x))return xE.log("Retrying inference stage"),await new Promise(b=>setTimeout(b,5e3)),{runnerResult:(await uf({...t,attempt:(l||1)+1,priorAgentSessionId:S.agentSessionId,contextPrefix:S.agentSessionId?"":"<important> The agent has already started on this work but ran into networking errors trying to complete it. Please continue from where it left off (you can use git commands to see what's currently changed thus far) and do not start over. Here is the full prompt for context: </important>"})).runnerResult,nativeResume:v};{if(xE.log("Do not retry inference stage"),S.error.toLowerCase().includes("usage exceeded")){let b=new ho(S.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);throw Object.assign(b,{agentSessionId:S.agentSessionId}),b}let R=S.isRetryableError||S.isProviderUnavailableError?new gf(S.error):new Error(S.error);throw Object.assign(R,{agentSessionId:S.agentSessionId}),R}}return{runnerResult:S,nativeResume:v}},BYt=async(t,e,r=process.cwd())=>{if(e)return{viable:!1,outcome:"not_eligible"};let n=t.previousSession,{viable:i,outcome:s}=xze(t);if(!i)return{viable:i,outcome:s};let o=n?.nativeSessionId,a=pc(t.runner),c=async()=>o?t.runner==="gemini"?!!await E7(o):jVe(a,o,t.runner,r):!1,l;if(VVe(t)&&await UVe(a,t.runner,r))l="local";else if(t.fastInit&&Je().warmNativeResumeEnabled&&await BVe({archive:a,cache:t.cache})&&await c())l="cache_restore";else{if(l="fetch",!Je().coldResumeFromS3Enabled)return{viable:!1,outcome:"cold_resume_disabled",source:l};if(!await zVe({runnerId:t.id,sessionId:t.sessionId,archive:a}))return{viable:!1,outcome:"fetch_failed",source:l}}return t.runner==="gemini"&&o&&!await w0(o)?{viable:!1,outcome:"sanitize_failed",source:l}:{viable:!0,sessionId:o,outcome:"resumed",source:l}},HYt=t=>!t||t.length===0?"":`
1000
+ `.trim(),F={...n,prompt:A},I=d??(b?x.sessionId:void 0),T=await sr(Ct(),`run-${n.runner}`,async C=>{let N=RX();C?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":lUe(n.runner),"gen_ai.system":n.runner,...N?{"gen_ai.input.messages":MM("user",A)}:{}});let z=Date.now(),Y=await o({aiGateway:c,config:F,netlify:i,persistSteps:a,continueSession:w||b,priorAgentSessionId:I,cwd:f,cliPath:r,abortSignal:p,onSessionId:h,..._?{forceLowEffortForCreditWrapUp:_}:{}}),ue=Date.now(),xe=Y.resolvedModel||n.model||"unknown",Me=Y.error?"error":"stop";return C?.setAttributes({...N?{"gen_ai.output.messages":MM("assistant",Y.result??Y.error??"",Me)}:{},"gen_ai.response.finish_reasons":[Me],"gen_ai.request.model":xe,"gen_ai.response.model":xe,"gen_ai.request.effort":Y.effort??"auto",...Y.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":Y.usage.input_tokens}:{},...Y.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":Y.usage.output_tokens}:{},...Y.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":Y.usage.cache_creation_input_tokens}:{},...Y.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":Y.usage.cache_read_input_tokens}:{},...Y.usage?.reasoning_output_tokens!=null?{"gen_ai.usage.reasoning.output_tokens":Y.usage.reasoning_output_tokens}:{}}),uUe(Y.steps??[],n.mode,z,ue),Y});return T.result&&(T.result=Hi(T.result)),T.error&&(T.error=Hi(T.error)),await a.flush(),T});if(S.aborted)return xE.log("Inference turn was interrupted (credit wrap-up); skipping retry/error handling",{agentSessionId:S.agentSessionId}),{runnerResult:S,nativeResume:v};if(S.error){if(Vi()){let R=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(R,{agentSessionId:S.agentSessionId}),R}let g=S.providerFailure,w=sN(g);xE.error("Runner failed",{stepsCount:S.steps.length,duration:S.duration,error:S.error,isRetryableError:S.isRetryableError,attempt:l||1,agentSessionId:S.agentSessionId,...g?{providerFailure:g,failureClass:w?.failureClass}:{}}),fe.inc("inference.failed",1,{attempt:l||1,is_retryable:!!S.isRetryableError,is_provider_unavailable:!!S.isProviderUnavailableError,is_answer_resume:!!n.answeredInteraction,upstream_status:g?.status??"none",failure_class:w?.failureClass??"unclassified"});let x=w?.maxAttempts??HVe;if(S.isRetryableError&&(!l||l<x))return xE.log("Retrying inference stage"),await new Promise(b=>setTimeout(b,5e3)),{runnerResult:(await uf({...t,attempt:(l||1)+1,priorAgentSessionId:S.agentSessionId,contextPrefix:S.agentSessionId?"":"<important> The agent has already started on this work but ran into networking errors trying to complete it. Please continue from where it left off (you can use git commands to see what's currently changed thus far) and do not start over. Here is the full prompt for context: </important>"})).runnerResult,nativeResume:v};{if(xE.log("Do not retry inference stage"),S.error.toLowerCase().includes("usage exceeded")){let b=new ho(S.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);throw Object.assign(b,{agentSessionId:S.agentSessionId}),b}let R=S.isRetryableError||S.isProviderUnavailableError?new gf(S.error):new Error(S.error);throw Object.assign(R,{agentSessionId:S.agentSessionId}),R}}return{runnerResult:S,nativeResume:v}},BYt=async({config:t,isRetry:e,cwd:r=process.cwd(),resumeForCreditWrapUp:n})=>{if(e||n)return{viable:!1,outcome:"not_eligible"};let i=t.previousSession,{viable:s,outcome:o}=xze(t);if(!s)return{viable:s,outcome:o};let a=i?.nativeSessionId,c=pc(t.runner),l=async()=>a?t.runner==="gemini"?!!await E7(a):jVe(c,a,t.runner,r):!1,u;if(VVe(t)&&await UVe(c,t.runner,r))u="local";else if(t.fastInit&&Je().warmNativeResumeEnabled&&await BVe({archive:c,cache:t.cache})&&await l())u="cache_restore";else{if(u="fetch",!Je().coldResumeFromS3Enabled)return{viable:!1,outcome:"cold_resume_disabled",source:u};if(!await zVe({runnerId:t.id,sessionId:t.sessionId,archive:c}))return{viable:!1,outcome:"fetch_failed",source:u}}return t.runner==="gemini"&&a&&!await w0(a)?{viable:!1,outcome:"sanitize_failed",source:u}:{viable:!0,sessionId:a,outcome:"resumed",source:u}},HYt=t=>!t||t.length===0?"":`
1001
1001
  Deploy failed. Here are the errors to review on the latest build:
1002
1002
 
1003
1003
  Below are all of the logs with potential issues that we extracted. Some of them may be false positives, discern them carefully and ensure fixes are relevant.