@netlify/agent-runner-cli 1.169.0 → 1.169.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +3 -3
- package/dist/bin.js +3 -3
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -139,7 +139,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
139
139
|
`,LF:`
|
|
140
140
|
`,concatBytes:ZF},LVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},UVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:LVe};import{Buffer as FVe}from"buffer";var kce=(t,e)=>t?void 0:zVe.bind(void 0,e),zVe=function*(t,e){if(typeof e!="string"&&!yr(e)&&!FVe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Mce=(t,e)=>t?jVe.bind(void 0,e):BVe.bind(void 0,e),jVe=function*(t,e){$ce(t,e),yield e},BVe=function*(t,e){if($ce(t,e),typeof e!="string"&&!yr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},$ce=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
141
141
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
142
|
-
if (condition) { yield value; }`)};import{Buffer as qVe}from"buffer";import{StringDecoder as VVe}from"string_decoder";var D0=(t,e,r)=>{if(r)return;if(t)return{transform:GVe.bind(void 0,new TextEncoder)};let n=new VVe(e);return{transform:HVe.bind(void 0,n),final:WVe.bind(void 0,n)}},GVe=function*(t,e){qVe.isBuffer(e)?yield Pa(e):typeof e=="string"?yield t.encode(e):yield e},HVe=function*(t,e){yield yr(e)?t.write(e):e},WVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Dce}from"util";var XF=Dce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),L0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=KVe}=e[r];for await(let i of n(t))yield*L0(i,e,r+1)},Lce=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*YVe(r,Number(e),t)},YVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*L0(n,r,e+1)},Uce=Dce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),KVe=function*(t){yield t};var QF=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Fce=(t,e)=>[...e.flatMap(r=>[...ad(r,t,0)]),...VS(t)],ad=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=JVe}=e[r];for(let i of n(t))yield*ad(i,e,r+1)},VS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ZVe(r,Number(e),t)},ZVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*ad(n,r,e+1)},JVe=function*(t){yield t};var ez=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=jce(t,s,o),l=sd(e),u=sd(r),d=l?XF.bind(void 0,L0,a):QF.bind(void 0,ad),f=l||u?XF.bind(void 0,Lce,a):QF.bind(void 0,VS),p=l||u?Uce.bind(void 0,a):void 0;return{stream:new XVe({writableObjectMode:n,writableHighWaterMark:zce(n),readableObjectMode:i,readableHighWaterMark:zce(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},U0=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=jce(s,r,a);t=Fce(c,t)}return t},jce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:kce(n,a)},D0(r,s,n),$0(r,o,n,c),{transform:t,final:e},{transform:Mce(i,a)},Nce({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Bce=(t,e)=>{for(let r of QVe(t))eGe(t,r,e)},QVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),eGe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Xc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>tGe(a,n));r.input=MS(s)},tGe=(t,e)=>{let r=U0(t,e,"utf8",!0);return rGe(r),MS(r)},rGe=t=>{let e=t.find(r=>typeof r!="string"&&!yr(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 sGe,appendFileSync as aGe}from"fs";var F0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Jp(r,n)&&!gi.has(e)&&nGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&iGe.has(o))||t.every(({type:i})=>Gi.has(i))),nGe=t=>t===1||t===2,iGe=new Set(["pipe","overlapped"]),qce=async(t,e,r,n)=>{for await(let i of t)oGe(e)||Gce(i,r,n)},Vce=(t,e,r)=>{for(let n of t)Gce(n,e,r)},oGe=t=>t._readableState.pipes.length>0,Gce=(t,e,r)=>{let n=QR(t);Ss({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Hce=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>cGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},cGe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Wae(t,o,d),p=Pa(f),{stdioItems:h,objectMode:m}=e[r],g=lGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=uGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});dGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?b:void 0;try{return n.error===void 0&&fGe(_,h,i),T}catch(v){return n.error=v,T}},lGe=(t,e,r,n)=>{try{return U0(t,e,r,!1)}catch(i){return n.error=i,t}},uGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:MS(t)};let s=aoe(t,r);return n[o]?{serializedResult:s,finalResult:JF(s,!i[o],e)}:{serializedResult:s}},dGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!F0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=JF(t,!1,s);try{Vce(a,e,n)}catch(c){r.error??=c}},fGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>k0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?aGe(n,t):(r.add(o),sGe(n,t))}};var Wce=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Na(e,r,"all")]:Array.isArray(e)?[Na(t,r,"all"),...e]:yr(t)&&yr(e)?sF([t,e]):`${t}${e}`};import{once as tz}from"events";var Yce=async(t,e)=>{let[r,n]=await pGe(t);return e.isForcefullyTerminated??=!1,[r,n]},pGe=async t=>{let[e,r]=await Promise.allSettled([tz(t,"spawn"),tz(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Kce(t):r.value},Kce=async t=>{try{return await tz(t,"exit")}catch{return Kce(t)}},Zce=async t=>{let[e,r]=await t;if(!hGe(e,r)&&rz(e,r))throw new Io;return[e,r]},hGe=(t,e)=>t===void 0&&e===void 0,rz=(t,e)=>t!==0||e!==null;var Jce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=mGe(t,e,r),s=o?.code==="ETIMEDOUT",a=Hae(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},mGe=(t,e,r)=>t!==void 0?t:rz(e,r)?new Io:void 0;var Xce=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=_Ge(t,e,r),d=EGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return ah(d,c,l)},_Ge=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=t0(t,e,r),a=yGe(r),{file:c,commandArguments:l,options:u}=v0(t,e,a);SGe(u);let d=Cce(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},yGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,SGe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&z0("ipcInput"),t&&z0("ipc: true"),r&&z0("detached: true"),n&&z0("cancelSignal")},z0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},EGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=vGe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Jce(c,r),{output:h,error:m=l}=Hce({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>Na(b,r,T)),_=Na(Wce(h,r),r,"all");return TGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},vGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Bce(o,r);let a=bGe(r);return gGe(...b0(t,e,a))}catch(a){return sh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},bGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:P0(e)}),TGe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?I0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):qS({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as u6e}from"events";import{spawn as d6e}from"child_process";import nle from"process";import{once as nz,on as wGe}from"events";var Qce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(eh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:m0(t)}),xGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),xGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{d0(e,i);let o=Jc(t,e,r),s=new AbortController;try{return await Promise.race([AGe(o,n,s),RGe(o,r,s),CGe(o,r,s)])}catch(a){throw th(t),a}finally{s.abort(),f0(e,i)}},AGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await nz(t,"message",{signal:r});return n}for await(let[n]of wGe(t,"message",{signal:r}))if(e(n))return n},RGe=async(t,e,{signal:r})=>{await nz(t,"disconnect",{signal:r}),Fse(e)},CGe=async(t,e,{signal:r})=>{let[n]=await nz(t,"strict:error",{signal:r});throw c0(n,e)};import{once as tle,on as PGe}from"events";var rle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>iz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),iz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{eh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:m0(t)}),d0(e,o);let s=Jc(t,e,r),a=new AbortController,c={};return IGe(t,s,a),OGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),NGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},IGe=async(t,e,r)=>{try{await tle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},OGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await tle(t,"strict:error",{signal:r.signal});n.error=c0(i,e),r.abort()}catch{}},NGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of PGe(r,"message",{signal:o.signal}))ele(s),yield c}catch{ele(s)}finally{o.abort(),f0(e,a),n||th(t),i&&await t}},ele=({error:t})=>{if(t)throw t};var ile=(t,{ipc:e})=>{Object.assign(t,sle(t,!1,e))},ole=()=>{let t=nle,e=!0,r=nle.channel!==void 0;return{...sle(t,e,r),getCancelSignal:fae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},sle=(t,e,r)=>({sendMessage:S0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Qce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:rle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as kGe}from"child_process";import{PassThrough as MGe,Readable as $Ge,Writable as DGe,Duplex as LGe}from"stream";var ale=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{YF(n);let a=new kGe;UGe(a,n),Object.assign(a,{readable:FGe,writable:zGe,duplex:jGe});let c=sh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=BGe(c,s,i);return{subprocess:a,promise:l}},UGe=(t,e)=>{let r=GS(),n=GS(),i=GS(),o=Array.from({length:e.length-3},GS),s=GS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},GS=()=>{let t=new MGe;return t.end(),t},FGe=()=>new $Ge({read(){}}),zGe=()=>new DGe({write(){}}),jGe=()=>new LGe({read(){},write(){}}),BGe=async(t,e,r)=>ah(t,e,r);import{createReadStream as cle,createWriteStream as lle}from"fs";import{Buffer as qGe}from"buffer";import{Readable as HS,Writable as VGe,Duplex as GGe}from"stream";var dle=(t,e)=>M0(HGe,t,e,!1),WS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Xc[t]}.`)},ule={fileNumber:WS,generator:ez,asyncGenerator:ez,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:GGe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},HGe={input:{...ule,fileUrl:({value:t})=>({stream:cle(t)}),filePath:({value:{file:t}})=>({stream:cle(t)}),webStream:({value:t})=>({stream:HS.fromWeb(t)}),iterable:({value:t})=>({stream:HS.from(t)}),asyncIterable:({value:t})=>({stream:HS.from(t)}),string:({value:t})=>({stream:HS.from(t)}),uint8Array:({value:t})=>({stream:HS.from(qGe.from(t))})},output:{...ule,fileUrl:({value:t})=>({stream:lle(t)}),filePath:({value:{file:t,append:e}})=>({stream:lle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:VGe.fromWeb(t)}),iterable:WS,asyncIterable:WS,string:WS,uint8Array:WS}};import{on as WGe,once as fle}from"events";import{PassThrough as YGe,getDefaultHighWaterMark as KGe}from"stream";import{finished as mle}from"stream/promises";function cd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)sz(i);let e=t.some(({readableObjectMode:i})=>i),r=ZGe(t,e),n=new oz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var ZGe=(t,e)=>{if(t.length===0)return KGe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},oz=class extends YGe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(sz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=JGe(this,this.#e,this.#o);let r=eHe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(sz(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},JGe=async(t,e,r)=>{j0(t,ple);let n=new AbortController;try{await Promise.race([XGe(t,n),QGe(t,e,r,n)])}finally{n.abort(),j0(t,-ple)}},XGe=async(t,{signal:e})=>{try{await mle(t,{signal:e,cleanup:!0})}catch(r){throw gle(t,r),r}},QGe=async(t,e,r,{signal:n})=>{for await(let[i]of WGe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},sz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},eHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{j0(t,hle);let a=new AbortController;try{await Promise.race([tHe(o,e,a),rHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),nHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),j0(t,-hle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?az(t):iHe(t))},tHe=async(t,e,{signal:r})=>{try{await t,r.aborted||az(e)}catch(n){r.aborted||gle(e,n)}},rHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await mle(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;_le(s)?i.add(e):yle(t,s)}},nHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await fle(t,i,{signal:o}),!t.readable)return fle(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},iHe=t=>{t.writable&&t.end()},gle=(t,e)=>{_le(e)?az(t):yle(t,e)},_le=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",az=t=>{(t.readable||t.writable)&&t.destroy()},yle=(t,e)=>{t.destroyed||(t.once("error",oHe),t.destroy(e))},oHe=()=>{},j0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ple=2,hle=1;import{finished as Sle}from"stream/promises";var lh=(t,e)=>{t.pipe(e),sHe(t,e),aHe(t,e)},sHe=async(t,e)=>{if(!(Po(t)||Po(e))){try{await Sle(t,{cleanup:!0,readable:!0,writable:!1})}catch{}cz(e)}},cz=t=>{t.writable&&t.end()},aHe=async(t,e)=>{if(!(Po(t)||Po(e))){try{await Sle(e,{cleanup:!0,readable:!1,writable:!0})}catch{}lz(t)}},lz=t=>{t.readable&&t.destroy()};var Ele=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Gi.has(c)))cHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Gi.has(c)))uHe({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:cd(o);lh(s,i)}},cHe=(t,e,r,n)=>{r==="output"?lh(t.stdio[n],e):lh(e,t.stdio[n]);let i=lHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},lHe=["stdin","stdout","stderr"],uHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;dHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},dHe=(t,{signal:e})=>{Po(t)&&id(t,fHe,e)},fHe=2;import{addAbortListener as mHe}from"events";var ld=[];ld.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ld.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ld.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var B0=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",uz=Symbol.for("signal-exit emitter"),dz=globalThis,pHe=Object.defineProperty.bind(Object),fz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(dz[uz])return dz[uz];pHe(dz,uz,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},q0=class{},hHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),pz=class extends q0{onExit(){return()=>{}}load(){}unload(){}},hz=class extends q0{#e=mz.platform==="win32"?"SIGINT":"SIGHUP";#r=new fz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ld)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!B0(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of ld)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,ld.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return B0(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&B0(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},mz=globalThis.process,{onExit:vle,load:X1t,unload:Q1t}=hHe(B0(mz)?new hz(mz):new pz);var ble=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=vle(()=>{t.kill()});mHe(n,()=>{i()})};var wle=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=e0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=gHe(r,n,i),{sourceStream:d,sourceError:f}=yHe(t,l),{options:p,fileDescriptors:h}=vs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},gHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=_He(t,e,...r),a=u0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},_He=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Tle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||iF(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=VR(r,...n);return{destination:e(Tle)(i,o,s),pipeOptions:s}}if(vs.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}`)},Tle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),yHe=(t,e)=>{try{return{sourceStream:rh(t,e)}}catch(r){return{sourceError:r}}};var Ale=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=SHe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw gz({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},SHe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return lz(t),n;if(e!==void 0)return cz(r),e},gz=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>sh({error:t,command:xle,escapedCommand:xle,fileDescriptors:e,options:r,startTime:n,isSync:!1}),xle="source.pipe(destination)";var Rle=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as EHe}from"stream/promises";var Cle=(t,e,r)=>{let n=V0.has(e)?bHe(t,e):vHe(t,e);return id(t,wHe,r.signal),id(e,xHe,r.signal),THe(e),n},vHe=(t,e)=>{let r=cd([t]);return lh(r,e),V0.set(e,r),r},bHe=(t,e)=>{let r=V0.get(e);return r.add(t),r},THe=async t=>{try{await EHe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}V0.delete(t)},V0=new WeakMap,wHe=2,xHe=1;import{aborted as AHe}from"util";var Ple=(t,e)=>t===void 0?[]:[RHe(t,e)],RHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await AHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw gz({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var G0=(t,...e)=>{if(or(e[0]))return G0.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=wle(t,...e),i=CHe({...n,destination:r});return i.pipe=G0.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},CHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=PHe(t,i);Ale({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Cle(e,o,d);return await Promise.race([Rle(u),...Ple(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},PHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as DHe}from"timers/promises";import{on as IHe}from"events";import{getDefaultHighWaterMark as OHe}from"stream";var H0=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return NHe(e,s),Ole({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},NHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},_z=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;kHe(e,s,t);let a=t.readableObjectMode&&!o;return Ole({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},kHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Ole=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=IHe(t,"data",{signal:e.signal,highWaterMark:Ile,highWatermark:Ile});return MHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},yz=OHe(!0),Ile=yz,MHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=$He({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*ad(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*VS(a)}},$He=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[D0(t,r,!e),$0(t,i,!n,{})].filter(Boolean);var Nle=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=LHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([UHe(t),d]);return}let f=KF(c,r),p=_z({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([FHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},LHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!F0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=_z({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await qce(a,t,r,o)},UHe=async t=>{await DHe(),t.readableFlowing===null&&t.resume()},FHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await A0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await R0(r,{maxBuffer:o})):await oh(r,{maxBuffer:o})}catch(a){return kle(qae({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},Sz=async t=>{try{return await t}catch(e){return kle(e)}},kle=({bufferedData:t})=>ooe(t)?new Uint8Array(t):t;import{finished as zHe}from"stream/promises";var YS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=jHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],zHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||VHe(a,e,r,n)}finally{s.abort()}},jHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&BHe(t,r,n),n},BHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qHe(e,r),n.call(t,...i)}},qHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},VHe=(t,e,r,n)=>{if(!GHe(t,e,r,n))throw t},GHe=(t,e,r,n=!0)=>r.propagating?Mle(t)||W0(t):(r.propagating=!0,Ez(r,e)===n?Mle(t):W0(t)),Ez=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",W0=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Mle=t=>t?.code==="EPIPE";var $le=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>vz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),vz=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=YS(t,e,l);if(Ez(l,e)){await u;return}let[d]=await Promise.all([Nle({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Dle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?cd([t,e].filter(Boolean)):void 0,Lle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>vz({...HHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:WHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),HHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},WHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as YHe}from"events";var Ule=t=>Jp(t,"ipc"),Fle=(t,e)=>{let r=QR(t);Ss({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var zle=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ule(o),a=Ia(e,"ipc"),c=Ia(r,"ipc");for await(let l of iz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Vae(t,i,c),i.push(l)),s&&Fle(l,o);return i},jle=async(t,e)=>(await Promise.allSettled([t]),e);var Ble=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let b=Yce(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=$le({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=Lle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),I=[],N=zle({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),O=KHe(m,t,T),$=ZHe(h,T);try{return await Promise.race([Promise.all([{},Zce(b),Promise.all(v),x,N,bae(t,d),...O,...$]),g,JHe(t,_),..._ae(t,o,f,_),...Use({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...mae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(z){return f.terminationReason??="other",Promise.all([{error:z},b,Promise.all(v.map(E=>Sz(E))),Sz(x),jle(N,I),Promise.allSettled(O),Promise.allSettled($)])}},KHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:YS(n,i,r)),ZHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>No(o,{checkOpen:!1})&&!Po(o)).map(({type:i,value:o,stream:s=o})=>YS(s,n,e,{isSameDirection:Gi.has(i),stopOnExit:i==="native"}))),JHe=async(t,{signal:e})=>{let[r]=await YHe(t,"error",{signal:e});throw r};var qle=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),KS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Es();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},uh=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 XHe}from"stream";import{callbackify as QHe}from"util";import{finished as Vle}from"stream/promises";var bz=async t=>{if(t!==void 0)try{await Tz(t)}catch{}},Gle=async t=>{if(t!==void 0)try{await wz(t)}catch{}},Tz=async t=>{await Vle(t,{cleanup:!0,readable:!1,writable:!0})},wz=async t=>{await Vle(t,{cleanup:!0,readable:!0,writable:!1})},Y0=async(t,e)=>{if(await t,e)throw e},K0=(t,e,r)=>{r&&!W0(r)?t.destroy(r):e&&t.destroy()};var Hle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||gi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=xz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Az(a,s),{read:f,onStdoutDataDone:p}=Rz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new XHe({read:f,destroy:QHe(Pz.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Cz({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},xz=(t,e,r)=>{let n=rh(t,e),i=KS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Az=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:yz},Rz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Es(),s=H0({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){e6e(this,s,o)},onStdoutDataDone:o}},e6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Cz=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await wz(t),await n,await bz(i),await e,r.readable&&r.push(null)}catch(o){await bz(i),Wle(r,o)}},Pz=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await uh(r,e)&&(Wle(t,n),await Y0(e,n))},Wle=(t,e)=>{K0(t,t.readable,e)};import{Writable as t6e}from"stream";import{callbackify as Yle}from"util";var Kle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Iz(t,r,e),s=new t6e({...Oz(n,t,i),destroy:Yle(kz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Nz(n,s),s},Iz=(t,e,r)=>{let n=u0(t,e),i=KS(r,n,"writableFinal"),o=KS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Oz=(t,e,r)=>({write:r6e.bind(void 0,t),final:Yle(n6e.bind(void 0,t,e,r))}),r6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},n6e=async(t,e,r)=>{await uh(r,e)&&(t.writable&&t.end(),await e)},Nz=async(t,e,r)=>{try{await Tz(t),e.writable&&e.end()}catch(n){await Gle(r),Zle(e,n)}},kz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await uh(r,e),await uh(n,e)&&(Zle(t,i),await Y0(e,i))},Zle=(t,e)=>{K0(t,t.writable,e)};import{Duplex as i6e}from"stream";import{callbackify as o6e}from"util";var Jle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||gi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=xz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Iz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Az(c,a),{read:g,onStdoutDataDone:_}=Rz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new i6e({read:g,...Oz(u,t,d),destroy:o6e(s6e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return Cz({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),Nz(u,b,c),b},s6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([Pz({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),kz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Mz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||gi.has(e),s=rh(t,r),a=H0({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return a6e(a,s,t)},a6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Xle=(t,{encoding:e})=>{let r=qle();t.readable=Hle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Kle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Jle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Mz.bind(void 0,t,e),t[Symbol.asyncIterator]=Mz.bind(void 0,t,e,{})};var Qle=(t,e)=>{for(let[r,n]of l6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},c6e=(async()=>{})().constructor.prototype,l6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(c6e,t)]);var eue=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=f6e(t,e,r),{subprocess:f,promise:p}=h6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=G0.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Qle(f,p),vs.set(f,{options:u,fileDescriptors:d}),f},f6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=t0(t,e,r),{file:a,commandArguments:c,options:l}=v0(t,e,r),u=p6e(l),d=dle(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},p6e=({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}},h6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=d6e(...b0(t,e,r))}catch(h){return ale({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;u6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ele(c,a,l),ble(c,r,l);let d={},f=Es();c.kill=Dse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Dle(c,r),Xle(c,r),ile(c,r);let p=m6e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},m6e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Ble({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((v,x)=>Na(v,e,x)),b=Na(m,e,"all"),T=g6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return ah(T,n,e)},g6e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?qS({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof bs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):I0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Z0=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,_6e(n,t[n],i)]));return{...t,...r}},_6e=(t,e,r)=>y6e.has(t)&&or(e)&&or(r)?{...e,...r}:r,y6e=new Set(["env",...uF]);var Qc=(t,e,r,n)=>{let i=(s,a,c)=>Qc(s,a,r,c),o=(...s)=>S6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},S6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(or(o))return i(t,Z0(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=E6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Xce(a,c,l):eue(a,c,l,i)},E6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=doe(e)?foe(e,r):[e,...r],[s,a,c]=VR(...o),l=Z0(Z0(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var tue=({file:t,commandArguments:e})=>nue(t,e),rue=({file:t,commandArguments:e})=>({...nue(t,e),isSync:!0}),nue=(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]=v6e(t);return{file:r,commandArguments:n}},v6e=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(b6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},b6e=/ +/g;var iue=(t,e,r)=>{t.sync=e(T6e,r),t.s=t.sync},oue=({options:t})=>sue(t),T6e=({options:t})=>({...sue(t),isSync:!0}),sue=t=>({options:{...w6e(t),...t}}),w6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},aue={preferLocal:!0};var cue=Qc(()=>({})),Bzt=Qc(()=>({isSync:!0})),lue=Qc(tue),qzt=Qc(rue),Vzt=Qc(Sae),Gzt=Qc(oue,{},aue,iue),{sendMessage:Hzt,getOneMessage:Wzt,getEachMessage:Yzt,getCancelSignal:Kzt}=ole();var uue=!1,due=()=>{uue=!0},ws=()=>uue;var ZS=null,fue=t=>(ZS&&ZS.destroy(),ZS=new ko({totalAllowedTime:t}),ZS),pue=()=>ZS;var ko=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&ws())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await $R({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{re.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var hue={name:"@netlify/agent-runner-cli",type:"module",version:"1.169.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var C6e=A6e(import.meta.url),P6e=ka.dirname(C6e),I6e=R6e(import.meta.url),dh=ce("shell"),$z=new Set,mue={preferLocal:!0},Wr=(t,e,r)=>{let[n,i]=O6e(e,r),o={...mue,...i},s=cue(t,n,o);_ue(s,o),Eue(s);let a=r?.idleTimeout;return a&&a>0&&Sue(s,a),s},gue=(t,e)=>{let r={...mue,...e},n=lue(t,r);return _ue(n,r),Eue(n),e?.idleTimeout&&e.idleTimeout>0&&Sue(n,e.idleTimeout),n},O6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},_ue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||xs.env.NETLIFY_LOCAL_QUIET==="true")return;if(xs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new xS).pipe(xs.stdout),t.stderr?.pipe(new xS).pipe(xs.stderr);return}t.stdout?.pipe(xs.stdout),t.stderr?.pipe(xs.stderr)},Dz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(xs.kill(-t.pid,e),dh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return dh.error("Error killing process:",r),!1}},yue=t=>Dz(t,"SIGKILL"),Sue=(t,e)=>{let r=null,n=()=>{dh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Dz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dh.log(`Force killing idle process ${t.pid}`),yue(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Eue=t=>{$z.add(t);let e=pue();if(e){let r=e.onTimesUp(()=>{dh.log(`Global timer expired, killing process ${t.pid}`),Dz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dh.log(`Force killing process ${t.pid} after timeout`),yue(t))},5e3)});t.on("exit",()=>{$z.delete(t),r()}),t.on("error",()=>{$z.delete(t),r()})}};function As(t,e){if(!xs.env.NETLIFY_LOCAL_MODE)try{let i=I6e.resolve(hue.name),o=ka.dirname(i);for(;o!==ka.dirname(o);){let s=ka.dirname(o);if(ka.basename(s)==="node_modules"){let a=ka.join(s,".bin",e);if(J0.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(xs.env.NODE_PATH){let i=ka.join(xs.env.NODE_PATH,".bin",e);if(J0.existsSync(i))return i}let r=ka.join(t,"node_modules",".bin",e);if(J0.existsSync(r))return r;let n=ka.join(P6e,"..","node_modules",".bin",e);if(J0.existsSync(n))return n}var N6e=ce("utils"),k6e=t=>new Promise(e=>{setTimeout(e,t)});var Lz=t=>{try{return new URL(t).hostname||null}catch{return null}},X0=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await k6e(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},el=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},vue=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):N6e.error("Could not parse JSON",n))}},M6e=t=>t.charAt(0).toUpperCase()+t.slice(1),Rs=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():M6e(e)).join(" ");function Ma(t,e){e&&t.log(`Skill invoked: ${e}`)}var Q0=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),bue=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var Uz=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},$6e=1e4,Fz=(t,e=$6e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{createHash as D6e}from"crypto";import{createReadStream as L6e}from"fs";import eC from"fs/promises";import Rue from"os";import tC from"path";var Tue=ce("repo"),Cue="runner-diffs-",Pue=t=>`${Cue}${t}-`,Iue=async t=>{let e=Rue.tmpdir(),r;try{r=await eC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Cue)&&!n.startsWith(Pue(t))).map(n=>eC.rm(tC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Kn=(t,e={})=>Wr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),rC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Tue.info("Getting runner diffs");let n=await F6e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=j6e(o);await B6e(h,r)}Tue.info("Changes after processing"),await jz(r);let s=await qz(o,r);if(await zz(s,r),i=await z6e(r),!i)return{hasChanges:!1,ignored:s};await Kn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await eC.mkdtemp(tC.join(Rue.tmpdir(),Pue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=tC.join(a,g);await Kn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:v}=await eC.stat(b);return{path:b,size:v}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Aue(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await xue(d,h)||(f=h)}await Aue(r),re.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await xue(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},wue=async t=>{let e=D6e("sha256");for await(let r of L6e(t))e.update(r);return e.digest("hex")},xue=async(t,e)=>t.size===e.size&&await wue(t.path)===await wue(e.path),Aue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Kn(["reset","--soft","HEAD~1"],{cwd:t})},zz=async(t=[],e=process.cwd())=>{await Kn(["add",".",...t],{cwd:e})},jz=async(t=process.cwd())=>{let e=await Kn(["status","-s"],{cwd:t});return String(e.stdout??"")},Oue=/.. (.+)?\.log$/,U6e=[Oue],F6e=async(t=process.cwd())=>{let e=await jz(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
142
|
+
if (condition) { yield value; }`)};import{Buffer as qVe}from"buffer";import{StringDecoder as VVe}from"string_decoder";var D0=(t,e,r)=>{if(r)return;if(t)return{transform:GVe.bind(void 0,new TextEncoder)};let n=new VVe(e);return{transform:HVe.bind(void 0,n),final:WVe.bind(void 0,n)}},GVe=function*(t,e){qVe.isBuffer(e)?yield Pa(e):typeof e=="string"?yield t.encode(e):yield e},HVe=function*(t,e){yield yr(e)?t.write(e):e},WVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Dce}from"util";var XF=Dce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),L0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=KVe}=e[r];for await(let i of n(t))yield*L0(i,e,r+1)},Lce=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*YVe(r,Number(e),t)},YVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*L0(n,r,e+1)},Uce=Dce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),KVe=function*(t){yield t};var QF=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Fce=(t,e)=>[...e.flatMap(r=>[...ad(r,t,0)]),...VS(t)],ad=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=JVe}=e[r];for(let i of n(t))yield*ad(i,e,r+1)},VS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ZVe(r,Number(e),t)},ZVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*ad(n,r,e+1)},JVe=function*(t){yield t};var ez=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=jce(t,s,o),l=sd(e),u=sd(r),d=l?XF.bind(void 0,L0,a):QF.bind(void 0,ad),f=l||u?XF.bind(void 0,Lce,a):QF.bind(void 0,VS),p=l||u?Uce.bind(void 0,a):void 0;return{stream:new XVe({writableObjectMode:n,writableHighWaterMark:zce(n),readableObjectMode:i,readableHighWaterMark:zce(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},U0=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=jce(s,r,a);t=Fce(c,t)}return t},jce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:kce(n,a)},D0(r,s,n),$0(r,o,n,c),{transform:t,final:e},{transform:Mce(i,a)},Nce({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Bce=(t,e)=>{for(let r of QVe(t))eGe(t,r,e)},QVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),eGe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Xc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>tGe(a,n));r.input=MS(s)},tGe=(t,e)=>{let r=U0(t,e,"utf8",!0);return rGe(r),MS(r)},rGe=t=>{let e=t.find(r=>typeof r!="string"&&!yr(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 sGe,appendFileSync as aGe}from"fs";var F0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Jp(r,n)&&!gi.has(e)&&nGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&iGe.has(o))||t.every(({type:i})=>Gi.has(i))),nGe=t=>t===1||t===2,iGe=new Set(["pipe","overlapped"]),qce=async(t,e,r,n)=>{for await(let i of t)oGe(e)||Gce(i,r,n)},Vce=(t,e,r)=>{for(let n of t)Gce(n,e,r)},oGe=t=>t._readableState.pipes.length>0,Gce=(t,e,r)=>{let n=QR(t);Ss({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Hce=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>cGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},cGe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Wae(t,o,d),p=Pa(f),{stdioItems:h,objectMode:m}=e[r],g=lGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=uGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});dGe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?b:void 0;try{return n.error===void 0&&fGe(_,h,i),T}catch(v){return n.error=v,T}},lGe=(t,e,r,n)=>{try{return U0(t,e,r,!1)}catch(i){return n.error=i,t}},uGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:MS(t)};let s=aoe(t,r);return n[o]?{serializedResult:s,finalResult:JF(s,!i[o],e)}:{serializedResult:s}},dGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!F0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=JF(t,!1,s);try{Vce(a,e,n)}catch(c){r.error??=c}},fGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>k0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?aGe(n,t):(r.add(o),sGe(n,t))}};var Wce=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Na(e,r,"all")]:Array.isArray(e)?[Na(t,r,"all"),...e]:yr(t)&&yr(e)?sF([t,e]):`${t}${e}`};import{once as tz}from"events";var Yce=async(t,e)=>{let[r,n]=await pGe(t);return e.isForcefullyTerminated??=!1,[r,n]},pGe=async t=>{let[e,r]=await Promise.allSettled([tz(t,"spawn"),tz(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Kce(t):r.value},Kce=async t=>{try{return await tz(t,"exit")}catch{return Kce(t)}},Zce=async t=>{let[e,r]=await t;if(!hGe(e,r)&&rz(e,r))throw new Io;return[e,r]},hGe=(t,e)=>t===void 0&&e===void 0,rz=(t,e)=>t!==0||e!==null;var Jce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=mGe(t,e,r),s=o?.code==="ETIMEDOUT",a=Hae(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},mGe=(t,e,r)=>t!==void 0?t:rz(e,r)?new Io:void 0;var Xce=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=_Ge(t,e,r),d=EGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return ah(d,c,l)},_Ge=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=t0(t,e,r),a=yGe(r),{file:c,commandArguments:l,options:u}=v0(t,e,a);SGe(u);let d=Cce(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},yGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,SGe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&z0("ipcInput"),t&&z0("ipc: true"),r&&z0("detached: true"),n&&z0("cancelSignal")},z0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},EGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=vGe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Jce(c,r),{output:h,error:m=l}=Hce({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>Na(b,r,T)),_=Na(Wce(h,r),r,"all");return TGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},vGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Bce(o,r);let a=bGe(r);return gGe(...b0(t,e,a))}catch(a){return sh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},bGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:P0(e)}),TGe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?I0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):qS({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as u6e}from"events";import{spawn as d6e}from"child_process";import nle from"process";import{once as nz,on as wGe}from"events";var Qce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(eh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:m0(t)}),xGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),xGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{d0(e,i);let o=Jc(t,e,r),s=new AbortController;try{return await Promise.race([AGe(o,n,s),RGe(o,r,s),CGe(o,r,s)])}catch(a){throw th(t),a}finally{s.abort(),f0(e,i)}},AGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await nz(t,"message",{signal:r});return n}for await(let[n]of wGe(t,"message",{signal:r}))if(e(n))return n},RGe=async(t,e,{signal:r})=>{await nz(t,"disconnect",{signal:r}),Fse(e)},CGe=async(t,e,{signal:r})=>{let[n]=await nz(t,"strict:error",{signal:r});throw c0(n,e)};import{once as tle,on as PGe}from"events";var rle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>iz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),iz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{eh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:m0(t)}),d0(e,o);let s=Jc(t,e,r),a=new AbortController,c={};return IGe(t,s,a),OGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),NGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},IGe=async(t,e,r)=>{try{await tle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},OGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await tle(t,"strict:error",{signal:r.signal});n.error=c0(i,e),r.abort()}catch{}},NGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of PGe(r,"message",{signal:o.signal}))ele(s),yield c}catch{ele(s)}finally{o.abort(),f0(e,a),n||th(t),i&&await t}},ele=({error:t})=>{if(t)throw t};var ile=(t,{ipc:e})=>{Object.assign(t,sle(t,!1,e))},ole=()=>{let t=nle,e=!0,r=nle.channel!==void 0;return{...sle(t,e,r),getCancelSignal:fae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},sle=(t,e,r)=>({sendMessage:S0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Qce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:rle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as kGe}from"child_process";import{PassThrough as MGe,Readable as $Ge,Writable as DGe,Duplex as LGe}from"stream";var ale=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{YF(n);let a=new kGe;UGe(a,n),Object.assign(a,{readable:FGe,writable:zGe,duplex:jGe});let c=sh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=BGe(c,s,i);return{subprocess:a,promise:l}},UGe=(t,e)=>{let r=GS(),n=GS(),i=GS(),o=Array.from({length:e.length-3},GS),s=GS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},GS=()=>{let t=new MGe;return t.end(),t},FGe=()=>new $Ge({read(){}}),zGe=()=>new DGe({write(){}}),jGe=()=>new LGe({read(){},write(){}}),BGe=async(t,e,r)=>ah(t,e,r);import{createReadStream as cle,createWriteStream as lle}from"fs";import{Buffer as qGe}from"buffer";import{Readable as HS,Writable as VGe,Duplex as GGe}from"stream";var dle=(t,e)=>M0(HGe,t,e,!1),WS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Xc[t]}.`)},ule={fileNumber:WS,generator:ez,asyncGenerator:ez,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:GGe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},HGe={input:{...ule,fileUrl:({value:t})=>({stream:cle(t)}),filePath:({value:{file:t}})=>({stream:cle(t)}),webStream:({value:t})=>({stream:HS.fromWeb(t)}),iterable:({value:t})=>({stream:HS.from(t)}),asyncIterable:({value:t})=>({stream:HS.from(t)}),string:({value:t})=>({stream:HS.from(t)}),uint8Array:({value:t})=>({stream:HS.from(qGe.from(t))})},output:{...ule,fileUrl:({value:t})=>({stream:lle(t)}),filePath:({value:{file:t,append:e}})=>({stream:lle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:VGe.fromWeb(t)}),iterable:WS,asyncIterable:WS,string:WS,uint8Array:WS}};import{on as WGe,once as fle}from"events";import{PassThrough as YGe,getDefaultHighWaterMark as KGe}from"stream";import{finished as mle}from"stream/promises";function cd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)sz(i);let e=t.some(({readableObjectMode:i})=>i),r=ZGe(t,e),n=new oz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var ZGe=(t,e)=>{if(t.length===0)return KGe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},oz=class extends YGe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(sz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=JGe(this,this.#e,this.#o);let r=eHe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(sz(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},JGe=async(t,e,r)=>{j0(t,ple);let n=new AbortController;try{await Promise.race([XGe(t,n),QGe(t,e,r,n)])}finally{n.abort(),j0(t,-ple)}},XGe=async(t,{signal:e})=>{try{await mle(t,{signal:e,cleanup:!0})}catch(r){throw gle(t,r),r}},QGe=async(t,e,r,{signal:n})=>{for await(let[i]of WGe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},sz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},eHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{j0(t,hle);let a=new AbortController;try{await Promise.race([tHe(o,e,a),rHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),nHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),j0(t,-hle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?az(t):iHe(t))},tHe=async(t,e,{signal:r})=>{try{await t,r.aborted||az(e)}catch(n){r.aborted||gle(e,n)}},rHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await mle(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;_le(s)?i.add(e):yle(t,s)}},nHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await fle(t,i,{signal:o}),!t.readable)return fle(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},iHe=t=>{t.writable&&t.end()},gle=(t,e)=>{_le(e)?az(t):yle(t,e)},_le=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",az=t=>{(t.readable||t.writable)&&t.destroy()},yle=(t,e)=>{t.destroyed||(t.once("error",oHe),t.destroy(e))},oHe=()=>{},j0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ple=2,hle=1;import{finished as Sle}from"stream/promises";var lh=(t,e)=>{t.pipe(e),sHe(t,e),aHe(t,e)},sHe=async(t,e)=>{if(!(Po(t)||Po(e))){try{await Sle(t,{cleanup:!0,readable:!0,writable:!1})}catch{}cz(e)}},cz=t=>{t.writable&&t.end()},aHe=async(t,e)=>{if(!(Po(t)||Po(e))){try{await Sle(e,{cleanup:!0,readable:!1,writable:!0})}catch{}lz(t)}},lz=t=>{t.readable&&t.destroy()};var Ele=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Gi.has(c)))cHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Gi.has(c)))uHe({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:cd(o);lh(s,i)}},cHe=(t,e,r,n)=>{r==="output"?lh(t.stdio[n],e):lh(e,t.stdio[n]);let i=lHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},lHe=["stdin","stdout","stderr"],uHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;dHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},dHe=(t,{signal:e})=>{Po(t)&&id(t,fHe,e)},fHe=2;import{addAbortListener as mHe}from"events";var ld=[];ld.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ld.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ld.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var B0=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",uz=Symbol.for("signal-exit emitter"),dz=globalThis,pHe=Object.defineProperty.bind(Object),fz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(dz[uz])return dz[uz];pHe(dz,uz,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},q0=class{},hHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),pz=class extends q0{onExit(){return()=>{}}load(){}unload(){}},hz=class extends q0{#e=mz.platform==="win32"?"SIGINT":"SIGHUP";#r=new fz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ld)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!B0(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of ld)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,ld.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return B0(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&B0(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},mz=globalThis.process,{onExit:vle,load:X1t,unload:Q1t}=hHe(B0(mz)?new hz(mz):new pz);var ble=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=vle(()=>{t.kill()});mHe(n,()=>{i()})};var wle=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=e0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=gHe(r,n,i),{sourceStream:d,sourceError:f}=yHe(t,l),{options:p,fileDescriptors:h}=vs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},gHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=_He(t,e,...r),a=u0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},_He=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Tle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||iF(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=VR(r,...n);return{destination:e(Tle)(i,o,s),pipeOptions:s}}if(vs.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}`)},Tle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),yHe=(t,e)=>{try{return{sourceStream:rh(t,e)}}catch(r){return{sourceError:r}}};var Ale=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=SHe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw gz({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},SHe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return lz(t),n;if(e!==void 0)return cz(r),e},gz=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>sh({error:t,command:xle,escapedCommand:xle,fileDescriptors:e,options:r,startTime:n,isSync:!1}),xle="source.pipe(destination)";var Rle=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as EHe}from"stream/promises";var Cle=(t,e,r)=>{let n=V0.has(e)?bHe(t,e):vHe(t,e);return id(t,wHe,r.signal),id(e,xHe,r.signal),THe(e),n},vHe=(t,e)=>{let r=cd([t]);return lh(r,e),V0.set(e,r),r},bHe=(t,e)=>{let r=V0.get(e);return r.add(t),r},THe=async t=>{try{await EHe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}V0.delete(t)},V0=new WeakMap,wHe=2,xHe=1;import{aborted as AHe}from"util";var Ple=(t,e)=>t===void 0?[]:[RHe(t,e)],RHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await AHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw gz({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var G0=(t,...e)=>{if(or(e[0]))return G0.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=wle(t,...e),i=CHe({...n,destination:r});return i.pipe=G0.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},CHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=PHe(t,i);Ale({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Cle(e,o,d);return await Promise.race([Rle(u),...Ple(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},PHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as DHe}from"timers/promises";import{on as IHe}from"events";import{getDefaultHighWaterMark as OHe}from"stream";var H0=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return NHe(e,s),Ole({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},NHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},_z=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;kHe(e,s,t);let a=t.readableObjectMode&&!o;return Ole({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},kHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Ole=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=IHe(t,"data",{signal:e.signal,highWaterMark:Ile,highWatermark:Ile});return MHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},yz=OHe(!0),Ile=yz,MHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=$He({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*ad(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*VS(a)}},$He=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[D0(t,r,!e),$0(t,i,!n,{})].filter(Boolean);var Nle=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=LHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([UHe(t),d]);return}let f=KF(c,r),p=_z({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([FHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},LHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!F0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=_z({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await qce(a,t,r,o)},UHe=async t=>{await DHe(),t.readableFlowing===null&&t.resume()},FHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await A0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await R0(r,{maxBuffer:o})):await oh(r,{maxBuffer:o})}catch(a){return kle(qae({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},Sz=async t=>{try{return await t}catch(e){return kle(e)}},kle=({bufferedData:t})=>ooe(t)?new Uint8Array(t):t;import{finished as zHe}from"stream/promises";var YS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=jHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],zHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||VHe(a,e,r,n)}finally{s.abort()}},jHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&BHe(t,r,n),n},BHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qHe(e,r),n.call(t,...i)}},qHe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},VHe=(t,e,r,n)=>{if(!GHe(t,e,r,n))throw t},GHe=(t,e,r,n=!0)=>r.propagating?Mle(t)||W0(t):(r.propagating=!0,Ez(r,e)===n?Mle(t):W0(t)),Ez=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",W0=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Mle=t=>t?.code==="EPIPE";var $le=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>vz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),vz=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=YS(t,e,l);if(Ez(l,e)){await u;return}let[d]=await Promise.all([Nle({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Dle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?cd([t,e].filter(Boolean)):void 0,Lle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>vz({...HHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:WHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),HHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},WHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as YHe}from"events";var Ule=t=>Jp(t,"ipc"),Fle=(t,e)=>{let r=QR(t);Ss({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var zle=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ule(o),a=Ia(e,"ipc"),c=Ia(r,"ipc");for await(let l of iz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Vae(t,i,c),i.push(l)),s&&Fle(l,o);return i},jle=async(t,e)=>(await Promise.allSettled([t]),e);var Ble=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let b=Yce(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=$le({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=Lle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),I=[],N=zle({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),O=KHe(m,t,T),$=ZHe(h,T);try{return await Promise.race([Promise.all([{},Zce(b),Promise.all(v),x,N,bae(t,d),...O,...$]),g,JHe(t,_),..._ae(t,o,f,_),...Use({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...mae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(z){return f.terminationReason??="other",Promise.all([{error:z},b,Promise.all(v.map(E=>Sz(E))),Sz(x),jle(N,I),Promise.allSettled(O),Promise.allSettled($)])}},KHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:YS(n,i,r)),ZHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>No(o,{checkOpen:!1})&&!Po(o)).map(({type:i,value:o,stream:s=o})=>YS(s,n,e,{isSameDirection:Gi.has(i),stopOnExit:i==="native"}))),JHe=async(t,{signal:e})=>{let[r]=await YHe(t,"error",{signal:e});throw r};var qle=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),KS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=Es();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},uh=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 XHe}from"stream";import{callbackify as QHe}from"util";import{finished as Vle}from"stream/promises";var bz=async t=>{if(t!==void 0)try{await Tz(t)}catch{}},Gle=async t=>{if(t!==void 0)try{await wz(t)}catch{}},Tz=async t=>{await Vle(t,{cleanup:!0,readable:!1,writable:!0})},wz=async t=>{await Vle(t,{cleanup:!0,readable:!0,writable:!1})},Y0=async(t,e)=>{if(await t,e)throw e},K0=(t,e,r)=>{r&&!W0(r)?t.destroy(r):e&&t.destroy()};var Hle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||gi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=xz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Az(a,s),{read:f,onStdoutDataDone:p}=Rz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new XHe({read:f,destroy:QHe(Pz.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Cz({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},xz=(t,e,r)=>{let n=rh(t,e),i=KS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Az=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:yz},Rz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=Es(),s=H0({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){e6e(this,s,o)},onStdoutDataDone:o}},e6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Cz=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await wz(t),await n,await bz(i),await e,r.readable&&r.push(null)}catch(o){await bz(i),Wle(r,o)}},Pz=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await uh(r,e)&&(Wle(t,n),await Y0(e,n))},Wle=(t,e)=>{K0(t,t.readable,e)};import{Writable as t6e}from"stream";import{callbackify as Yle}from"util";var Kle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Iz(t,r,e),s=new t6e({...Oz(n,t,i),destroy:Yle(kz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Nz(n,s),s},Iz=(t,e,r)=>{let n=u0(t,e),i=KS(r,n,"writableFinal"),o=KS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Oz=(t,e,r)=>({write:r6e.bind(void 0,t),final:Yle(n6e.bind(void 0,t,e,r))}),r6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},n6e=async(t,e,r)=>{await uh(r,e)&&(t.writable&&t.end(),await e)},Nz=async(t,e,r)=>{try{await Tz(t),e.writable&&e.end()}catch(n){await Gle(r),Zle(e,n)}},kz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await uh(r,e),await uh(n,e)&&(Zle(t,i),await Y0(e,i))},Zle=(t,e)=>{K0(t,t.writable,e)};import{Duplex as i6e}from"stream";import{callbackify as o6e}from"util";var Jle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||gi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=xz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Iz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Az(c,a),{read:g,onStdoutDataDone:_}=Rz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new i6e({read:g,...Oz(u,t,d),destroy:o6e(s6e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return Cz({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),Nz(u,b,c),b},s6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([Pz({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),kz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var Mz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||gi.has(e),s=rh(t,r),a=H0({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return a6e(a,s,t)},a6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Xle=(t,{encoding:e})=>{let r=qle();t.readable=Hle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Kle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Jle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Mz.bind(void 0,t,e),t[Symbol.asyncIterator]=Mz.bind(void 0,t,e,{})};var Qle=(t,e)=>{for(let[r,n]of l6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},c6e=(async()=>{})().constructor.prototype,l6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(c6e,t)]);var eue=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=f6e(t,e,r),{subprocess:f,promise:p}=h6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=G0.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Qle(f,p),vs.set(f,{options:u,fileDescriptors:d}),f},f6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=t0(t,e,r),{file:a,commandArguments:c,options:l}=v0(t,e,r),u=p6e(l),d=dle(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},p6e=({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}},h6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=d6e(...b0(t,e,r))}catch(h){return ale({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;u6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ele(c,a,l),ble(c,r,l);let d={},f=Es();c.kill=Dse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Dle(c,r),Xle(c,r),ile(c,r);let p=m6e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},m6e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Ble({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((v,x)=>Na(v,e,x)),b=Na(m,e,"all"),T=g6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return ah(T,n,e)},g6e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?qS({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof bs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):I0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Z0=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,_6e(n,t[n],i)]));return{...t,...r}},_6e=(t,e,r)=>y6e.has(t)&&or(e)&&or(r)?{...e,...r}:r,y6e=new Set(["env",...uF]);var Qc=(t,e,r,n)=>{let i=(s,a,c)=>Qc(s,a,r,c),o=(...s)=>S6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},S6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(or(o))return i(t,Z0(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=E6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Xce(a,c,l):eue(a,c,l,i)},E6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=doe(e)?foe(e,r):[e,...r],[s,a,c]=VR(...o),l=Z0(Z0(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var tue=({file:t,commandArguments:e})=>nue(t,e),rue=({file:t,commandArguments:e})=>({...nue(t,e),isSync:!0}),nue=(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]=v6e(t);return{file:r,commandArguments:n}},v6e=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(b6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},b6e=/ +/g;var iue=(t,e,r)=>{t.sync=e(T6e,r),t.s=t.sync},oue=({options:t})=>sue(t),T6e=({options:t})=>({...sue(t),isSync:!0}),sue=t=>({options:{...w6e(t),...t}}),w6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},aue={preferLocal:!0};var cue=Qc(()=>({})),Bzt=Qc(()=>({isSync:!0})),lue=Qc(tue),qzt=Qc(rue),Vzt=Qc(Sae),Gzt=Qc(oue,{},aue,iue),{sendMessage:Hzt,getOneMessage:Wzt,getEachMessage:Yzt,getCancelSignal:Kzt}=ole();var uue=!1,due=()=>{uue=!0},ws=()=>uue;var ZS=null,fue=t=>(ZS&&ZS.destroy(),ZS=new ko({totalAllowedTime:t}),ZS),pue=()=>ZS;var ko=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&ws())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await $R({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{re.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var hue={name:"@netlify/agent-runner-cli",type:"module",version:"1.169.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.5","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var C6e=A6e(import.meta.url),P6e=ka.dirname(C6e),I6e=R6e(import.meta.url),dh=ce("shell"),$z=new Set,mue={preferLocal:!0},Wr=(t,e,r)=>{let[n,i]=O6e(e,r),o={...mue,...i},s=cue(t,n,o);_ue(s,o),Eue(s);let a=r?.idleTimeout;return a&&a>0&&Sue(s,a),s},gue=(t,e)=>{let r={...mue,...e},n=lue(t,r);return _ue(n,r),Eue(n),e?.idleTimeout&&e.idleTimeout>0&&Sue(n,e.idleTimeout),n},O6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},_ue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||xs.env.NETLIFY_LOCAL_QUIET==="true")return;if(xs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new xS).pipe(xs.stdout),t.stderr?.pipe(new xS).pipe(xs.stderr);return}t.stdout?.pipe(xs.stdout),t.stderr?.pipe(xs.stderr)},Dz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(xs.kill(-t.pid,e),dh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return dh.error("Error killing process:",r),!1}},yue=t=>Dz(t,"SIGKILL"),Sue=(t,e)=>{let r=null,n=()=>{dh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Dz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dh.log(`Force killing idle process ${t.pid}`),yue(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Eue=t=>{$z.add(t);let e=pue();if(e){let r=e.onTimesUp(()=>{dh.log(`Global timer expired, killing process ${t.pid}`),Dz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(dh.log(`Force killing process ${t.pid} after timeout`),yue(t))},5e3)});t.on("exit",()=>{$z.delete(t),r()}),t.on("error",()=>{$z.delete(t),r()})}};function As(t,e){if(!xs.env.NETLIFY_LOCAL_MODE)try{let i=I6e.resolve(hue.name),o=ka.dirname(i);for(;o!==ka.dirname(o);){let s=ka.dirname(o);if(ka.basename(s)==="node_modules"){let a=ka.join(s,".bin",e);if(J0.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(xs.env.NODE_PATH){let i=ka.join(xs.env.NODE_PATH,".bin",e);if(J0.existsSync(i))return i}let r=ka.join(t,"node_modules",".bin",e);if(J0.existsSync(r))return r;let n=ka.join(P6e,"..","node_modules",".bin",e);if(J0.existsSync(n))return n}var N6e=ce("utils"),k6e=t=>new Promise(e=>{setTimeout(e,t)});var Lz=t=>{try{return new URL(t).hostname||null}catch{return null}},X0=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await k6e(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},el=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},vue=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):N6e.error("Could not parse JSON",n))}},M6e=t=>t.charAt(0).toUpperCase()+t.slice(1),Rs=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():M6e(e)).join(" ");function Ma(t,e){e&&t.log(`Skill invoked: ${e}`)}var Q0=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),bue=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var Uz=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},$6e=1e4,Fz=(t,e=$6e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{createHash as D6e}from"crypto";import{createReadStream as L6e}from"fs";import eC from"fs/promises";import Rue from"os";import tC from"path";var Tue=ce("repo"),Cue="runner-diffs-",Pue=t=>`${Cue}${t}-`,Iue=async t=>{let e=Rue.tmpdir(),r;try{r=await eC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Cue)&&!n.startsWith(Pue(t))).map(n=>eC.rm(tC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Kn=(t,e={})=>Wr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),rC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Tue.info("Getting runner diffs");let n=await F6e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=j6e(o);await B6e(h,r)}Tue.info("Changes after processing"),await jz(r);let s=await qz(o,r);if(await zz(s,r),i=await z6e(r),!i)return{hasChanges:!1,ignored:s};await Kn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await eC.mkdtemp(tC.join(Rue.tmpdir(),Pue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=tC.join(a,g);await Kn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:v}=await eC.stat(b);return{path:b,size:v}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Aue(r),{hasChanges:!1,ignored:s};let u=await c({from:t.runSha,to:"HEAD",fileName:"session-binary.patch",binary:!0}),d,f;if(t.sha){d=await c({from:t.sha,to:"HEAD",fileName:"cumulative.patch"});let h=await c({from:t.sha,to:"HEAD",fileName:"cumulative-binary.patch",binary:!0});await xue(d,h)||(f=h)}await Aue(r),re.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await xue(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},wue=async t=>{let e=D6e("sha256");for await(let r of L6e(t))e.update(r);return e.digest("hex")},xue=async(t,e)=>t.size===e.size&&await wue(t.path)===await wue(e.path),Aue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Kn(["reset","--soft","HEAD~1"],{cwd:t})},zz=async(t=[],e=process.cwd())=>{await Kn(["add",".",...t],{cwd:e})},jz=async(t=process.cwd())=>{let e=await Kn(["status","-s"],{cwd:t});return String(e.stdout??"")},Oue=/.. (.+)?\.log$/,U6e=[Oue],F6e=async(t=process.cwd())=>{let e=await jz(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
143
143
|
`).filter(i=>U6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},z6e=async(t=process.cwd())=>{try{return await Kn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},Bz=async(t=process.cwd())=>{let{stdout:e}=await Kn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Nue=async(t=process.cwd())=>{let{stdout:e}=await Kn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},qz=async(t,e=process.cwd())=>{t||=await jz(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
144
144
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${tC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Oue)?.[1];o&&n.push(`:!${o}.log`)}),n},kue=async(t=process.cwd())=>{await Kn(["reset","--hard","HEAD"],{cwd:t})},Mue=async(t=process.cwd())=>{let e=await Kn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
145
145
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},j6e=t=>{let e=t.split(`
|
|
@@ -618,10 +618,10 @@ Use the following file for the complete context of the ask, the environment, and
|
|
|
618
618
|
|
|
619
619
|
`)},$nt=t=>{let e=t.map(r=>r.authorization).filter(r=>!!r).map(r=>r.granted?`- ${r.service} is now authorized. Its tools are available to you.`:`- The user declined to authorize ${r.service}. Continue without it and do not request authorization for ${r.service} again in this run.`);return e.length?["## Service authorization","",...e].join(`
|
|
620
620
|
`):""};import hc from"fs/promises";import Mxe from"os";import mc from"path";import{rm as OY}from"fs/promises";import{resolve as Dnt}from"path";var Lnt=".netlify/cache/",_f=function({cacheDir:t=Lnt,cwd:e="."}={}){return Dnt(e,t)};import{promises as Hlt}from"fs";import{basename as oxe,dirname as sxe,join as Wlt}from"path";import clt from"process";import llt from"events";import bt from"path";import ult from"os";async function Nb(t,e,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:n=!0,signal:i}={}){return new Promise((o,s)=>{if(t[Symbol.iterator]===void 0&&t[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(r)&&r>=1||r===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let a=[],c=[],l=new Map,u=!1,d=!1,f=!1,p=0,h=0,m=t[Symbol.iterator]===void 0?t[Symbol.asyncIterator]():t[Symbol.iterator](),g=()=>{T(i.reason)},_=()=>{i?.removeEventListener("abort",g)},b=x=>{o(x),_()},T=x=>{u=!0,d=!0,s(x),_()};i&&(i.aborted&&T(i.reason),i.addEventListener("abort",g,{once:!0}));let v=async()=>{if(d)return;let x=await m.next(),I=h;if(h++,x.done){if(f=!0,p===0&&!d){if(!n&&c.length>0){T(new AggregateError(c));return}if(d=!0,l.size===0){b(a);return}let N=[];for(let[O,$]of a.entries())l.get(O)!==PEe&&N.push($);b(N)}return}p++,(async()=>{try{let N=await x.value;if(d)return;let O=await e(N,I);O===PEe&&l.set(I,O),a[I]=O,p--,await v()}catch(N){if(n)T(N);else{c.push(N),p--;try{await v()}catch(O){T(O)}}}})()};(async()=>{for(let x=0;x<r;x++){try{await v()}catch(I){T(I);break}if(f||u)break}})()})}var PEe=Symbol("skip");import Sf from"path";import osr,{constants as s3}from"fs";import a3 from"fs/promises";var X6=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Q6=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},IEe=t=>globalThis.DOMException===void 0?new Q6(t):new DOMException(t),OEe=t=>{let e=t.reason===void 0?IEe("This operation was aborted."):t.reason;return e instanceof Error?e:IEe(e)};function e3(t,e){let{milliseconds:r,fallback:n,message:i,customTimers:o={setTimeout,clearTimeout}}=e,s,a,l=new Promise((u,d)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:p}=e;p.aborted&&d(OEe(p)),a=()=>{d(OEe(p))},p.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let f=new X6;s=o.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(p){d(p)}return}typeof t.cancel=="function"&&t.cancel(),i===!1?u():i instanceof Error?d(i):(f.message=i??`Promise timed out after ${r} milliseconds`,d(f))},r),(async()=>{try{u(await t)}catch(p){d(p)}})()}).finally(()=>{l.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return l.clear=()=>{o.clearTimeout.call(void 0,s),s=void 0},l}var Unt=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 Fnt(t,e,r){let n,i=new Promise((o,s)=>{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}=Unt(t),d=(...p)=>{let h=r.multiArgs?p:p[0];r.filter&&!r.filter(h)||(c.push(h),r.count===c.length&&(n(),o(c)))},f=p=>{n(),s(p)};n=()=>{for(let p of a)u(p,d);for(let p of r.rejectionEvents)u(p,f)};for(let p of a)l(p,d);for(let p of r.rejectionEvents)l(p,f);r.signal&&r.signal.addEventListener("abort",()=>{f(r.signal.reason)},{once:!0}),r.resolveImmediately&&o(c)});if(i.cancel=n,typeof r.timeout=="number"){let o=e3(i,{milliseconds:r.timeout});return o.cancel=n,o}return i}function KO(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=Fnt(t,e,r),i=n.then(o=>o[0]);return i.cancel=n.cancel,i}var Ln=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CopyFileError"}};var Go=Fn(BEe(),1);import{promisify as kb}from"util";var Xor=kb(Go.default.stat),Znt=kb(Go.default.lstat),Jnt=kb(Go.default.utimes),Xnt=kb(Go.default.chmod),Qnt=kb(Go.default.mkdir),Qor=Go.default.closeSync.bind(Go.default),qEe=Go.default.createWriteStream.bind(Go.default);async function VEe(t,e){let r=Go.default.createReadStream(t,e);try{await KO(r,["readable","end"])}catch(n){throw new Ln(`Cannot read from \`${t}\`: ${n.message}`,{cause:n})}return r}var o3=t=>Znt(t).catch(e=>{throw new Ln(`lstat \`${t}\` failed: ${e.message}`,{cause:e})}),GEe=(t,e,r)=>Jnt(t,e,r).catch(n=>{throw new Ln(`utimes \`${t}\` failed: ${n.message}`,{cause:n})}),HEe=(t,e)=>Xnt(t,e).catch(r=>{throw new Ln(`chmod \`${t}\` failed: ${r.message}`,{cause:r})});var WEe=(t,e)=>Qnt(t,{...e,recursive:!0}).catch(r=>{throw new Ln(`Cannot create directory \`${t}\`: ${r.message}`,{cause:r})});var tit=(t,e,r)=>({sourcePath:Sf.resolve(t,e),destinationPath:Sf.resolve(t,r)}),rit=(t,e)=>{if(!t.isFile())throw Object.assign(new Ln(`EISDIR: illegal operation on a directory '${e}'`),{errno:-21,code:"EISDIR",source:e})};async function YEe(t,e,r={}){if(!t||!e)throw new Ln("`source` and `destination` required");r.cwd&&({sourcePath:t,destinationPath:e}=tit(r.cwd,t,e)),r={overwrite:!0,...r};let n=await o3(t),{size:i}=n;rit(n,t);let o=Sf.dirname(e);if(Sf.parse(o).root===o||await WEe(Sf.dirname(e),{mode:r.directoryMode}),typeof r.onProgress=="function"){let a=await VEe(t),c=qEe(e,{flags:r.overwrite?"w":"wx"}),l=p=>{r.onProgress({sourcePath:Sf.resolve(t),destinationPath:Sf.resolve(e),size:i,writtenBytes:p,percent:p===i?1:p/i})},u=-1;a.on("data",()=>{let p=c.bytesWritten,h=p===i?1:p/i;(h===1||h-u>=.01)&&(u=h,l(p))});let d;a.once("error",p=>{d=new Ln(`Cannot read from \`${t}\`: ${p.message}`,{cause:p})});let f=!1;try{let p=KO(c,"close");a.pipe(c),await p,l(i),f=!0}catch(p){throw new Ln(`Cannot write to \`${e}\`: ${p.message}`,{cause:p})}if(d)throw d;if(f){let p=await o3(t);return Promise.all([GEe(e,p.atime,p.mtime).catch(h=>{if(h.code!=="EPERM")throw h}),HEe(e,p.mode)])}}else{let a=r.overwrite?s3.COPYFILE_FICLONE:s3.COPYFILE_FICLONE|s3.COPYFILE_EXCL;try{await a3.copyFile(t,e,a),await Promise.all([a3.utimes(e,n.atime,n.mtime).catch(c=>{if(c.code!=="EPERM")throw c}),a3.chmod(e,n.mode)])}catch(c){throw new Ln(c.message,{cause:c})}}}async function c3(t,e,r){return(await Nb(t,(i,o)=>Promise.all([e(i,o),i]),r)).filter(i=>!!i[0]).map(i=>i[1])}import dwe from"process";import tlt from"fs";import c_ from"path";import{on as nit,once as iit}from"events";import{PassThrough as oit}from"stream";import{finished as JEe}from"stream/promises";function f3(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)u3(i);let e=t.some(({readableObjectMode:i})=>i),r=sit(t,e),n=new l3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&eve(n),n}var sit=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},l3=class extends oit{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){u3(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=ait(this,this.#e),uit({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return u3(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},ait=async(t,e)=>{eN(t,KEe);let r=new AbortController;try{await Promise.race([cit(t,r),lit(t,e,r)])}finally{r.abort(),eN(t,-KEe)}},cit=async(t,{signal:e})=>{await JEe(t,{signal:e,cleanup:!0})},lit=async(t,e,{signal:r})=>{for await(let[n]of nit(t,"unpipe",{signal:r}))e.has(n)&&n.emit(QEe)},u3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},uit=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o})=>{eN(t,ZEe);let s=new AbortController;try{await Promise.race([dit(o,e),fit({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:s}),pit({stream:e,streams:r,ended:n,aborted:i,controller:s})])}finally{s.abort(),eN(t,-ZEe)}r.size===n.size+i.size&&(n.size===0&&i.size>0?d3(t):eve(t))},XEe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",dit=async(t,e)=>{try{await t,d3(e)}catch(r){XEe(r)?d3(e):tve(e,r)}},fit=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await JEe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;XEe(s)?i.add(e):tve(t,s)}},pit=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await iit(t,QEe,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},QEe=Symbol("unpipe"),eve=t=>{t.writable&&t.end()},d3=t=>{(t.readable||t.writable)&&t.destroy()},tve=(t,e)=>{t.destroyed||(t.once("error",hit),t.destroy(e))},hit=()=>{},eN=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},KEe=2,ZEe=1;var l_=Fn(zb(),1);import Act from"fs";import Rct from"fs/promises";async function XW(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await Rct[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function QW(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return Act[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var Far=XW.bind(void 0,"stat","isFile"),HTe=XW.bind(void 0,"stat","isDirectory"),zar=XW.bind(void 0,"lstat","isSymbolicLink"),jar=QW.bind(void 0,"statSync","isFile"),WTe=QW.bind(void 0,"statSync","isDirectory"),Bar=QW.bind(void 0,"lstatSync","isSymbolicLink");var aY=Fn(zb(),1),rwe=Fn(sY(),1);import Yct from"process";import Kct from"fs";import Zct from"fs/promises";import a_ from"path";function s_(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var Bb=t=>t[0]==="!";var Jct=["**/node_modules","**/flow-typed","**/coverage","**/.git"],nwe={absolute:!0,dot:!0},iwe="**/.gitignore",Xct=(t,e)=>Bb(t)?"!"+a_.posix.join(e,t.slice(1)):a_.posix.join(e,t),Qct=(t,e)=>{let r=s_(a_.relative(e,a_.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>Xct(n,r))},elt=(t,e)=>{if(e=s_(e),a_.isAbsolute(t)){if(s_(t).startsWith(e))return a_.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},owe=(t,e)=>{let r=t.flatMap(i=>Qct(i,e)),n=(0,rwe.default)().add(r);return i=>(i=Yn(i),i=elt(i,e),i?n.ignores(s_(i)):!1)},swe=(t={})=>({cwd:Yn(t.cwd)??Yct.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...Jct]}),awe=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=swe(e),s=await(0,aY.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...nwe}),a=await Promise.all(s.map(async c=>({filePath:c,content:await Zct.readFile(c,"utf8")})));return owe(a,r)},cwe=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=swe(e),a=aY.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...nwe}).map(c=>({filePath:c,content:Kct.readFileSync(c,"utf8")}));return owe(a,r)};var rlt=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},fwe=(t,e)=>{let r=Bb(t)?t.slice(1):t;return c_.isAbsolute(r)?r:c_.join(e,r)},pwe=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>c_.posix.join(t,`**/${c_.extname(i)?i:`${i}${n}`}`)):[c_.posix.join(t,`**${n?`/*${n}`:""}`)]},lwe=async(t,{cwd:e=dwe.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async o=>await HTe(fwe(o,e))?pwe({directoryPath:o,files:r,extensions:n}):o))).flat(),uwe=(t,{cwd:e=dwe.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>WTe(fwe(i,e))?pwe({directoryPath:i,files:r,extensions:n}):i),cY=t=>(t=[...new Set([t].flat())],rlt(t),t),nlt=t=>{if(!t)return;let e;try{e=tlt.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},hwe=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Yn(t.cwd)},nlt(t.cwd),t),mwe=t=>async(e,r)=>t(cY(e),hwe(r)),NN=t=>(e,r)=>t(cY(e),hwe(r)),gwe=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?cY(e):[];return r&&n.push(iwe),n},ilt=async t=>{let e=gwe(t);return ywe(e.length>0&&await awe(e,t))},_we=t=>{let e=gwe(t);return ywe(e.length>0&&cwe(e,t))},ywe=t=>{let e=new Set;return r=>{let n=c_.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},Swe=(t,e)=>t.flat().filter(r=>e(r)),Ewe=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(o=>Bb(o));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let o of r)o.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},vwe=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),bwe=async(t,e)=>{let r=Ewe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=vwe(i,n);return Promise.all(r.map(async s=>{let{patterns:a,options:c}=s;return[a,c.ignore]=await Promise.all([lwe(a,o),lwe(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},lY=(t,e)=>{let r=Ewe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=vwe(i,n);return r.map(s=>{let{patterns:a,options:c}=s;return a=uwe(a,o),c.ignore=uwe(c.ignore,{cwd:n}),{patterns:a,options:c}})},lcr=mwe(async(t,e)=>{let[r,n]=await Promise.all([bwe(t,e),ilt(e)]),i=await Promise.all(r.map(o=>(0,l_.default)(o.patterns,o.options)));return Swe(i,n)}),Twe=NN((t,e)=>{let r=lY(t,e),n=_we(e),i=r.map(o=>l_.default.sync(o.patterns,o.options));return Swe(i,n)}),ucr=NN((t,e)=>{let r=lY(t,e),n=_we(e),i=r.map(s=>l_.default.stream(s.patterns,s.options));return f3(i).filter(s=>n(s))}),Tf=NN((t,e)=>t.some(r=>l_.default.isDynamicPattern(r,e))),dcr=mwe(bwe),fcr=NN(lY),{convertPathToPattern:pcr}=l_.default;var xwe=Fn(M3(),1);var cu=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CpyError"}};import MN from"path";import wwe from"fs";var olt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],slt=new RegExp(olt.join("|"));function alt(t){return slt.test(t)}function kN(t){return!alt(t)}var qb=class{constructor(e,r,n){this.path=e,this.originalPath=e,this.destination=r,this.options=n,this.isDirectory=!1,!Tf(e)&&wwe.existsSync(e)&&wwe.lstatSync(e).isDirectory()&&(this.path=[e,"**"].join("/"),this.isDirectory=!0)}get name(){return MN.basename(this.originalPath)}get normalizedPath(){let e=this.originalPath.split("/"),r=e.findIndex(i=>i?Tf(i):!1),n=e.slice(0,r).join("/");return n?MN.isAbsolute(n)?n:MN.join(this.options.cwd,n):this.destination}hasMagic(){return Tf(this.options.flat?this.path:this.originalPath)}getMatches(){let e=Twe(this.path,{...this.options,dot:!0,absolute:!0,onlyFiles:!0});return this.options.ignoreJunk&&(e=e.filter(r=>kN(MN.basename(r)))),e}};var dlt={ignoreJunk:!0,flat:!1,cwd:clt.cwd()},uY=class{constructor(e,r,n){this.path=e.split("/").join(bt.sep),this.relativePath=r.split("/").join(bt.sep),this.pattern=n,Object.freeze(this)}get name(){return bt.basename(this.path)}get nameWithoutExtension(){return bt.basename(this.path,bt.extname(this.path))}get extension(){return bt.extname(this.path).slice(1)}},flt=t=>t.flatMap(e=>xwe.default.braces(e,{expand:!0,nodupes:!0})),plt=({entry:t,destination:e,options:r})=>t.pattern.hasMagic()?r.flat?bt.isAbsolute(e)?bt.join(e,t.name):bt.join(r.cwd,e,t.name):bt.join(e,bt.relative(t.pattern.normalizedPath,t.path)):bt.isAbsolute(e)?bt.join(e,t.name):t.pattern.isDirectory&&bt.relative(r.cwd,t.path).startsWith("..")?bt.join(r.cwd,e,bt.basename(t.pattern.originalPath),bt.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&t.path===t.relativePath?bt.join(r.cwd,e,bt.basename(t.pattern.originalPath),bt.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&r.flat?bt.join(r.cwd,e,bt.basename(t.pattern.originalPath)):bt.join(r.cwd,e,bt.relative(r.cwd,t.path)),hlt=(t,e)=>{let r=bt.dirname(t);if(typeof e=="string")return bt.join(r,e);if(typeof e=="function"){let n=bt.basename(t);return bt.join(r,e(n))}return t};function dY(t,e,{concurrency:r=ult.availableParallelism(),...n}={}){let i=new Map,o=new llt;n={...dlt,...n};let s=(async()=>{let a=[],c=0,l=0,u=flt([t??[]].flat()).map(h=>h.replaceAll("\\","/")),d=u.filter(h=>!h.startsWith("!")),f=u.filter(h=>h.startsWith("!"));if(d.length===0||!e)throw new cu("`source` and `destination` required");u=u.map(h=>new qb(h,e,{...n,ignore:f}));for(let h of u){let m=[];try{m=h.getMatches()}catch(g){throw new cu(`Cannot glob \`${h.originalPath}\`: ${g.message}`,{cause:g})}if(m.length===0&&!Tf(h.originalPath)&&!Tf(f))throw new cu(`Cannot copy \`${h.originalPath}\`: the file doesn't exist`);a=[...a,...m.map(g=>new uY(g,bt.relative(n.cwd,g),h))]}n.filter!==void 0&&(a=await c3(a,n.filter,{concurrency:1024})),a.length===0&&o.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0});let p=h=>{let m=i.get(h.sourcePath)||{writtenBytes:0,percent:0};(m.writtenBytes!==h.writtenBytes||m.percent!==h.percent)&&(l-=m.writtenBytes,l+=h.writtenBytes,h.percent===1&&m.percent!==1&&c++,i.set(h.sourcePath,{writtenBytes:h.writtenBytes,percent:h.percent}),o.emit("progress",{totalFiles:a.length,percent:c/a.length,completedFiles:c,completedSize:l,sourcePath:h.sourcePath,destinationPath:h.destinationPath}))};return Nb(a,async h=>{let m=hlt(plt({entry:h,destination:e,options:n}),n.rename);try{await YEe(h.path,m,{...n,onProgress:p})}catch(g){throw new cu(`Cannot copy from \`${h.relativePath}\` to \`${m}\`: ${g.message}`,{cause:g})}return m},{concurrency:r})})();return s.on=(...a)=>(o.on(...a),s),s}import Vwe from"process";import Dlt from"fs";import f_ from"path";import{on as mlt,once as glt}from"events";import{PassThrough as _lt}from"stream";import{finished as Cwe}from"stream/promises";function mY(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)pY(i);let e=t.some(({readableObjectMode:i})=>i),r=ylt(t,e),n=new fY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&Owe(n),n}var ylt=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},fY=class extends _lt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){pY(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=Slt(this,this.#e),blt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return pY(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},Slt=async(t,e)=>{$N(t,Awe);let r=new AbortController;try{await Promise.race([Elt(t,r),vlt(t,e,r)])}finally{r.abort(),$N(t,-Awe)}},Elt=async(t,{signal:e})=>{await Cwe(t,{signal:e,cleanup:!0})},vlt=async(t,e,{signal:r})=>{for await(let[n]of mlt(t,"unpipe",{signal:r}))e.has(n)&&n.emit(Iwe)},pY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},blt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o})=>{$N(t,Rwe);let s=new AbortController;try{await Promise.race([Tlt(o,e),wlt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:s}),xlt({stream:e,streams:r,ended:n,aborted:i,controller:s})])}finally{s.abort(),$N(t,-Rwe)}r.size===n.size+i.size&&(n.size===0&&i.size>0?hY(t):Owe(t))},Pwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Tlt=async(t,e)=>{try{await t,hY(e)}catch(r){Pwe(r)?hY(e):Nwe(e,r)}},wlt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Cwe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Pwe(s)?i.add(e):Nwe(t,s)}},xlt=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await glt(t,Iwe,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},Iwe=Symbol("unpipe"),Owe=t=>{t.writable&&t.end()},hY=t=>{(t.readable||t.writable)&&t.destroy()},Nwe=(t,e)=>{t.destroyed||(t.once("error",Alt),t.destroy(e))},Alt=()=>{},$N=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Awe=2,Rwe=1;var p_=Fn(zb(),1);import Rlt from"fs";import Clt from"fs/promises";async function gY(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await Clt[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function _Y(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return Rlt[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var Fcr=gY.bind(void 0,"stat","isFile"),kwe=gY.bind(void 0,"stat","isDirectory"),zcr=gY.bind(void 0,"lstat","isSymbolicLink"),jcr=_Y.bind(void 0,"statSync","isFile"),Mwe=_Y.bind(void 0,"statSync","isDirectory"),Bcr=_Y.bind(void 0,"lstatSync","isSymbolicLink");var yY=Fn(zb(),1),$we=Fn(sY(),1);import Plt from"process";import Ilt from"fs";import Olt from"fs/promises";import d_ from"path";function u_(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var Vb=t=>t[0]==="!";var Nlt=["**/node_modules","**/flow-typed","**/coverage","**/.git"],Dwe={absolute:!0,dot:!0},Lwe="**/.gitignore",klt=(t,e)=>Vb(t)?"!"+d_.posix.join(e,t.slice(1)):d_.posix.join(e,t),Mlt=(t,e)=>{let r=u_(d_.relative(e,d_.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>klt(n,r))},$lt=(t,e)=>{if(e=u_(e),d_.isAbsolute(t)){if(u_(t).startsWith(e))return d_.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},Uwe=(t,e)=>{let r=t.flatMap(i=>Mlt(i,e)),n=(0,$we.default)().add(r);return i=>(i=Yn(i),i=$lt(i,e),i?n.ignores(u_(i)):!1)},Fwe=(t={})=>({cwd:Yn(t.cwd)??Plt.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...Nlt]}),zwe=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=Fwe(e),s=await(0,yY.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...Dwe}),a=await Promise.all(s.map(async c=>({filePath:c,content:await Olt.readFile(c,"utf8")})));return Uwe(a,r)},jwe=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=Fwe(e),a=yY.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...Dwe}).map(c=>({filePath:c,content:Ilt.readFileSync(c,"utf8")}));return Uwe(a,r)};var Llt=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},Gwe=(t,e)=>{let r=Vb(t)?t.slice(1):t;return f_.isAbsolute(r)?r:f_.join(e,r)},Hwe=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>f_.posix.join(t,`**/${f_.extname(i)?i:`${i}${n}`}`)):[f_.posix.join(t,`**${n?`/*${n}`:""}`)]},Bwe=async(t,{cwd:e=Vwe.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async o=>await kwe(Gwe(o,e))?Hwe({directoryPath:o,files:r,extensions:n}):o))).flat(),qwe=(t,{cwd:e=Vwe.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>Mwe(Gwe(i,e))?Hwe({directoryPath:i,files:r,extensions:n}):i),SY=t=>(t=[...new Set([t].flat())],Llt(t),t),Ult=t=>{if(!t)return;let e;try{e=Dlt.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},Wwe=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Yn(t.cwd)},Ult(t.cwd),t),Ywe=t=>async(e,r)=>t(SY(e),Wwe(r)),DN=t=>(e,r)=>t(SY(e),Wwe(r)),Kwe=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?SY(e):[];return r&&n.push(Lwe),n},Flt=async t=>{let e=Kwe(t);return Jwe(e.length>0&&await zwe(e,t))},Zwe=t=>{let e=Kwe(t);return Jwe(e.length>0&&jwe(e,t))},Jwe=t=>{let e=new Set;return r=>{let n=f_.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},Xwe=(t,e)=>t.flat().filter(r=>e(r)),Qwe=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(o=>Vb(o));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let o of r)o.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},exe=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),txe=async(t,e)=>{let r=Qwe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=exe(i,n);return Promise.all(r.map(async s=>{let{patterns:a,options:c}=s;return[a,c.ignore]=await Promise.all([Bwe(a,o),Bwe(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},EY=(t,e)=>{let r=Qwe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=exe(i,n);return r.map(s=>{let{patterns:a,options:c}=s;return a=qwe(a,o),c.ignore=qwe(c.ignore,{cwd:n}),{patterns:a,options:c}})},rxe=Ywe(async(t,e)=>{let[r,n]=await Promise.all([txe(t,e),Flt(e)]),i=await Promise.all(r.map(o=>(0,p_.default)(o.patterns,o.options)));return Xwe(i,n)}),clr=DN((t,e)=>{let r=EY(t,e),n=Zwe(e),i=r.map(o=>p_.default.sync(o.patterns,o.options));return Xwe(i,n)}),llr=DN((t,e)=>{let r=EY(t,e),n=Zwe(e),i=r.map(s=>p_.default.stream(s.patterns,s.options));return mY(i).filter(s=>n(s))}),ulr=DN((t,e)=>t.some(r=>p_.default.isDynamicPattern(r,e))),dlr=Ywe(txe),flr=DN(EY),{convertPathToPattern:plr}=p_.default;import jlt from"process";import Gb from"path";import vlr,{promises as LN}from"fs";import glr,{promises as zlt}from"fs";async function nxe(t){try{return await zlt.access(t),!0}catch{return!1}}var Blt=(t,e,r)=>(e=Gb.resolve(t,e),r=Gb.resolve(t,r),{sourcePath:e,destinationPath:r}),qlt=(t,e,r="Path")=>{if(!t||!e)throw new TypeError(`\`source${r}\` and \`destination${r}\` required`)},Vlt=(t,e)=>{if(Gb.dirname(t)!==Gb.dirname(e))throw new Error("`source` and `destination` must be in the same directory")},Glt=async(t,e,{overwrite:r=!0,cwd:n=jlt.cwd(),directoryMode:i,validateDirectory:o=!1}={})=>{if(n&&({sourcePath:t,destinationPath:e}=Blt(n,t,e)),o&&Vlt(t,e),!r&&await nxe(e))throw new Error(`The destination file exists: ${e}`);await LN.mkdir(Gb.dirname(e),{recursive:!0,mode:i});try{await LN.rename(t,e)}catch(s){if(s.code==="EXDEV")await LN.copyFile(t,e),await LN.unlink(t);else throw s}};async function ixe(t,e,r){return qlt(t,e),Glt(t,e,r)}var vY=async function(t,e,r=!1){if(r)return ixe(t,e,{overwrite:!1});let{srcGlob:n,dest:i,...o}=await axe(t,sxe(e));if(n&&i)return dY(n,i,{...o,overwrite:!1})},Hb=async function(t){let{srcGlob:e,isDir:r,dest:n,...i}=await axe(t,"");return e!==void 0&&!await Ylt(e,r,i)},Ylt=async function(t,e,r){return e?(await rxe(t,r)).filter(o=>kN(oxe(o))).length===0:!1},axe=async function(t,e){let r=await Klt(t);if(r===void 0)return{srcGlob:void 0,isDir:!1,cwd:""};let n=r.isDirectory(),i=oxe(t),o=sxe(t),s={srcGlob:i,dest:e,isDir:n,cwd:o,dot:!0};return n?{...s,srcGlob:`${i}/**`,dest:Wlt(e,i)}:s},Klt=async t=>{try{return await Hlt.stat(t)}catch{return}};import{join as Vut}from"path";import{stat as Zlt,lstat as cxe,readdir as Jlt,realpath as Xlt}from"fs/promises";import{Readable as Qlt}from"stream";import{resolve as lxe,relative as eut,join as tut,sep as rut}from"path";var Ci={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},bY={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:Ci.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(bY);var pxe="READDIRP_RECURSIVE_ERROR",nut=new Set(["ENOENT","EPERM","EACCES","ELOOP",pxe]),uxe=[Ci.DIR_TYPE,Ci.EVERYTHING_TYPE,Ci.FILE_DIR_TYPE,Ci.FILE_TYPE],iut=new Set([Ci.DIR_TYPE,Ci.EVERYTHING_TYPE,Ci.FILE_DIR_TYPE]),out=new Set([Ci.EVERYTHING_TYPE,Ci.FILE_DIR_TYPE,Ci.FILE_TYPE]),sut=t=>nut.has(t.code),aut=process.platform==="win32",dxe=t=>!0,fxe=t=>{if(t===void 0)return dxe;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 dxe},TY=class extends Qlt{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...bY,...e},{root:n,type:i}=r;this._fileFilter=fxe(r.fileFilter),this._directoryFilter=fxe(r.directoryFilter);let o=r.lstat?cxe:Zlt;aut?this._stat=s=>o(s,{bigint:!0}):this._stat=o,this._maxDepth=r.depth??bY.depth,this._wantsDir=i?iut.has(i):!1,this._wantsFile=i?out.has(i):!1,this._wantsEverything=i===Ci.EVERYTHING_TYPE,this._root=lxe(n),this._isDirent=!r.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let r=this.parent,n=r&&r.files;if(n&&n.length>0){let{path:i,depth:o}=r,s=n.splice(0,e).map(c=>this._formatEntry(c,i)),a=await Promise.all(s);for(let c of a){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(o<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,o+1)),this._wantsDir&&(this.push(c),e--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let i=this.parents.pop();if(!i){this.push(null);break}if(this.parent=await i,this.destroyed)return}}}catch(r){this.destroy(r)}finally{this.reading=!1}}}async _exploreDir(e,r){let n;try{n=await Jlt(e,this._rdOptions)}catch(i){this._onError(i)}return{files:n,depth:r,path:e}}async _formatEntry(e,r){let n,i=this._isDirent?e.name:e;try{let o=lxe(tut(r,i));n={path:eut(this._root,o),fullPath:o,basename:i},n[this._statsProp]=this._isDirent?e:await this._stat(o)}catch(o){this._onError(o);return}return n}_onError(e){sut(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let r=e[this._statsProp];if(r.isFile())return"file";if(r.isDirectory())return"directory";if(r&&r.isSymbolicLink()){let n=e.fullPath;try{let i=await Xlt(n),o=await cxe(i);if(o.isFile())return"file";if(o.isDirectory()){let s=i.length;if(n.startsWith(i)&&n.substr(s,1)===rut){let a=new Error(`Circular symlink detected: "${n}" points to "${i}"`);return a.code=pxe,this._onError(a)}return"directory"}}catch(i){return this._onError(i),""}}}_includeAsFile(e){let r=e&&e[this._statsProp];return r&&this._wantsEverything&&!r.isDirectory()}};function cut(t,e={}){let r=e.entryType||e.type;if(r==="both"&&(r=Ci.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&&!uxe.includes(r))throw new Error(`readdirp: Invalid type passed. Use one of ${uxe.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new TY(e)}function hxe(t,e={}){return new Promise((r,n)=>{let i=[];cut(t,e).on("data",o=>i.push(o)).on("end",()=>r(i)).on("error",o=>n(o))})}import{mkdir as vut,readFile as vxe,rm as but,writeFile as Tut}from"fs/promises";import{existsSync as bxe}from"fs";import{dirname as wut}from"path";var mxe=t=>{if(!(!Number.isInteger(t)||t<1))return Date.now()+t*1e3},gxe=t=>t!==void 0&&Date.now()>t;import{createHash as _ut}from"crypto";import{createReadStream as yut}from"fs";import dut from"process";import fut from"path";import Vlr,{promises as _xe}from"fs";import{fileURLToPath as put}from"url";var wY=class{value;next;constructor(e){this.value=e}},Wb=class{#e;#r;#t;constructor(){this.clear()}enqueue(e){let r=new wY(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 UN(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 Wb,r=0,n=()=>{r--,e.size>0&&e.dequeue()()},i=async(a,c,l)=>{r++;let u=(async()=>a(...l))();c(u);try{await u}catch{}n()},o=(a,c,l)=>{e.enqueue(i.bind(void 0,a,c,l)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.dequeue()()))()},s=(a,...c)=>new Promise(l=>{o(a,l,c)});return Object.defineProperties(s,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),s}var FN=class extends Error{constructor(e){super(),this.value=e}},lut=async(t,e)=>e(await t),uut=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new FN(e[0]);return!1};async function xY(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let i=UN(r),o=[...t].map(a=>[a,i(lut,a,e)]),s=UN(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(o.map(a=>s(uut,a)))}catch(a){if(a instanceof FN)return a.value;throw a}}var yxe={directory:"isDirectory",file:"isFile"};function hut(t){if(!Object.hasOwnProperty.call(yxe,t))throw new Error(`Invalid type specified: ${t}`)}var mut=(t,e)=>e[yxe[t]](),gut=t=>t instanceof URL?put(t):t;async function Sxe(t,{cwd:e=dut.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:i,preserveOrder:o}={}){hut(r),e=gut(e);let s=n?_xe.stat:_xe.lstat;return xY(t,async a=>{try{let c=await s(fut.resolve(e,a));return mut(r,c)}catch{return!1}},{concurrency:i,preserveOrder:o})}var Sut="sha1",Exe=async function(t,e){if(e||t.length===0)return;let r=await Sxe(t);return r===void 0?void 0:await Eut(r)},Eut=async function(t){let e=yut(t,"utf8"),r=_ut(Sut,{encoding:"hex"});return e.pipe(r),await oh(r)};var Txe=async function({cachePath:t,move:e,ttl:r,digests:n}){let i=zN(t),o=mxe(r),s=await Exe(n,e),c=`${JSON.stringify({expires:o,hash:s},null,2)}
|
|
621
|
-
`,l=await xut({hash:s,manifestPath:i,manifestString:c});return{manifestInfo:{manifestPath:i,manifestString:c},identical:l}},xut=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!bxe(e)?!1:await vxe(e,"utf8")===r},wxe=async function({manifestPath:t,manifestString:e}){await vut(wut(t),{recursive:!0}),await Tut(t,e)},xxe=async function(t){let e=zN(t);await but(e,{force:!0,recursive:!0,maxRetries:3})},zN=function(t){return`${t}${Rxe}`},Axe=function(t){return t.endsWith(Rxe)},Rxe=".netlify.cache.json",AY=async function(t){let e=zN(t);if(!bxe(e))return!1;let{expires:r}=await Aut(t);return gxe(r)},Aut=async function(t){let e=zN(t),r=await vxe(e,"utf-8");return JSON.parse(r)};import{homedir as Out}from"os";import{resolve as Cxe,isAbsolute as Nut,join as kut,sep as CY}from"path";import{normalize as Rut}from"path";import{existsSync as Cut}from"fs";import Put from"process";var RY=function(t){try{let e=Iut(t);return Cut(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},Iut=function(t=Put.cwd()){return Rut(t)};var Yb=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await Mut(t,r),i=await Uut({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:i}},Mut=async function(t,e){let r=await RY(e),n=$ut(t,r);return Dut(n,r),n},$ut=function(t,e){if(Nut(t))return Cxe(t);if(e!=="")return Cxe(e,t);throw new Error(`Current directory does not exist: ${e}`)},Dut=function(t,e){if(e!==""&&Lut(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},Lut=function(t,e){return`${e}${CY}`.startsWith(`${t}${CY}`)},Uut=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=_f({cacheDir:e,cwd:r}),{name:i,relPath:o}=await Fut(t,r);return kut(n,i,o)},Fut=async function(t,e){let r=await PY(e),n=zut(t);return r.map(({name:i,base:o})=>But(i,o,n)).find(Boolean)},zut=function(t){return t.replace(jut,"\\")},jut=/^[a-zA-Z]:\\/,But=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},PY=async function(t){return[...await qut(t),{name:"home",base:Out()},{name:"root",base:CY}]},qut=async function(t){let e=await RY(t);return e===""?[]:[{name:"cwd",base:e}]};var Gut=1,IY=async function({cacheDir:t,cwd:e,depth:r=Gut}={}){let n=await PY(e),i=_f({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>Hut({name:a,base:c,cacheDir:i,depth:r})))).flat()},Hut=async function({name:t,base:e,cacheDir:r,depth:n}){return(await hxe(`${r}/${t}`,{fileFilter:Wut,depth:n,type:"files_directories"})).map(({path:s})=>Vut(e,s))},Wut=function({basename:t}){return!Axe(t)};var Yut=async function(t,{move:e=Pxe,ttl:r=Xut,digests:n=[],cacheDir:i,cwd:o}={}){let{srcPath:s,cachePath:a}=await Yb({path:t,cacheDir:i,cwdOpt:o});if(!await Hb(s))return!1;let{manifestInfo:c,identical:l}=await Txe({cachePath:a,move:e,ttl:r,digests:n});return l||(await OY(a,{force:!0,recursive:!0,maxRetries:3}),await vY(s,a,e),await wxe(c)),!0},Kut=async function(t,{move:e=Pxe,cacheDir:r,cwd:n}={}){let{srcPath:i,cachePath:o}=await Yb({path:t,cacheDir:r,cwdOpt:n});return!await Hb(o)||await AY(o)?!1:(await OY(i,{force:!0,recursive:!0,maxRetries:3}),await vY(o,i,e),!0)},Zut=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Yb({path:t,cacheDir:e,cwdOpt:r});return await Hb(n)?(await OY(n,{force:!0,recursive:!0,maxRetries:3}),await xxe(n),!0):!1},Jut=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Yb({path:t,cacheDir:e,cwdOpt:r});return await Hb(n)&&!await AY(n)},Pxe=!1,Xut=void 0,jN=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(i=>t(i,...r)))).some(Boolean):t(e,...r)},Qut=jN.bind(null,Yut),edt=jN.bind(null,Kut),tdt=jN.bind(null,Zut),rdt=jN.bind(null,Jut),Ixe=function(t){return{save:(e,r)=>Qut(e,{...t,...r}),restore:(e,r)=>edt(e,{...t,...r}),remove:(e,r)=>tdt(e,{...t,...r}),has:(e,r)=>rdt(e,{...t,...r}),list:e=>IY({...t,...e}),getCacheDir:e=>_f({...t,...e})}};var ndt=ce("opencode_session"),idt=async t=>{try{let e=await iO(t),{stdout:r}=await Wr(e,["session","list","--format","json"],{cwd:t,env:{...process.env,OPENCODE_DISABLE_AUTOUPDATE:"1"}}),n=String(r??"").trim();if(!n)return[];let i=JSON.parse(n);return Array.isArray(i)?i:[]}catch(e){return ndt.warn("Could not list opencode sessions",{error:e?.message}),[]}},NY=new Map,Oxe=t=>{let e=NY.get(t);if(e)return e;let r=idt(t).finally(()=>NY.delete(t));return NY.set(t,r),r},Nxe=async t=>(await Oxe(t)).length>0,kxe=async(t,e)=>e?(await Oxe(t)).some(r=>r.id===e):!1;var Dr=ce("native_session"),kY=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await hc.stat(mc.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),wf=async({runnerId:t,sessionId:e,archive:r,nativeSessionId:n})=>{if(!r)return Dr.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:i,include:o}=r,s=!1;try{s=(await hc.stat(i)).isDirectory()}catch{}if(!s)return Dr.log(`Native session base dir ${i} not found, skipping`),null;let a=await kY(i,o);if(a.length===0)return Dr.log(`No native session history found under ${i}, skipping`),null;let c=mc.join(Mxe.tmpdir(),`native-session-${e}.zip`);try{await Wr("zip",["-r","-q","-X",c,...a],{cwd:i});let l=await hc.readFile(c);Dr.log(`Zipped native session (${l.length} bytes) from ${a.join(", ")}`,{nativeSessionId:n});let{upload_url:u,s3_key:d}=await Vie(t,e);return await Xie(u,l,{contentType:"application/zip"}),Dr.log("Successfully uploaded native session to S3"),d}catch(l){return Dr.error("Failed to archive/upload native session, continuing without it:",l),null}finally{await hc.rm(c,{force:!0}).catch(()=>{})}},$xe=async(t,e,r=process.cwd())=>{if(e==="opencode")return Nxe(r);if(!t)return!1;let{baseDir:n,include:i}=t,o=await kY(n,i);for(let s of o)if((await hc.readdir(mc.join(n,s)).catch(()=>[])).length>0)return!0;return!1},odt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Dxe=async(t,e)=>{let r=await hc.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await Dxe(mc.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},Lxe=async(t,e,r,n=process.cwd())=>{if(r==="opencode")return kxe(n,e);if(!t||!e)return!1;let i=new RegExp(`(^|[^a-zA-Z0-9])${odt(e)}([^a-zA-Z0-9]|$)`),{baseDir:o,include:s}=t,a=await kY(o,s);for(let c of a)if(await Dxe(mc.join(o,c),i))return!0;return!1},Uxe=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return Dr.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,i=mc.join(Mxe.tmpdir(),`native-session-restore-${e}.zip`);try{let o=await Gie(t,e);if(!o?.download_url)return Dr.log("No native session available to restore, skipping"),!1;let s=await Jie(o.download_url);return await hc.writeFile(i,s),Dr.log(`Downloaded native session (${s.length} bytes) to ${i}`),await hc.mkdir(n,{recursive:!0}),await Wr("unzip",["-o","-q",i,"-d",n]),Dr.log(`Restored native session into ${n}`),!0}catch(o){return Dr.error("Failed to fetch/restore native session, continuing without it:",o),!1}finally{await hc.rm(i,{force:!0}).catch(()=>{})}},sdt="native-sessions",Fxe=(t,e)=>Ixe({cacheDir:mc.join(e.dir,sdt),cwd:t}),zxe=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await Fxe(r,e).restore(n.map(o=>mc.join(r,o)),{})?(Dr.log(`Restored native session from buildbot cache into ${r}`),!0):(Dr.log("No native session in buildbot cache, skipping restore"),!1)}catch(i){return Dr.error("Failed to restore native session from buildbot cache, continuing without it:",i),!1}},Kb=async({archive:t,cache:e,nativeSessionId:r})=>{if(!e?.dir||!t)return Dr.log("No buildbot cache configured for the native session, skipping cache seed",{nativeSessionId:r}),!1;let{baseDir:n,include:i}=t;try{return await Fxe(n,e).save(i.map(s=>mc.join(n,s)),{})?(Dr.log(`Saved native session to buildbot cache under ${e.dir}`,{nativeSessionId:r}),!0):(Dr.log("No native session history to save to buildbot cache, skipping"),!1)}catch(o){return Dr.error("Failed to save native session to buildbot cache, continuing:",o),!1}};var h_=ce("inference_stage"),jxe=5,lu=async t=>{let{additionalContext:e,cliPath:r,config:n,context:i,buildErrors:o,runner:s,persistSteps:a,aiGateway:c,attempt:l,contextPrefix:u,priorAgentSessionId:d,cwd:f,abortSignal:p,onSessionId:h,resumeForCreditWrapUp:m,forceLowEffortForCreditWrapUp:g,answerFold:_}=t;if(ws())throw new Error("Shutdown in progress, aborting inference stage");h_.log(`Running inference stage, attempt ${l} of ${jxe}`);let b=!1,T=await $t(dt(),"inference-stage",async v=>{v?.setAttributes({"inference.attempt":l||1}),Eie();let x=!!(l&&l>1),I=await adt(n,x,f),N=!!m&&!!d;N&&n.runner==="gemini"&&!await Nv(d)&&(N=!1);let O=I.viable||N;b=O,I.outcome!=="not_eligible"&&re.inc("inference.native_resume",1,{outcome:I.outcome,...I.source?{source:I.source}:{}});let $=n;if("prompt"in n&&n.answeredInteraction&&Ve().questionsEnabled){let w=n.answeredInteraction,P=O||x&&!!d,W=[w];if(!P){_.allAnswered??=xEe(n);let H=await _.allAnswered;H===null&&(_.allAnswered=void 0),H&&H.length>0&&(W=H.some(me=>me.refId===w.refId)?H:[...H,w])}$={...n,prompt:CEe(n.prompt,W)},!x&&!_.counted&&(_.counted=!0,h_.log("Resuming session with answered questions",{sessionId:n.sessionId,interactionCount:W.length}),re.inc("inference.answer_resume",1,{fold:P?"latest":"all"}),REe(w))}let{prompt:z}=await $t(dt(),"compose-prompt",async()=>await fEe({cliPath:r,config:$,buildErrorContext:cdt(o),netlify:i,additionalContext:e,resumePrompt:O,preserveResultsFile:!!m})),E=`
|
|
621
|
+
`,l=await xut({hash:s,manifestPath:i,manifestString:c});return{manifestInfo:{manifestPath:i,manifestString:c},identical:l}},xut=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!bxe(e)?!1:await vxe(e,"utf8")===r},wxe=async function({manifestPath:t,manifestString:e}){await vut(wut(t),{recursive:!0}),await Tut(t,e)},xxe=async function(t){let e=zN(t);await but(e,{force:!0,recursive:!0,maxRetries:3})},zN=function(t){return`${t}${Rxe}`},Axe=function(t){return t.endsWith(Rxe)},Rxe=".netlify.cache.json",AY=async function(t){let e=zN(t);if(!bxe(e))return!1;let{expires:r}=await Aut(t);return gxe(r)},Aut=async function(t){let e=zN(t),r=await vxe(e,"utf-8");return JSON.parse(r)};import{homedir as Out}from"os";import{resolve as Cxe,isAbsolute as Nut,join as kut,sep as CY}from"path";import{normalize as Rut}from"path";import{existsSync as Cut}from"fs";import Put from"process";var RY=function(t){try{let e=Iut(t);return Cut(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},Iut=function(t=Put.cwd()){return Rut(t)};var Yb=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await Mut(t,r),i=await Uut({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:i}},Mut=async function(t,e){let r=await RY(e),n=$ut(t,r);return Dut(n,r),n},$ut=function(t,e){if(Nut(t))return Cxe(t);if(e!=="")return Cxe(e,t);throw new Error(`Current directory does not exist: ${e}`)},Dut=function(t,e){if(e!==""&&Lut(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},Lut=function(t,e){return`${e}${CY}`.startsWith(`${t}${CY}`)},Uut=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=_f({cacheDir:e,cwd:r}),{name:i,relPath:o}=await Fut(t,r);return kut(n,i,o)},Fut=async function(t,e){let r=await PY(e),n=zut(t);return r.map(({name:i,base:o})=>But(i,o,n)).find(Boolean)},zut=function(t){return t.replace(jut,"\\")},jut=/^[a-zA-Z]:\\/,But=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},PY=async function(t){return[...await qut(t),{name:"home",base:Out()},{name:"root",base:CY}]},qut=async function(t){let e=await RY(t);return e===""?[]:[{name:"cwd",base:e}]};var Gut=1,IY=async function({cacheDir:t,cwd:e,depth:r=Gut}={}){let n=await PY(e),i=_f({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>Hut({name:a,base:c,cacheDir:i,depth:r})))).flat()},Hut=async function({name:t,base:e,cacheDir:r,depth:n}){return(await hxe(`${r}/${t}`,{fileFilter:Wut,depth:n,type:"files_directories"})).map(({path:s})=>Vut(e,s))},Wut=function({basename:t}){return!Axe(t)};var Yut=async function(t,{move:e=Pxe,ttl:r=Xut,digests:n=[],cacheDir:i,cwd:o}={}){let{srcPath:s,cachePath:a}=await Yb({path:t,cacheDir:i,cwdOpt:o});if(!await Hb(s))return!1;let{manifestInfo:c,identical:l}=await Txe({cachePath:a,move:e,ttl:r,digests:n});return l||(await OY(a,{force:!0,recursive:!0,maxRetries:3}),await vY(s,a,e),await wxe(c)),!0},Kut=async function(t,{move:e=Pxe,cacheDir:r,cwd:n}={}){let{srcPath:i,cachePath:o}=await Yb({path:t,cacheDir:r,cwdOpt:n});return!await Hb(o)||await AY(o)?!1:(await OY(i,{force:!0,recursive:!0,maxRetries:3}),await vY(o,i,e),!0)},Zut=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Yb({path:t,cacheDir:e,cwdOpt:r});return await Hb(n)?(await OY(n,{force:!0,recursive:!0,maxRetries:3}),await xxe(n),!0):!1},Jut=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Yb({path:t,cacheDir:e,cwdOpt:r});return await Hb(n)&&!await AY(n)},Pxe=!1,Xut=void 0,jN=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(i=>t(i,...r)))).some(Boolean):t(e,...r)},Qut=jN.bind(null,Yut),edt=jN.bind(null,Kut),tdt=jN.bind(null,Zut),rdt=jN.bind(null,Jut),Ixe=function(t){return{save:(e,r)=>Qut(e,{...t,...r}),restore:(e,r)=>edt(e,{...t,...r}),remove:(e,r)=>tdt(e,{...t,...r}),has:(e,r)=>rdt(e,{...t,...r}),list:e=>IY({...t,...e}),getCacheDir:e=>_f({...t,...e})}};var ndt=ce("opencode_session"),idt=async t=>{try{let e=await iO(t),{stdout:r}=await Wr(e,["session","list","--format","json"],{cwd:t,env:{...process.env,OPENCODE_DISABLE_AUTOUPDATE:"1"}}),n=String(r??"").trim();if(!n)return[];let i=JSON.parse(n);return Array.isArray(i)?i:[]}catch(e){return ndt.warn("Could not list opencode sessions",{error:e?.message}),[]}},NY=new Map,Oxe=t=>{let e=NY.get(t);if(e)return e;let r=idt(t).finally(()=>NY.delete(t));return NY.set(t,r),r},Nxe=async t=>(await Oxe(t)).length>0,kxe=async(t,e)=>e?(await Oxe(t)).some(r=>r.id===e):!1;var Dr=ce("native_session"),kY=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await hc.stat(mc.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),wf=async({runnerId:t,sessionId:e,archive:r,nativeSessionId:n})=>{if(!r)return Dr.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:i,include:o}=r,s=!1;try{s=(await hc.stat(i)).isDirectory()}catch{}if(!s)return Dr.log(`Native session base dir ${i} not found, skipping`),null;let a=await kY(i,o);if(a.length===0)return Dr.log(`No native session history found under ${i}, skipping`),null;let c=mc.join(Mxe.tmpdir(),`native-session-${e}.zip`);try{await Wr("zip",["-r","-q","-X",c,...a],{cwd:i});let l=await hc.readFile(c);Dr.log(`Zipped native session (${l.length} bytes) from ${a.join(", ")}`,{nativeSessionId:n});let{upload_url:u,s3_key:d}=await Vie(t,e);return await Xie(u,l,{contentType:"application/zip"}),Dr.log("Successfully uploaded native session to S3"),d}catch(l){return Dr.error("Failed to archive/upload native session, continuing without it:",l),null}finally{await hc.rm(c,{force:!0}).catch(()=>{})}},$xe=async(t,e,r=process.cwd())=>{if(e==="opencode")return Nxe(r);if(!t)return!1;let{baseDir:n,include:i}=t,o=await kY(n,i);for(let s of o)if((await hc.readdir(mc.join(n,s)).catch(()=>[])).length>0)return!0;return!1},odt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Dxe=async(t,e)=>{let r=await hc.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await Dxe(mc.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},Lxe=async(t,e,r,n=process.cwd())=>{if(r==="opencode")return kxe(n,e);if(!t||!e)return!1;let i=new RegExp(`(^|[^a-zA-Z0-9])${odt(e)}([^a-zA-Z0-9]|$)`),{baseDir:o,include:s}=t,a=await kY(o,s);for(let c of a)if(await Dxe(mc.join(o,c),i))return!0;return!1},Uxe=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return Dr.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,i=mc.join(Mxe.tmpdir(),`native-session-restore-${e}.zip`);try{let o=await Gie(t,e);if(!o?.download_url)return Dr.log("No native session available to restore, skipping"),!1;let s=await Jie(o.download_url);return await hc.writeFile(i,s),Dr.log(`Downloaded native session (${s.length} bytes) to ${i}`),await hc.mkdir(n,{recursive:!0}),await Wr("unzip",["-o","-q",i,"-d",n]),Dr.log(`Restored native session into ${n}`),!0}catch(o){return Dr.error("Failed to fetch/restore native session, continuing without it:",o),!1}finally{await hc.rm(i,{force:!0}).catch(()=>{})}},sdt="native-sessions",Fxe=(t,e)=>Ixe({cacheDir:mc.join(e.dir,sdt),cwd:t}),zxe=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await Fxe(r,e).restore(n.map(o=>mc.join(r,o)),{})?(Dr.log(`Restored native session from buildbot cache into ${r}`),!0):(Dr.log("No native session in buildbot cache, skipping restore"),!1)}catch(i){return Dr.error("Failed to restore native session from buildbot cache, continuing without it:",i),!1}},Kb=async({archive:t,cache:e,nativeSessionId:r})=>{if(!e?.dir||!t)return Dr.log("No buildbot cache configured for the native session, skipping cache seed",{nativeSessionId:r}),!1;let{baseDir:n,include:i}=t;try{return await Fxe(n,e).save(i.map(s=>mc.join(n,s)),{})?(Dr.log(`Saved native session to buildbot cache under ${e.dir}`,{nativeSessionId:r}),!0):(Dr.log("No native session history to save to buildbot cache, skipping"),!1)}catch(o){return Dr.error("Failed to save native session to buildbot cache, continuing:",o),!1}};var h_=ce("inference_stage"),jxe=5,lu=async t=>{let{additionalContext:e,cliPath:r,config:n,context:i,buildErrors:o,runner:s,persistSteps:a,aiGateway:c,attempt:l,contextPrefix:u,priorAgentSessionId:d,cwd:f,abortSignal:p,onSessionId:h,resumeForCreditWrapUp:m,forceLowEffortForCreditWrapUp:g,answerFold:_}=t;if(ws())throw new Error("Shutdown in progress, aborting inference stage");h_.log(`Running inference stage, attempt ${l} of ${jxe}`);let b=!1,T=await $t(dt(),"inference-stage",async v=>{v?.setAttributes({"inference.attempt":l||1}),Eie();let x=!!(l&&l>1),I=await adt({config:n,isRetry:x,cwd:f,resumeForCreditWrapUp:m}),N=!!m&&!!d;N&&n.runner==="gemini"&&!await Nv(d)&&(N=!1);let O=I.viable||N;b=O,I.outcome!=="not_eligible"&&re.inc("inference.native_resume",1,{outcome:I.outcome,...I.source?{source:I.source}:{}});let $=n;if("prompt"in n&&n.answeredInteraction&&Ve().questionsEnabled){let w=n.answeredInteraction,P=O||x&&!!d,W=[w];if(!P){_.allAnswered??=xEe(n);let H=await _.allAnswered;H===null&&(_.allAnswered=void 0),H&&H.length>0&&(W=H.some(me=>me.refId===w.refId)?H:[...H,w])}$={...n,prompt:CEe(n.prompt,W)},!x&&!_.counted&&(_.counted=!0,h_.log("Resuming session with answered questions",{sessionId:n.sessionId,interactionCount:W.length}),re.inc("inference.answer_resume",1,{fold:P?"latest":"all"}),REe(w))}let{prompt:z}=await $t(dt(),"compose-prompt",async()=>await fEe({cliPath:r,config:$,buildErrorContext:cdt(o),netlify:i,additionalContext:e,resumePrompt:O,preserveResultsFile:!!m})),E=`
|
|
622
622
|
${u||""}
|
|
623
623
|
${z}
|
|
624
|
-
`.trim(),ee={...n,prompt:E},M=d??(O?I.sessionId:void 0),S=await $t(dt(),`run-${n.runner}`,async w=>{let P=ZU();w?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":Cie(n.runner),"gen_ai.system":n.runner,...P?{"gen_ai.input.messages":MR("user",E)}:{}});let W=Date.now(),H=await s({aiGateway:c,config:ee,netlify:i,persistSteps:a,continueSession:x||O,priorAgentSessionId:M,cwd:f,cliPath:r,abortSignal:p,onSessionId:h,...g?{forceLowEffortForCreditWrapUp:g}:{}}),me=Date.now(),Le=H.resolvedModel||n.model||"unknown",ke=H.error?"error":"stop";return w?.setAttributes({...P?{"gen_ai.output.messages":MR("assistant",H.result??H.error??"",ke)}:{},"gen_ai.response.finish_reasons":[ke],"gen_ai.request.model":Le,"gen_ai.response.model":Le,"gen_ai.request.effort":H.effort??"auto",...H.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":H.usage.input_tokens}:{},...H.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":H.usage.output_tokens}:{},...H.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":H.usage.cache_creation_input_tokens}:{},...H.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":H.usage.cache_read_input_tokens}:{},...H.usage?.reasoning_output_tokens!=null?{"gen_ai.usage.reasoning.output_tokens":H.usage.reasoning_output_tokens}:{}}),Pie(H.steps??[],n.mode,W,me),H});return S.result&&(S.result=Wn(S.result)),S.error&&(S.error=Wn(S.error)),await a.flush(),S});if(T.aborted)return h_.log("Inference turn was interrupted (credit wrap-up); skipping retry/error handling",{agentSessionId:T.agentSessionId}),{runnerResult:T,nativeResume:b};if(T.error){if(ws()){let N=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(N,{agentSessionId:T.agentSessionId}),N}let v=T.providerFailure,x=bI(v);h_.error("Runner failed",{stepsCount:T.steps.length,duration:T.duration,error:T.error,isRetryableError:T.isRetryableError,attempt:l||1,agentSessionId:T.agentSessionId,...v?{providerFailure:v,failureClass:x?.failureClass}:{}}),re.inc("inference.failed",1,{attempt:l||1,is_retryable:!!T.isRetryableError,is_provider_unavailable:!!T.isProviderUnavailableError,is_answer_resume:!!n.answeredInteraction,upstream_status:v?.status??"none",failure_class:x?.failureClass??"unclassified"});let I=x?.maxAttempts??jxe;if(T.isRetryableError&&(!l||l<I))return h_.log("Retrying inference stage"),await new Promise(O=>setTimeout(O,5e3)),{runnerResult:(await lu({...t,attempt:(l||1)+1,priorAgentSessionId:T.agentSessionId,contextPrefix:T.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:b};{if(h_.log("Do not retry inference stage"),T.error.toLowerCase().includes("usage exceeded")){let O=new Ro(T.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);throw Object.assign(O,{agentSessionId:T.agentSessionId}),O}let N=T.isRetryableError||T.isProviderUnavailableError?new Wp(T.error):new Error(T.error);throw Object.assign(N,{agentSessionId:T.agentSessionId}),N}}return{runnerResult:T,nativeResume:b}},adt=async(t,e,r=process.cwd())=>{if(e)return{viable:!1,outcome:"not_eligible"};let
|
|
624
|
+
`.trim(),ee={...n,prompt:E},M=d??(O?I.sessionId:void 0),S=await $t(dt(),`run-${n.runner}`,async w=>{let P=ZU();w?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":Cie(n.runner),"gen_ai.system":n.runner,...P?{"gen_ai.input.messages":MR("user",E)}:{}});let W=Date.now(),H=await s({aiGateway:c,config:ee,netlify:i,persistSteps:a,continueSession:x||O,priorAgentSessionId:M,cwd:f,cliPath:r,abortSignal:p,onSessionId:h,...g?{forceLowEffortForCreditWrapUp:g}:{}}),me=Date.now(),Le=H.resolvedModel||n.model||"unknown",ke=H.error?"error":"stop";return w?.setAttributes({...P?{"gen_ai.output.messages":MR("assistant",H.result??H.error??"",ke)}:{},"gen_ai.response.finish_reasons":[ke],"gen_ai.request.model":Le,"gen_ai.response.model":Le,"gen_ai.request.effort":H.effort??"auto",...H.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":H.usage.input_tokens}:{},...H.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":H.usage.output_tokens}:{},...H.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":H.usage.cache_creation_input_tokens}:{},...H.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":H.usage.cache_read_input_tokens}:{},...H.usage?.reasoning_output_tokens!=null?{"gen_ai.usage.reasoning.output_tokens":H.usage.reasoning_output_tokens}:{}}),Pie(H.steps??[],n.mode,W,me),H});return S.result&&(S.result=Wn(S.result)),S.error&&(S.error=Wn(S.error)),await a.flush(),S});if(T.aborted)return h_.log("Inference turn was interrupted (credit wrap-up); skipping retry/error handling",{agentSessionId:T.agentSessionId}),{runnerResult:T,nativeResume:b};if(T.error){if(ws()){let N=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(N,{agentSessionId:T.agentSessionId}),N}let v=T.providerFailure,x=bI(v);h_.error("Runner failed",{stepsCount:T.steps.length,duration:T.duration,error:T.error,isRetryableError:T.isRetryableError,attempt:l||1,agentSessionId:T.agentSessionId,...v?{providerFailure:v,failureClass:x?.failureClass}:{}}),re.inc("inference.failed",1,{attempt:l||1,is_retryable:!!T.isRetryableError,is_provider_unavailable:!!T.isProviderUnavailableError,is_answer_resume:!!n.answeredInteraction,upstream_status:v?.status??"none",failure_class:x?.failureClass??"unclassified"});let I=x?.maxAttempts??jxe;if(T.isRetryableError&&(!l||l<I))return h_.log("Retrying inference stage"),await new Promise(O=>setTimeout(O,5e3)),{runnerResult:(await lu({...t,attempt:(l||1)+1,priorAgentSessionId:T.agentSessionId,contextPrefix:T.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:b};{if(h_.log("Do not retry inference stage"),T.error.toLowerCase().includes("usage exceeded")){let O=new Ro(T.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);throw Object.assign(O,{agentSessionId:T.agentSessionId}),O}let N=T.isRetryableError||T.isProviderUnavailableError?new Wp(T.error):new Error(T.error);throw Object.assign(N,{agentSessionId:T.agentSessionId}),N}}return{runnerResult:T,nativeResume:b}},adt=async({config:t,isRetry:e,cwd:r=process.cwd(),resumeForCreditWrapUp:n})=>{if(e||n)return{viable:!1,outcome:"not_eligible"};let i=t.previousSession,{viable:o,outcome:s}=EEe(t);if(!o)return{viable:o,outcome:s};let a=i?.nativeSessionId,c=Bs(t.runner),l=async()=>a?t.runner==="gemini"?!!await wG(a):Lxe(c,a,t.runner,r):!1,u;if(yEe(t)&&await $xe(c,t.runner,r))u="local";else if(t.fastInit&&Ve().warmNativeResumeEnabled&&await zxe({archive:c,cache:t.cache})&&await l())u="cache_restore";else{if(u="fetch",!Ve().coldResumeFromS3Enabled)return{viable:!1,outcome:"cold_resume_disabled",source:u};if(!await Uxe({runnerId:t.id,sessionId:t.sessionId,archive:c}))return{viable:!1,outcome:"fetch_failed",source:u}}return t.runner==="gemini"&&a&&!await Nv(a)?{viable:!1,outcome:"sanitize_failed",source:u}:{viable:!0,sessionId:a,outcome:"resumed",source:u}},cdt=t=>!t||t.length===0?"":`
|
|
625
625
|
Deploy failed. Here are the errors to review on the latest build:
|
|
626
626
|
|
|
627
627
|
Below are all of the logs with potential issues that we extracted. Some of them may be false positives, discern them carefully and ensure fixes are relevant.
|