@netlify/agent-runner-cli 1.136.0-ex-2324.1 → 1.136.0-ex-2324.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +2 -2
- package/dist/bin.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -501,7 +501,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
501
501
|
`,LF:`
|
|
502
502
|
`,concatBytes:KU},PZe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},xZe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:PZe};import{Buffer as IZe}from"buffer";var dle=(t,e)=>t?void 0:NZe.bind(void 0,e),NZe=function*(t,e){if(typeof e!="string"&&!ar(e)&&!IZe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},hle=(t,e)=>t?MZe.bind(void 0,e):LZe.bind(void 0,e),MZe=function*(t,e){ple(t,e),yield e},LZe=function*(t,e){if(ple(t,e),typeof e!="string"&&!ar(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},ple=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
503
503
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
504
|
-
if (condition) { yield value; }`)};import{Buffer as DZe}from"buffer";import{StringDecoder as kZe}from"string_decoder";var DA=(t,e,r)=>{if(r)return;if(t)return{transform:$Ze.bind(void 0,new TextEncoder)};let n=new kZe(e);return{transform:FZe.bind(void 0,n),final:UZe.bind(void 0,n)}},$Ze=function*(t,e){DZe.isBuffer(e)?yield wa(e):typeof e=="string"?yield t.encode(e):yield e},FZe=function*(t,e){yield ar(e)?t.write(e):e},UZe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as mle}from"util";var XU=mle(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),kA=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=BZe}=e[r];for await(let s of n(t))yield*kA(s,e,r+1)},gle=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*qZe(r,Number(e),t)},qZe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*kA(n,r,e+1)},_le=mle(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),BZe=function*(t){yield t};var QU=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},yle=(t,e)=>[...e.flatMap(r=>[...yf(r,t,0)]),...eE(t)],yf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=HZe}=e[r];for(let s of n(t))yield*yf(s,e,r+1)},eE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*jZe(r,Number(e),t)},jZe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*yf(n,r,e+1)},HZe=function*(t){yield t};var ZU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=Ele(t,o,i),l=_f(e),u=_f(r),f=l?XU.bind(void 0,kA,a):QU.bind(void 0,yf),d=l||u?XU.bind(void 0,gle,a):QU.bind(void 0,eE),h=l||u?_le.bind(void 0,a):void 0;return{stream:new VZe({writableObjectMode:n,writableHighWaterMark:Sle(n),readableObjectMode:s,readableHighWaterMark:Sle(s),transform(m,g,y){f([m,c,0],this,y)},flush(m){d([c],this,m)},destroy:h})}},$A=(t,e,r,n)=>{let s=e.filter(({type:o})=>o==="generator"),i=n?s.reverse():s;for(let{value:o,optionName:a}of i){let c=Ele(o,r,a);t=yle(c,t)}return t},Ele=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:dle(n,a)},DA(r,o,n),LA(r,i,n,c),{transform:t,final:e},{transform:hle(s,a)},fle({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var Tle=(t,e)=>{for(let r of GZe(t))zZe(t,r,e)},GZe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),zZe=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${ol[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>WZe(a,n));r.input=VS(o)},WZe=(t,e)=>{let r=$A(t,e,"utf8",!0);return YZe(r),VS(r)},YZe=t=>{let e=t.find(r=>typeof r!="string"&&!ar(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 QZe,appendFileSync as ZZe}from"fs";var FA=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&kp(r,n)&&!es.has(e)&&KZe(n)&&(t.some(({type:s,value:i})=>s==="native"&&JZe.has(i))||t.every(({type:s})=>Bs.has(s))),KZe=t=>t===1||t===2,JZe=new Set(["pipe","overlapped"]),ble=async(t,e,r,n)=>{for await(let s of t)XZe(e)||wle(s,r,n)},vle=(t,e,r)=>{for(let n of t)wle(n,e,r)},XZe=t=>t._readableState.pipes.length>0,wle=(t,e,r)=>{let n=QR(t);ho({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Rle=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:s})=>{if(e===null)return{output:Array.from({length:3})};let i={},o=new Set([]);return{output:e.map((c,l)=>eet({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},eet=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:f})=>{if(t===null)return;let d=Ace(t,i,f),h=wa(d),{stdioItems:p,objectMode:m}=e[r],g=tet([h],p,c,n),{serializedResult:y,finalResult:T=y}=ret({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});net({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let S=a[r]?T:void 0;try{return n.error===void 0&&set(y,p,s),S}catch(_){return n.error=_,S}},tet=(t,e,r,n)=>{try{return $A(t,e,r,!1)}catch(s){return n.error=s,t}},ret=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:VS(t)};let o=qie(t,r);return n[i]?{serializedResult:o,finalResult:JU(o,!s[i],e)}:{serializedResult:o}},net=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!FA({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=JU(t,!1,o);try{vle(a,e,n)}catch(c){r.error??=c}},set=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>NA.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?ZZe(n,t):(r.add(i),QZe(n,t))}};var Ale=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ca(e,r,"all")]:Array.isArray(e)?[Ca(t,r,"all"),...e]:ar(t)&&ar(e)?iU([t,e]):`${t}${e}`};import{once as eq}from"events";var Cle=async(t,e)=>{let[r,n]=await iet(t);return e.isForcefullyTerminated??=!1,[r,n]},iet=async t=>{let[e,r]=await Promise.allSettled([eq(t,"spawn"),eq(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Ole(t):r.value},Ole=async t=>{try{return await eq(t,"exit")}catch{return Ole(t)}},Ple=async t=>{let[e,r]=await t;if(!oet(e,r)&&tq(e,r))throw new gi;return[e,r]},oet=(t,e)=>t===void 0&&e===void 0,tq=(t,e)=>t!==0||e!==null;var xle=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=aet(t,e,r),o=i?.code==="ETIMEDOUT",a=Rce(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},aet=(t,e,r)=>t!==void 0?t:tq(e,r)?new gi:void 0;var Ile=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=uet(t,e,r),f=het({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return zp(f,c,l)},uet=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=eA(t,e,r),a=fet(r),{file:c,commandArguments:l,options:u}=EA(t,e,a);det(u);let f=ale(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},fet=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,det=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&UA("ipcInput"),t&&UA("ipc: true"),r&&UA("detached: true"),n&&UA("cancelSignal")},UA=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},het=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=pet({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:f,timedOut:d,isMaxBuffer:h}=xle(c,r),{output:p,error:m=l}=Rle({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),g=p.map((T,S)=>Ca(T,r,S)),y=Ca(Ale(p,r),r,"all");return get({error:m,exitCode:u,signal:f,timedOut:d,isMaxBuffer:h,stdio:g,all:y,options:r,command:n,escapedCommand:s,startTime:a})},pet=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{Tle(i,r);let a=met(r);return cet(...TA(t,e,a))}catch(a){return Gp({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},met=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:OA(e)}),get=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:s,stdio:i,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?PA({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):ZS({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:s,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:i,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as srt}from"events";import{spawn as irt}from"child_process";import kle from"process";import{once as rq,on as _et}from"events";var Nle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Up({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:pA(t)}),yet({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),yet=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{uA(e,s);let i=il(t,e,r),o=new AbortController;try{return await Promise.race([Eet(i,n,o),Tet(i,r,o),bet(i,r,o)])}catch(a){throw qp(t),a}finally{o.abort(),fA(e,s)}},Eet=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await rq(t,"message",{signal:r});return n}for await(let[n]of _et(t,"message",{signal:r}))if(e(n))return n},Tet=async(t,e,{signal:r})=>{await rq(t,"disconnect",{signal:r}),yae(e)},bet=async(t,e,{signal:r})=>{let[n]=await rq(t,"strict:error",{signal:r});throw aA(n,e)};import{once as Lle,on as vet}from"events";var Dle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>nq({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),nq=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Up({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:pA(t)}),uA(e,i);let o=il(t,e,r),a=new AbortController,c={};return wet(t,o,a),Ret({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Aet({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},wet=async(t,e,r)=>{try{await Lle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Ret=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await Lle(t,"strict:error",{signal:r.signal});n.error=aA(s,e),r.abort()}catch{}},Aet=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of vet(r,"message",{signal:i.signal}))Mle(o),yield c}catch{Mle(o)}finally{i.abort(),fA(e,a),n||qp(t),s&&await t}},Mle=({error:t})=>{if(t)throw t};var $le=(t,{ipc:e})=>{Object.assign(t,Ule(t,!1,e))},Fle=()=>{let t=kle,e=!0,r=kle.channel!==void 0;return{...Ule(t,e,r),getCancelSignal:Gae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Ule=(t,e,r)=>({sendMessage:yA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Nle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Dle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Cet}from"child_process";import{PassThrough as Oet,Readable as Pet,Writable as xet,Duplex as Iet}from"stream";var qle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{WU(n);let a=new Cet;Net(a,n),Object.assign(a,{readable:Met,writable:Let,duplex:Det});let c=Gp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=ket(c,o,s);return{subprocess:a,promise:l}},Net=(t,e)=>{let r=tE(),n=tE(),s=tE(),i=Array.from({length:e.length-3},tE),o=tE(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},tE=()=>{let t=new Oet;return t.end(),t},Met=()=>new Pet({read(){}}),Let=()=>new xet({write(){}}),Det=()=>new Iet({read(){},write(){}}),ket=async(t,e,r)=>zp(t,e,r);import{createReadStream as Ble,createWriteStream as jle}from"fs";import{Buffer as $et}from"buffer";import{Readable as rE,Writable as Fet,Duplex as Uet}from"stream";var Vle=(t,e)=>MA(qet,t,e,!1),nE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ol[t]}.`)},Hle={fileNumber:nE,generator:ZU,asyncGenerator:ZU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Uet.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},qet={input:{...Hle,fileUrl:({value:t})=>({stream:Ble(t)}),filePath:({value:{file:t}})=>({stream:Ble(t)}),webStream:({value:t})=>({stream:rE.fromWeb(t)}),iterable:({value:t})=>({stream:rE.from(t)}),asyncIterable:({value:t})=>({stream:rE.from(t)}),string:({value:t})=>({stream:rE.from(t)}),uint8Array:({value:t})=>({stream:rE.from($et.from(t))})},output:{...Hle,fileUrl:({value:t})=>({stream:jle(t)}),filePath:({value:{file:t,append:e}})=>({stream:jle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Fet.fromWeb(t)}),iterable:nE,asyncIterable:nE,string:nE,uint8Array:nE}};import{on as Bet,once as Gle}from"events";import{PassThrough as jet,getDefaultHighWaterMark as Het}from"stream";import{finished as Yle}from"stream/promises";function Sf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)iq(s);let e=t.some(({readableObjectMode:s})=>s),r=Vet(t,e),n=new sq({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var Vet=(t,e)=>{if(t.length===0)return Het(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},sq=class extends jet{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(iq(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Get(this,this.#e,this.#i);let r=Yet({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(iq(e),!this.#e.has(e))return!1;let r=this.#s.get(e);return r===void 0?!1:(this.#s.delete(e),e.unpipe(this),await r,!0)}},Get=async(t,e,r)=>{qA(t,zle);let n=new AbortController;try{await Promise.race([zet(t,n),Wet(t,e,r,n)])}finally{n.abort(),qA(t,-zle)}},zet=async(t,{signal:e})=>{try{await Yle(t,{signal:e,cleanup:!0})}catch(r){throw Kle(t,r),r}},Wet=async(t,e,r,{signal:n})=>{for await(let[s]of Bet(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},iq=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Yet=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{qA(t,Wle);let a=new AbortController;try{await Promise.race([Ket(i,e,a),Jet({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),Xet({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),qA(t,-Wle)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?oq(t):Qet(t))},Ket=async(t,e,{signal:r})=>{try{await t,r.aborted||oq(e)}catch(n){r.aborted||Kle(e,n)}},Jet=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await Yle(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;Jle(o)?s.add(e):Xle(t,o)}},Xet=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await Gle(t,s,{signal:i}),!t.readable)return Gle(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},Qet=t=>{t.writable&&t.end()},Kle=(t,e)=>{Jle(e)?oq(t):Xle(t,e)},Jle=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oq=t=>{(t.readable||t.writable)&&t.destroy()},Xle=(t,e)=>{t.destroyed||(t.once("error",Zet),t.destroy(e))},Zet=()=>{},qA=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},zle=2,Wle=1;import{finished as Qle}from"stream/promises";var Yp=(t,e)=>{t.pipe(e),ett(t,e),ttt(t,e)},ett=async(t,e)=>{if(!(mi(t)||mi(e))){try{await Qle(t,{cleanup:!0,readable:!0,writable:!1})}catch{}aq(e)}},aq=t=>{t.writable&&t.end()},ttt=async(t,e)=>{if(!(mi(t)||mi(e))){try{await Qle(e,{cleanup:!0,readable:!1,writable:!0})}catch{}cq(t)}},cq=t=>{t.readable&&t.destroy()};var Zle=(t,e,r)=>{let n=new Map;for(let[s,{stdioItems:i,direction:o}]of Object.entries(e)){for(let{stream:a}of i.filter(({type:c})=>Bs.has(c)))rtt(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!Bs.has(c)))stt({subprocess:t,stream:a,direction:o,fdNumber:s,pipeGroups:n,controller:r})}for(let[s,i]of n.entries()){let o=i.length===1?i[0]:Sf(i);Yp(o,s)}},rtt=(t,e,r,n)=>{r==="output"?Yp(t.stdio[n],e):Yp(e,t.stdio[n]);let s=ntt[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},ntt=["stdin","stdout","stderr"],stt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;itt(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},itt=(t,{signal:e})=>{mi(t)&&mf(t,ott,e)},ott=2;import{addAbortListener as ltt}from"events";var Ef=[];Ef.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ef.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ef.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var BA=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",lq=Symbol.for("signal-exit emitter"),uq=globalThis,att=Object.defineProperty.bind(Object),fq=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(uq[lq])return uq[lq];att(uq,lq,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},jA=class{},ctt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),dq=class extends jA{onExit(){return()=>{}}load(){}unload(){}},hq=class extends jA{#e=pq.platform==="win32"?"SIGINT":"SIGHUP";#r=new fq;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of Ef)this.#s[r]=()=>{let n=this.#t.listeners(r),{count:s}=this.#r,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#i=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!BA(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 Ef)try{let r=this.#s[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,Ef.forEach(e=>{let r=this.#s[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.#i,this.#r.count-=1)}#a(e){return BA(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#i.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&BA(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let s=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),s}else return n.call(this.#t,e,...r)}},pq=globalThis.process,{onExit:eue,load:ZGt,unload:ezt}=ctt(BA(pq)?new hq(pq):new dq);var tue=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=eue(()=>{t.kill()});ltt(n,()=>{s()})};var nue=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=ZR(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=utt(r,n,s),{sourceStream:f,sourceError:d}=dtt(t,l),{options:h,fileDescriptors:p}=mo.get(t);return{sourcePromise:e,sourceStream:f,sourceOptions:h,sourceError:d,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},utt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=ftt(t,e,...r),a=lA(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},ftt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(rue,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||nU(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[s,i,o]=HR(r,...n);return{destination:e(rue)(s,i,o),pipeOptions:o}}if(mo.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}`)},rue=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),dtt=(t,e)=>{try{return{sourceStream:Bp(t,e)}}catch(r){return{sourceError:r}}};var iue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=htt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw mq({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},htt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return cq(t),n;if(e!==void 0)return aq(r),e},mq=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Gp({error:t,command:sue,escapedCommand:sue,fileDescriptors:e,options:r,startTime:n,isSync:!1}),sue="source.pipe(destination)";var oue=async t=>{let[{status:e,reason:r,value:n=r},{status:s,reason:i,value:o=i}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),s==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as ptt}from"stream/promises";var aue=(t,e,r)=>{let n=HA.has(e)?gtt(t,e):mtt(t,e);return mf(t,ytt,r.signal),mf(e,Stt,r.signal),_tt(e),n},mtt=(t,e)=>{let r=Sf([t]);return Yp(r,e),HA.set(e,r),r},gtt=(t,e)=>{let r=HA.get(e);return r.add(t),r},_tt=async t=>{try{await ptt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}HA.delete(t)},HA=new WeakMap,ytt=2,Stt=1;import{aborted as Ett}from"util";var cue=(t,e)=>t===void 0?[]:[Ttt(t,e)],Ttt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await Ett(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw mq({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var VA=(t,...e)=>{if(Jt(e[0]))return VA.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=nue(t,...e),s=btt({...n,destination:r});return s.pipe=VA.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},btt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=vtt(t,s);iue({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let f=new AbortController;try{let d=aue(e,i,f);return await Promise.race([oue(u),...cue(a,{sourceStream:e,mergedStream:d,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{f.abort()}},vtt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as xtt}from"timers/promises";import{on as wtt}from"events";import{getDefaultHighWaterMark as Rtt}from"stream";var GA=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return Att(e,o),uue({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},Att=async(t,e)=>{try{await t}catch{}finally{e.abort()}},gq=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;Ctt(e,o,t);let a=t.readableObjectMode&&!i;return uue({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Ctt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},uue=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=wtt(t,"data",{signal:e.signal,highWaterMark:lue,highWatermark:lue});return Ott({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},_q=Rtt(!0),lue=_q,Ott=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Ptt({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*yf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*eE(a)}},Ptt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[DA(t,r,!e),LA(t,s,!n,{})].filter(Boolean);var fue=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let f=Itt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([Ntt(t),f]);return}let d=YU(c,r),h=gq({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:d,allMixed:a}),[p]=await Promise.all([Mtt({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),f]);return p},Itt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!FA({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=gq({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await ble(a,t,r,i)},Ntt=async t=>{await xtt(),t.readableFlowing===null&&t.resume()},Mtt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await RA(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await AA(r,{maxBuffer:i})):await Vp(r,{maxBuffer:i})}catch(a){return due(bce({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},yq=async t=>{try{return await t}catch(e){return due(e)}},due=({bufferedData:t})=>Fie(t)?new Uint8Array(t):t;import{finished as Ltt}from"stream/promises";var sE=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Dtt(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Ltt(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Ftt(a,e,r,n)}finally{o.abort()}},Dtt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&ktt(t,r,n),n},ktt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{$tt(e,r),n.call(t,...s)}},$tt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Ftt=(t,e,r,n)=>{if(!Utt(t,e,r,n))throw t},Utt=(t,e,r,n=!0)=>r.propagating?hue(t)||zA(t):(r.propagating=!0,Sq(r,e)===n?hue(t):zA(t)),Sq=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",zA=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",hue=t=>t?.code==="EPIPE";var pue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>Eq({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),Eq=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=sE(t,e,l);if(Sq(l,e)){await u;return}let[f]=await Promise.all([fue({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return f};var mue=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Sf([t,e].filter(Boolean)):void 0,gue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>Eq({...qtt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:Btt(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),qtt=({stdout:t,stderr:e,all:r},[,n,s])=>{let i=n||s;return i?n?s?{stream:r,buffer:i}:{stream:t,buffer:i}:{stream:e,buffer:i}:{stream:r,buffer:i}},Btt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as jtt}from"events";var _ue=t=>kp(t,"ipc"),yue=(t,e)=>{let r=QR(t);ho({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Sue=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=_ue(i),a=Ra(e,"ipc"),c=Ra(r,"ipc");for await(let l of nq({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(vce(t,s,c),s.push(l)),o&&yue(l,i);return s},Eue=async(t,e)=>(await Promise.allSettled([t]),e);var Tue=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:f},context:d,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:g,controller:y})=>{let T=Cle(t,d),S={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:T,propagating:!1},_=pue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),A=gue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),P=[],C=Sue({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:h}),R=Htt(m,t,S),O=Vtt(p,S);try{return await Promise.race([Promise.all([{},Ple(T),Promise.all(_),A,C,tce(t,f),...R,...O]),g,Gtt(t,y),...Jae(t,i,d,y),..._ae({subprocess:t,cancelSignal:o,gracefulCancel:a,context:d,controller:y}),...Yae({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:d,controller:y})])}catch(w){return d.terminationReason??="other",Promise.all([{error:w},T,Promise.all(_.map(b=>yq(b))),yq(A),Eue(C,P),Promise.allSettled(R),Promise.allSettled(O)])}},Htt=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:sE(n,s,r)),Vtt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>yi(i,{checkOpen:!1})&&!mi(i)).map(({type:s,value:i,stream:o=i})=>sE(o,n,e,{isSameDirection:Bs.has(s),stopOnExit:s==="native"}))),Gtt=async(t,{signal:e})=>{let[r]=await jtt(t,"error",{signal:e});throw r};var bue=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),iE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=po();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Kp=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 ztt}from"stream";import{callbackify as Wtt}from"util";import{finished as vue}from"stream/promises";var Tq=async t=>{if(t!==void 0)try{await bq(t)}catch{}},wue=async t=>{if(t!==void 0)try{await vq(t)}catch{}},bq=async t=>{await vue(t,{cleanup:!0,readable:!1,writable:!0})},vq=async t=>{await vue(t,{cleanup:!0,readable:!0,writable:!1})},WA=async(t,e)=>{if(await t,e)throw e},YA=(t,e,r)=>{r&&!zA(r)?t.destroy(r):e&&t.destroy()};var Rue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||es.has(r),{subprocessStdout:a,waitReadableDestroy:c}=wq(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:f}=Rq(a,o),{read:d,onStdoutDataDone:h}=Aq({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new ztt({read:d,destroy:Wtt(Oq.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:f,objectMode:u,encoding:l});return Cq({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},wq=(t,e,r)=>{let n=Bp(t,e),s=iE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},Rq=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:_q},Aq=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=po(),o=GA({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Ytt(this,o,i)},onStdoutDataDone:i}},Ytt=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},Cq=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await vq(t),await n,await Tq(s),await e,r.readable&&r.push(null)}catch(i){await Tq(s),Aue(r,i)}},Oq=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Kp(r,e)&&(Aue(t,n),await WA(e,n))},Aue=(t,e)=>{YA(t,t.readable,e)};import{Writable as Ktt}from"stream";import{callbackify as Cue}from"util";var Oue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=Pq(t,r,e),o=new Ktt({...xq(n,t,s),destroy:Cue(Nq.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Iq(n,o),o},Pq=(t,e,r)=>{let n=lA(t,e),s=iE(r,n,"writableFinal"),i=iE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},xq=(t,e,r)=>({write:Jtt.bind(void 0,t),final:Cue(Xtt.bind(void 0,t,e,r))}),Jtt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Xtt=async(t,e,r)=>{await Kp(r,e)&&(t.writable&&t.end(),await e)},Iq=async(t,e,r)=>{try{await bq(t),e.writable&&e.end()}catch(n){await wue(r),Pue(e,n)}},Nq=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Kp(r,e),await Kp(n,e)&&(Pue(t,s),await WA(e,s))},Pue=(t,e)=>{YA(t,t.writable,e)};import{Duplex as Qtt}from"stream";import{callbackify as Ztt}from"util";var xue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||es.has(r),{subprocessStdout:c,waitReadableDestroy:l}=wq(t,n,e),{subprocessStdin:u,waitWritableFinal:f,waitWritableDestroy:d}=Pq(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=Rq(c,a),{read:g,onStdoutDataDone:y}=Aq({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),T=new Qtt({read:g,...xq(u,t,f),destroy:Ztt(ert.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:f,waitWritableDestroy:d})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return Cq({subprocessStdout:c,onStdoutDataDone:y,readable:T,subprocess:t,subprocessStdin:u}),Iq(u,T,c),T},ert=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([Oq({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),Nq({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var Mq=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||es.has(e),o=Bp(t,r),a=GA({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return trt(a,o,t)},trt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Iue=(t,{encoding:e})=>{let r=bue();t.readable=Rue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Oue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=xue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Mq.bind(void 0,t,e),t[Symbol.asyncIterator]=Mq.bind(void 0,t,e,{})};var Nue=(t,e)=>{for(let[r,n]of nrt){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},rrt=(async()=>{})().constructor.prototype,nrt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(rrt,t)]);var Mue=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:f}=ort(t,e,r),{subprocess:d,promise:h}=crt({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:f});return d.pipe=VA.bind(void 0,{source:d,sourcePromise:h,boundOptions:{},createNested:n}),Nue(d,h),mo.set(d,{options:u,fileDescriptors:f}),d},ort=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=eA(t,e,r),{file:a,commandArguments:c,options:l}=EA(t,e,r),u=art(l),f=Vle(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},art=({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}},crt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=irt(...TA(t,e,r))}catch(p){return qle({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;srt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Zle(c,a,l),tue(c,r,l);let f={},d=po();c.kill=mae.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:d,context:f,controller:l}),c.all=mue(c,r),Iue(c,r),$le(c,r);let h=lrt({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:f,onInternalError:d,controller:l});return{subprocess:c,promise:h}},lrt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[f,[d,h],p,m,g]=await Tue({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let y=p.map((_,A)=>Ca(_,e,A)),T=Ca(m,e,"all"),S=urt({errorInfo:f,exitCode:d,signal:h,stdio:y,all:T,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return zp(S,n,e)},urt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?ZS({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 go,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):PA({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var KA=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,frt(n,t[n],s)]));return{...t,...r}},frt=(t,e,r)=>drt.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,drt=new Set(["env",...lU]);var al=(t,e,r,n)=>{let s=(o,a,c)=>al(o,a,r,c),i=(...o)=>hrt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},hrt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(Jt(i))return s(t,KA(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=prt({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?Ile(a,c,l):Mue(a,c,l,s)},prt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=Vie(e)?Gie(e,r):[e,...r],[o,a,c]=HR(...i),l=KA(KA(n,s),c),{file:u=o,commandArguments:f=a,options:d=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:f,options:d,isSync:h}};var Lue=({file:t,commandArguments:e})=>kue(t,e),Due=({file:t,commandArguments:e})=>({...kue(t,e),isSync:!0}),kue=(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]=mrt(t);return{file:r,commandArguments:n}},mrt=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(grt)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},grt=/ +/g;var $ue=(t,e,r)=>{t.sync=e(_rt,r),t.s=t.sync},Fue=({options:t})=>Uue(t),_rt=({options:t})=>({...Uue(t),isSync:!0}),Uue=t=>({options:{...yrt(t),...t}}),yrt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},que={preferLocal:!0};var Bue=al(()=>({})),H4t=al(()=>({isSync:!0})),jue=al(Lue),V4t=al(Due),G4t=al(Qae),z4t=al(Fue,{},que,$ue),{sendMessage:W4t,getOneMessage:Y4t,getEachMessage:K4t,getCancelSignal:J4t}=Fle();import{Transform as Srt}from"stream";var Ert=["NETLIFY_AI_GATEWAY_KEY"];function Trt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...Ert])]}function brt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function vrt(){let e=Trt().map(r=>process.env[r]).filter(r=>!(!r||brt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function js(t){if(typeof t!="string")return t;let e=vrt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let s=new RegExp(wrt(n),"g");r=r.replace(s,"******")}),r}function wrt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var oE=class extends Srt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let s=e.toString(),i=js(s);n(null,i)}},JA=Symbol("maskedWrite");function Hue(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[JA]){let e=process.stdout.write.bind(process.stdout),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[JA]=!0,process.stdout.write=r}if(!process.stderr.write[JA]){let e=process.stderr.write.bind(process.stderr),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[JA]=!0,process.stderr.write=r}}}var Vue=!1,Gue=()=>{Vue=!0},ts=()=>Vue;var aE=null,zue=t=>(aE&&aE.destroy(),aE=new Oa({totalAllowedTime:t}),aE),Wue=()=>aE;var Oa=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&ts())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let i=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,f)=>{o=setTimeout(()=>{f(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await BR({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{xe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),i(),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 Yue={name:"@netlify/agent-runner-cli",type:"module",version:"1.136.0-ex-2324.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0"}};var Ort=Art(import.meta.url),Prt=Pa.dirname(Ort),xrt=Crt(import.meta.url),Jp=Se("shell"),Lq=new Set,Kue={preferLocal:!0},rs=(t,e,r)=>{let[n,s]=Irt(e,r),i={...Kue,...s},o=Bue(t,n,i);Xue(o,i),efe(o);let a=r?.idleTimeout;return a&&a>0&&Zue(o,a),o},Jue=(t,e)=>{let r={...Kue,...e},n=jue(t,r);return Xue(n,r),efe(n),e?.idleTimeout&&e.idleTimeout>0&&Zue(n,e.idleTimeout),n},Irt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Xue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(xa.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new oE).pipe(xa.stdout),t.stderr?.pipe(new oE).pipe(xa.stderr);return}t.stdout?.pipe(xa.stdout),t.stderr?.pipe(xa.stderr)},Dq=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(xa.kill(-t.pid,e),Jp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Jp.error("Error killing process:",r),!1}},Que=t=>Dq(t,"SIGKILL"),Zue=(t,e)=>{let r=null,n=()=>{Jp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Dq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Jp.log(`Force killing idle process ${t.pid}`),Que(t))},5e3)},s=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};s(),t.stdout?.on("data",s),t.stderr?.on("data",s);let i=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",i),t.on("error",i)},efe=t=>{Lq.add(t);let e=Wue();if(e){let r=e.onTimesUp(()=>{Jp.log(`Global timer expired, killing process ${t.pid}`),Dq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Jp.log(`Force killing process ${t.pid} after timeout`),Que(t))},5e3)});t.on("exit",()=>{Lq.delete(t),r()}),t.on("error",()=>{Lq.delete(t),r()})}};function cl(t,e){if(!xa.env.NETLIFY_LOCAL_MODE)try{let s=xrt.resolve(Yue.name),i=Pa.dirname(s);for(;i!==Pa.dirname(i);){let o=Pa.dirname(i);if(Pa.basename(o)==="node_modules"){let a=Pa.join(o,".bin",e);if(XA.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(xa.env.NODE_PATH){let s=Pa.join(xa.env.NODE_PATH,".bin",e);if(XA.existsSync(s))return s}let r=Pa.join(t,"node_modules",".bin",e);if(XA.existsSync(r))return r;let n=Pa.join(Prt,"..","node_modules",".bin",e);if(XA.existsSync(n))return n}import eI from"process";import{fileURLToPath as _gt}from"url";import{createRequire as ygt}from"module";import tI from"path";var Nrt="__netlify__getTracer",Mrt="__netlify__shutdownTracers",et=(t,e)=>globalThis[Nrt]?.(t,e),tfe=async()=>globalThis[Mrt]?.();function Tf(t,e,r,n,s){let i=typeof n=="function"?n:typeof r=="function"?r:s;if(!i)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,i):i()}import Pst from"process";var rfe=typeof globalThis=="object"?globalThis:global;var Ia="1.9.0";var nfe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Lrt(t){var e=new Set([t]),r=new Set,n=t.match(nfe);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(c){return c===t};function i(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(nfe);if(!l)return i(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||s.major!==u.major?i(c):s.major===0?s.minor===u.minor&&s.patch<=u.patch?o(c):i(c):s.minor<=u.minor?o(c):i(c)}}var sfe=Lrt(Ia);var Drt=Ia.split(".")[0],cE=Symbol.for("opentelemetry.js.api."+Drt),lE=rfe;function ll(t,e,r,n){var s;n===void 0&&(n=!1);var i=lE[cE]=(s=lE[cE])!==null&&s!==void 0?s:{version:Ia};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==Ia){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+Ia);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Ia+"."),!0}function Si(t){var e,r,n=(e=lE[cE])===null||e===void 0?void 0:e.version;if(!(!n||!sfe(n)))return(r=lE[cE])===null||r===void 0?void 0:r[t]}function ul(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Ia+".");var r=lE[cE];r&&delete r[t]}var krt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},$rt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},ife=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return uE("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return uE("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return uE("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return uE("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return uE("verbose",this._namespace,e)},t})();function uE(t,e,r){var n=Si("diag");if(n)return r.unshift(e),n[t].apply(n,$rt([],krt(r),!1))}var yn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(yn||(yn={}));function ofe(t,e){t<yn.NONE?t=yn.NONE:t>yn.ALL&&(t=yn.ALL),e=e||{};function r(n,s){var i=e[n];return typeof i=="function"&&t>=s?i.bind(e):function(){}}return{error:r("error",yn.ERROR),warn:r("warn",yn.WARN),info:r("info",yn.INFO),debug:r("debug",yn.DEBUG),verbose:r("verbose",yn.VERBOSE)}}var Frt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Urt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},qrt="diag",ns=(function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var a=Si("diag");if(a)return a[s].apply(a,Urt([],Frt(i),!1))}}var r=this,n=function(s,i){var o,a,c;if(i===void 0&&(i={logLevel:yn.INFO}),s===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof i=="number"&&(i={logLevel:i});var u=Si("diag"),f=ofe((a=i.logLevel)!==null&&a!==void 0?a:yn.INFO,s);if(u&&!i.suppressOverrideMessage){var d=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+d),f.warn("Current logger will overwrite one already registered from "+d)}return ll("diag",f,r,!0)};r.setLogger=n,r.disable=function(){ul(qrt,r)},r.createComponentLogger=function(s){return new ife(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var Brt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},jrt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},afe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=Brt(e,2),n=r[0],s=r[1];return[n,s]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var i=new t(this._entries);try{for(var o=jrt(n),a=o.next();!a.done;a=o.next()){var c=a.value;i._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t})();var UWt=ns.instance();function cfe(t){return t===void 0&&(t={}),new afe(new Map(Object.entries(t)))}function QA(t){return Symbol.for(t)}var Hrt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var i=new t(r._currentContext);return i._currentContext.set(n,s),i},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t})(),lfe=new Hrt;var ufe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},ffe={set:function(t,e,r){t!=null&&(t[e]=r)}};var Vrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Grt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},dfe=(function(){function t(){}return t.prototype.active=function(){return lfe},t.prototype.with=function(e,r,n){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return r.call.apply(r,Grt([n],Vrt(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var zrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Wrt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},kq="context",Yrt=new dfe,fl=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ll(kq,e,ns.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,Wrt([e,r,n],zrt(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Si(kq)||Yrt},t.prototype.disable=function(){this._getContextManager().disable(),ul(kq,ns.instance())},t})();var ZA;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(ZA||(ZA={}));var $q="0000000000000000",Fq="00000000000000000000000000000000",hfe={traceId:Fq,spanId:$q,traceFlags:ZA.NONE};var dl=(function(){function t(e){e===void 0&&(e=hfe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var Uq=QA("OpenTelemetry Context Key SPAN");function eC(t){return t.getValue(Uq)||void 0}function pfe(){return eC(fl.getInstance().active())}function fE(t,e){return t.setValue(Uq,e)}function mfe(t){return t.deleteValue(Uq)}function gfe(t,e){return fE(t,new dl(e))}function tC(t){var e;return(e=eC(t))===null||e===void 0?void 0:e.spanContext()}var Krt=/^([0-9a-f]{32})$/i,Jrt=/^[0-9a-f]{16}$/i;function Xrt(t){return Krt.test(t)&&t!==Fq}function Qrt(t){return Jrt.test(t)&&t!==$q}function rC(t){return Xrt(t.traceId)&&Qrt(t.spanId)}function _fe(t){return new dl(t)}var qq=fl.getInstance(),nC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=qq.active());var s=!!r?.root;if(s)return new dl;var i=n&&tC(n);return Zrt(i)&&rC(i)?new dl(i):new dl},t.prototype.startActiveSpan=function(e,r,n,s){var i,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(i=r,a=n):(i=r,o=n,a=s);var c=o??qq.active(),l=this.startSpan(e,i,c),u=fE(c,l);return qq.with(u,a,void 0,l)}},t})();function Zrt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var ent=new nC,yfe=(function(){function t(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,s){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):ent},t})();var Sfe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new nC},t})();var tnt=new Sfe,Bq=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var s;return(s=this.getDelegateTracer(e,r,n))!==null&&s!==void 0?s:new yfe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:tnt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,r,n)},t})();var hl;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(hl||(hl={}));var yo;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(yo||(yo={}));var Na=fl.getInstance();var jq=ns.instance();var Efe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var Hq=QA("OpenTelemetry Baggage Key");function Vq(t){return t.getValue(Hq)||void 0}function Tfe(){return Vq(fl.getInstance().active())}function bfe(t,e){return t.setValue(Hq,e)}function vfe(t){return t.deleteValue(Hq)}var Gq="propagation",rnt=new Efe,wfe=(function(){function t(){this.createBaggage=cfe,this.getBaggage=Vq,this.getActiveBaggage=Tfe,this.setBaggage=bfe,this.deleteBaggage=vfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ll(Gq,e,ns.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=ffe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=ufe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ul(Gq,ns.instance())},t.prototype._getGlobalPropagator=function(){return Si(Gq)||rnt},t})();var dE=wfe.getInstance();var zq="trace",Rfe=(function(){function t(){this._proxyTracerProvider=new Bq,this.wrapSpanContext=_fe,this.isSpanContextValid=rC,this.deleteSpan=mfe,this.getSpan=eC,this.getActiveSpan=pfe,this.getSpanContext=tC,this.setSpan=fE,this.setSpanContext=gfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=ll(zq,this._proxyTracerProvider,ns.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return Si(zq)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){ul(zq,ns.instance()),this._proxyTracerProvider=new Bq},t})();var hE=Rfe.getInstance();var snt=function(t,e){e.recordException(t),e.setStatus({code:yo.ERROR})};var bf=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,s){var i=Afe(r,n,s),o=i.opts,a=i.ctx,c=i.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return Cfe(l,o,c)})},t.prototype.withSpan=function(e,r,n,s){var i=Afe(r,n,s),o=i.opts,a=i.ctx,c=i.fn,l=this._tracer.startSpan(e,o,a);return Cfe(l,o,c)},t})();function Afe(t,e,r){var n,s,i;return!e&&!r?i=t:r?(n=t,s=e,i=r):(n=t,i=e),n=n??{},s=s??Na.active(),{opts:n,ctx:s,fn:i}}function Cfe(t,e,r){var n,s=(n=e.onException)!==null&&n!==void 0?n:snt,i=function(a){throw s(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},i):(t.end(),o)}catch(a){throw i(a)}}HB();He();var FE=class{emit(e){}enabled(){return!1}},qhe=new FE;var UE=Symbol.for("io.opentelemetry.js.api.logs"),om=globalThis;function Bhe(t,e,r){return n=>n===t?e:r}var VB=1;var GB=class{getLogger(e,r,n){return new FE}},YC=new GB;var KC=class{constructor(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}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):qhe}};var qE=class{getLogger(e,r,n){var s;return(s=this._getDelegateLogger(e,r,n))!==null&&s!==void 0?s:new KC(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:YC}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getLogger(e,r,n)}};var JC=class t{constructor(){this._proxyLoggerProvider=new qE}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return om[UE]?this.getLoggerProvider():(om[UE]=Bhe(VB,e,YC),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=om[UE])===null||e===void 0?void 0:e.call(om,VB))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete om[UE],this._proxyLoggerProvider=new qE}};var jhe=JC.getInstance();function Hhe(t,e,r,n){for(let s=0,i=t.length;s<i;s++){let o=t[s];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function Vhe(t){t.forEach(e=>e.disable())}function zB(t){let e=t.tracerProvider||cr.getTracerProvider(),r=t.meterProvider||wE.getMeterProvider(),n=t.loggerProvider||jhe.getLoggerProvider(),s=t.instrumentations?.flat()??[];return Hhe(s,e,r,n),()=>{Vhe(s)}}Ht();var yO=fn(c2(),1);Ht();var vpe=t=>{throw TypeError(t)},d2=(t,e,r)=>e.has(t)||vpe("Cannot "+r),_O=(t,e,r)=>(d2(t,e,"read from private field"),r?r.call(t):e.get(t)),l2=(t,e,r)=>e.has(t)?vpe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Epe=(t,e,r,n)=>(d2(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Ost=(t,e,r)=>(d2(t,e,"access private method"),r),Tpe="__netlify__getTracer",xst="__netlify__shutdownTracers",Ist="__nfOTLPTrace",jE,HE,f2,wpe,Nst=class{constructor(){l2(this,f2),l2(this,jE),l2(this,HE),Epe(this,jE,new Ro(Ost(this,f2,wpe),this)),Epe(this,HE,jq.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(_O(this,HE).debug(`export ${t.length.toString()} spans`),_O(this,jE).isCalled){e({code:It.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Ist,JSON.stringify(Mst(t))),e({code:It.SUCCESS})}shutdown(){return _O(this,jE).call()}};jE=new WeakMap;HE=new WeakMap;f2=new WeakSet;wpe=function(){return _O(this,HE).debug("Shutting down"),Promise.resolve()};function Mst(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:gO(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||hl.SERVER,startTimeUnixNano:u2(e.startTime),endTimeUnixNano:u2(e.endTime),attributes:gO(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:u2(n.time),attributes:gO(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:gO(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function gO(t){return Object.keys(t).map(e=>Rpe(e,t[e]))}function Rpe(t,e){return{key:t,value:Ape(e)}}function Ape(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(Ape)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>Rpe(r,n))}}:{}}function u2(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var bpe={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},Cpe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Tpe))return;let e=Pst.version.slice(1),r=WC({"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??[Lst()],s=new yO.NodeTracerProvider({resource:r,spanProcessors:n});s.register({propagator:new $a});let i=t.instrumentations??[];zB({instrumentations:i,tracerProvider:s}),Object.defineProperty(globalThis,Tpe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new bf(hE.getTracer(a,c)):new bf(hE.getTracer(bpe.name,bpe.version))}}),Object.defineProperty(globalThis,xst,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await s.shutdown()})},Lst=()=>new yO.SimpleSpanProcessor(new Nst);Ht();var VE=fn(c2(),1);import*as SO from"diagnostics_channel";var Ope=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?yo.ERROR:yo.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],s=this.config.redactHeaders??[],i=n.some(a=>r.includes(a.toString())),o={};if(i)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(d=>typeof d=="string"?d==u:d.test(u)))continue;let f=`http.${t}.header.${u}`;s===!0||s.some(d=>typeof d=="string"?d==u:d.test(u))?o[f]="REDACTED":o[f]=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 bf?t:new bf(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){SO.subscribe(t,e);let r=()=>SO.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(s=>typeof s=="string"?r.href.startsWith(s):s.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:hl.CLIENT},Na.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:yo.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 qTe=fn(FTe(),1);var JG=Se("tracing"),UTe=8e3,BTe=async(t,e,r)=>{let n=[new VE.SimpleSpanProcessor(new XG),new VE.SimpleSpanProcessor(new qTe.OTLPTraceExporter({url:r.exporterUrl}))];return await Cpe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new Ope({skipHeaders:!0})]}),r.traceparent?(dE.setGlobalPropagator(new $a),dE.extract(Na.active(),{traceparent:r.traceparent,isRemote:!0})):Na.active()};function yt(t,e,r){return JG.log(`\u23F3 TRACE: ${e} starting...`),Tf(t,e,r)}var XG=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,s=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?s.push(`${a}=${c.toFixed(2)}ms`):s.push(`${a}=${c}`);let i=e.status?.code===2?"\u274C":"\u2705",o=s.length>0?` [${s.join(", ")}]`:"";JG.log(`${i} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&JG.log(` \u274C Error: ${e.status.message}`)}};function QG(){return process.env.AGENT_RUNNER_CAPTURE_LLM_CONTENT!=="false"}function jTe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t}function Zx(t,e,r){let n={role:t,parts:[{type:"text",content:js(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function HTe(t,e,r,n){if(!t.length)return;let s=et();if(!s)return;let i=QG(),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),f=a.title||a.type||`step-${a.id??c}`,d=a.type==="tool_use"||a.type==="tool_result",h=a.message?a.message.length>UTe?`${a.message.slice(0,UTe)}\u2026`:a.message:void 0;s.startSpan(f,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":f,"gen_ai.operation.name":d?"execute_tool":"chat",...d?{"gen_ai.tool.name":f}:{},"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}:{},...i&&h?d?{"gen_ai.tool.call.result":js(h)}:{"gen_ai.output.messages":Zx("assistant",h)}:{}}}).end(u)})}import{readdir as pgt,rm as mgt}from"fs/promises";import{join as ggt}from"path";async function VTe(t,e=[]){let n=(await pgt(t)).filter(s=>!e.includes(s));await Promise.all(n.map(s=>mgt(ggt(t,s),{recursive:!0,force:!0})))}var Sgt=tI.dirname(_gt(import.meta.url)),GTe=ygt(import.meta.url),Egt=tI.resolve(Sgt,"scripts/scaffold.js"),Tgt="scripts/scaffold.js",bgt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,ZG=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},vgt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),wgt=t=>{let e=ZG(t);return e==="node"||e.endsWith("/node")},id=t=>{if(typeof t!="string")return!1;let e=t.match(bgt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&vgt(ZG(e[r]));)r+=1;if(r>=e.length||!wgt(e[r]))return!1;let n=e[r+1];return n?ZG(n).includes(Tgt):!1},nb=Se("create_stage"),Rgt="After completing the user's request:\n- Add a README.md to the project root describing what the project is, the key technologies used, and how to run it locally.\n- Add an AGENTS.md to the project root describing the project architecture, key directories, coding conventions, and any non-obvious decisions. This file is read by AI agents in future sessions to understand the project.\n\nDo 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.\n\nCommands 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.",Agt="./.netlify-cache",Cgt=({cwd:t=eI.cwd()}={})=>{let e=eI.env.NVM_BIN?`${eI.env.NVM_BIN}/node`:"node",r;try{let n=GTe.resolve("@netlify/ts-cli/package.json"),s=tI.dirname(n),i=GTe("@netlify/ts-cli/package.json");r=tI.join(s,i.bin)}catch{r=cl(t,"ts-cli")}return{nodeCmd:e,tsCliPath:r}},Ogt=t=>{let e;try{if(!t)throw new Error("empty response");e=JSON.parse(t)}catch(r){return nb.error("Failed to parse template list from ts-cli",{raw:t,error:r.message}),xe.inc("context.degraded",1,{component:"templates"}),[]}return e.filter(r=>r.type==="example").map(r=>{let{type:n,...s}=r;return s})},Pgt=({templates:t,nodeCmd:e,scaffoldScriptPath:r})=>{let n=JSON.stringify(t.map(({id:i,name:o,description:a})=>({id:i,name:o,description:a})),null,2);return["You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",t.length>0?`## Available Templates
|
|
504
|
+
if (condition) { yield value; }`)};import{Buffer as DZe}from"buffer";import{StringDecoder as kZe}from"string_decoder";var DA=(t,e,r)=>{if(r)return;if(t)return{transform:$Ze.bind(void 0,new TextEncoder)};let n=new kZe(e);return{transform:FZe.bind(void 0,n),final:UZe.bind(void 0,n)}},$Ze=function*(t,e){DZe.isBuffer(e)?yield wa(e):typeof e=="string"?yield t.encode(e):yield e},FZe=function*(t,e){yield ar(e)?t.write(e):e},UZe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as mle}from"util";var XU=mle(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),kA=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=BZe}=e[r];for await(let s of n(t))yield*kA(s,e,r+1)},gle=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*qZe(r,Number(e),t)},qZe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*kA(n,r,e+1)},_le=mle(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),BZe=function*(t){yield t};var QU=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},yle=(t,e)=>[...e.flatMap(r=>[...yf(r,t,0)]),...eE(t)],yf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=HZe}=e[r];for(let s of n(t))yield*yf(s,e,r+1)},eE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*jZe(r,Number(e),t)},jZe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*yf(n,r,e+1)},HZe=function*(t){yield t};var ZU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=Ele(t,o,i),l=_f(e),u=_f(r),f=l?XU.bind(void 0,kA,a):QU.bind(void 0,yf),d=l||u?XU.bind(void 0,gle,a):QU.bind(void 0,eE),h=l||u?_le.bind(void 0,a):void 0;return{stream:new VZe({writableObjectMode:n,writableHighWaterMark:Sle(n),readableObjectMode:s,readableHighWaterMark:Sle(s),transform(m,g,y){f([m,c,0],this,y)},flush(m){d([c],this,m)},destroy:h})}},$A=(t,e,r,n)=>{let s=e.filter(({type:o})=>o==="generator"),i=n?s.reverse():s;for(let{value:o,optionName:a}of i){let c=Ele(o,r,a);t=yle(c,t)}return t},Ele=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:dle(n,a)},DA(r,o,n),LA(r,i,n,c),{transform:t,final:e},{transform:hle(s,a)},fle({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var Tle=(t,e)=>{for(let r of GZe(t))zZe(t,r,e)},GZe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),zZe=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${ol[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>WZe(a,n));r.input=VS(o)},WZe=(t,e)=>{let r=$A(t,e,"utf8",!0);return YZe(r),VS(r)},YZe=t=>{let e=t.find(r=>typeof r!="string"&&!ar(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 QZe,appendFileSync as ZZe}from"fs";var FA=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&kp(r,n)&&!es.has(e)&&KZe(n)&&(t.some(({type:s,value:i})=>s==="native"&&JZe.has(i))||t.every(({type:s})=>Bs.has(s))),KZe=t=>t===1||t===2,JZe=new Set(["pipe","overlapped"]),ble=async(t,e,r,n)=>{for await(let s of t)XZe(e)||wle(s,r,n)},vle=(t,e,r)=>{for(let n of t)wle(n,e,r)},XZe=t=>t._readableState.pipes.length>0,wle=(t,e,r)=>{let n=QR(t);ho({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Rle=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:s})=>{if(e===null)return{output:Array.from({length:3})};let i={},o=new Set([]);return{output:e.map((c,l)=>eet({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},eet=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:f})=>{if(t===null)return;let d=Ace(t,i,f),h=wa(d),{stdioItems:p,objectMode:m}=e[r],g=tet([h],p,c,n),{serializedResult:y,finalResult:T=y}=ret({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});net({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let S=a[r]?T:void 0;try{return n.error===void 0&&set(y,p,s),S}catch(_){return n.error=_,S}},tet=(t,e,r,n)=>{try{return $A(t,e,r,!1)}catch(s){return n.error=s,t}},ret=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:VS(t)};let o=qie(t,r);return n[i]?{serializedResult:o,finalResult:JU(o,!s[i],e)}:{serializedResult:o}},net=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!FA({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=JU(t,!1,o);try{vle(a,e,n)}catch(c){r.error??=c}},set=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>NA.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?ZZe(n,t):(r.add(i),QZe(n,t))}};var Ale=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ca(e,r,"all")]:Array.isArray(e)?[Ca(t,r,"all"),...e]:ar(t)&&ar(e)?iU([t,e]):`${t}${e}`};import{once as eq}from"events";var Cle=async(t,e)=>{let[r,n]=await iet(t);return e.isForcefullyTerminated??=!1,[r,n]},iet=async t=>{let[e,r]=await Promise.allSettled([eq(t,"spawn"),eq(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Ole(t):r.value},Ole=async t=>{try{return await eq(t,"exit")}catch{return Ole(t)}},Ple=async t=>{let[e,r]=await t;if(!oet(e,r)&&tq(e,r))throw new gi;return[e,r]},oet=(t,e)=>t===void 0&&e===void 0,tq=(t,e)=>t!==0||e!==null;var xle=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=aet(t,e,r),o=i?.code==="ETIMEDOUT",a=Rce(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},aet=(t,e,r)=>t!==void 0?t:tq(e,r)?new gi:void 0;var Ile=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=uet(t,e,r),f=het({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return zp(f,c,l)},uet=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=eA(t,e,r),a=fet(r),{file:c,commandArguments:l,options:u}=EA(t,e,a);det(u);let f=ale(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},fet=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,det=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&UA("ipcInput"),t&&UA("ipc: true"),r&&UA("detached: true"),n&&UA("cancelSignal")},UA=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},het=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=pet({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:f,timedOut:d,isMaxBuffer:h}=xle(c,r),{output:p,error:m=l}=Rle({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),g=p.map((T,S)=>Ca(T,r,S)),y=Ca(Ale(p,r),r,"all");return get({error:m,exitCode:u,signal:f,timedOut:d,isMaxBuffer:h,stdio:g,all:y,options:r,command:n,escapedCommand:s,startTime:a})},pet=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{Tle(i,r);let a=met(r);return cet(...TA(t,e,a))}catch(a){return Gp({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},met=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:OA(e)}),get=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:s,stdio:i,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?PA({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):ZS({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:s,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:i,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as srt}from"events";import{spawn as irt}from"child_process";import kle from"process";import{once as rq,on as _et}from"events";var Nle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Up({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:pA(t)}),yet({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),yet=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{uA(e,s);let i=il(t,e,r),o=new AbortController;try{return await Promise.race([Eet(i,n,o),Tet(i,r,o),bet(i,r,o)])}catch(a){throw qp(t),a}finally{o.abort(),fA(e,s)}},Eet=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await rq(t,"message",{signal:r});return n}for await(let[n]of _et(t,"message",{signal:r}))if(e(n))return n},Tet=async(t,e,{signal:r})=>{await rq(t,"disconnect",{signal:r}),yae(e)},bet=async(t,e,{signal:r})=>{let[n]=await rq(t,"strict:error",{signal:r});throw aA(n,e)};import{once as Lle,on as vet}from"events";var Dle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>nq({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),nq=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Up({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:pA(t)}),uA(e,i);let o=il(t,e,r),a=new AbortController,c={};return wet(t,o,a),Ret({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Aet({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},wet=async(t,e,r)=>{try{await Lle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Ret=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await Lle(t,"strict:error",{signal:r.signal});n.error=aA(s,e),r.abort()}catch{}},Aet=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of vet(r,"message",{signal:i.signal}))Mle(o),yield c}catch{Mle(o)}finally{i.abort(),fA(e,a),n||qp(t),s&&await t}},Mle=({error:t})=>{if(t)throw t};var $le=(t,{ipc:e})=>{Object.assign(t,Ule(t,!1,e))},Fle=()=>{let t=kle,e=!0,r=kle.channel!==void 0;return{...Ule(t,e,r),getCancelSignal:Gae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Ule=(t,e,r)=>({sendMessage:yA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Nle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Dle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Cet}from"child_process";import{PassThrough as Oet,Readable as Pet,Writable as xet,Duplex as Iet}from"stream";var qle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{WU(n);let a=new Cet;Net(a,n),Object.assign(a,{readable:Met,writable:Let,duplex:Det});let c=Gp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=ket(c,o,s);return{subprocess:a,promise:l}},Net=(t,e)=>{let r=tE(),n=tE(),s=tE(),i=Array.from({length:e.length-3},tE),o=tE(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},tE=()=>{let t=new Oet;return t.end(),t},Met=()=>new Pet({read(){}}),Let=()=>new xet({write(){}}),Det=()=>new Iet({read(){},write(){}}),ket=async(t,e,r)=>zp(t,e,r);import{createReadStream as Ble,createWriteStream as jle}from"fs";import{Buffer as $et}from"buffer";import{Readable as rE,Writable as Fet,Duplex as Uet}from"stream";var Vle=(t,e)=>MA(qet,t,e,!1),nE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ol[t]}.`)},Hle={fileNumber:nE,generator:ZU,asyncGenerator:ZU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Uet.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},qet={input:{...Hle,fileUrl:({value:t})=>({stream:Ble(t)}),filePath:({value:{file:t}})=>({stream:Ble(t)}),webStream:({value:t})=>({stream:rE.fromWeb(t)}),iterable:({value:t})=>({stream:rE.from(t)}),asyncIterable:({value:t})=>({stream:rE.from(t)}),string:({value:t})=>({stream:rE.from(t)}),uint8Array:({value:t})=>({stream:rE.from($et.from(t))})},output:{...Hle,fileUrl:({value:t})=>({stream:jle(t)}),filePath:({value:{file:t,append:e}})=>({stream:jle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Fet.fromWeb(t)}),iterable:nE,asyncIterable:nE,string:nE,uint8Array:nE}};import{on as Bet,once as Gle}from"events";import{PassThrough as jet,getDefaultHighWaterMark as Het}from"stream";import{finished as Yle}from"stream/promises";function Sf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)iq(s);let e=t.some(({readableObjectMode:s})=>s),r=Vet(t,e),n=new sq({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var Vet=(t,e)=>{if(t.length===0)return Het(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},sq=class extends jet{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(iq(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Get(this,this.#e,this.#i);let r=Yet({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(iq(e),!this.#e.has(e))return!1;let r=this.#s.get(e);return r===void 0?!1:(this.#s.delete(e),e.unpipe(this),await r,!0)}},Get=async(t,e,r)=>{qA(t,zle);let n=new AbortController;try{await Promise.race([zet(t,n),Wet(t,e,r,n)])}finally{n.abort(),qA(t,-zle)}},zet=async(t,{signal:e})=>{try{await Yle(t,{signal:e,cleanup:!0})}catch(r){throw Kle(t,r),r}},Wet=async(t,e,r,{signal:n})=>{for await(let[s]of Bet(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},iq=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Yet=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{qA(t,Wle);let a=new AbortController;try{await Promise.race([Ket(i,e,a),Jet({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),Xet({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),qA(t,-Wle)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?oq(t):Qet(t))},Ket=async(t,e,{signal:r})=>{try{await t,r.aborted||oq(e)}catch(n){r.aborted||Kle(e,n)}},Jet=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await Yle(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;Jle(o)?s.add(e):Xle(t,o)}},Xet=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await Gle(t,s,{signal:i}),!t.readable)return Gle(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},Qet=t=>{t.writable&&t.end()},Kle=(t,e)=>{Jle(e)?oq(t):Xle(t,e)},Jle=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oq=t=>{(t.readable||t.writable)&&t.destroy()},Xle=(t,e)=>{t.destroyed||(t.once("error",Zet),t.destroy(e))},Zet=()=>{},qA=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},zle=2,Wle=1;import{finished as Qle}from"stream/promises";var Yp=(t,e)=>{t.pipe(e),ett(t,e),ttt(t,e)},ett=async(t,e)=>{if(!(mi(t)||mi(e))){try{await Qle(t,{cleanup:!0,readable:!0,writable:!1})}catch{}aq(e)}},aq=t=>{t.writable&&t.end()},ttt=async(t,e)=>{if(!(mi(t)||mi(e))){try{await Qle(e,{cleanup:!0,readable:!1,writable:!0})}catch{}cq(t)}},cq=t=>{t.readable&&t.destroy()};var Zle=(t,e,r)=>{let n=new Map;for(let[s,{stdioItems:i,direction:o}]of Object.entries(e)){for(let{stream:a}of i.filter(({type:c})=>Bs.has(c)))rtt(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!Bs.has(c)))stt({subprocess:t,stream:a,direction:o,fdNumber:s,pipeGroups:n,controller:r})}for(let[s,i]of n.entries()){let o=i.length===1?i[0]:Sf(i);Yp(o,s)}},rtt=(t,e,r,n)=>{r==="output"?Yp(t.stdio[n],e):Yp(e,t.stdio[n]);let s=ntt[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},ntt=["stdin","stdout","stderr"],stt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;itt(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},itt=(t,{signal:e})=>{mi(t)&&mf(t,ott,e)},ott=2;import{addAbortListener as ltt}from"events";var Ef=[];Ef.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ef.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ef.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var BA=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",lq=Symbol.for("signal-exit emitter"),uq=globalThis,att=Object.defineProperty.bind(Object),fq=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(uq[lq])return uq[lq];att(uq,lq,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},jA=class{},ctt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),dq=class extends jA{onExit(){return()=>{}}load(){}unload(){}},hq=class extends jA{#e=pq.platform==="win32"?"SIGINT":"SIGHUP";#r=new fq;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of Ef)this.#s[r]=()=>{let n=this.#t.listeners(r),{count:s}=this.#r,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#i=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!BA(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 Ef)try{let r=this.#s[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,Ef.forEach(e=>{let r=this.#s[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.#i,this.#r.count-=1)}#a(e){return BA(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#i.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&BA(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let s=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),s}else return n.call(this.#t,e,...r)}},pq=globalThis.process,{onExit:eue,load:ZGt,unload:ezt}=ctt(BA(pq)?new hq(pq):new dq);var tue=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=eue(()=>{t.kill()});ltt(n,()=>{s()})};var nue=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=ZR(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=utt(r,n,s),{sourceStream:f,sourceError:d}=dtt(t,l),{options:h,fileDescriptors:p}=mo.get(t);return{sourcePromise:e,sourceStream:f,sourceOptions:h,sourceError:d,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},utt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=ftt(t,e,...r),a=lA(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},ftt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(rue,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||nU(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[s,i,o]=HR(r,...n);return{destination:e(rue)(s,i,o),pipeOptions:o}}if(mo.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}`)},rue=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),dtt=(t,e)=>{try{return{sourceStream:Bp(t,e)}}catch(r){return{sourceError:r}}};var iue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=htt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw mq({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},htt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return cq(t),n;if(e!==void 0)return aq(r),e},mq=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Gp({error:t,command:sue,escapedCommand:sue,fileDescriptors:e,options:r,startTime:n,isSync:!1}),sue="source.pipe(destination)";var oue=async t=>{let[{status:e,reason:r,value:n=r},{status:s,reason:i,value:o=i}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),s==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as ptt}from"stream/promises";var aue=(t,e,r)=>{let n=HA.has(e)?gtt(t,e):mtt(t,e);return mf(t,ytt,r.signal),mf(e,Stt,r.signal),_tt(e),n},mtt=(t,e)=>{let r=Sf([t]);return Yp(r,e),HA.set(e,r),r},gtt=(t,e)=>{let r=HA.get(e);return r.add(t),r},_tt=async t=>{try{await ptt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}HA.delete(t)},HA=new WeakMap,ytt=2,Stt=1;import{aborted as Ett}from"util";var cue=(t,e)=>t===void 0?[]:[Ttt(t,e)],Ttt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await Ett(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw mq({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var VA=(t,...e)=>{if(Jt(e[0]))return VA.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=nue(t,...e),s=btt({...n,destination:r});return s.pipe=VA.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},btt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=vtt(t,s);iue({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let f=new AbortController;try{let d=aue(e,i,f);return await Promise.race([oue(u),...cue(a,{sourceStream:e,mergedStream:d,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{f.abort()}},vtt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as xtt}from"timers/promises";import{on as wtt}from"events";import{getDefaultHighWaterMark as Rtt}from"stream";var GA=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return Att(e,o),uue({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},Att=async(t,e)=>{try{await t}catch{}finally{e.abort()}},gq=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;Ctt(e,o,t);let a=t.readableObjectMode&&!i;return uue({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Ctt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},uue=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=wtt(t,"data",{signal:e.signal,highWaterMark:lue,highWatermark:lue});return Ott({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},_q=Rtt(!0),lue=_q,Ott=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Ptt({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*yf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*eE(a)}},Ptt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[DA(t,r,!e),LA(t,s,!n,{})].filter(Boolean);var fue=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let f=Itt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([Ntt(t),f]);return}let d=YU(c,r),h=gq({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:d,allMixed:a}),[p]=await Promise.all([Mtt({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),f]);return p},Itt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!FA({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=gq({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await ble(a,t,r,i)},Ntt=async t=>{await xtt(),t.readableFlowing===null&&t.resume()},Mtt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await RA(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await AA(r,{maxBuffer:i})):await Vp(r,{maxBuffer:i})}catch(a){return due(bce({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},yq=async t=>{try{return await t}catch(e){return due(e)}},due=({bufferedData:t})=>Fie(t)?new Uint8Array(t):t;import{finished as Ltt}from"stream/promises";var sE=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Dtt(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Ltt(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Ftt(a,e,r,n)}finally{o.abort()}},Dtt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&ktt(t,r,n),n},ktt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{$tt(e,r),n.call(t,...s)}},$tt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Ftt=(t,e,r,n)=>{if(!Utt(t,e,r,n))throw t},Utt=(t,e,r,n=!0)=>r.propagating?hue(t)||zA(t):(r.propagating=!0,Sq(r,e)===n?hue(t):zA(t)),Sq=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",zA=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",hue=t=>t?.code==="EPIPE";var pue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>Eq({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),Eq=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=sE(t,e,l);if(Sq(l,e)){await u;return}let[f]=await Promise.all([fue({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return f};var mue=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Sf([t,e].filter(Boolean)):void 0,gue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>Eq({...qtt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:Btt(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),qtt=({stdout:t,stderr:e,all:r},[,n,s])=>{let i=n||s;return i?n?s?{stream:r,buffer:i}:{stream:t,buffer:i}:{stream:e,buffer:i}:{stream:r,buffer:i}},Btt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as jtt}from"events";var _ue=t=>kp(t,"ipc"),yue=(t,e)=>{let r=QR(t);ho({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Sue=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=_ue(i),a=Ra(e,"ipc"),c=Ra(r,"ipc");for await(let l of nq({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(vce(t,s,c),s.push(l)),o&&yue(l,i);return s},Eue=async(t,e)=>(await Promise.allSettled([t]),e);var Tue=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:f},context:d,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:g,controller:y})=>{let T=Cle(t,d),S={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:T,propagating:!1},_=pue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),A=gue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),P=[],C=Sue({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:h}),R=Htt(m,t,S),O=Vtt(p,S);try{return await Promise.race([Promise.all([{},Ple(T),Promise.all(_),A,C,tce(t,f),...R,...O]),g,Gtt(t,y),...Jae(t,i,d,y),..._ae({subprocess:t,cancelSignal:o,gracefulCancel:a,context:d,controller:y}),...Yae({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:d,controller:y})])}catch(w){return d.terminationReason??="other",Promise.all([{error:w},T,Promise.all(_.map(b=>yq(b))),yq(A),Eue(C,P),Promise.allSettled(R),Promise.allSettled(O)])}},Htt=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:sE(n,s,r)),Vtt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>yi(i,{checkOpen:!1})&&!mi(i)).map(({type:s,value:i,stream:o=i})=>sE(o,n,e,{isSameDirection:Bs.has(s),stopOnExit:s==="native"}))),Gtt=async(t,{signal:e})=>{let[r]=await jtt(t,"error",{signal:e});throw r};var bue=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),iE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=po();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Kp=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 ztt}from"stream";import{callbackify as Wtt}from"util";import{finished as vue}from"stream/promises";var Tq=async t=>{if(t!==void 0)try{await bq(t)}catch{}},wue=async t=>{if(t!==void 0)try{await vq(t)}catch{}},bq=async t=>{await vue(t,{cleanup:!0,readable:!1,writable:!0})},vq=async t=>{await vue(t,{cleanup:!0,readable:!0,writable:!1})},WA=async(t,e)=>{if(await t,e)throw e},YA=(t,e,r)=>{r&&!zA(r)?t.destroy(r):e&&t.destroy()};var Rue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||es.has(r),{subprocessStdout:a,waitReadableDestroy:c}=wq(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:f}=Rq(a,o),{read:d,onStdoutDataDone:h}=Aq({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new ztt({read:d,destroy:Wtt(Oq.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:f,objectMode:u,encoding:l});return Cq({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},wq=(t,e,r)=>{let n=Bp(t,e),s=iE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},Rq=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:_q},Aq=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=po(),o=GA({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Ytt(this,o,i)},onStdoutDataDone:i}},Ytt=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},Cq=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await vq(t),await n,await Tq(s),await e,r.readable&&r.push(null)}catch(i){await Tq(s),Aue(r,i)}},Oq=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Kp(r,e)&&(Aue(t,n),await WA(e,n))},Aue=(t,e)=>{YA(t,t.readable,e)};import{Writable as Ktt}from"stream";import{callbackify as Cue}from"util";var Oue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=Pq(t,r,e),o=new Ktt({...xq(n,t,s),destroy:Cue(Nq.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Iq(n,o),o},Pq=(t,e,r)=>{let n=lA(t,e),s=iE(r,n,"writableFinal"),i=iE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},xq=(t,e,r)=>({write:Jtt.bind(void 0,t),final:Cue(Xtt.bind(void 0,t,e,r))}),Jtt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Xtt=async(t,e,r)=>{await Kp(r,e)&&(t.writable&&t.end(),await e)},Iq=async(t,e,r)=>{try{await bq(t),e.writable&&e.end()}catch(n){await wue(r),Pue(e,n)}},Nq=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Kp(r,e),await Kp(n,e)&&(Pue(t,s),await WA(e,s))},Pue=(t,e)=>{YA(t,t.writable,e)};import{Duplex as Qtt}from"stream";import{callbackify as Ztt}from"util";var xue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||es.has(r),{subprocessStdout:c,waitReadableDestroy:l}=wq(t,n,e),{subprocessStdin:u,waitWritableFinal:f,waitWritableDestroy:d}=Pq(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=Rq(c,a),{read:g,onStdoutDataDone:y}=Aq({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),T=new Qtt({read:g,...xq(u,t,f),destroy:Ztt(ert.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:f,waitWritableDestroy:d})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return Cq({subprocessStdout:c,onStdoutDataDone:y,readable:T,subprocess:t,subprocessStdin:u}),Iq(u,T,c),T},ert=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([Oq({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),Nq({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var Mq=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||es.has(e),o=Bp(t,r),a=GA({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return trt(a,o,t)},trt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Iue=(t,{encoding:e})=>{let r=bue();t.readable=Rue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Oue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=xue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Mq.bind(void 0,t,e),t[Symbol.asyncIterator]=Mq.bind(void 0,t,e,{})};var Nue=(t,e)=>{for(let[r,n]of nrt){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},rrt=(async()=>{})().constructor.prototype,nrt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(rrt,t)]);var Mue=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:f}=ort(t,e,r),{subprocess:d,promise:h}=crt({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:f});return d.pipe=VA.bind(void 0,{source:d,sourcePromise:h,boundOptions:{},createNested:n}),Nue(d,h),mo.set(d,{options:u,fileDescriptors:f}),d},ort=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=eA(t,e,r),{file:a,commandArguments:c,options:l}=EA(t,e,r),u=art(l),f=Vle(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},art=({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}},crt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=irt(...TA(t,e,r))}catch(p){return qle({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;srt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Zle(c,a,l),tue(c,r,l);let f={},d=po();c.kill=mae.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:d,context:f,controller:l}),c.all=mue(c,r),Iue(c,r),$le(c,r);let h=lrt({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:f,onInternalError:d,controller:l});return{subprocess:c,promise:h}},lrt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[f,[d,h],p,m,g]=await Tue({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let y=p.map((_,A)=>Ca(_,e,A)),T=Ca(m,e,"all"),S=urt({errorInfo:f,exitCode:d,signal:h,stdio:y,all:T,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return zp(S,n,e)},urt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?ZS({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 go,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):PA({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var KA=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,frt(n,t[n],s)]));return{...t,...r}},frt=(t,e,r)=>drt.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,drt=new Set(["env",...lU]);var al=(t,e,r,n)=>{let s=(o,a,c)=>al(o,a,r,c),i=(...o)=>hrt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},hrt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(Jt(i))return s(t,KA(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=prt({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?Ile(a,c,l):Mue(a,c,l,s)},prt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=Vie(e)?Gie(e,r):[e,...r],[o,a,c]=HR(...i),l=KA(KA(n,s),c),{file:u=o,commandArguments:f=a,options:d=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:f,options:d,isSync:h}};var Lue=({file:t,commandArguments:e})=>kue(t,e),Due=({file:t,commandArguments:e})=>({...kue(t,e),isSync:!0}),kue=(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]=mrt(t);return{file:r,commandArguments:n}},mrt=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(grt)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},grt=/ +/g;var $ue=(t,e,r)=>{t.sync=e(_rt,r),t.s=t.sync},Fue=({options:t})=>Uue(t),_rt=({options:t})=>({...Uue(t),isSync:!0}),Uue=t=>({options:{...yrt(t),...t}}),yrt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},que={preferLocal:!0};var Bue=al(()=>({})),H4t=al(()=>({isSync:!0})),jue=al(Lue),V4t=al(Due),G4t=al(Qae),z4t=al(Fue,{},que,$ue),{sendMessage:W4t,getOneMessage:Y4t,getEachMessage:K4t,getCancelSignal:J4t}=Fle();import{Transform as Srt}from"stream";var Ert=["NETLIFY_AI_GATEWAY_KEY"];function Trt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...Ert])]}function brt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function vrt(){let e=Trt().map(r=>process.env[r]).filter(r=>!(!r||brt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function js(t){if(typeof t!="string")return t;let e=vrt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let s=new RegExp(wrt(n),"g");r=r.replace(s,"******")}),r}function wrt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var oE=class extends Srt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let s=e.toString(),i=js(s);n(null,i)}},JA=Symbol("maskedWrite");function Hue(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[JA]){let e=process.stdout.write.bind(process.stdout),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[JA]=!0,process.stdout.write=r}if(!process.stderr.write[JA]){let e=process.stderr.write.bind(process.stderr),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[JA]=!0,process.stderr.write=r}}}var Vue=!1,Gue=()=>{Vue=!0},ts=()=>Vue;var aE=null,zue=t=>(aE&&aE.destroy(),aE=new Oa({totalAllowedTime:t}),aE),Wue=()=>aE;var Oa=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&ts())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let i=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,f)=>{o=setTimeout(()=>{f(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await BR({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{xe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),i(),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 Yue={name:"@netlify/agent-runner-cli",type:"module",version:"1.136.0-ex-2324.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0"}};var Ort=Art(import.meta.url),Prt=Pa.dirname(Ort),xrt=Crt(import.meta.url),Jp=Se("shell"),Lq=new Set,Kue={preferLocal:!0},rs=(t,e,r)=>{let[n,s]=Irt(e,r),i={...Kue,...s},o=Bue(t,n,i);Xue(o,i),efe(o);let a=r?.idleTimeout;return a&&a>0&&Zue(o,a),o},Jue=(t,e)=>{let r={...Kue,...e},n=jue(t,r);return Xue(n,r),efe(n),e?.idleTimeout&&e.idleTimeout>0&&Zue(n,e.idleTimeout),n},Irt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Xue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(xa.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new oE).pipe(xa.stdout),t.stderr?.pipe(new oE).pipe(xa.stderr);return}t.stdout?.pipe(xa.stdout),t.stderr?.pipe(xa.stderr)},Dq=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(xa.kill(-t.pid,e),Jp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Jp.error("Error killing process:",r),!1}},Que=t=>Dq(t,"SIGKILL"),Zue=(t,e)=>{let r=null,n=()=>{Jp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Dq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Jp.log(`Force killing idle process ${t.pid}`),Que(t))},5e3)},s=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};s(),t.stdout?.on("data",s),t.stderr?.on("data",s);let i=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",i),t.on("error",i)},efe=t=>{Lq.add(t);let e=Wue();if(e){let r=e.onTimesUp(()=>{Jp.log(`Global timer expired, killing process ${t.pid}`),Dq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Jp.log(`Force killing process ${t.pid} after timeout`),Que(t))},5e3)});t.on("exit",()=>{Lq.delete(t),r()}),t.on("error",()=>{Lq.delete(t),r()})}};function cl(t,e){if(!xa.env.NETLIFY_LOCAL_MODE)try{let s=xrt.resolve(Yue.name),i=Pa.dirname(s);for(;i!==Pa.dirname(i);){let o=Pa.dirname(i);if(Pa.basename(o)==="node_modules"){let a=Pa.join(o,".bin",e);if(XA.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(xa.env.NODE_PATH){let s=Pa.join(xa.env.NODE_PATH,".bin",e);if(XA.existsSync(s))return s}let r=Pa.join(t,"node_modules",".bin",e);if(XA.existsSync(r))return r;let n=Pa.join(Prt,"..","node_modules",".bin",e);if(XA.existsSync(n))return n}import eI from"process";import{fileURLToPath as _gt}from"url";import{createRequire as ygt}from"module";import tI from"path";var Nrt="__netlify__getTracer",Mrt="__netlify__shutdownTracers",et=(t,e)=>globalThis[Nrt]?.(t,e),tfe=async()=>globalThis[Mrt]?.();function Tf(t,e,r,n,s){let i=typeof n=="function"?n:typeof r=="function"?r:s;if(!i)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,i):i()}import Pst from"process";var rfe=typeof globalThis=="object"?globalThis:global;var Ia="1.9.0";var nfe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Lrt(t){var e=new Set([t]),r=new Set,n=t.match(nfe);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(c){return c===t};function i(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(nfe);if(!l)return i(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||s.major!==u.major?i(c):s.major===0?s.minor===u.minor&&s.patch<=u.patch?o(c):i(c):s.minor<=u.minor?o(c):i(c)}}var sfe=Lrt(Ia);var Drt=Ia.split(".")[0],cE=Symbol.for("opentelemetry.js.api."+Drt),lE=rfe;function ll(t,e,r,n){var s;n===void 0&&(n=!1);var i=lE[cE]=(s=lE[cE])!==null&&s!==void 0?s:{version:Ia};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==Ia){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+Ia);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Ia+"."),!0}function Si(t){var e,r,n=(e=lE[cE])===null||e===void 0?void 0:e.version;if(!(!n||!sfe(n)))return(r=lE[cE])===null||r===void 0?void 0:r[t]}function ul(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Ia+".");var r=lE[cE];r&&delete r[t]}var krt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},$rt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},ife=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return uE("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return uE("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return uE("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return uE("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return uE("verbose",this._namespace,e)},t})();function uE(t,e,r){var n=Si("diag");if(n)return r.unshift(e),n[t].apply(n,$rt([],krt(r),!1))}var yn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(yn||(yn={}));function ofe(t,e){t<yn.NONE?t=yn.NONE:t>yn.ALL&&(t=yn.ALL),e=e||{};function r(n,s){var i=e[n];return typeof i=="function"&&t>=s?i.bind(e):function(){}}return{error:r("error",yn.ERROR),warn:r("warn",yn.WARN),info:r("info",yn.INFO),debug:r("debug",yn.DEBUG),verbose:r("verbose",yn.VERBOSE)}}var Frt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Urt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},qrt="diag",ns=(function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var a=Si("diag");if(a)return a[s].apply(a,Urt([],Frt(i),!1))}}var r=this,n=function(s,i){var o,a,c;if(i===void 0&&(i={logLevel:yn.INFO}),s===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof i=="number"&&(i={logLevel:i});var u=Si("diag"),f=ofe((a=i.logLevel)!==null&&a!==void 0?a:yn.INFO,s);if(u&&!i.suppressOverrideMessage){var d=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+d),f.warn("Current logger will overwrite one already registered from "+d)}return ll("diag",f,r,!0)};r.setLogger=n,r.disable=function(){ul(qrt,r)},r.createComponentLogger=function(s){return new ife(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var Brt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},jrt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},afe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=Brt(e,2),n=r[0],s=r[1];return[n,s]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var i=new t(this._entries);try{for(var o=jrt(n),a=o.next();!a.done;a=o.next()){var c=a.value;i._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t})();var UWt=ns.instance();function cfe(t){return t===void 0&&(t={}),new afe(new Map(Object.entries(t)))}function QA(t){return Symbol.for(t)}var Hrt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var i=new t(r._currentContext);return i._currentContext.set(n,s),i},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t})(),lfe=new Hrt;var ufe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},ffe={set:function(t,e,r){t!=null&&(t[e]=r)}};var Vrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Grt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},dfe=(function(){function t(){}return t.prototype.active=function(){return lfe},t.prototype.with=function(e,r,n){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return r.call.apply(r,Grt([n],Vrt(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var zrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Wrt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},kq="context",Yrt=new dfe,fl=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ll(kq,e,ns.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,Wrt([e,r,n],zrt(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Si(kq)||Yrt},t.prototype.disable=function(){this._getContextManager().disable(),ul(kq,ns.instance())},t})();var ZA;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(ZA||(ZA={}));var $q="0000000000000000",Fq="00000000000000000000000000000000",hfe={traceId:Fq,spanId:$q,traceFlags:ZA.NONE};var dl=(function(){function t(e){e===void 0&&(e=hfe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var Uq=QA("OpenTelemetry Context Key SPAN");function eC(t){return t.getValue(Uq)||void 0}function pfe(){return eC(fl.getInstance().active())}function fE(t,e){return t.setValue(Uq,e)}function mfe(t){return t.deleteValue(Uq)}function gfe(t,e){return fE(t,new dl(e))}function tC(t){var e;return(e=eC(t))===null||e===void 0?void 0:e.spanContext()}var Krt=/^([0-9a-f]{32})$/i,Jrt=/^[0-9a-f]{16}$/i;function Xrt(t){return Krt.test(t)&&t!==Fq}function Qrt(t){return Jrt.test(t)&&t!==$q}function rC(t){return Xrt(t.traceId)&&Qrt(t.spanId)}function _fe(t){return new dl(t)}var qq=fl.getInstance(),nC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=qq.active());var s=!!r?.root;if(s)return new dl;var i=n&&tC(n);return Zrt(i)&&rC(i)?new dl(i):new dl},t.prototype.startActiveSpan=function(e,r,n,s){var i,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(i=r,a=n):(i=r,o=n,a=s);var c=o??qq.active(),l=this.startSpan(e,i,c),u=fE(c,l);return qq.with(u,a,void 0,l)}},t})();function Zrt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var ent=new nC,yfe=(function(){function t(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,s){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):ent},t})();var Sfe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new nC},t})();var tnt=new Sfe,Bq=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var s;return(s=this.getDelegateTracer(e,r,n))!==null&&s!==void 0?s:new yfe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:tnt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,r,n)},t})();var hl;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(hl||(hl={}));var yo;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(yo||(yo={}));var Na=fl.getInstance();var jq=ns.instance();var Efe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var Hq=QA("OpenTelemetry Baggage Key");function Vq(t){return t.getValue(Hq)||void 0}function Tfe(){return Vq(fl.getInstance().active())}function bfe(t,e){return t.setValue(Hq,e)}function vfe(t){return t.deleteValue(Hq)}var Gq="propagation",rnt=new Efe,wfe=(function(){function t(){this.createBaggage=cfe,this.getBaggage=Vq,this.getActiveBaggage=Tfe,this.setBaggage=bfe,this.deleteBaggage=vfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ll(Gq,e,ns.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=ffe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=ufe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ul(Gq,ns.instance())},t.prototype._getGlobalPropagator=function(){return Si(Gq)||rnt},t})();var dE=wfe.getInstance();var zq="trace",Rfe=(function(){function t(){this._proxyTracerProvider=new Bq,this.wrapSpanContext=_fe,this.isSpanContextValid=rC,this.deleteSpan=mfe,this.getSpan=eC,this.getActiveSpan=pfe,this.getSpanContext=tC,this.setSpan=fE,this.setSpanContext=gfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=ll(zq,this._proxyTracerProvider,ns.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return Si(zq)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){ul(zq,ns.instance()),this._proxyTracerProvider=new Bq},t})();var hE=Rfe.getInstance();var snt=function(t,e){e.recordException(t),e.setStatus({code:yo.ERROR})};var bf=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,s){var i=Afe(r,n,s),o=i.opts,a=i.ctx,c=i.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return Cfe(l,o,c)})},t.prototype.withSpan=function(e,r,n,s){var i=Afe(r,n,s),o=i.opts,a=i.ctx,c=i.fn,l=this._tracer.startSpan(e,o,a);return Cfe(l,o,c)},t})();function Afe(t,e,r){var n,s,i;return!e&&!r?i=t:r?(n=t,s=e,i=r):(n=t,i=e),n=n??{},s=s??Na.active(),{opts:n,ctx:s,fn:i}}function Cfe(t,e,r){var n,s=(n=e.onException)!==null&&n!==void 0?n:snt,i=function(a){throw s(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},i):(t.end(),o)}catch(a){throw i(a)}}HB();He();var FE=class{emit(e){}enabled(){return!1}},qhe=new FE;var UE=Symbol.for("io.opentelemetry.js.api.logs"),om=globalThis;function Bhe(t,e,r){return n=>n===t?e:r}var VB=1;var GB=class{getLogger(e,r,n){return new FE}},YC=new GB;var KC=class{constructor(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}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):qhe}};var qE=class{getLogger(e,r,n){var s;return(s=this._getDelegateLogger(e,r,n))!==null&&s!==void 0?s:new KC(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:YC}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getLogger(e,r,n)}};var JC=class t{constructor(){this._proxyLoggerProvider=new qE}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return om[UE]?this.getLoggerProvider():(om[UE]=Bhe(VB,e,YC),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=om[UE])===null||e===void 0?void 0:e.call(om,VB))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete om[UE],this._proxyLoggerProvider=new qE}};var jhe=JC.getInstance();function Hhe(t,e,r,n){for(let s=0,i=t.length;s<i;s++){let o=t[s];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function Vhe(t){t.forEach(e=>e.disable())}function zB(t){let e=t.tracerProvider||cr.getTracerProvider(),r=t.meterProvider||wE.getMeterProvider(),n=t.loggerProvider||jhe.getLoggerProvider(),s=t.instrumentations?.flat()??[];return Hhe(s,e,r,n),()=>{Vhe(s)}}Ht();var yO=fn(c2(),1);Ht();var vpe=t=>{throw TypeError(t)},d2=(t,e,r)=>e.has(t)||vpe("Cannot "+r),_O=(t,e,r)=>(d2(t,e,"read from private field"),r?r.call(t):e.get(t)),l2=(t,e,r)=>e.has(t)?vpe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Epe=(t,e,r,n)=>(d2(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Ost=(t,e,r)=>(d2(t,e,"access private method"),r),Tpe="__netlify__getTracer",xst="__netlify__shutdownTracers",Ist="__nfOTLPTrace",jE,HE,f2,wpe,Nst=class{constructor(){l2(this,f2),l2(this,jE),l2(this,HE),Epe(this,jE,new Ro(Ost(this,f2,wpe),this)),Epe(this,HE,jq.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(_O(this,HE).debug(`export ${t.length.toString()} spans`),_O(this,jE).isCalled){e({code:It.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Ist,JSON.stringify(Mst(t))),e({code:It.SUCCESS})}shutdown(){return _O(this,jE).call()}};jE=new WeakMap;HE=new WeakMap;f2=new WeakSet;wpe=function(){return _O(this,HE).debug("Shutting down"),Promise.resolve()};function Mst(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:gO(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||hl.SERVER,startTimeUnixNano:u2(e.startTime),endTimeUnixNano:u2(e.endTime),attributes:gO(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:u2(n.time),attributes:gO(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:gO(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function gO(t){return Object.keys(t).map(e=>Rpe(e,t[e]))}function Rpe(t,e){return{key:t,value:Ape(e)}}function Ape(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(Ape)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>Rpe(r,n))}}:{}}function u2(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var bpe={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},Cpe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Tpe))return;let e=Pst.version.slice(1),r=WC({"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??[Lst()],s=new yO.NodeTracerProvider({resource:r,spanProcessors:n});s.register({propagator:new $a});let i=t.instrumentations??[];zB({instrumentations:i,tracerProvider:s}),Object.defineProperty(globalThis,Tpe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new bf(hE.getTracer(a,c)):new bf(hE.getTracer(bpe.name,bpe.version))}}),Object.defineProperty(globalThis,xst,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await s.shutdown()})},Lst=()=>new yO.SimpleSpanProcessor(new Nst);Ht();var VE=fn(c2(),1);import*as SO from"diagnostics_channel";var Ope=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?yo.ERROR:yo.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],s=this.config.redactHeaders??[],i=n.some(a=>r.includes(a.toString())),o={};if(i)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(d=>typeof d=="string"?d==u:d.test(u)))continue;let f=`http.${t}.header.${u}`;s===!0||s.some(d=>typeof d=="string"?d==u:d.test(u))?o[f]="REDACTED":o[f]=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 bf?t:new bf(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){SO.subscribe(t,e);let r=()=>SO.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(s=>typeof s=="string"?r.href.startsWith(s):s.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:hl.CLIENT},Na.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:yo.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 qTe=fn(FTe(),1);var JG=Se("tracing"),UTe=8e3,BTe=async(t,e,r)=>{let n=[new VE.SimpleSpanProcessor(new XG),new VE.SimpleSpanProcessor(new qTe.OTLPTraceExporter({url:r.exporterUrl}))];return await Cpe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new Ope({skipHeaders:!0})]}),r.traceparent?(dE.setGlobalPropagator(new $a),dE.extract(Na.active(),{traceparent:r.traceparent,isRemote:!0})):Na.active()};function yt(t,e,r){return JG.log(`\u23F3 TRACE: ${e} starting...`),Tf(t,e,r)}var XG=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,s=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?s.push(`${a}=${c.toFixed(2)}ms`):s.push(`${a}=${c}`);let i=e.status?.code===2?"\u274C":"\u2705",o=s.length>0?` [${s.join(", ")}]`:"";JG.log(`${i} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&JG.log(` \u274C Error: ${e.status.message}`)}};function QG(){return process.env.AGENT_RUNNER_CAPTURE_LLM_CONTENT!=="false"}function jTe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t}function Zx(t,e,r){let n={role:t,parts:[{type:"text",content:js(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function HTe(t,e,r,n){if(!t.length)return;let s=et();if(!s)return;let i=QG(),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),f=a.title||a.type||`step-${a.id??c}`,d=a.type==="tool_use"||a.type==="tool_result",h=a.message?a.message.length>UTe?`${a.message.slice(0,UTe)}\u2026`:a.message:void 0;s.startSpan(f,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":f,"gen_ai.operation.name":d?"execute_tool":"chat",...d?{"gen_ai.tool.name":f}:{},"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}:{},...i&&h?d?{"gen_ai.tool.call.result":js(h)}:{"gen_ai.output.messages":Zx("assistant",h)}:{}}}).end(u)})}import{readdir as pgt,rm as mgt}from"fs/promises";import{join as ggt}from"path";async function VTe(t,e=[]){let n=(await pgt(t)).filter(s=>!e.includes(s));await Promise.all(n.map(s=>mgt(ggt(t,s),{recursive:!0,force:!0})))}var Sgt=tI.dirname(_gt(import.meta.url)),GTe=ygt(import.meta.url),Egt=tI.resolve(Sgt,"scripts/scaffold.js"),Tgt="scripts/scaffold.js",bgt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,ZG=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},vgt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),wgt=t=>{let e=ZG(t);return e==="node"||e.endsWith("/node")},id=t=>{if(typeof t!="string")return!1;let e=t.match(bgt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&vgt(ZG(e[r]));)r+=1;if(r>=e.length||!wgt(e[r]))return!1;let n=e[r+1];return n?ZG(n).includes(Tgt):!1},nb=Se("create_stage"),Rgt="After completing the user's request:\n- Add a README.md to the project root describing what the project is, the key technologies used, and how to run it locally.\n- Add an AGENTS.md to the project root describing the project architecture, key directories, coding conventions, and any non-obvious decisions. This file is read by AI agents in future sessions to understand the project.\n\nDo 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.\n\nCommands 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.",Agt="./.netlify-cache",Cgt=({cwd:t=eI.cwd()}={})=>{let e=eI.env.NVM_BIN?`${eI.env.NVM_BIN}/node`:"node",r;try{let n=GTe.resolve("@netlify/ts-cli/package.json"),s=tI.dirname(n),i=GTe("@netlify/ts-cli/package.json");r=tI.join(s,i.bin)}catch{r=cl(t,"ts-cli")}return{nodeCmd:e,tsCliPath:r}},Ogt=t=>{let e;try{if(!t)throw new Error("empty response");e=JSON.parse(t)}catch(r){return nb.error("Failed to parse template list from ts-cli",{raw:t,error:r.message}),xe.inc("context.degraded",1,{component:"templates"}),[]}return e.filter(r=>r.type==="example").map(r=>{let{type:n,...s}=r;return s})},Pgt=({templates:t,nodeCmd:e,scaffoldScriptPath:r})=>{let n=JSON.stringify(t.map(({id:i,name:o,description:a})=>({id:i,name:o,description:a})),null,2);return["You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",t.length>0?`## Available Templates
|
|
505
505
|
|
|
506
506
|
Start with one of the following templates by using the Bash command below, unless there's a strong reason to start from scratch based on the users prompt.
|
|
507
507
|
|
|
@@ -744,7 +744,7 @@ You're an AI agent designed to assist with tasks related to a Netlify project. P
|
|
|
744
744
|
|
|
745
745
|
Use the following file for the complete context of the ask, the environment, and what's available. ${u} You MUST READ ALL OF IT. Make sure to read it first. Never cite or paraphrase private context.
|
|
746
746
|
`),S};var fSt=Se("prompt"),Jve=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:s,resumePrompt:i})=>{let o=await Kve({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:s,resumePrompt:i});return process.env.AGENT_RUNNER_DEBUG&&fSt.log("Contextful Prompt:",o),{prompt:o}};var Xve=t=>{let e=t.previousSession;return e?e.agent!==t.runner?{viable:!1,outcome:"agent_switch"}:e.nativeSessionId?{viable:!0,outcome:"resumed"}:{viable:!1,outcome:"missing_native_session_id"}:{viable:!1,outcome:"not_eligible"}};import _c from"fs/promises";import JCe from"os";import yc from"path";import{rm as UW}from"fs/promises";import{resolve as dSt}from"path";var hSt=".netlify/cache/",Md=function({cacheDir:t=hSt,cwd:e="."}={}){return dSt(e,t)};import{promises as ywt}from"fs";import{basename as wCe,dirname as RCe,join as Swt}from"path";import L0t from"process";import D0t from"events";import at from"path";import k0t from"os";async function $b(t,e,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:n=!0,signal:s}={}){return new Promise((i,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,f=!1,d=!1,h=0,p=0,m=t[Symbol.iterator]===void 0?t[Symbol.asyncIterator]():t[Symbol.iterator](),g=()=>{S(s.reason)},y=()=>{s?.removeEventListener("abort",g)},T=A=>{i(A),y()},S=A=>{u=!0,f=!0,o(A),y()};s&&(s.aborted&&S(s.reason),s.addEventListener("abort",g,{once:!0}));let _=async()=>{if(f)return;let A=await m.next(),P=p;if(p++,A.done){if(d=!0,h===0&&!f){if(!n&&c.length>0){S(new AggregateError(c));return}if(f=!0,l.size===0){T(a);return}let C=[];for(let[R,O]of a.entries())l.get(R)!==Qve&&C.push(O);T(C)}return}h++,(async()=>{try{let C=await A.value;if(f)return;let R=await e(C,P);R===Qve&&l.set(P,R),a[P]=R,h--,await _()}catch(C){if(n)S(C);else{c.push(C),h--;try{await _()}catch(R){S(R)}}}})()};(async()=>{for(let A=0;A<r;A++){try{await _()}catch(P){S(P);break}if(d||u)break}})()})}var Qve=Symbol("skip");import Dd from"path";import Ehr,{constants as m3}from"fs";import g3 from"fs/promises";var a3=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},c3=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Zve=t=>globalThis.DOMException===void 0?new c3(t):new DOMException(t),e0e=t=>{let e=t.reason===void 0?Zve("This operation was aborted."):t.reason;return e instanceof Error?e:Zve(e)};function l3(t,e){let{milliseconds:r,fallback:n,message:s,customTimers:i={setTimeout,clearTimeout}}=e,o,a,l=new Promise((u,f)=>{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:h}=e;h.aborted&&f(e0e(h)),a=()=>{f(e0e(h))},h.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(u,f);return}let d=new a3;o=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(h){f(h)}return}typeof t.cancel=="function"&&t.cancel(),s===!1?u():s instanceof Error?f(s):(d.message=s??`Promise timed out after ${r} milliseconds`,f(d))},r),(async()=>{try{u(await t)}catch(h){f(h)}})()}).finally(()=>{l.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return l.clear=()=>{i.clearTimeout.call(void 0,o),o=void 0},l}var pSt=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 mSt(t,e,r){let n,s=new Promise((i,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}=pSt(t),f=(...h)=>{let p=r.multiArgs?h:h[0];r.filter&&!r.filter(p)||(c.push(p),r.count===c.length&&(n(),i(c)))},d=h=>{n(),o(h)};n=()=>{for(let h of a)u(h,f);for(let h of r.rejectionEvents)u(h,d)};for(let h of a)l(h,f);for(let h of r.rejectionEvents)l(h,d);r.signal&&r.signal.addEventListener("abort",()=>{d(r.signal.reason)},{once:!0}),r.resolveImmediately&&i(c)});if(s.cancel=n,typeof r.timeout=="number"){let i=l3(s,{milliseconds:r.timeout});return i.cancel=n,i}return s}function GI(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=mSt(t,e,r),s=n.then(i=>i[0]);return s.cancel=n.cancel,s}var Rn=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CopyFileError"}};var Hi=fn(f0e(),1);import{promisify as Fb}from"util";var hhr=Fb(Hi.default.stat),ASt=Fb(Hi.default.lstat),CSt=Fb(Hi.default.utimes),OSt=Fb(Hi.default.chmod),PSt=Fb(Hi.default.mkdir),phr=Hi.default.closeSync.bind(Hi.default),d0e=Hi.default.createWriteStream.bind(Hi.default);async function h0e(t,e){let r=Hi.default.createReadStream(t,e);try{await GI(r,["readable","end"])}catch(n){throw new Rn(`Cannot read from \`${t}\`: ${n.message}`,{cause:n})}return r}var p3=t=>ASt(t).catch(e=>{throw new Rn(`lstat \`${t}\` failed: ${e.message}`,{cause:e})}),p0e=(t,e,r)=>CSt(t,e,r).catch(n=>{throw new Rn(`utimes \`${t}\` failed: ${n.message}`,{cause:n})}),m0e=(t,e)=>OSt(t,e).catch(r=>{throw new Rn(`chmod \`${t}\` failed: ${r.message}`,{cause:r})});var g0e=(t,e)=>PSt(t,{...e,recursive:!0}).catch(r=>{throw new Rn(`Cannot create directory \`${t}\`: ${r.message}`,{cause:r})});var ISt=(t,e,r)=>({sourcePath:Dd.resolve(t,e),destinationPath:Dd.resolve(t,r)}),NSt=(t,e)=>{if(!t.isFile())throw Object.assign(new Rn(`EISDIR: illegal operation on a directory '${e}'`),{errno:-21,code:"EISDIR",source:e})};async function _0e(t,e,r={}){if(!t||!e)throw new Rn("`source` and `destination` required");r.cwd&&({sourcePath:t,destinationPath:e}=ISt(r.cwd,t,e)),r={overwrite:!0,...r};let n=await p3(t),{size:s}=n;NSt(n,t);let i=Dd.dirname(e);if(Dd.parse(i).root===i||await g0e(Dd.dirname(e),{mode:r.directoryMode}),typeof r.onProgress=="function"){let a=await h0e(t),c=d0e(e,{flags:r.overwrite?"w":"wx"}),l=h=>{r.onProgress({sourcePath:Dd.resolve(t),destinationPath:Dd.resolve(e),size:s,writtenBytes:h,percent:h===s?1:h/s})},u=-1;a.on("data",()=>{let h=c.bytesWritten,p=h===s?1:h/s;(p===1||p-u>=.01)&&(u=p,l(h))});let f;a.once("error",h=>{f=new Rn(`Cannot read from \`${t}\`: ${h.message}`,{cause:h})});let d=!1;try{let h=GI(c,"close");a.pipe(c),await h,l(s),d=!0}catch(h){throw new Rn(`Cannot write to \`${e}\`: ${h.message}`,{cause:h})}if(f)throw f;if(d){let h=await p3(t);return Promise.all([p0e(e,h.atime,h.mtime).catch(p=>{if(p.code!=="EPERM")throw p}),m0e(e,h.mode)])}}else{let a=r.overwrite?m3.COPYFILE_FICLONE:m3.COPYFILE_FICLONE|m3.COPYFILE_EXCL;try{await g3.copyFile(t,e,a),await Promise.all([g3.utimes(e,n.atime,n.mtime).catch(c=>{if(c.code!=="EPERM")throw c}),g3.chmod(e,n.mode)])}catch(c){throw new Rn(c.message,{cause:c})}}}async function _3(t,e,r){return(await $b(t,(s,i)=>Promise.all([e(s,i),s]),r)).filter(s=>!!s[0]).map(s=>s[1])}import xAe from"process";import C0t from"fs";import m_ from"path";import{on as MSt,once as LSt}from"events";import{PassThrough as DSt}from"stream";import{finished as E0e}from"stream/promises";function T3(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)S3(s);let e=t.some(({readableObjectMode:s})=>s),r=kSt(t,e),n=new y3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return t.length===0&&v0e(n),n}var kSt=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},y3=class extends DSt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){S3(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=$St(this,this.#e),qSt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return S3(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},$St=async(t,e)=>{JI(t,y0e);let r=new AbortController;try{await Promise.race([FSt(t,r),USt(t,e,r)])}finally{r.abort(),JI(t,-y0e)}},FSt=async(t,{signal:e})=>{await E0e(t,{signal:e,cleanup:!0})},USt=async(t,e,{signal:r})=>{for await(let[n]of MSt(t,"unpipe",{signal:r}))e.has(n)&&n.emit(b0e)},S3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},qSt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i})=>{JI(t,S0e);let o=new AbortController;try{await Promise.race([BSt(i,e),jSt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:o}),HSt({stream:e,streams:r,ended:n,aborted:s,controller:o})])}finally{o.abort(),JI(t,-S0e)}r.size===n.size+s.size&&(n.size===0&&s.size>0?E3(t):v0e(t))},T0e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",BSt=async(t,e)=>{try{await t,E3(e)}catch(r){T0e(r)?E3(e):w0e(e,r)}},jSt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await E0e(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;T0e(o)?s.add(e):w0e(t,o)}},HSt=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:s}})=>{await LSt(t,b0e,{signal:s}),e.delete(t),r.delete(t),n.delete(t)},b0e=Symbol("unpipe"),v0e=t=>{t.writable&&t.end()},E3=t=>{(t.readable||t.writable)&&t.destroy()},w0e=(t,e)=>{t.destroyed||(t.once("error",VSt),t.destroy(e))},VSt=()=>{},JI=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},y0e=2,S0e=1;var g_=fn(Gb(),1);import Qvt from"fs";import Zvt from"fs/promises";async function oW(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await Zvt[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function aW(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return Qvt[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var Xpr=oW.bind(void 0,"stat","isFile"),fAe=oW.bind(void 0,"stat","isDirectory"),Qpr=oW.bind(void 0,"lstat","isSymbolicLink"),Zpr=aW.bind(void 0,"statSync","isFile"),dAe=aW.bind(void 0,"statSync","isDirectory"),emr=aW.bind(void 0,"lstatSync","isSymbolicLink");var mW=fn(Gb(),1),TAe=fn(pW(),1);import E0t from"process";import T0t from"fs";import b0t from"fs/promises";import p_ from"path";function h_(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var Wb=t=>t[0]==="!";var v0t=["**/node_modules","**/flow-typed","**/coverage","**/.git"],bAe={absolute:!0,dot:!0},vAe="**/.gitignore",w0t=(t,e)=>Wb(t)?"!"+p_.posix.join(e,t.slice(1)):p_.posix.join(e,t),R0t=(t,e)=>{let r=h_(p_.relative(e,p_.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>w0t(n,r))},A0t=(t,e)=>{if(e=h_(e),p_.isAbsolute(t)){if(h_(t).startsWith(e))return p_.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},wAe=(t,e)=>{let r=t.flatMap(s=>R0t(s,e)),n=(0,TAe.default)().add(r);return s=>(s=kn(s),s=A0t(s,e),s?n.ignores(h_(s)):!1)},RAe=(t={})=>({cwd:kn(t.cwd)??E0t.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...v0t]}),AAe=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=RAe(e),o=await(0,mW.default)(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...bAe}),a=await Promise.all(o.map(async c=>({filePath:c,content:await b0t.readFile(c,"utf8")})));return wAe(a,r)},CAe=(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=RAe(e),a=mW.default.sync(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...bAe}).map(c=>({filePath:c,content:T0t.readFileSync(c,"utf8")}));return wAe(a,r)};var O0t=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},IAe=(t,e)=>{let r=Wb(t)?t.slice(1):t;return m_.isAbsolute(r)?r:m_.join(e,r)},NAe=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(s=>m_.posix.join(t,`**/${m_.extname(s)?s:`${s}${n}`}`)):[m_.posix.join(t,`**${n?`/*${n}`:""}`)]},OAe=async(t,{cwd:e=xAe.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async i=>await fAe(IAe(i,e))?NAe({directoryPath:i,files:r,extensions:n}):i))).flat(),PAe=(t,{cwd:e=xAe.cwd(),files:r,extensions:n}={})=>t.flatMap(s=>dAe(IAe(s,e))?NAe({directoryPath:s,files:r,extensions:n}):s),gW=t=>(t=[...new Set([t].flat())],O0t(t),t),P0t=t=>{if(!t)return;let e;try{e=C0t.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},MAe=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:kn(t.cwd)},P0t(t.cwd),t),LAe=t=>async(e,r)=>t(gW(e),MAe(r)),ON=t=>(e,r)=>t(gW(e),MAe(r)),DAe=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?gW(e):[];return r&&n.push(vAe),n},x0t=async t=>{let e=DAe(t);return $Ae(e.length>0&&await AAe(e,t))},kAe=t=>{let e=DAe(t);return $Ae(e.length>0&&CAe(e,t))},$Ae=t=>{let e=new Set;return r=>{let n=m_.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},FAe=(t,e)=>t.flat().filter(r=>e(r)),UAe=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(i=>Wb(i));if(n===-1){r.push({patterns:t,options:e});break}let s=t[n].slice(1);for(let i of r)i.options.ignore.push(s);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,s]}}),t=t.slice(n+1)}return r},qAe=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),BAe=async(t,e)=>{let r=UAe(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=qAe(s,n);return Promise.all(r.map(async o=>{let{patterns:a,options:c}=o;return[a,c.ignore]=await Promise.all([OAe(a,i),OAe(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},_W=(t,e)=>{let r=UAe(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=qAe(s,n);return r.map(o=>{let{patterns:a,options:c}=o;return a=PAe(a,i),c.ignore=PAe(c.ignore,{cwd:n}),{patterns:a,options:c}})},Tmr=LAe(async(t,e)=>{let[r,n]=await Promise.all([BAe(t,e),x0t(e)]),s=await Promise.all(r.map(i=>(0,g_.default)(i.patterns,i.options)));return FAe(s,n)}),jAe=ON((t,e)=>{let r=_W(t,e),n=kAe(e),s=r.map(i=>g_.default.sync(i.patterns,i.options));return FAe(s,n)}),bmr=ON((t,e)=>{let r=_W(t,e),n=kAe(e),s=r.map(o=>g_.default.stream(o.patterns,o.options));return T3(s).filter(o=>n(o))}),Ud=ON((t,e)=>t.some(r=>g_.default.isDynamicPattern(r,e))),vmr=LAe(BAe),wmr=ON(_W),{convertPathToPattern:Rmr}=g_.default;var VAe=fn(H3(),1);var hu=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CpyError"}};import xN from"path";import HAe from"fs";var I0t=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],N0t=new RegExp(I0t.join("|"));function M0t(t){return N0t.test(t)}function PN(t){return!M0t(t)}var Yb=class{constructor(e,r,n){this.path=e,this.originalPath=e,this.destination=r,this.options=n,this.isDirectory=!1,!Ud(e)&&HAe.existsSync(e)&&HAe.lstatSync(e).isDirectory()&&(this.path=[e,"**"].join("/"),this.isDirectory=!0)}get name(){return xN.basename(this.originalPath)}get normalizedPath(){let e=this.originalPath.split("/"),r=e.findIndex(s=>s?Ud(s):!1),n=e.slice(0,r).join("/");return n?xN.isAbsolute(n)?n:xN.join(this.options.cwd,n):this.destination}hasMagic(){return Ud(this.options.flat?this.path:this.originalPath)}getMatches(){let e=jAe(this.path,{...this.options,dot:!0,absolute:!0,onlyFiles:!0});return this.options.ignoreJunk&&(e=e.filter(r=>PN(xN.basename(r)))),e}};var $0t={ignoreJunk:!0,flat:!1,cwd:L0t.cwd()},yW=class{constructor(e,r,n){this.path=e.split("/").join(at.sep),this.relativePath=r.split("/").join(at.sep),this.pattern=n,Object.freeze(this)}get name(){return at.basename(this.path)}get nameWithoutExtension(){return at.basename(this.path,at.extname(this.path))}get extension(){return at.extname(this.path).slice(1)}},F0t=t=>t.flatMap(e=>VAe.default.braces(e,{expand:!0,nodupes:!0})),U0t=({entry:t,destination:e,options:r})=>t.pattern.hasMagic()?r.flat?at.isAbsolute(e)?at.join(e,t.name):at.join(r.cwd,e,t.name):at.join(e,at.relative(t.pattern.normalizedPath,t.path)):at.isAbsolute(e)?at.join(e,t.name):t.pattern.isDirectory&&at.relative(r.cwd,t.path).startsWith("..")?at.join(r.cwd,e,at.basename(t.pattern.originalPath),at.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&t.path===t.relativePath?at.join(r.cwd,e,at.basename(t.pattern.originalPath),at.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&r.flat?at.join(r.cwd,e,at.basename(t.pattern.originalPath)):at.join(r.cwd,e,at.relative(r.cwd,t.path)),q0t=(t,e)=>{let r=at.dirname(t);if(typeof e=="string")return at.join(r,e);if(typeof e=="function"){let n=at.basename(t);return at.join(r,e(n))}return t};function SW(t,e,{concurrency:r=k0t.availableParallelism(),...n}={}){let s=new Map,i=new D0t;n={...$0t,...n};let o=(async()=>{let a=[],c=0,l=0,u=F0t([t??[]].flat()).map(p=>p.replaceAll("\\","/")),f=u.filter(p=>!p.startsWith("!")),d=u.filter(p=>p.startsWith("!"));if(f.length===0||!e)throw new hu("`source` and `destination` required");u=u.map(p=>new Yb(p,e,{...n,ignore:d}));for(let p of u){let m=[];try{m=p.getMatches()}catch(g){throw new hu(`Cannot glob \`${p.originalPath}\`: ${g.message}`,{cause:g})}if(m.length===0&&!Ud(p.originalPath)&&!Ud(d))throw new hu(`Cannot copy \`${p.originalPath}\`: the file doesn't exist`);a=[...a,...m.map(g=>new yW(g,at.relative(n.cwd,g),p))]}n.filter!==void 0&&(a=await _3(a,n.filter,{concurrency:1024})),a.length===0&&i.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0});let h=p=>{let m=s.get(p.sourcePath)||{writtenBytes:0,percent:0};(m.writtenBytes!==p.writtenBytes||m.percent!==p.percent)&&(l-=m.writtenBytes,l+=p.writtenBytes,p.percent===1&&m.percent!==1&&c++,s.set(p.sourcePath,{writtenBytes:p.writtenBytes,percent:p.percent}),i.emit("progress",{totalFiles:a.length,percent:c/a.length,completedFiles:c,completedSize:l,sourcePath:p.sourcePath,destinationPath:p.destinationPath}))};return $b(a,async p=>{let m=q0t(U0t({entry:p,destination:e,options:n}),n.rename);try{await _0e(p.path,m,{...n,onProgress:h})}catch(g){throw new hu(`Cannot copy from \`${p.relativePath}\` to \`${m}\`: ${g.message}`,{cause:g})}return m},{concurrency:r})})();return o.on=(...a)=>(i.on(...a),o),o}import lCe from"process";import cwt from"fs";import S_ from"path";import{on as B0t,once as j0t}from"events";import{PassThrough as H0t}from"stream";import{finished as WAe}from"stream/promises";function vW(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)TW(s);let e=t.some(({readableObjectMode:s})=>s),r=V0t(t,e),n=new EW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return t.length===0&&JAe(n),n}var V0t=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},EW=class extends H0t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){TW(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=G0t(this,this.#e),Y0t({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return TW(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},G0t=async(t,e)=>{IN(t,GAe);let r=new AbortController;try{await Promise.race([z0t(t,r),W0t(t,e,r)])}finally{r.abort(),IN(t,-GAe)}},z0t=async(t,{signal:e})=>{await WAe(t,{signal:e,cleanup:!0})},W0t=async(t,e,{signal:r})=>{for await(let[n]of B0t(t,"unpipe",{signal:r}))e.has(n)&&n.emit(KAe)},TW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Y0t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i})=>{IN(t,zAe);let o=new AbortController;try{await Promise.race([K0t(i,e),J0t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:o}),X0t({stream:e,streams:r,ended:n,aborted:s,controller:o})])}finally{o.abort(),IN(t,-zAe)}r.size===n.size+s.size&&(n.size===0&&s.size>0?bW(t):JAe(t))},YAe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",K0t=async(t,e)=>{try{await t,bW(e)}catch(r){YAe(r)?bW(e):XAe(e,r)}},J0t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await WAe(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;YAe(o)?s.add(e):XAe(t,o)}},X0t=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:s}})=>{await j0t(t,KAe,{signal:s}),e.delete(t),r.delete(t),n.delete(t)},KAe=Symbol("unpipe"),JAe=t=>{t.writable&&t.end()},bW=t=>{(t.readable||t.writable)&&t.destroy()},XAe=(t,e)=>{t.destroyed||(t.once("error",Q0t),t.destroy(e))},Q0t=()=>{},IN=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},GAe=2,zAe=1;var E_=fn(Gb(),1);import Z0t from"fs";import ewt from"fs/promises";async function wW(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await ewt[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function RW(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return Z0t[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var Xmr=wW.bind(void 0,"stat","isFile"),QAe=wW.bind(void 0,"stat","isDirectory"),Qmr=wW.bind(void 0,"lstat","isSymbolicLink"),Zmr=RW.bind(void 0,"statSync","isFile"),ZAe=RW.bind(void 0,"statSync","isDirectory"),egr=RW.bind(void 0,"lstatSync","isSymbolicLink");var AW=fn(Gb(),1),eCe=fn(pW(),1);import twt from"process";import rwt from"fs";import nwt from"fs/promises";import y_ from"path";function __(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var Kb=t=>t[0]==="!";var swt=["**/node_modules","**/flow-typed","**/coverage","**/.git"],tCe={absolute:!0,dot:!0},rCe="**/.gitignore",iwt=(t,e)=>Kb(t)?"!"+y_.posix.join(e,t.slice(1)):y_.posix.join(e,t),owt=(t,e)=>{let r=__(y_.relative(e,y_.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>iwt(n,r))},awt=(t,e)=>{if(e=__(e),y_.isAbsolute(t)){if(__(t).startsWith(e))return y_.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},nCe=(t,e)=>{let r=t.flatMap(s=>owt(s,e)),n=(0,eCe.default)().add(r);return s=>(s=kn(s),s=awt(s,e),s?n.ignores(__(s)):!1)},sCe=(t={})=>({cwd:kn(t.cwd)??twt.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...swt]}),iCe=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=sCe(e),o=await(0,AW.default)(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...tCe}),a=await Promise.all(o.map(async c=>({filePath:c,content:await nwt.readFile(c,"utf8")})));return nCe(a,r)},oCe=(t,e)=>{let{cwd:r,suppressErrors:n,deep:s,ignore:i}=sCe(e),a=AW.default.sync(t,{cwd:r,suppressErrors:n,deep:s,ignore:i,...tCe}).map(c=>({filePath:c,content:rwt.readFileSync(c,"utf8")}));return nCe(a,r)};var lwt=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},uCe=(t,e)=>{let r=Kb(t)?t.slice(1):t;return S_.isAbsolute(r)?r:S_.join(e,r)},fCe=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(s=>S_.posix.join(t,`**/${S_.extname(s)?s:`${s}${n}`}`)):[S_.posix.join(t,`**${n?`/*${n}`:""}`)]},aCe=async(t,{cwd:e=lCe.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async i=>await QAe(uCe(i,e))?fCe({directoryPath:i,files:r,extensions:n}):i))).flat(),cCe=(t,{cwd:e=lCe.cwd(),files:r,extensions:n}={})=>t.flatMap(s=>ZAe(uCe(s,e))?fCe({directoryPath:s,files:r,extensions:n}):s),CW=t=>(t=[...new Set([t].flat())],lwt(t),t),uwt=t=>{if(!t)return;let e;try{e=cwt.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},dCe=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:kn(t.cwd)},uwt(t.cwd),t),hCe=t=>async(e,r)=>t(CW(e),dCe(r)),NN=t=>(e,r)=>t(CW(e),dCe(r)),pCe=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?CW(e):[];return r&&n.push(rCe),n},fwt=async t=>{let e=pCe(t);return gCe(e.length>0&&await iCe(e,t))},mCe=t=>{let e=pCe(t);return gCe(e.length>0&&oCe(e,t))},gCe=t=>{let e=new Set;return r=>{let n=S_.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},_Ce=(t,e)=>t.flat().filter(r=>e(r)),yCe=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(i=>Kb(i));if(n===-1){r.push({patterns:t,options:e});break}let s=t[n].slice(1);for(let i of r)i.options.ignore.push(s);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,s]}}),t=t.slice(n+1)}return r},SCe=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),ECe=async(t,e)=>{let r=yCe(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=SCe(s,n);return Promise.all(r.map(async o=>{let{patterns:a,options:c}=o;return[a,c.ignore]=await Promise.all([aCe(a,i),aCe(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},OW=(t,e)=>{let r=yCe(t,e),{cwd:n,expandDirectories:s}=e;if(!s)return r;let i=SCe(s,n);return r.map(o=>{let{patterns:a,options:c}=o;return a=cCe(a,i),c.ignore=cCe(c.ignore,{cwd:n}),{patterns:a,options:c}})},TCe=hCe(async(t,e)=>{let[r,n]=await Promise.all([ECe(t,e),fwt(e)]),s=await Promise.all(r.map(i=>(0,E_.default)(i.patterns,i.options)));return _Ce(s,n)}),Egr=NN((t,e)=>{let r=OW(t,e),n=mCe(e),s=r.map(i=>E_.default.sync(i.patterns,i.options));return _Ce(s,n)}),Tgr=NN((t,e)=>{let r=OW(t,e),n=mCe(e),s=r.map(o=>E_.default.stream(o.patterns,o.options));return vW(s).filter(o=>n(o))}),bgr=NN((t,e)=>t.some(r=>E_.default.isDynamicPattern(r,e))),vgr=hCe(ECe),wgr=NN(OW),{convertPathToPattern:Rgr}=E_.default;import hwt from"process";import Jb from"path";import Mgr,{promises as MN}from"fs";import Ogr,{promises as dwt}from"fs";async function bCe(t){try{return await dwt.access(t),!0}catch{return!1}}var pwt=(t,e,r)=>(e=Jb.resolve(t,e),r=Jb.resolve(t,r),{sourcePath:e,destinationPath:r}),mwt=(t,e,r="Path")=>{if(!t||!e)throw new TypeError(`\`source${r}\` and \`destination${r}\` required`)},gwt=(t,e)=>{if(Jb.dirname(t)!==Jb.dirname(e))throw new Error("`source` and `destination` must be in the same directory")},_wt=async(t,e,{overwrite:r=!0,cwd:n=hwt.cwd(),directoryMode:s,validateDirectory:i=!1}={})=>{if(n&&({sourcePath:t,destinationPath:e}=pwt(n,t,e)),i&&gwt(t,e),!r&&await bCe(e))throw new Error(`The destination file exists: ${e}`);await MN.mkdir(Jb.dirname(e),{recursive:!0,mode:s});try{await MN.rename(t,e)}catch(o){if(o.code==="EXDEV")await MN.copyFile(t,e),await MN.unlink(t);else throw o}};async function vCe(t,e,r){return mwt(t,e),_wt(t,e,r)}var PW=async function(t,e,r=!1){if(r)return vCe(t,e,{overwrite:!1});let{srcGlob:n,dest:s,...i}=await ACe(t,RCe(e));if(n&&s)return SW(n,s,{...i,overwrite:!1})},Xb=async function(t){let{srcGlob:e,isDir:r,dest:n,...s}=await ACe(t,"");return e!==void 0&&!await Ewt(e,r,s)},Ewt=async function(t,e,r){return e?(await TCe(t,r)).filter(i=>PN(wCe(i))).length===0:!1},ACe=async function(t,e){let r=await Twt(t);if(r===void 0)return{srcGlob:void 0,isDir:!1,cwd:""};let n=r.isDirectory(),s=wCe(t),i=RCe(t),o={srcGlob:s,dest:e,isDir:n,cwd:i,dot:!0};return n?{...o,srcGlob:`${s}/**`,dest:Swt(e,s)}:o},Twt=async t=>{try{return await ywt.stat(t)}catch{return}};import{join as gRt}from"path";import{stat as bwt,lstat as CCe,readdir as vwt,realpath as wwt}from"fs/promises";import{Readable as Rwt}from"stream";import{resolve as OCe,relative as Awt,join as Cwt,sep as Owt}from"path";var Es={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},xW={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:Es.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(xW);var NCe="READDIRP_RECURSIVE_ERROR",Pwt=new Set(["ENOENT","EPERM","EACCES","ELOOP",NCe]),PCe=[Es.DIR_TYPE,Es.EVERYTHING_TYPE,Es.FILE_DIR_TYPE,Es.FILE_TYPE],xwt=new Set([Es.DIR_TYPE,Es.EVERYTHING_TYPE,Es.FILE_DIR_TYPE]),Iwt=new Set([Es.EVERYTHING_TYPE,Es.FILE_DIR_TYPE,Es.FILE_TYPE]),Nwt=t=>Pwt.has(t.code),Mwt=process.platform==="win32",xCe=t=>!0,ICe=t=>{if(t===void 0)return xCe;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 xCe},IW=class extends Rwt{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...xW,...e},{root:n,type:s}=r;this._fileFilter=ICe(r.fileFilter),this._directoryFilter=ICe(r.directoryFilter);let i=r.lstat?CCe:bwt;Mwt?this._stat=o=>i(o,{bigint:!0}):this._stat=i,this._maxDepth=r.depth??xW.depth,this._wantsDir=s?xwt.has(s):!1,this._wantsFile=s?Iwt.has(s):!1,this._wantsEverything=s===Es.EVERYTHING_TYPE,this._root=OCe(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:s,depth:i}=r,o=n.splice(0,e).map(c=>this._formatEntry(c,s)),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)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),e--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let s=this.parents.pop();if(!s){this.push(null);break}if(this.parent=await s,this.destroyed)return}}}catch(r){this.destroy(r)}finally{this.reading=!1}}}async _exploreDir(e,r){let n;try{n=await vwt(e,this._rdOptions)}catch(s){this._onError(s)}return{files:n,depth:r,path:e}}async _formatEntry(e,r){let n,s=this._isDirent?e.name:e;try{let i=OCe(Cwt(r,s));n={path:Awt(this._root,i),fullPath:i,basename:s},n[this._statsProp]=this._isDirent?e:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(e){Nwt(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 s=await wwt(n),i=await CCe(s);if(i.isFile())return"file";if(i.isDirectory()){let o=s.length;if(n.startsWith(s)&&n.substr(o,1)===Owt){let a=new Error(`Circular symlink detected: "${n}" points to "${s}"`);return a.code=NCe,this._onError(a)}return"directory"}}catch(s){return this._onError(s),""}}}_includeAsFile(e){let r=e&&e[this._statsProp];return r&&this._wantsEverything&&!r.isDirectory()}};function Lwt(t,e={}){let r=e.entryType||e.type;if(r==="both"&&(r=Es.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&&!PCe.includes(r))throw new Error(`readdirp: Invalid type passed. Use one of ${PCe.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new IW(e)}function MCe(t,e={}){return new Promise((r,n)=>{let s=[];Lwt(t,e).on("data",i=>s.push(i)).on("end",()=>r(s)).on("error",i=>n(i))})}import{mkdir as Wwt,readFile as qCe,rm as Ywt,writeFile as Kwt}from"fs/promises";import{existsSync as BCe}from"fs";import{dirname as Jwt}from"path";var LCe=t=>{if(!(!Number.isInteger(t)||t<1))return Date.now()+t*1e3},DCe=t=>t!==void 0&&Date.now()>t;import{createHash as Hwt}from"crypto";import{createReadStream as Vwt}from"fs";import $wt from"process";import Fwt from"path";import r_r,{promises as kCe}from"fs";import{fileURLToPath as Uwt}from"url";var NW=class{value;next;constructor(e){this.value=e}},Qb=class{#e;#r;#t;constructor(){this.clear()}enqueue(e){let r=new NW(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 LN(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 Qb,r=0,n=()=>{r--,e.size>0&&e.dequeue()()},s=async(a,c,l)=>{r++;let u=(async()=>a(...l))();c(u);try{await u}catch{}n()},i=(a,c,l)=>{e.enqueue(s.bind(void 0,a,c,l)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.dequeue()()))()},o=(a,...c)=>new Promise(l=>{i(a,l,c)});return Object.defineProperties(o,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}var DN=class extends Error{constructor(e){super(),this.value=e}},Dwt=async(t,e)=>e(await t),kwt=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new DN(e[0]);return!1};async function MW(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let s=LN(r),i=[...t].map(a=>[a,s(Dwt,a,e)]),o=LN(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(i.map(a=>o(kwt,a)))}catch(a){if(a instanceof DN)return a.value;throw a}}var $Ce={directory:"isDirectory",file:"isFile"};function qwt(t){if(!Object.hasOwnProperty.call($Ce,t))throw new Error(`Invalid type specified: ${t}`)}var Bwt=(t,e)=>e[$Ce[t]](),jwt=t=>t instanceof URL?Uwt(t):t;async function FCe(t,{cwd:e=$wt.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:s,preserveOrder:i}={}){qwt(r),e=jwt(e);let o=n?kCe.stat:kCe.lstat;return MW(t,async a=>{try{let c=await o(Fwt.resolve(e,a));return Bwt(r,c)}catch{return!1}},{concurrency:s,preserveOrder:i})}var Gwt="sha1",UCe=async function(t,e){if(e||t.length===0)return;let r=await FCe(t);return r===void 0?void 0:await zwt(r)},zwt=async function(t){let e=Vwt(t,"utf8"),r=Hwt(Gwt,{encoding:"hex"});return e.pipe(r),await Vp(r)};var jCe=async function({cachePath:t,move:e,ttl:r,digests:n}){let s=kN(t),i=LCe(r),o=await UCe(n,e),c=`${JSON.stringify({expires:i,hash:o},null,2)}
|
|
747
|
-
`,l=await Xwt({hash:o,manifestPath:s,manifestString:c});return{manifestInfo:{manifestPath:s,manifestString:c},identical:l}},Xwt=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!BCe(e)?!1:await qCe(e,"utf8")===r},HCe=async function({manifestPath:t,manifestString:e}){await Wwt(Jwt(t),{recursive:!0}),await Kwt(t,e)},VCe=async function(t){let e=kN(t);await Ywt(e,{force:!0,recursive:!0,maxRetries:3})},kN=function(t){return`${t}${zCe}`},GCe=function(t){return t.endsWith(zCe)},zCe=".netlify.cache.json",LW=async function(t){let e=kN(t);if(!BCe(e))return!1;let{expires:r}=await Qwt(t);return DCe(r)},Qwt=async function(t){let e=kN(t),r=await qCe(e,"utf-8");return JSON.parse(r)};import{homedir as nRt}from"os";import{resolve as WCe,isAbsolute as sRt,join as iRt,sep as kW}from"path";import{normalize as Zwt}from"path";import{existsSync as eRt}from"fs";import tRt from"process";var DW=function(t){try{let e=rRt(t);return eRt(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},rRt=function(t=tRt.cwd()){return Zwt(t)};var Zb=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await oRt(t,r),s=await uRt({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:s}},oRt=async function(t,e){let r=await DW(e),n=aRt(t,r);return cRt(n,r),n},aRt=function(t,e){if(sRt(t))return WCe(t);if(e!=="")return WCe(e,t);throw new Error(`Current directory does not exist: ${e}`)},cRt=function(t,e){if(e!==""&&lRt(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},lRt=function(t,e){return`${e}${kW}`.startsWith(`${t}${kW}`)},uRt=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Md({cacheDir:e,cwd:r}),{name:s,relPath:i}=await fRt(t,r);return iRt(n,s,i)},fRt=async function(t,e){let r=await $W(e),n=dRt(t);return r.map(({name:s,base:i})=>pRt(s,i,n)).find(Boolean)},dRt=function(t){return t.replace(hRt,"\\")},hRt=/^[a-zA-Z]:\\/,pRt=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},$W=async function(t){return[...await mRt(t),{name:"home",base:nRt()},{name:"root",base:kW}]},mRt=async function(t){let e=await DW(t);return e===""?[]:[{name:"cwd",base:e}]};var _Rt=1,FW=async function({cacheDir:t,cwd:e,depth:r=_Rt}={}){let n=await $W(e),s=Md({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>yRt({name:a,base:c,cacheDir:s,depth:r})))).flat()},yRt=async function({name:t,base:e,cacheDir:r,depth:n}){return(await MCe(`${r}/${t}`,{fileFilter:SRt,depth:n,type:"files_directories"})).map(({path:o})=>gRt(e,o))},SRt=function({basename:t}){return!GCe(t)};var ERt=async function(t,{move:e=YCe,ttl:r=wRt,digests:n=[],cacheDir:s,cwd:i}={}){let{srcPath:o,cachePath:a}=await Zb({path:t,cacheDir:s,cwdOpt:i});if(!await Xb(o))return!1;let{manifestInfo:c,identical:l}=await jCe({cachePath:a,move:e,ttl:r,digests:n});return l||(await UW(a,{force:!0,recursive:!0,maxRetries:3}),await PW(o,a,e),await HCe(c)),!0},TRt=async function(t,{move:e=YCe,cacheDir:r,cwd:n}={}){let{srcPath:s,cachePath:i}=await Zb({path:t,cacheDir:r,cwdOpt:n});return!await Xb(i)||await LW(i)?!1:(await UW(s,{force:!0,recursive:!0,maxRetries:3}),await PW(i,s,e),!0)},bRt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Zb({path:t,cacheDir:e,cwdOpt:r});return await Xb(n)?(await UW(n,{force:!0,recursive:!0,maxRetries:3}),await VCe(n),!0):!1},vRt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Zb({path:t,cacheDir:e,cwdOpt:r});return await Xb(n)&&!await LW(n)},YCe=!1,wRt=void 0,$N=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(s=>t(s,...r)))).some(Boolean):t(e,...r)},RRt=$N.bind(null,ERt),ARt=$N.bind(null,TRt),CRt=$N.bind(null,bRt),ORt=$N.bind(null,vRt),KCe=function(t){return{save:(e,r)=>RRt(e,{...t,...r}),restore:(e,r)=>ARt(e,{...t,...r}),remove:(e,r)=>CRt(e,{...t,...r}),has:(e,r)=>ORt(e,{...t,...r}),list:e=>FW({...t,...e}),getCacheDir:e=>Md({...t,...e})}};var zr=Se("native_session"),qW=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await _c.stat(yc.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),FN=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return zr.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:n,include:s}=r,i=!1;try{i=(await _c.stat(n)).isDirectory()}catch{}if(!i)return zr.log(`Native session base dir ${n} not found, skipping`),null;let o=await qW(n,s);if(o.length===0)return zr.log(`No native session history found under ${n}, skipping`),null;let a=yc.join(JCe.tmpdir(),`native-session-${e}.zip`);try{await rs("zip",["-r","-q","-X",a,...o],{cwd:n});let c=await _c.readFile(a);zr.log(`Zipped native session (${c.length} bytes) from ${o.join(", ")}`);let{upload_url:l,s3_key:u}=await wve(t,e);return await Mb(l,c,{contentType:"application/zip"}),zr.log("Successfully uploaded native session to S3"),u}catch(c){return zr.error("Failed to archive/upload native session, continuing without it:",c),null}finally{await _c.rm(a,{force:!0}).catch(()=>{})}},XCe=async t=>{if(!t)return!1;let{baseDir:e,include:r}=t,n=await qW(e,r);for(let s of n)if((await _c.readdir(yc.join(e,s)).catch(()=>[])).length>0)return!0;return!1},PRt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),QCe=async(t,e)=>{let r=await _c.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await QCe(yc.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},ZCe=async(t,e)=>{if(!t||!e)return!1;let r=new RegExp(`(^|[^a-zA-Z0-9])${PRt(e)}([^a-zA-Z0-9]|$)`),{baseDir:n,include:s}=t,i=await qW(n,s);for(let o of i)if(await QCe(yc.join(n,o),r))return!0;return!1},eOe=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return zr.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,s=yc.join(JCe.tmpdir(),`native-session-restore-${e}.zip`);try{let i=await Rve(t,e);if(!i?.download_url)return zr.log("No native session available to restore, skipping"),!1;let o=await Nve(i.download_url);return await _c.writeFile(s,o),zr.log(`Downloaded native session (${o.length} bytes) to ${s}`),await _c.mkdir(n,{recursive:!0}),await rs("unzip",["-o","-q",s,"-d",n]),zr.log(`Restored native session into ${n}`),!0}catch(i){return zr.error("Failed to fetch/restore native session, continuing without it:",i),!1}finally{await _c.rm(s,{force:!0}).catch(()=>{})}},xRt="native-sessions",tOe=(t,e)=>KCe({cacheDir:yc.join(e.dir,xRt),cwd:t}),rOe=async({archive:t,cache:e})=>{if(!e?.
|
|
747
|
+
`,l=await Xwt({hash:o,manifestPath:s,manifestString:c});return{manifestInfo:{manifestPath:s,manifestString:c},identical:l}},Xwt=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!BCe(e)?!1:await qCe(e,"utf8")===r},HCe=async function({manifestPath:t,manifestString:e}){await Wwt(Jwt(t),{recursive:!0}),await Kwt(t,e)},VCe=async function(t){let e=kN(t);await Ywt(e,{force:!0,recursive:!0,maxRetries:3})},kN=function(t){return`${t}${zCe}`},GCe=function(t){return t.endsWith(zCe)},zCe=".netlify.cache.json",LW=async function(t){let e=kN(t);if(!BCe(e))return!1;let{expires:r}=await Qwt(t);return DCe(r)},Qwt=async function(t){let e=kN(t),r=await qCe(e,"utf-8");return JSON.parse(r)};import{homedir as nRt}from"os";import{resolve as WCe,isAbsolute as sRt,join as iRt,sep as kW}from"path";import{normalize as Zwt}from"path";import{existsSync as eRt}from"fs";import tRt from"process";var DW=function(t){try{let e=rRt(t);return eRt(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},rRt=function(t=tRt.cwd()){return Zwt(t)};var Zb=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await oRt(t,r),s=await uRt({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:s}},oRt=async function(t,e){let r=await DW(e),n=aRt(t,r);return cRt(n,r),n},aRt=function(t,e){if(sRt(t))return WCe(t);if(e!=="")return WCe(e,t);throw new Error(`Current directory does not exist: ${e}`)},cRt=function(t,e){if(e!==""&&lRt(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},lRt=function(t,e){return`${e}${kW}`.startsWith(`${t}${kW}`)},uRt=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Md({cacheDir:e,cwd:r}),{name:s,relPath:i}=await fRt(t,r);return iRt(n,s,i)},fRt=async function(t,e){let r=await $W(e),n=dRt(t);return r.map(({name:s,base:i})=>pRt(s,i,n)).find(Boolean)},dRt=function(t){return t.replace(hRt,"\\")},hRt=/^[a-zA-Z]:\\/,pRt=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},$W=async function(t){return[...await mRt(t),{name:"home",base:nRt()},{name:"root",base:kW}]},mRt=async function(t){let e=await DW(t);return e===""?[]:[{name:"cwd",base:e}]};var _Rt=1,FW=async function({cacheDir:t,cwd:e,depth:r=_Rt}={}){let n=await $W(e),s=Md({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>yRt({name:a,base:c,cacheDir:s,depth:r})))).flat()},yRt=async function({name:t,base:e,cacheDir:r,depth:n}){return(await MCe(`${r}/${t}`,{fileFilter:SRt,depth:n,type:"files_directories"})).map(({path:o})=>gRt(e,o))},SRt=function({basename:t}){return!GCe(t)};var ERt=async function(t,{move:e=YCe,ttl:r=wRt,digests:n=[],cacheDir:s,cwd:i}={}){let{srcPath:o,cachePath:a}=await Zb({path:t,cacheDir:s,cwdOpt:i});if(!await Xb(o))return!1;let{manifestInfo:c,identical:l}=await jCe({cachePath:a,move:e,ttl:r,digests:n});return l||(await UW(a,{force:!0,recursive:!0,maxRetries:3}),await PW(o,a,e),await HCe(c)),!0},TRt=async function(t,{move:e=YCe,cacheDir:r,cwd:n}={}){let{srcPath:s,cachePath:i}=await Zb({path:t,cacheDir:r,cwdOpt:n});return!await Xb(i)||await LW(i)?!1:(await UW(s,{force:!0,recursive:!0,maxRetries:3}),await PW(i,s,e),!0)},bRt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Zb({path:t,cacheDir:e,cwdOpt:r});return await Xb(n)?(await UW(n,{force:!0,recursive:!0,maxRetries:3}),await VCe(n),!0):!1},vRt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Zb({path:t,cacheDir:e,cwdOpt:r});return await Xb(n)&&!await LW(n)},YCe=!1,wRt=void 0,$N=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(s=>t(s,...r)))).some(Boolean):t(e,...r)},RRt=$N.bind(null,ERt),ARt=$N.bind(null,TRt),CRt=$N.bind(null,bRt),ORt=$N.bind(null,vRt),KCe=function(t){return{save:(e,r)=>RRt(e,{...t,...r}),restore:(e,r)=>ARt(e,{...t,...r}),remove:(e,r)=>CRt(e,{...t,...r}),has:(e,r)=>ORt(e,{...t,...r}),list:e=>FW({...t,...e}),getCacheDir:e=>Md({...t,...e})}};var zr=Se("native_session"),qW=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await _c.stat(yc.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),FN=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return zr.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:n,include:s}=r,i=!1;try{i=(await _c.stat(n)).isDirectory()}catch{}if(!i)return zr.log(`Native session base dir ${n} not found, skipping`),null;let o=await qW(n,s);if(o.length===0)return zr.log(`No native session history found under ${n}, skipping`),null;let a=yc.join(JCe.tmpdir(),`native-session-${e}.zip`);try{await rs("zip",["-r","-q","-X",a,...o],{cwd:n});let c=await _c.readFile(a);zr.log(`Zipped native session (${c.length} bytes) from ${o.join(", ")}`);let{upload_url:l,s3_key:u}=await wve(t,e);return await Mb(l,c,{contentType:"application/zip"}),zr.log("Successfully uploaded native session to S3"),u}catch(c){return zr.error("Failed to archive/upload native session, continuing without it:",c),null}finally{await _c.rm(a,{force:!0}).catch(()=>{})}},XCe=async t=>{if(!t)return!1;let{baseDir:e,include:r}=t,n=await qW(e,r);for(let s of n)if((await _c.readdir(yc.join(e,s)).catch(()=>[])).length>0)return!0;return!1},PRt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),QCe=async(t,e)=>{let r=await _c.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await QCe(yc.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},ZCe=async(t,e)=>{if(!t||!e)return!1;let r=new RegExp(`(^|[^a-zA-Z0-9])${PRt(e)}([^a-zA-Z0-9]|$)`),{baseDir:n,include:s}=t,i=await qW(n,s);for(let o of i)if(await QCe(yc.join(n,o),r))return!0;return!1},eOe=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return zr.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,s=yc.join(JCe.tmpdir(),`native-session-restore-${e}.zip`);try{let i=await Rve(t,e);if(!i?.download_url)return zr.log("No native session available to restore, skipping"),!1;let o=await Nve(i.download_url);return await _c.writeFile(s,o),zr.log(`Downloaded native session (${o.length} bytes) to ${s}`),await _c.mkdir(n,{recursive:!0}),await rs("unzip",["-o","-q",s,"-d",n]),zr.log(`Restored native session into ${n}`),!0}catch(i){return zr.error("Failed to fetch/restore native session, continuing without it:",i),!1}finally{await _c.rm(s,{force:!0}).catch(()=>{})}},xRt="native-sessions",tOe=(t,e)=>KCe({cacheDir:yc.join(e.dir,xRt),cwd:t}),rOe=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await tOe(r,e).restore(n.map(i=>yc.join(r,i)),{})?(zr.log(`Restored native session from buildbot cache into ${r}`),!0):(zr.log("No native session in buildbot cache, skipping restore"),!1)}catch(s){return zr.error("Failed to restore native session from buildbot cache, continuing without it:",s),!1}},UN=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await tOe(r,e).save(n.map(i=>yc.join(r,i)),{})?(zr.log(`Saved native session to buildbot cache under ${e.dir}`),!0):(zr.log("No native session history to save to buildbot cache, skipping"),!1)}catch(s){return zr.error("Failed to save native session to buildbot cache, continuing:",s),!1}};var qN=Se("inference_stage"),nOe=5,qd=async t=>{let{additionalContext:e,cliPath:r,config:n,context:s,buildErrors:i,runner:o,persistSteps:a,aiGateway:c,attempt:l,contextPrefix:u,priorAgentSessionId:f,cwd:d}=t;if(ts())throw new Error("Shutdown in progress, aborting inference stage");qN.log(`Running inference stage, attempt ${l} of ${nOe}`);let h=!1,p=await yt(et(),"inference-stage",async m=>{m?.setAttributes({"inference.attempt":l||1}),Hue();let g=!!(l&&l>1),y=await IRt(n,g);h=y.viable,y.outcome!=="not_eligible"&&xe.inc("inference.native_resume",1,{outcome:y.outcome,...y.source?{source:y.source}:{}});let{prompt:T}=await yt(et(),"compose-prompt",async()=>await Jve({cliPath:r,config:n,buildErrorContext:NRt(i),netlify:s,additionalContext:e,resumePrompt:y.viable})),S=`
|
|
748
748
|
${u||""}
|
|
749
749
|
${T}
|
|
750
750
|
`.trim(),_={...n,prompt:S},A=f??(y.viable?y.sessionId:void 0),P=await yt(et(),`run-${n.runner}`,async C=>{let R=QG();C?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":jTe(n.runner),"gen_ai.system":n.runner,...R?{"gen_ai.input.messages":Zx("user",S)}:{}});let O=Date.now(),w=await o({aiGateway:c,config:_,netlify:s,persistSteps:a,continueSession:g||y.viable,priorAgentSessionId:A,cwd:d}),b=Date.now(),D=w.resolvedModel||n.model||"unknown",I=w.error?"error":"stop";return C?.setAttributes({...R?{"gen_ai.output.messages":Zx("assistant",w.result??w.error??"",I)}:{},"gen_ai.response.finish_reasons":[I],"gen_ai.request.model":D,"gen_ai.response.model":D,...w.effort?{"gen_ai.request.effort":w.effort}:{},...w.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":w.usage.input_tokens}:{},...w.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":w.usage.output_tokens}:{},...w.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":w.usage.cache_creation_input_tokens}:{},...w.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":w.usage.cache_read_input_tokens}:{}}),HTe(w.steps??[],n.mode,O,b),w});return P.result&&(P.result=js(P.result)),P.error&&(P.error=js(P.error)),await a.flush(),P});if(p.error){if(ts()){let m=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(m,{agentSessionId:p.agentSessionId}),m}if(qN.error("Runner failed",{stepsCount:p.steps.length,duration:p.duration,error:p.error,isRetryableError:p.isRetryableError,attempt:l||1,agentSessionId:p.agentSessionId}),xe.inc("inference.failed",1,{attempt:l||1,is_retryable:!!p.isRetryableError,is_provider_unavailable:!!p.isProviderUnavailableError}),p.isRetryableError&&(!l||l<nOe))return qN.log("Retrying inference stage"),await new Promise(g=>setTimeout(g,5e3)),{runnerResult:(await qd({...t,attempt:(l||1)+1,priorAgentSessionId:p.agentSessionId,contextPrefix:p.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:h};{if(qN.log("Do not retry inference stage"),p.error.toLowerCase().includes("usage exceeded"))throw new ii(p.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);let m=p.isRetryableError||p.isProviderUnavailableError?new vu(p.error):new Error(p.error);throw Object.assign(m,{agentSessionId:p.agentSessionId}),m}}return{runnerResult:p,nativeResume:h}},IRt=async(t,e)=>{if(e)return{viable:!1,outcome:"not_eligible"};let r=t.previousSession,{viable:n,outcome:s}=Xve(t);if(!n)return{viable:n,outcome:s};let i=r?.nativeSessionId,o=Zg(t.runner),a=async()=>i?t.runner==="gemini"?!!await Vz(i):ZCe(o,i):!1,c;if(sOe(t)&&await XCe(o))c="local";else if(t.fastInit&&Gt().warmNativeResumeEnabled&&await rOe({archive:o,cache:t.cache})&&await a())c="cache_restore";else{if(c="fetch",!Gt().coldResumeFromS3Enabled)return{viable:!1,outcome:"cold_resume_disabled",source:c};if(!await eOe({runnerId:t.id,sessionId:t.sessionId,archive:o}))return{viable:!1,outcome:"fetch_failed",source:c}}return t.runner==="gemini"&&i&&!await DI(i)?{viable:!1,outcome:"sanitize_failed",source:c}:{viable:!0,sessionId:i,outcome:"resumed",source:c}},NRt=t=>!t||t.length===0?"":`
|