@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/bin-local.js
CHANGED
|
@@ -140,7 +140,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
140
140
|
`,LF:`
|
|
141
141
|
`,concatBytes:rz},QVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},eGe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:QVe};import{Buffer as tGe}from"buffer";var Vce=(t,e)=>t?void 0:rGe.bind(void 0,e),rGe=function*(t,e){if(typeof e!="string"&&!yr(e)&&!tGe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Gce=(t,e)=>t?nGe.bind(void 0,e):iGe.bind(void 0,e),nGe=function*(t,e){Hce(t,e),yield e},iGe=function*(t,e){if(Hce(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},Hce=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
142
142
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
143
|
-
if (condition) { yield value; }`)};import{Buffer as oGe}from"buffer";import{StringDecoder as sGe}from"string_decoder";var j0=(t,e,r)=>{if(r)return;if(t)return{transform:aGe.bind(void 0,new TextEncoder)};let n=new sGe(e);return{transform:cGe.bind(void 0,n),final:lGe.bind(void 0,n)}},aGe=function*(t,e){oGe.isBuffer(e)?yield Na(e):typeof e=="string"?yield t.encode(e):yield e},cGe=function*(t,e){yield yr(e)?t.write(e):e},lGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Wce}from"util";var iz=Wce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),B0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=dGe}=e[r];for await(let i of n(t))yield*B0(i,e,r+1)},Yce=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*uGe(r,Number(e),t)},uGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*B0(n,r,e+1)},Kce=Wce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),dGe=function*(t){yield t};var oz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Zce=(t,e)=>[...e.flatMap(r=>[...ud(r,t,0)]),...WS(t)],ud=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=pGe}=e[r];for(let i of n(t))yield*ud(i,e,r+1)},WS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*fGe(r,Number(e),t)},fGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*ud(n,r,e+1)},pGe=function*(t){yield t};var sz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Xce(t,s,o),l=ld(e),u=ld(r),d=l?iz.bind(void 0,B0,a):oz.bind(void 0,ud),f=l||u?iz.bind(void 0,Yce,a):oz.bind(void 0,WS),p=l||u?Kce.bind(void 0,a):void 0;return{stream:new hGe({writableObjectMode:n,writableHighWaterMark:Jce(n),readableObjectMode:i,readableHighWaterMark:Jce(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},q0=(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=Xce(s,r,a);t=Zce(c,t)}return t},Xce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Vce(n,a)},j0(r,s,n),z0(r,o,n,c),{transform:t,final:e},{transform:Gce(i,a)},qce({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Qce=(t,e)=>{for(let r of mGe(t))gGe(t,r,e)},mGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),gGe=(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 ${tl[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>_Ge(a,n));r.input=LS(s)},_Ge=(t,e)=>{let r=q0(t,e,"utf8",!0);return yGe(r),LS(r)},yGe=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 bGe,appendFileSync as TGe}from"fs";var V0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&eh(r,n)&&!Si.has(e)&&SGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&EGe.has(o))||t.every(({type:i})=>Yi.has(i))),SGe=t=>t===1||t===2,EGe=new Set(["pipe","overlapped"]),ele=async(t,e,r,n)=>{for await(let i of t)vGe(e)||rle(i,r,n)},tle=(t,e,r)=>{for(let n of t)rle(n,e,r)},vGe=t=>t._readableState.pipes.length>0,rle=(t,e,r)=>{let n=i0(t);Ts({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var nle=({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)=>wGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},wGe=({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=ice(t,o,d),p=Na(f),{stdioItems:h,objectMode:m}=e[r],g=xGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=AGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});RGe({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&&CGe(_,h,i),T}catch(S){return n.error=S,T}},xGe=(t,e,r,n)=>{try{return q0(t,e,r,!1)}catch(i){return n.error=i,t}},AGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:LS(t)};let s=yoe(t,r);return n[o]?{serializedResult:s,finalResult:nz(s,!i[o],e)}:{serializedResult:s}},RGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!V0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=nz(t,!1,s);try{tle(a,e,n)}catch(c){r.error??=c}},CGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>U0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?TGe(n,t):(r.add(o),bGe(n,t))}};var ile=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,$a(e,r,"all")]:Array.isArray(e)?[$a(t,r,"all"),...e]:yr(t)&&yr(e)?fF([t,e]):`${t}${e}`};import{once as az}from"events";var ole=async(t,e)=>{let[r,n]=await PGe(t);return e.isForcefullyTerminated??=!1,[r,n]},PGe=async t=>{let[e,r]=await Promise.allSettled([az(t,"spawn"),az(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?sle(t):r.value},sle=async t=>{try{return await az(t,"exit")}catch{return sle(t)}},ale=async t=>{let[e,r]=await t;if(!IGe(e,r)&&cz(e,r))throw new ko;return[e,r]},IGe=(t,e)=>t===void 0&&e===void 0,cz=(t,e)=>t!==0||e!==null;var cle=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=OGe(t,e,r),s=o?.code==="ETIMEDOUT",a=nce(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},OGe=(t,e,r)=>t!==void 0?t:cz(e,r)?new ko:void 0;var lle=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=kGe(t,e,r),d=DGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return uh(d,c,l)},kGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=s0(t,e,r),a=MGe(r),{file:c,commandArguments:l,options:u}=A0(t,e,a);$Ge(u);let d=Fce(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},MGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,$Ge=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&G0("ipcInput"),t&&G0("ipc: true"),r&&G0("detached: true"),n&&G0("cancelSignal")},G0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},DGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=LGe({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}=cle(c,r),{output:h,error:m=l}=nle({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>$a(b,r,T)),_=$a(ile(h,r),r,"all");return FGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},LGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Qce(o,r);let a=UGe(r);return NGe(...R0(t,e,a))}catch(a){return lh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},UGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:M0(e)}),FGe=({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?$0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):HS({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 A6e}from"events";import{spawn as R6e}from"child_process";import hle from"process";import{once as lz,on as zGe}from"events";var ule=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(nh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:E0(t)}),jGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),jGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{g0(e,i);let o=el(t,e,r),s=new AbortController;try{return await Promise.race([BGe(o,n,s),qGe(o,r,s),VGe(o,r,s)])}catch(a){throw ih(t),a}finally{s.abort(),_0(e,i)}},BGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await lz(t,"message",{signal:r});return n}for await(let[n]of zGe(t,"message",{signal:r}))if(e(n))return n},qGe=async(t,e,{signal:r})=>{await lz(t,"disconnect",{signal:r}),Zse(e)},VGe=async(t,e,{signal:r})=>{let[n]=await lz(t,"strict:error",{signal:r});throw p0(n,e)};import{once as fle,on as GGe}from"events";var ple=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>uz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),uz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{nh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:E0(t)}),g0(e,o);let s=el(t,e,r),a=new AbortController,c={};return HGe(t,s,a),WGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),YGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},HGe=async(t,e,r)=>{try{await fle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},WGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await fle(t,"strict:error",{signal:r.signal});n.error=p0(i,e),r.abort()}catch{}},YGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of GGe(r,"message",{signal:o.signal}))dle(s),yield c}catch{dle(s)}finally{o.abort(),_0(e,a),n||ih(t),i&&await t}},dle=({error:t})=>{if(t)throw t};var mle=(t,{ipc:e})=>{Object.assign(t,_le(t,!1,e))},gle=()=>{let t=hle,e=!0,r=hle.channel!==void 0;return{..._le(t,e,r),getCancelSignal:Tae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},_le=(t,e,r)=>({sendMessage:w0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ule.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ple.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as KGe}from"child_process";import{PassThrough as ZGe,Readable as JGe,Writable as XGe,Duplex as QGe}from"stream";var yle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ez(n);let a=new KGe;eHe(a,n),Object.assign(a,{readable:tHe,writable:rHe,duplex:nHe});let c=lh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=iHe(c,s,i);return{subprocess:a,promise:l}},eHe=(t,e)=>{let r=YS(),n=YS(),i=YS(),o=Array.from({length:e.length-3},YS),s=YS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},YS=()=>{let t=new ZGe;return t.end(),t},tHe=()=>new JGe({read(){}}),rHe=()=>new XGe({write(){}}),nHe=()=>new QGe({read(){},write(){}}),iHe=async(t,e,r)=>uh(t,e,r);import{createReadStream as Sle,createWriteStream as Ele}from"fs";import{Buffer as oHe}from"buffer";import{Readable as KS,Writable as sHe,Duplex as aHe}from"stream";var ble=(t,e)=>F0(cHe,t,e,!1),ZS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${tl[t]}.`)},vle={fileNumber:ZS,generator:sz,asyncGenerator:sz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:aHe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},cHe={input:{...vle,fileUrl:({value:t})=>({stream:Sle(t)}),filePath:({value:{file:t}})=>({stream:Sle(t)}),webStream:({value:t})=>({stream:KS.fromWeb(t)}),iterable:({value:t})=>({stream:KS.from(t)}),asyncIterable:({value:t})=>({stream:KS.from(t)}),string:({value:t})=>({stream:KS.from(t)}),uint8Array:({value:t})=>({stream:KS.from(oHe.from(t))})},output:{...vle,fileUrl:({value:t})=>({stream:Ele(t)}),filePath:({value:{file:t,append:e}})=>({stream:Ele(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:sHe.fromWeb(t)}),iterable:ZS,asyncIterable:ZS,string:ZS,uint8Array:ZS}};import{on as lHe,once as Tle}from"events";import{PassThrough as uHe,getDefaultHighWaterMark as dHe}from"stream";import{finished as Ale}from"stream/promises";function dd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)fz(i);let e=t.some(({readableObjectMode:i})=>i),r=fHe(t,e),n=new dz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var fHe=(t,e)=>{if(t.length===0)return dHe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},dz=class extends uHe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(fz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=pHe(this,this.#e,this.#o);let r=gHe({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(fz(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)}},pHe=async(t,e,r)=>{H0(t,wle);let n=new AbortController;try{await Promise.race([hHe(t,n),mHe(t,e,r,n)])}finally{n.abort(),H0(t,-wle)}},hHe=async(t,{signal:e})=>{try{await Ale(t,{signal:e,cleanup:!0})}catch(r){throw Rle(t,r),r}},mHe=async(t,e,r,{signal:n})=>{for await(let[i]of lHe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},fz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},gHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{H0(t,xle);let a=new AbortController;try{await Promise.race([_He(o,e,a),yHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),SHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),H0(t,-xle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?pz(t):EHe(t))},_He=async(t,e,{signal:r})=>{try{await t,r.aborted||pz(e)}catch(n){r.aborted||Rle(e,n)}},yHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Ale(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Cle(s)?i.add(e):Ple(t,s)}},SHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Tle(t,i,{signal:o}),!t.readable)return Tle(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},EHe=t=>{t.writable&&t.end()},Rle=(t,e)=>{Cle(e)?pz(t):Ple(t,e)},Cle=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",pz=t=>{(t.readable||t.writable)&&t.destroy()},Ple=(t,e)=>{t.destroyed||(t.once("error",vHe),t.destroy(e))},vHe=()=>{},H0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},wle=2,xle=1;import{finished as Ile}from"stream/promises";var fh=(t,e)=>{t.pipe(e),bHe(t,e),THe(t,e)},bHe=async(t,e)=>{if(!(No(t)||No(e))){try{await Ile(t,{cleanup:!0,readable:!0,writable:!1})}catch{}hz(e)}},hz=t=>{t.writable&&t.end()},THe=async(t,e)=>{if(!(No(t)||No(e))){try{await Ile(e,{cleanup:!0,readable:!1,writable:!0})}catch{}mz(t)}},mz=t=>{t.readable&&t.destroy()};var Ole=(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})=>Yi.has(c)))wHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yi.has(c)))AHe({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]:dd(o);fh(s,i)}},wHe=(t,e,r,n)=>{r==="output"?fh(t.stdio[n],e):fh(e,t.stdio[n]);let i=xHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},xHe=["stdin","stdout","stderr"],AHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;RHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},RHe=(t,{signal:e})=>{No(t)&&ad(t,CHe,e)},CHe=2;import{addAbortListener as OHe}from"events";var fd=[];fd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&fd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&fd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var W0=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",gz=Symbol.for("signal-exit emitter"),_z=globalThis,PHe=Object.defineProperty.bind(Object),yz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(_z[gz])return _z[gz];PHe(_z,gz,{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}},Y0=class{},IHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Sz=class extends Y0{onExit(){return()=>{}}load(){}unload(){}},Ez=class extends Y0{#e=vz.platform==="win32"?"SIGINT":"SIGHUP";#r=new yz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of fd)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(!W0(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 fd)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,fd.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 W0(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"&&W0(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)}},vz=globalThis.process,{onExit:Nle,load:mUt,unload:gUt}=IHe(W0(vz)?new Ez(vz):new Sz);var kle=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Nle(()=>{t.kill()});OHe(n,()=>{i()})};var $le=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=o0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=NHe(r,n,i),{sourceStream:d,sourceError:f}=MHe(t,l),{options:p,fileDescriptors:h}=xs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},NHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=kHe(t,e,...r),a=m0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},kHe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Mle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||uF(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]=KR(r,...n);return{destination:e(Mle)(i,o,s),pipeOptions:s}}if(xs.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}`)},Mle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),MHe=(t,e)=>{try{return{sourceStream:oh(t,e)}}catch(r){return{sourceError:r}}};var Lle=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=$He({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw bz({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},$He=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return mz(t),n;if(e!==void 0)return hz(r),e},bz=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>lh({error:t,command:Dle,escapedCommand:Dle,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Dle="source.pipe(destination)";var Ule=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 DHe}from"stream/promises";var Fle=(t,e,r)=>{let n=K0.has(e)?UHe(t,e):LHe(t,e);return ad(t,zHe,r.signal),ad(e,jHe,r.signal),FHe(e),n},LHe=(t,e)=>{let r=dd([t]);return fh(r,e),K0.set(e,r),r},UHe=(t,e)=>{let r=K0.get(e);return r.add(t),r},FHe=async t=>{try{await DHe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}K0.delete(t)},K0=new WeakMap,zHe=2,jHe=1;import{aborted as BHe}from"util";var zle=(t,e)=>t===void 0?[]:[qHe(t,e)],qHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await BHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw bz({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Z0=(t,...e)=>{if(or(e[0]))return Z0.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=$le(t,...e),i=VHe({...n,destination:r});return i.pipe=Z0.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},VHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=GHe(t,i);Lle({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Fle(e,o,d);return await Promise.race([Ule(u),...zle(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},GHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as XHe}from"timers/promises";import{on as HHe}from"events";import{getDefaultHighWaterMark as WHe}from"stream";var J0=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return YHe(e,s),Ble({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},YHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Tz=({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 Ble({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()}},Ble=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=HHe(t,"data",{signal:e.signal,highWaterMark:jle,highWatermark:jle});return ZHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},wz=WHe(!0),jle=wz,ZHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=JHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*ud(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*WS(a)}},JHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[j0(t,r,!e),z0(t,i,!n,{})].filter(Boolean);var qle=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=QHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([e6e(t),d]);return}let f=tz(c,r),p=Tz({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([t6e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},QHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!V0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=Tz({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await ele(a,t,r,o)},e6e=async t=>{await XHe(),t.readableFlowing===null&&t.resume()},t6e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await O0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await N0(r,{maxBuffer:o})):await ch(r,{maxBuffer:o})}catch(a){return Vle(ece({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},xz=async t=>{try{return await t}catch(e){return Vle(e)}},Vle=({bufferedData:t})=>goe(t)?new Uint8Array(t):t;import{finished as r6e}from"stream/promises";var JS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=n6e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],r6e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||s6e(a,e,r,n)}finally{s.abort()}},n6e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&i6e(t,r,n),n},i6e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{o6e(e,r),n.call(t,...i)}},o6e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},s6e=(t,e,r,n)=>{if(!a6e(t,e,r,n))throw t},a6e=(t,e,r,n=!0)=>r.propagating?Gle(t)||X0(t):(r.propagating=!0,Az(r,e)===n?Gle(t):X0(t)),Az=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",X0=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Gle=t=>t?.code==="EPIPE";var Hle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>Rz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Rz=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=JS(t,e,l);if(Az(l,e)){await u;return}let[d]=await Promise.all([qle({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 Wle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?dd([t,e].filter(Boolean)):void 0,Yle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Rz({...c6e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:l6e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),c6e=({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}},l6e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as u6e}from"events";var Kle=t=>eh(t,"ipc"),Zle=(t,e)=>{let r=i0(t);Ts({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Jle=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Kle(o),a=ka(e,"ipc"),c=ka(r,"ipc");for await(let l of uz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(tce(t,i,c),i.push(l)),s&&Zle(l,o);return i},Xle=async(t,e)=>(await Promise.allSettled([t]),e);var Qle=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=ole(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=Hle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=Yle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),I=[],C=Jle({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),N=d6e(m,t,T),k=f6e(h,T);try{return await Promise.race([Promise.all([{},ale(b),Promise.all(S),w,C,kae(t,d),...N,...k]),g,p6e(t,_),...Cae(t,o,f,_),...Kse({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Aae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(U){return f.terminationReason??="other",Promise.all([{error:U},b,Promise.all(S.map(v=>xz(v))),xz(w),Xle(C,I),Promise.allSettled(N),Promise.allSettled(k)])}},d6e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:JS(n,i,r)),f6e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>$o(o,{checkOpen:!1})&&!No(o)).map(({type:i,value:o,stream:s=o})=>JS(s,n,e,{isSameDirection:Yi.has(i),stopOnExit:i==="native"}))),p6e=async(t,{signal:e})=>{let[r]=await u6e(t,"error",{signal:e});throw r};var eue=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),XS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ws();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},ph=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 h6e}from"stream";import{callbackify as m6e}from"util";import{finished as tue}from"stream/promises";var Cz=async t=>{if(t!==void 0)try{await Pz(t)}catch{}},rue=async t=>{if(t!==void 0)try{await Iz(t)}catch{}},Pz=async t=>{await tue(t,{cleanup:!0,readable:!1,writable:!0})},Iz=async t=>{await tue(t,{cleanup:!0,readable:!0,writable:!1})},Q0=async(t,e)=>{if(await t,e)throw e},eC=(t,e,r)=>{r&&!X0(r)?t.destroy(r):e&&t.destroy()};var nue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||Si.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Oz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Nz(a,s),{read:f,onStdoutDataDone:p}=kz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new h6e({read:f,destroy:m6e($z.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Mz({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Oz=(t,e,r)=>{let n=oh(t,e),i=XS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Nz=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:wz},kz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ws(),s=J0({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){g6e(this,s,o)},onStdoutDataDone:o}},g6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Mz=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Iz(t),await n,await Cz(i),await e,r.readable&&r.push(null)}catch(o){await Cz(i),iue(r,o)}},$z=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ph(r,e)&&(iue(t,n),await Q0(e,n))},iue=(t,e)=>{eC(t,t.readable,e)};import{Writable as _6e}from"stream";import{callbackify as oue}from"util";var sue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Dz(t,r,e),s=new _6e({...Lz(n,t,i),destroy:oue(Fz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Uz(n,s),s},Dz=(t,e,r)=>{let n=m0(t,e),i=XS(r,n,"writableFinal"),o=XS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Lz=(t,e,r)=>({write:y6e.bind(void 0,t),final:oue(S6e.bind(void 0,t,e,r))}),y6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},S6e=async(t,e,r)=>{await ph(r,e)&&(t.writable&&t.end(),await e)},Uz=async(t,e,r)=>{try{await Pz(t),e.writable&&e.end()}catch(n){await rue(r),aue(e,n)}},Fz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ph(r,e),await ph(n,e)&&(aue(t,i),await Q0(e,i))},aue=(t,e)=>{eC(t,t.writable,e)};import{Duplex as E6e}from"stream";import{callbackify as v6e}from"util";var cue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||Si.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Oz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Dz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Nz(c,a),{read:g,onStdoutDataDone:_}=kz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new E6e({read:g,...Lz(u,t,d),destroy:v6e(b6e.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 Mz({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),Uz(u,b,c),b},b6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([$z({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Fz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var zz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||Si.has(e),s=oh(t,r),a=J0({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return T6e(a,s,t)},T6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var lue=(t,{encoding:e})=>{let r=eue();t.readable=nue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=sue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=cue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zz.bind(void 0,t,e),t[Symbol.asyncIterator]=zz.bind(void 0,t,e,{})};var uue=(t,e)=>{for(let[r,n]of x6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},w6e=(async()=>{})().constructor.prototype,x6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(w6e,t)]);var due=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=C6e(t,e,r),{subprocess:f,promise:p}=I6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Z0.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),uue(f,p),xs.set(f,{options:u,fileDescriptors:d}),f},C6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=s0(t,e,r),{file:a,commandArguments:c,options:l}=A0(t,e,r),u=P6e(l),d=ble(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}},I6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=R6e(...R0(t,e,r))}catch(h){return yle({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;A6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ole(c,a,l),kle(c,r,l);let d={},f=ws();c.kill=Wse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Wle(c,r),lue(c,r),mle(c,r);let p=O6e({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}},O6e=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 Qle({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((S,w)=>$a(S,e,w)),b=$a(m,e,"all"),T=N6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return uh(T,n,e)},N6e=({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?HS({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 As,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):$0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var tC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,k6e(n,t[n],i)]));return{...t,...r}},k6e=(t,e,r)=>M6e.has(t)&&or(e)&&or(r)?{...e,...r}:r,M6e=new Set(["env",...gF]);var rl=(t,e,r,n)=>{let i=(s,a,c)=>rl(s,a,r,c),o=(...s)=>$6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},$6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(or(o))return i(t,tC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=D6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?lle(a,c,l):due(a,c,l,i)},D6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=boe(e)?Toe(e,r):[e,...r],[s,a,c]=KR(...o),l=tC(tC(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 fue=({file:t,commandArguments:e})=>hue(t,e),pue=({file:t,commandArguments:e})=>({...hue(t,e),isSync:!0}),hue=(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]=L6e(t);return{file:r,commandArguments:n}},L6e=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(U6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},U6e=/ +/g;var mue=(t,e,r)=>{t.sync=e(F6e,r),t.s=t.sync},gue=({options:t})=>_ue(t),F6e=({options:t})=>({..._ue(t),isSync:!0}),_ue=t=>({options:{...z6e(t),...t}}),z6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},yue={preferLocal:!0};var Sue=rl(()=>({})),ojt=rl(()=>({isSync:!0})),Eue=rl(fue),sjt=rl(pue),ajt=rl(Iae),cjt=rl(gue,{},yue,mue),{sendMessage:ljt,getOneMessage:ujt,getEachMessage:djt,getCancelSignal:fjt}=gle();var vue=!1,bue=()=>{vue=!0},Cs=()=>vue;var QS=null,Tue=t=>(QS&&QS.destroy(),QS=new Do({totalAllowedTime:t}),QS),wue=()=>QS;var Do=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&&Cs())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 zR({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 xue={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 V6e=B6e(import.meta.url),G6e=Da.dirname(V6e),H6e=q6e(import.meta.url),hh=ce("shell"),jz=new Set,Aue={preferLocal:!0},Sr=(t,e,r)=>{let[n,i]=W6e(e,r),o={...Aue,...i},s=Sue(t,n,o);Cue(s,o),Oue(s);let a=r?.idleTimeout;return a&&a>0&&Iue(s,a),s},Rue=(t,e)=>{let r={...Aue,...e},n=Eue(t,r);return Cue(n,r),Oue(n),e?.idleTimeout&&e.idleTimeout>0&&Iue(n,e.idleTimeout),n},W6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Cue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ps.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ps.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new CS).pipe(Ps.stdout),t.stderr?.pipe(new CS).pipe(Ps.stderr);return}t.stdout?.pipe(Ps.stdout),t.stderr?.pipe(Ps.stderr)},Bz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ps.kill(-t.pid,e),hh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return hh.error("Error killing process:",r),!1}},Pue=t=>Bz(t,"SIGKILL"),Iue=(t,e)=>{let r=null,n=()=>{hh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Bz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hh.log(`Force killing idle process ${t.pid}`),Pue(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)},Oue=t=>{jz.add(t);let e=wue();if(e){let r=e.onTimesUp(()=>{hh.log(`Global timer expired, killing process ${t.pid}`),Bz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hh.log(`Force killing process ${t.pid} after timeout`),Pue(t))},5e3)});t.on("exit",()=>{jz.delete(t),r()}),t.on("error",()=>{jz.delete(t),r()})}};function nC(t,e){return!!Lo(t,e)}function Lo(t,e){if(!Ps.env.NETLIFY_LOCAL_MODE)try{let i=H6e.resolve(xue.name),o=Da.dirname(i);for(;o!==Da.dirname(o);){let s=Da.dirname(o);if(Da.basename(s)==="node_modules"){let a=Da.join(s,".bin",e);if(rC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ps.env.NODE_PATH){let i=Da.join(Ps.env.NODE_PATH,".bin",e);if(rC.existsSync(i))return i}let r=Da.join(t,"node_modules",".bin",e);if(rC.existsSync(r))return r;let n=Da.join(G6e,"..","node_modules",".bin",e);if(rC.existsSync(n))return n}var Y6e=ce("utils"),K6e=t=>new Promise(e=>{setTimeout(e,t)});var qz=t=>{try{return new URL(t).hostname||null}catch{return null}},iC=(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},nl=(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},Nue=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):Y6e.error("Could not parse JSON",n))}},Z6e=t=>t.charAt(0).toUpperCase()+t.slice(1),Is=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():Z6e(e)).join(" ");function La(t,e){e&&t.log(`Skill invoked: ${e}`)}var oC=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),kue=(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 Vz=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}},J6e=1e4,Gz=(t,e=J6e)=>{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 X6e}from"crypto";import{createReadStream as Q6e}from"fs";import sC from"fs/promises";import Uue from"os";import aC from"path";var Mue=ce("repo"),Fue="runner-diffs-",zue=t=>`${Fue}${t}-`,jue=async t=>{let e=Uue.tmpdir(),r;try{r=await sC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Fue)&&!n.startsWith(zue(t))).map(n=>sC.rm(aC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Jn=(t,e={})=>Sr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),cC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Mue.info("Getting runner diffs");let n=await t3e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=n3e(o);await i3e(h,r)}Mue.info("Changes after processing"),await Wz(r);let s=await Yz(o,r);if(await Hz(s,r),i=await r3e(r),!i)return{hasChanges:!1,ignored:s};await Jn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await sC.mkdtemp(aC.join(Uue.tmpdir(),zue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=aC.join(a,g);await Jn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await sC.stat(b);return{path:b,size:S}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Lue(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 Due(d,h)||(f=h)}await Lue(r),re.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Due(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},$ue=async t=>{let e=X6e("sha256");for await(let r of Q6e(t))e.update(r);return e.digest("hex")},Due=async(t,e)=>t.size===e.size&&await $ue(t.path)===await $ue(e.path),Lue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Jn(["reset","--soft","HEAD~1"],{cwd:t})},Hz=async(t=[],e=process.cwd())=>{await Jn(["add",".",...t],{cwd:e})},Wz=async(t=process.cwd())=>{let e=await Jn(["status","-s"],{cwd:t});return String(e.stdout??"")},Bue=/.. (.+)?\.log$/,e3e=[Bue],t3e=async(t=process.cwd())=>{let e=await Wz(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
143
|
+
if (condition) { yield value; }`)};import{Buffer as oGe}from"buffer";import{StringDecoder as sGe}from"string_decoder";var j0=(t,e,r)=>{if(r)return;if(t)return{transform:aGe.bind(void 0,new TextEncoder)};let n=new sGe(e);return{transform:cGe.bind(void 0,n),final:lGe.bind(void 0,n)}},aGe=function*(t,e){oGe.isBuffer(e)?yield Na(e):typeof e=="string"?yield t.encode(e):yield e},cGe=function*(t,e){yield yr(e)?t.write(e):e},lGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Wce}from"util";var iz=Wce(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),B0=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=dGe}=e[r];for await(let i of n(t))yield*B0(i,e,r+1)},Yce=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*uGe(r,Number(e),t)},uGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*B0(n,r,e+1)},Kce=Wce(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),dGe=function*(t){yield t};var oz=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Zce=(t,e)=>[...e.flatMap(r=>[...ud(r,t,0)]),...WS(t)],ud=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=pGe}=e[r];for(let i of n(t))yield*ud(i,e,r+1)},WS=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*fGe(r,Number(e),t)},fGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*ud(n,r,e+1)},pGe=function*(t){yield t};var sz=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Xce(t,s,o),l=ld(e),u=ld(r),d=l?iz.bind(void 0,B0,a):oz.bind(void 0,ud),f=l||u?iz.bind(void 0,Yce,a):oz.bind(void 0,WS),p=l||u?Kce.bind(void 0,a):void 0;return{stream:new hGe({writableObjectMode:n,writableHighWaterMark:Jce(n),readableObjectMode:i,readableHighWaterMark:Jce(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},q0=(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=Xce(s,r,a);t=Zce(c,t)}return t},Xce=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Vce(n,a)},j0(r,s,n),z0(r,o,n,c),{transform:t,final:e},{transform:Gce(i,a)},qce({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Qce=(t,e)=>{for(let r of mGe(t))gGe(t,r,e)},mGe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),gGe=(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 ${tl[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>_Ge(a,n));r.input=LS(s)},_Ge=(t,e)=>{let r=q0(t,e,"utf8",!0);return yGe(r),LS(r)},yGe=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 bGe,appendFileSync as TGe}from"fs";var V0=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&eh(r,n)&&!Si.has(e)&&SGe(n)&&(t.some(({type:i,value:o})=>i==="native"&&EGe.has(o))||t.every(({type:i})=>Yi.has(i))),SGe=t=>t===1||t===2,EGe=new Set(["pipe","overlapped"]),ele=async(t,e,r,n)=>{for await(let i of t)vGe(e)||rle(i,r,n)},tle=(t,e,r)=>{for(let n of t)rle(n,e,r)},vGe=t=>t._readableState.pipes.length>0,rle=(t,e,r)=>{let n=i0(t);Ts({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var nle=({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)=>wGe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},wGe=({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=ice(t,o,d),p=Na(f),{stdioItems:h,objectMode:m}=e[r],g=xGe([p],h,c,n),{serializedResult:_,finalResult:b=_}=AGe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});RGe({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&&CGe(_,h,i),T}catch(S){return n.error=S,T}},xGe=(t,e,r,n)=>{try{return q0(t,e,r,!1)}catch(i){return n.error=i,t}},AGe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:LS(t)};let s=yoe(t,r);return n[o]?{serializedResult:s,finalResult:nz(s,!i[o],e)}:{serializedResult:s}},RGe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!V0({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=nz(t,!1,s);try{tle(a,e,n)}catch(c){r.error??=c}},CGe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>U0.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?TGe(n,t):(r.add(o),bGe(n,t))}};var ile=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,$a(e,r,"all")]:Array.isArray(e)?[$a(t,r,"all"),...e]:yr(t)&&yr(e)?fF([t,e]):`${t}${e}`};import{once as az}from"events";var ole=async(t,e)=>{let[r,n]=await PGe(t);return e.isForcefullyTerminated??=!1,[r,n]},PGe=async t=>{let[e,r]=await Promise.allSettled([az(t,"spawn"),az(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?sle(t):r.value},sle=async t=>{try{return await az(t,"exit")}catch{return sle(t)}},ale=async t=>{let[e,r]=await t;if(!IGe(e,r)&&cz(e,r))throw new ko;return[e,r]},IGe=(t,e)=>t===void 0&&e===void 0,cz=(t,e)=>t!==0||e!==null;var cle=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=OGe(t,e,r),s=o?.code==="ETIMEDOUT",a=nce(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},OGe=(t,e,r)=>t!==void 0?t:cz(e,r)?new ko:void 0;var lle=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=kGe(t,e,r),d=DGe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return uh(d,c,l)},kGe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=s0(t,e,r),a=MGe(r),{file:c,commandArguments:l,options:u}=A0(t,e,a);$Ge(u);let d=Fce(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},MGe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,$Ge=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&G0("ipcInput"),t&&G0("ipc: true"),r&&G0("detached: true"),n&&G0("cancelSignal")},G0=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},DGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=LGe({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}=cle(c,r),{output:h,error:m=l}=nle({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((b,T)=>$a(b,r,T)),_=$a(ile(h,r),r,"all");return FGe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},LGe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Qce(o,r);let a=UGe(r);return NGe(...R0(t,e,a))}catch(a){return lh({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},UGe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:M0(e)}),FGe=({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?$0({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):HS({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 A6e}from"events";import{spawn as R6e}from"child_process";import hle from"process";import{once as lz,on as zGe}from"events";var ule=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(nh({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:E0(t)}),jGe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),jGe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{g0(e,i);let o=el(t,e,r),s=new AbortController;try{return await Promise.race([BGe(o,n,s),qGe(o,r,s),VGe(o,r,s)])}catch(a){throw ih(t),a}finally{s.abort(),_0(e,i)}},BGe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await lz(t,"message",{signal:r});return n}for await(let[n]of zGe(t,"message",{signal:r}))if(e(n))return n},qGe=async(t,e,{signal:r})=>{await lz(t,"disconnect",{signal:r}),Zse(e)},VGe=async(t,e,{signal:r})=>{let[n]=await lz(t,"strict:error",{signal:r});throw p0(n,e)};import{once as fle,on as GGe}from"events";var ple=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>uz({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),uz=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{nh({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:E0(t)}),g0(e,o);let s=el(t,e,r),a=new AbortController,c={};return HGe(t,s,a),WGe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),YGe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},HGe=async(t,e,r)=>{try{await fle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},WGe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await fle(t,"strict:error",{signal:r.signal});n.error=p0(i,e),r.abort()}catch{}},YGe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of GGe(r,"message",{signal:o.signal}))dle(s),yield c}catch{dle(s)}finally{o.abort(),_0(e,a),n||ih(t),i&&await t}},dle=({error:t})=>{if(t)throw t};var mle=(t,{ipc:e})=>{Object.assign(t,_le(t,!1,e))},gle=()=>{let t=hle,e=!0,r=hle.channel!==void 0;return{..._le(t,e,r),getCancelSignal:Tae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},_le=(t,e,r)=>({sendMessage:w0.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ule.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ple.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as KGe}from"child_process";import{PassThrough as ZGe,Readable as JGe,Writable as XGe,Duplex as QGe}from"stream";var yle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ez(n);let a=new KGe;eHe(a,n),Object.assign(a,{readable:tHe,writable:rHe,duplex:nHe});let c=lh({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=iHe(c,s,i);return{subprocess:a,promise:l}},eHe=(t,e)=>{let r=YS(),n=YS(),i=YS(),o=Array.from({length:e.length-3},YS),s=YS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},YS=()=>{let t=new ZGe;return t.end(),t},tHe=()=>new JGe({read(){}}),rHe=()=>new XGe({write(){}}),nHe=()=>new QGe({read(){},write(){}}),iHe=async(t,e,r)=>uh(t,e,r);import{createReadStream as Sle,createWriteStream as Ele}from"fs";import{Buffer as oHe}from"buffer";import{Readable as KS,Writable as sHe,Duplex as aHe}from"stream";var ble=(t,e)=>F0(cHe,t,e,!1),ZS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${tl[t]}.`)},vle={fileNumber:ZS,generator:sz,asyncGenerator:sz,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:aHe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},cHe={input:{...vle,fileUrl:({value:t})=>({stream:Sle(t)}),filePath:({value:{file:t}})=>({stream:Sle(t)}),webStream:({value:t})=>({stream:KS.fromWeb(t)}),iterable:({value:t})=>({stream:KS.from(t)}),asyncIterable:({value:t})=>({stream:KS.from(t)}),string:({value:t})=>({stream:KS.from(t)}),uint8Array:({value:t})=>({stream:KS.from(oHe.from(t))})},output:{...vle,fileUrl:({value:t})=>({stream:Ele(t)}),filePath:({value:{file:t,append:e}})=>({stream:Ele(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:sHe.fromWeb(t)}),iterable:ZS,asyncIterable:ZS,string:ZS,uint8Array:ZS}};import{on as lHe,once as Tle}from"events";import{PassThrough as uHe,getDefaultHighWaterMark as dHe}from"stream";import{finished as Ale}from"stream/promises";function dd(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)fz(i);let e=t.some(({readableObjectMode:i})=>i),r=fHe(t,e),n=new dz({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var fHe=(t,e)=>{if(t.length===0)return dHe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},dz=class extends uHe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(fz(e),this.#e.has(e))return;this.#e.add(e),this.#n??=pHe(this,this.#e,this.#o);let r=gHe({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(fz(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)}},pHe=async(t,e,r)=>{H0(t,wle);let n=new AbortController;try{await Promise.race([hHe(t,n),mHe(t,e,r,n)])}finally{n.abort(),H0(t,-wle)}},hHe=async(t,{signal:e})=>{try{await Ale(t,{signal:e,cleanup:!0})}catch(r){throw Rle(t,r),r}},mHe=async(t,e,r,{signal:n})=>{for await(let[i]of lHe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},fz=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},gHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{H0(t,xle);let a=new AbortController;try{await Promise.race([_He(o,e,a),yHe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),SHe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),H0(t,-xle)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?pz(t):EHe(t))},_He=async(t,e,{signal:r})=>{try{await t,r.aborted||pz(e)}catch(n){r.aborted||Rle(e,n)}},yHe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Ale(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Cle(s)?i.add(e):Ple(t,s)}},SHe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Tle(t,i,{signal:o}),!t.readable)return Tle(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},EHe=t=>{t.writable&&t.end()},Rle=(t,e)=>{Cle(e)?pz(t):Ple(t,e)},Cle=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",pz=t=>{(t.readable||t.writable)&&t.destroy()},Ple=(t,e)=>{t.destroyed||(t.once("error",vHe),t.destroy(e))},vHe=()=>{},H0=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},wle=2,xle=1;import{finished as Ile}from"stream/promises";var fh=(t,e)=>{t.pipe(e),bHe(t,e),THe(t,e)},bHe=async(t,e)=>{if(!(No(t)||No(e))){try{await Ile(t,{cleanup:!0,readable:!0,writable:!1})}catch{}hz(e)}},hz=t=>{t.writable&&t.end()},THe=async(t,e)=>{if(!(No(t)||No(e))){try{await Ile(e,{cleanup:!0,readable:!1,writable:!0})}catch{}mz(t)}},mz=t=>{t.readable&&t.destroy()};var Ole=(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})=>Yi.has(c)))wHe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yi.has(c)))AHe({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]:dd(o);fh(s,i)}},wHe=(t,e,r,n)=>{r==="output"?fh(t.stdio[n],e):fh(e,t.stdio[n]);let i=xHe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},xHe=["stdin","stdout","stderr"],AHe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;RHe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},RHe=(t,{signal:e})=>{No(t)&&ad(t,CHe,e)},CHe=2;import{addAbortListener as OHe}from"events";var fd=[];fd.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&fd.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&fd.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var W0=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",gz=Symbol.for("signal-exit emitter"),_z=globalThis,PHe=Object.defineProperty.bind(Object),yz=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(_z[gz])return _z[gz];PHe(_z,gz,{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}},Y0=class{},IHe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Sz=class extends Y0{onExit(){return()=>{}}load(){}unload(){}},Ez=class extends Y0{#e=vz.platform==="win32"?"SIGINT":"SIGHUP";#r=new yz;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of fd)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(!W0(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 fd)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,fd.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 W0(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"&&W0(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)}},vz=globalThis.process,{onExit:Nle,load:mUt,unload:gUt}=IHe(W0(vz)?new Ez(vz):new Sz);var kle=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Nle(()=>{t.kill()});OHe(n,()=>{i()})};var $le=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=o0(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=NHe(r,n,i),{sourceStream:d,sourceError:f}=MHe(t,l),{options:p,fileDescriptors:h}=xs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},NHe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=kHe(t,e,...r),a=m0(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},kHe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Mle,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||uF(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]=KR(r,...n);return{destination:e(Mle)(i,o,s),pipeOptions:s}}if(xs.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}`)},Mle=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),MHe=(t,e)=>{try{return{sourceStream:oh(t,e)}}catch(r){return{sourceError:r}}};var Lle=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=$He({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw bz({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},$He=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return mz(t),n;if(e!==void 0)return hz(r),e},bz=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>lh({error:t,command:Dle,escapedCommand:Dle,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Dle="source.pipe(destination)";var Ule=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 DHe}from"stream/promises";var Fle=(t,e,r)=>{let n=K0.has(e)?UHe(t,e):LHe(t,e);return ad(t,zHe,r.signal),ad(e,jHe,r.signal),FHe(e),n},LHe=(t,e)=>{let r=dd([t]);return fh(r,e),K0.set(e,r),r},UHe=(t,e)=>{let r=K0.get(e);return r.add(t),r},FHe=async t=>{try{await DHe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}K0.delete(t)},K0=new WeakMap,zHe=2,jHe=1;import{aborted as BHe}from"util";var zle=(t,e)=>t===void 0?[]:[qHe(t,e)],qHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await BHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw bz({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Z0=(t,...e)=>{if(or(e[0]))return Z0.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=$le(t,...e),i=VHe({...n,destination:r});return i.pipe=Z0.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},VHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=GHe(t,i);Lle({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Fle(e,o,d);return await Promise.race([Ule(u),...zle(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},GHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as XHe}from"timers/promises";import{on as HHe}from"events";import{getDefaultHighWaterMark as WHe}from"stream";var J0=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return YHe(e,s),Ble({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},YHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Tz=({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 Ble({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()}},Ble=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=HHe(t,"data",{signal:e.signal,highWaterMark:jle,highWatermark:jle});return ZHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},wz=WHe(!0),jle=wz,ZHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=JHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*ud(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*WS(a)}},JHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[j0(t,r,!e),z0(t,i,!n,{})].filter(Boolean);var qle=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=QHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([e6e(t),d]);return}let f=tz(c,r),p=Tz({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([t6e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},QHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!V0({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=Tz({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await ele(a,t,r,o)},e6e=async t=>{await XHe(),t.readableFlowing===null&&t.resume()},t6e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await O0(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await N0(r,{maxBuffer:o})):await ch(r,{maxBuffer:o})}catch(a){return Vle(ece({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},xz=async t=>{try{return await t}catch(e){return Vle(e)}},Vle=({bufferedData:t})=>goe(t)?new Uint8Array(t):t;import{finished as r6e}from"stream/promises";var JS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=n6e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],r6e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||s6e(a,e,r,n)}finally{s.abort()}},n6e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&i6e(t,r,n),n},i6e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{o6e(e,r),n.call(t,...i)}},o6e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},s6e=(t,e,r,n)=>{if(!a6e(t,e,r,n))throw t},a6e=(t,e,r,n=!0)=>r.propagating?Gle(t)||X0(t):(r.propagating=!0,Az(r,e)===n?Gle(t):X0(t)),Az=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",X0=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Gle=t=>t?.code==="EPIPE";var Hle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>Rz({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Rz=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=JS(t,e,l);if(Az(l,e)){await u;return}let[d]=await Promise.all([qle({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 Wle=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?dd([t,e].filter(Boolean)):void 0,Yle=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Rz({...c6e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:l6e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),c6e=({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}},l6e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as u6e}from"events";var Kle=t=>eh(t,"ipc"),Zle=(t,e)=>{let r=i0(t);Ts({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Jle=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Kle(o),a=ka(e,"ipc"),c=ka(r,"ipc");for await(let l of uz({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(tce(t,i,c),i.push(l)),s&&Zle(l,o);return i},Xle=async(t,e)=>(await Promise.allSettled([t]),e);var Qle=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=ole(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=Hle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=Yle({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),I=[],C=Jle({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),N=d6e(m,t,T),k=f6e(h,T);try{return await Promise.race([Promise.all([{},ale(b),Promise.all(S),w,C,kae(t,d),...N,...k]),g,p6e(t,_),...Cae(t,o,f,_),...Kse({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...Aae({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch(U){return f.terminationReason??="other",Promise.all([{error:U},b,Promise.all(S.map(v=>xz(v))),xz(w),Xle(C,I),Promise.allSettled(N),Promise.allSettled(k)])}},d6e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:JS(n,i,r)),f6e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>$o(o,{checkOpen:!1})&&!No(o)).map(({type:i,value:o,stream:s=o})=>JS(s,n,e,{isSameDirection:Yi.has(i),stopOnExit:i==="native"}))),p6e=async(t,{signal:e})=>{let[r]=await u6e(t,"error",{signal:e});throw r};var eue=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),XS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ws();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},ph=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 h6e}from"stream";import{callbackify as m6e}from"util";import{finished as tue}from"stream/promises";var Cz=async t=>{if(t!==void 0)try{await Pz(t)}catch{}},rue=async t=>{if(t!==void 0)try{await Iz(t)}catch{}},Pz=async t=>{await tue(t,{cleanup:!0,readable:!1,writable:!0})},Iz=async t=>{await tue(t,{cleanup:!0,readable:!0,writable:!1})},Q0=async(t,e)=>{if(await t,e)throw e},eC=(t,e,r)=>{r&&!X0(r)?t.destroy(r):e&&t.destroy()};var nue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||Si.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Oz(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Nz(a,s),{read:f,onStdoutDataDone:p}=kz({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new h6e({read:f,destroy:m6e($z.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return Mz({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},Oz=(t,e,r)=>{let n=oh(t,e),i=XS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Nz=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:wz},kz=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ws(),s=J0({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){g6e(this,s,o)},onStdoutDataDone:o}},g6e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Mz=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Iz(t),await n,await Cz(i),await e,r.readable&&r.push(null)}catch(o){await Cz(i),iue(r,o)}},$z=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ph(r,e)&&(iue(t,n),await Q0(e,n))},iue=(t,e)=>{eC(t,t.readable,e)};import{Writable as _6e}from"stream";import{callbackify as oue}from"util";var sue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=Dz(t,r,e),s=new _6e({...Lz(n,t,i),destroy:oue(Fz.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Uz(n,s),s},Dz=(t,e,r)=>{let n=m0(t,e),i=XS(r,n,"writableFinal"),o=XS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},Lz=(t,e,r)=>({write:y6e.bind(void 0,t),final:oue(S6e.bind(void 0,t,e,r))}),y6e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},S6e=async(t,e,r)=>{await ph(r,e)&&(t.writable&&t.end(),await e)},Uz=async(t,e,r)=>{try{await Pz(t),e.writable&&e.end()}catch(n){await rue(r),aue(e,n)}},Fz=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ph(r,e),await ph(n,e)&&(aue(t,i),await Q0(e,i))},aue=(t,e)=>{eC(t,t.writable,e)};import{Duplex as E6e}from"stream";import{callbackify as v6e}from"util";var cue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||Si.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Oz(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=Dz(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Nz(c,a),{read:g,onStdoutDataDone:_}=kz({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new E6e({read:g,...Lz(u,t,d),destroy:v6e(b6e.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 Mz({subprocessStdout:c,onStdoutDataDone:_,readable:b,subprocess:t,subprocessStdin:u}),Uz(u,b,c),b},b6e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([$z({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),Fz({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var zz=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||Si.has(e),s=oh(t,r),a=J0({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return T6e(a,s,t)},T6e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var lue=(t,{encoding:e})=>{let r=eue();t.readable=nue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=sue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=cue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zz.bind(void 0,t,e),t[Symbol.asyncIterator]=zz.bind(void 0,t,e,{})};var uue=(t,e)=>{for(let[r,n]of x6e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},w6e=(async()=>{})().constructor.prototype,x6e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(w6e,t)]);var due=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=C6e(t,e,r),{subprocess:f,promise:p}=I6e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Z0.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),uue(f,p),xs.set(f,{options:u,fileDescriptors:d}),f},C6e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=s0(t,e,r),{file:a,commandArguments:c,options:l}=A0(t,e,r),u=P6e(l),d=ble(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}},I6e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=R6e(...R0(t,e,r))}catch(h){return yle({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;A6e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ole(c,a,l),kle(c,r,l);let d={},f=ws();c.kill=Wse.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Wle(c,r),lue(c,r),mle(c,r);let p=O6e({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}},O6e=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 Qle({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((S,w)=>$a(S,e,w)),b=$a(m,e,"all"),T=N6e({errorInfo:d,exitCode:f,signal:p,stdio:_,all:b,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return uh(T,n,e)},N6e=({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?HS({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 As,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):$0({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var tC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,k6e(n,t[n],i)]));return{...t,...r}},k6e=(t,e,r)=>M6e.has(t)&&or(e)&&or(r)?{...e,...r}:r,M6e=new Set(["env",...gF]);var rl=(t,e,r,n)=>{let i=(s,a,c)=>rl(s,a,r,c),o=(...s)=>$6e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},$6e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(or(o))return i(t,tC(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=D6e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?lle(a,c,l):due(a,c,l,i)},D6e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=boe(e)?Toe(e,r):[e,...r],[s,a,c]=KR(...o),l=tC(tC(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 fue=({file:t,commandArguments:e})=>hue(t,e),pue=({file:t,commandArguments:e})=>({...hue(t,e),isSync:!0}),hue=(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]=L6e(t);return{file:r,commandArguments:n}},L6e=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(U6e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},U6e=/ +/g;var mue=(t,e,r)=>{t.sync=e(F6e,r),t.s=t.sync},gue=({options:t})=>_ue(t),F6e=({options:t})=>({..._ue(t),isSync:!0}),_ue=t=>({options:{...z6e(t),...t}}),z6e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},yue={preferLocal:!0};var Sue=rl(()=>({})),ojt=rl(()=>({isSync:!0})),Eue=rl(fue),sjt=rl(pue),ajt=rl(Iae),cjt=rl(gue,{},yue,mue),{sendMessage:ljt,getOneMessage:ujt,getEachMessage:djt,getCancelSignal:fjt}=gle();var vue=!1,bue=()=>{vue=!0},Cs=()=>vue;var QS=null,Tue=t=>(QS&&QS.destroy(),QS=new Do({totalAllowedTime:t}),QS),wue=()=>QS;var Do=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&&Cs())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 zR({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 xue={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 V6e=B6e(import.meta.url),G6e=Da.dirname(V6e),H6e=q6e(import.meta.url),hh=ce("shell"),jz=new Set,Aue={preferLocal:!0},Sr=(t,e,r)=>{let[n,i]=W6e(e,r),o={...Aue,...i},s=Sue(t,n,o);Cue(s,o),Oue(s);let a=r?.idleTimeout;return a&&a>0&&Iue(s,a),s},Rue=(t,e)=>{let r={...Aue,...e},n=Eue(t,r);return Cue(n,r),Oue(n),e?.idleTimeout&&e.idleTimeout>0&&Iue(n,e.idleTimeout),n},W6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Cue=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||Ps.env.NETLIFY_LOCAL_QUIET==="true")return;if(Ps.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new CS).pipe(Ps.stdout),t.stderr?.pipe(new CS).pipe(Ps.stderr);return}t.stdout?.pipe(Ps.stdout),t.stderr?.pipe(Ps.stderr)},Bz=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ps.kill(-t.pid,e),hh.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return hh.error("Error killing process:",r),!1}},Pue=t=>Bz(t,"SIGKILL"),Iue=(t,e)=>{let r=null,n=()=>{hh.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Bz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hh.log(`Force killing idle process ${t.pid}`),Pue(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)},Oue=t=>{jz.add(t);let e=wue();if(e){let r=e.onTimesUp(()=>{hh.log(`Global timer expired, killing process ${t.pid}`),Bz(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hh.log(`Force killing process ${t.pid} after timeout`),Pue(t))},5e3)});t.on("exit",()=>{jz.delete(t),r()}),t.on("error",()=>{jz.delete(t),r()})}};function nC(t,e){return!!Lo(t,e)}function Lo(t,e){if(!Ps.env.NETLIFY_LOCAL_MODE)try{let i=H6e.resolve(xue.name),o=Da.dirname(i);for(;o!==Da.dirname(o);){let s=Da.dirname(o);if(Da.basename(s)==="node_modules"){let a=Da.join(s,".bin",e);if(rC.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ps.env.NODE_PATH){let i=Da.join(Ps.env.NODE_PATH,".bin",e);if(rC.existsSync(i))return i}let r=Da.join(t,"node_modules",".bin",e);if(rC.existsSync(r))return r;let n=Da.join(G6e,"..","node_modules",".bin",e);if(rC.existsSync(n))return n}var Y6e=ce("utils"),K6e=t=>new Promise(e=>{setTimeout(e,t)});var qz=t=>{try{return new URL(t).hostname||null}catch{return null}},iC=(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},nl=(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},Nue=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):Y6e.error("Could not parse JSON",n))}},Z6e=t=>t.charAt(0).toUpperCase()+t.slice(1),Is=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():Z6e(e)).join(" ");function La(t,e){e&&t.log(`Skill invoked: ${e}`)}var oC=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),kue=(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 Vz=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}},J6e=1e4,Gz=(t,e=J6e)=>{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 X6e}from"crypto";import{createReadStream as Q6e}from"fs";import sC from"fs/promises";import Uue from"os";import aC from"path";var Mue=ce("repo"),Fue="runner-diffs-",zue=t=>`${Fue}${t}-`,jue=async t=>{let e=Uue.tmpdir(),r;try{r=await sC.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Fue)&&!n.startsWith(zue(t))).map(n=>sC.rm(aC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Jn=(t,e={})=>Sr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),cC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Mue.info("Getting runner diffs");let n=await t3e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=n3e(o);await i3e(h,r)}Mue.info("Changes after processing"),await Wz(r);let s=await Yz(o,r);if(await Hz(s,r),i=await r3e(r),!i)return{hasChanges:!1,ignored:s};await Jn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await sC.mkdtemp(aC.join(Uue.tmpdir(),zue(t.sessionId))),c=async({from:h,to:m,fileName:g,binary:_})=>{let b=aC.join(a,g);await Jn([..._?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await sC.stat(b);return{path:b,size:S}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await Lue(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 Due(d,h)||(f=h)}await Lue(r),re.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Due(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},$ue=async t=>{let e=X6e("sha256");for await(let r of Q6e(t))e.update(r);return e.digest("hex")},Due=async(t,e)=>t.size===e.size&&await $ue(t.path)===await $ue(e.path),Lue=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Jn(["reset","--soft","HEAD~1"],{cwd:t})},Hz=async(t=[],e=process.cwd())=>{await Jn(["add",".",...t],{cwd:e})},Wz=async(t=process.cwd())=>{let e=await Jn(["status","-s"],{cwd:t});return String(e.stdout??"")},Bue=/.. (.+)?\.log$/,e3e=[Bue],t3e=async(t=process.cwd())=>{let e=await Wz(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
144
144
|
`).filter(i=>e3e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},r3e=async(t=process.cwd())=>{try{return await Jn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},eE=async(t=process.cwd())=>{let{stdout:e}=await Jn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},que=async(t=process.cwd())=>{let{stdout:e}=await Jn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},Yz=async(t,e=process.cwd())=>{t||=await Wz(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
145
145
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${aC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Bue)?.[1];o&&n.push(`:!${o}.log`)}),n},Vue=async(t=process.cwd())=>{await Jn(["reset","--hard","HEAD"],{cwd:t})},Gue=async(t=process.cwd())=>{let e=await Jn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
146
146
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},n3e=t=>{let e=t.split(`
|
|
@@ -619,10 +619,10 @@ Use the following file for the complete context of the ask, the environment, and
|
|
|
619
619
|
|
|
620
620
|
`)},Znt=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(`
|
|
621
621
|
`):""};import _c from"fs/promises";import Gxe from"os";import yc from"path";import{rm as LY}from"fs/promises";import{resolve as Jnt}from"path";var Xnt=".netlify/cache/",Ef=function({cacheDir:t=Xnt,cwd:e="."}={}){return Jnt(e,t)};import{promises as aut}from"fs";import{basename as gxe,dirname as _xe,join as cut}from"path";import Tlt from"process";import wlt from"events";import bt from"path";import xlt from"os";async function Db(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=w=>{o(w),_()},T=w=>{u=!0,d=!0,s(w),_()};i&&(i.aborted&&T(i.reason),i.addEventListener("abort",g,{once:!0}));let S=async()=>{if(d)return;let w=await m.next(),I=h;if(h++,w.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 C=[];for(let[N,k]of a.entries())l.get(N)!==zEe&&C.push(k);b(C)}return}p++,(async()=>{try{let C=await w.value;if(d)return;let N=await e(C,I);N===zEe&&l.set(I,N),a[I]=N,p--,await S()}catch(C){if(n)T(C);else{c.push(C),p--;try{await S()}catch(N){T(N)}}}})()};(async()=>{for(let w=0;w<r;w++){try{await S()}catch(I){T(I);break}if(f||u)break}})()})}var zEe=Symbol("skip");import bf from"path";import bsr,{constants as f3}from"fs";import p3 from"fs/promises";var i3=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},o3=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},jEe=t=>globalThis.DOMException===void 0?new o3(t):new DOMException(t),BEe=t=>{let e=t.reason===void 0?jEe("This operation was aborted."):t.reason;return e instanceof Error?e:jEe(e)};function s3(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(BEe(p)),a=()=>{d(BEe(p))},p.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let f=new i3;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 Qnt=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 eit(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}=Qnt(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=s3(i,{milliseconds:r.timeout});return o.cancel=n,o}return i}function tN(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=eit(t,e,r),i=n.then(o=>o[0]);return i.cancel=n.cancel,i}var Fn=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CopyFileError"}};var Ko=wn(QEe(),1);import{promisify as Lb}from"util";var msr=Lb(Ko.default.stat),dit=Lb(Ko.default.lstat),fit=Lb(Ko.default.utimes),pit=Lb(Ko.default.chmod),hit=Lb(Ko.default.mkdir),gsr=Ko.default.closeSync.bind(Ko.default),eve=Ko.default.createWriteStream.bind(Ko.default);async function tve(t,e){let r=Ko.default.createReadStream(t,e);try{await tN(r,["readable","end"])}catch(n){throw new Fn(`Cannot read from \`${t}\`: ${n.message}`,{cause:n})}return r}var d3=t=>dit(t).catch(e=>{throw new Fn(`lstat \`${t}\` failed: ${e.message}`,{cause:e})}),rve=(t,e,r)=>fit(t,e,r).catch(n=>{throw new Fn(`utimes \`${t}\` failed: ${n.message}`,{cause:n})}),nve=(t,e)=>pit(t,e).catch(r=>{throw new Fn(`chmod \`${t}\` failed: ${r.message}`,{cause:r})});var ive=(t,e)=>hit(t,{...e,recursive:!0}).catch(r=>{throw new Fn(`Cannot create directory \`${t}\`: ${r.message}`,{cause:r})});var git=(t,e,r)=>({sourcePath:bf.resolve(t,e),destinationPath:bf.resolve(t,r)}),_it=(t,e)=>{if(!t.isFile())throw Object.assign(new Fn(`EISDIR: illegal operation on a directory '${e}'`),{errno:-21,code:"EISDIR",source:e})};async function ove(t,e,r={}){if(!t||!e)throw new Fn("`source` and `destination` required");r.cwd&&({sourcePath:t,destinationPath:e}=git(r.cwd,t,e)),r={overwrite:!0,...r};let n=await d3(t),{size:i}=n;_it(n,t);let o=bf.dirname(e);if(bf.parse(o).root===o||await ive(bf.dirname(e),{mode:r.directoryMode}),typeof r.onProgress=="function"){let a=await tve(t),c=eve(e,{flags:r.overwrite?"w":"wx"}),l=p=>{r.onProgress({sourcePath:bf.resolve(t),destinationPath:bf.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 Fn(`Cannot read from \`${t}\`: ${p.message}`,{cause:p})});let f=!1;try{let p=tN(c,"close");a.pipe(c),await p,l(i),f=!0}catch(p){throw new Fn(`Cannot write to \`${e}\`: ${p.message}`,{cause:p})}if(d)throw d;if(f){let p=await d3(t);return Promise.all([rve(e,p.atime,p.mtime).catch(h=>{if(h.code!=="EPERM")throw h}),nve(e,p.mode)])}}else{let a=r.overwrite?f3.COPYFILE_FICLONE:f3.COPYFILE_FICLONE|f3.COPYFILE_EXCL;try{await p3.copyFile(t,e,a),await Promise.all([p3.utimes(e,n.atime,n.mtime).catch(c=>{if(c.code!=="EPERM")throw c}),p3.chmod(e,n.mode)])}catch(c){throw new Fn(c.message,{cause:c})}}}async function h3(t,e,r){return(await Db(t,(i,o)=>Promise.all([e(i,o),i]),r)).filter(i=>!!i[0]).map(i=>i[1])}import bwe from"process";import glt from"fs";import d_ from"path";import{on as yit,once as Sit}from"events";import{PassThrough as Eit}from"stream";import{finished as cve}from"stream/promises";function y3(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)g3(i);let e=t.some(({readableObjectMode:i})=>i),r=vit(t,e),n=new m3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&dve(n),n}var vit=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},m3=class extends Eit{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){g3(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=bit(this,this.#e),xit({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return g3(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},bit=async(t,e)=>{sN(t,sve);let r=new AbortController;try{await Promise.race([Tit(t,r),wit(t,e,r)])}finally{r.abort(),sN(t,-sve)}},Tit=async(t,{signal:e})=>{await cve(t,{signal:e,cleanup:!0})},wit=async(t,e,{signal:r})=>{for await(let[n]of yit(t,"unpipe",{signal:r}))e.has(n)&&n.emit(uve)},g3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},xit=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o})=>{sN(t,ave);let s=new AbortController;try{await Promise.race([Ait(o,e),Rit({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:s}),Cit({stream:e,streams:r,ended:n,aborted:i,controller:s})])}finally{s.abort(),sN(t,-ave)}r.size===n.size+i.size&&(n.size===0&&i.size>0?_3(t):dve(t))},lve=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ait=async(t,e)=>{try{await t,_3(e)}catch(r){lve(r)?_3(e):fve(e,r)}},Rit=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await cve(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;lve(s)?i.add(e):fve(t,s)}},Cit=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await Sit(t,uve,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},uve=Symbol("unpipe"),dve=t=>{t.writable&&t.end()},_3=t=>{(t.readable||t.writable)&&t.destroy()},fve=(t,e)=>{t.destroyed||(t.once("error",Pit),t.destroy(e))},Pit=()=>{},sN=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},sve=2,ave=1;var f_=wn(Vb(),1);import jct from"fs";import Bct from"fs/promises";async function iY(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await Bct[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function oY(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return jct[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var rcr=iY.bind(void 0,"stat","isFile"),nwe=iY.bind(void 0,"stat","isDirectory"),ncr=iY.bind(void 0,"lstat","isSymbolicLink"),icr=oY.bind(void 0,"statSync","isFile"),iwe=oY.bind(void 0,"statSync","isDirectory"),ocr=oY.bind(void 0,"lstatSync","isSymbolicLink");var pY=wn(Vb(),1),pwe=wn(fY(),1);import llt from"process";import ult from"fs";import dlt from"fs/promises";import u_ from"path";function l_(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var Hb=t=>t[0]==="!";var flt=["**/node_modules","**/flow-typed","**/coverage","**/.git"],hwe={absolute:!0,dot:!0},mwe="**/.gitignore",plt=(t,e)=>Hb(t)?"!"+u_.posix.join(e,t.slice(1)):u_.posix.join(e,t),hlt=(t,e)=>{let r=l_(u_.relative(e,u_.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>plt(n,r))},mlt=(t,e)=>{if(e=l_(e),u_.isAbsolute(t)){if(l_(t).startsWith(e))return u_.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},gwe=(t,e)=>{let r=t.flatMap(i=>hlt(i,e)),n=(0,pwe.default)().add(r);return i=>(i=Zn(i),i=mlt(i,e),i?n.ignores(l_(i)):!1)},_we=(t={})=>({cwd:Zn(t.cwd)??llt.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...flt]}),ywe=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=_we(e),s=await(0,pY.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...hwe}),a=await Promise.all(s.map(async c=>({filePath:c,content:await dlt.readFile(c,"utf8")})));return gwe(a,r)},Swe=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=_we(e),a=pY.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...hwe}).map(c=>({filePath:c,content:ult.readFileSync(c,"utf8")}));return gwe(a,r)};var _lt=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},Twe=(t,e)=>{let r=Hb(t)?t.slice(1):t;return d_.isAbsolute(r)?r:d_.join(e,r)},wwe=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>d_.posix.join(t,`**/${d_.extname(i)?i:`${i}${n}`}`)):[d_.posix.join(t,`**${n?`/*${n}`:""}`)]},Ewe=async(t,{cwd:e=bwe.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async o=>await nwe(Twe(o,e))?wwe({directoryPath:o,files:r,extensions:n}):o))).flat(),vwe=(t,{cwd:e=bwe.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>iwe(Twe(i,e))?wwe({directoryPath:i,files:r,extensions:n}):i),hY=t=>(t=[...new Set([t].flat())],_lt(t),t),ylt=t=>{if(!t)return;let e;try{e=glt.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},xwe=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Zn(t.cwd)},ylt(t.cwd),t),Awe=t=>async(e,r)=>t(hY(e),xwe(r)),UN=t=>(e,r)=>t(hY(e),xwe(r)),Rwe=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?hY(e):[];return r&&n.push(mwe),n},Slt=async t=>{let e=Rwe(t);return Pwe(e.length>0&&await ywe(e,t))},Cwe=t=>{let e=Rwe(t);return Pwe(e.length>0&&Swe(e,t))},Pwe=t=>{let e=new Set;return r=>{let n=d_.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},Iwe=(t,e)=>t.flat().filter(r=>e(r)),Owe=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(o=>Hb(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},Nwe=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),kwe=async(t,e)=>{let r=Owe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=Nwe(i,n);return Promise.all(r.map(async s=>{let{patterns:a,options:c}=s;return[a,c.ignore]=await Promise.all([Ewe(a,o),Ewe(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},mY=(t,e)=>{let r=Owe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=Nwe(i,n);return r.map(s=>{let{patterns:a,options:c}=s;return a=vwe(a,o),c.ignore=vwe(c.ignore,{cwd:n}),{patterns:a,options:c}})},Acr=Awe(async(t,e)=>{let[r,n]=await Promise.all([kwe(t,e),Slt(e)]),i=await Promise.all(r.map(o=>(0,f_.default)(o.patterns,o.options)));return Iwe(i,n)}),Mwe=UN((t,e)=>{let r=mY(t,e),n=Cwe(e),i=r.map(o=>f_.default.sync(o.patterns,o.options));return Iwe(i,n)}),Rcr=UN((t,e)=>{let r=mY(t,e),n=Cwe(e),i=r.map(s=>f_.default.stream(s.patterns,s.options));return y3(i).filter(s=>n(s))}),Af=UN((t,e)=>t.some(r=>f_.default.isDynamicPattern(r,e))),Ccr=Awe(kwe),Pcr=UN(mY),{convertPathToPattern:Icr}=f_.default;var Dwe=wn(z3(),1);var du=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CpyError"}};import zN from"path";import $we from"fs";var Elt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],vlt=new RegExp(Elt.join("|"));function blt(t){return vlt.test(t)}function FN(t){return!blt(t)}var Wb=class{constructor(e,r,n){this.path=e,this.originalPath=e,this.destination=r,this.options=n,this.isDirectory=!1,!Af(e)&&$we.existsSync(e)&&$we.lstatSync(e).isDirectory()&&(this.path=[e,"**"].join("/"),this.isDirectory=!0)}get name(){return zN.basename(this.originalPath)}get normalizedPath(){let e=this.originalPath.split("/"),r=e.findIndex(i=>i?Af(i):!1),n=e.slice(0,r).join("/");return n?zN.isAbsolute(n)?n:zN.join(this.options.cwd,n):this.destination}hasMagic(){return Af(this.options.flat?this.path:this.originalPath)}getMatches(){let e=Mwe(this.path,{...this.options,dot:!0,absolute:!0,onlyFiles:!0});return this.options.ignoreJunk&&(e=e.filter(r=>FN(zN.basename(r)))),e}};var Alt={ignoreJunk:!0,flat:!1,cwd:Tlt.cwd()},gY=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)}},Rlt=t=>t.flatMap(e=>Dwe.default.braces(e,{expand:!0,nodupes:!0})),Clt=({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)),Plt=(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 _Y(t,e,{concurrency:r=xlt.availableParallelism(),...n}={}){let i=new Map,o=new wlt;n={...Alt,...n};let s=(async()=>{let a=[],c=0,l=0,u=Rlt([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 du("`source` and `destination` required");u=u.map(h=>new Wb(h,e,{...n,ignore:f}));for(let h of u){let m=[];try{m=h.getMatches()}catch(g){throw new du(`Cannot glob \`${h.originalPath}\`: ${g.message}`,{cause:g})}if(m.length===0&&!Af(h.originalPath)&&!Af(f))throw new du(`Cannot copy \`${h.originalPath}\`: the file doesn't exist`);a=[...a,...m.map(g=>new gY(g,bt.relative(n.cwd,g),h))]}n.filter!==void 0&&(a=await h3(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 Db(a,async h=>{let m=Plt(Clt({entry:h,destination:e,options:n}),n.rename);try{await ove(h.path,m,{...n,onProgress:p})}catch(g){throw new du(`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 txe from"process";import Jlt from"fs";import m_ from"path";import{on as Ilt,once as Olt}from"events";import{PassThrough as Nlt}from"stream";import{finished as Fwe}from"stream/promises";function vY(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)SY(i);let e=t.some(({readableObjectMode:i})=>i),r=klt(t,e),n=new yY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&Bwe(n),n}var klt=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},yY=class extends Nlt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){SY(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=Mlt(this,this.#e),Llt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return SY(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},Mlt=async(t,e)=>{jN(t,Lwe);let r=new AbortController;try{await Promise.race([$lt(t,r),Dlt(t,e,r)])}finally{r.abort(),jN(t,-Lwe)}},$lt=async(t,{signal:e})=>{await Fwe(t,{signal:e,cleanup:!0})},Dlt=async(t,e,{signal:r})=>{for await(let[n]of Ilt(t,"unpipe",{signal:r}))e.has(n)&&n.emit(jwe)},SY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Llt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o})=>{jN(t,Uwe);let s=new AbortController;try{await Promise.race([Ult(o,e),Flt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:s}),zlt({stream:e,streams:r,ended:n,aborted:i,controller:s})])}finally{s.abort(),jN(t,-Uwe)}r.size===n.size+i.size&&(n.size===0&&i.size>0?EY(t):Bwe(t))},zwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ult=async(t,e)=>{try{await t,EY(e)}catch(r){zwe(r)?EY(e):qwe(e,r)}},Flt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Fwe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;zwe(s)?i.add(e):qwe(t,s)}},zlt=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await Olt(t,jwe,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},jwe=Symbol("unpipe"),Bwe=t=>{t.writable&&t.end()},EY=t=>{(t.readable||t.writable)&&t.destroy()},qwe=(t,e)=>{t.destroyed||(t.once("error",jlt),t.destroy(e))},jlt=()=>{},jN=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Lwe=2,Uwe=1;var g_=wn(Vb(),1);import Blt from"fs";import qlt from"fs/promises";async function bY(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await qlt[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function TY(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return Blt[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var rlr=bY.bind(void 0,"stat","isFile"),Vwe=bY.bind(void 0,"stat","isDirectory"),nlr=bY.bind(void 0,"lstat","isSymbolicLink"),ilr=TY.bind(void 0,"statSync","isFile"),Gwe=TY.bind(void 0,"statSync","isDirectory"),olr=TY.bind(void 0,"lstatSync","isSymbolicLink");var wY=wn(Vb(),1),Hwe=wn(fY(),1);import Vlt from"process";import Glt from"fs";import Hlt from"fs/promises";import h_ from"path";function p_(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var Yb=t=>t[0]==="!";var Wlt=["**/node_modules","**/flow-typed","**/coverage","**/.git"],Wwe={absolute:!0,dot:!0},Ywe="**/.gitignore",Ylt=(t,e)=>Yb(t)?"!"+h_.posix.join(e,t.slice(1)):h_.posix.join(e,t),Klt=(t,e)=>{let r=p_(h_.relative(e,h_.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>Ylt(n,r))},Zlt=(t,e)=>{if(e=p_(e),h_.isAbsolute(t)){if(p_(t).startsWith(e))return h_.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},Kwe=(t,e)=>{let r=t.flatMap(i=>Klt(i,e)),n=(0,Hwe.default)().add(r);return i=>(i=Zn(i),i=Zlt(i,e),i?n.ignores(p_(i)):!1)},Zwe=(t={})=>({cwd:Zn(t.cwd)??Vlt.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...Wlt]}),Jwe=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=Zwe(e),s=await(0,wY.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...Wwe}),a=await Promise.all(s.map(async c=>({filePath:c,content:await Hlt.readFile(c,"utf8")})));return Kwe(a,r)},Xwe=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:o}=Zwe(e),a=wY.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:o,...Wwe}).map(c=>({filePath:c,content:Glt.readFileSync(c,"utf8")}));return Kwe(a,r)};var Xlt=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},rxe=(t,e)=>{let r=Yb(t)?t.slice(1):t;return m_.isAbsolute(r)?r:m_.join(e,r)},nxe=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>m_.posix.join(t,`**/${m_.extname(i)?i:`${i}${n}`}`)):[m_.posix.join(t,`**${n?`/*${n}`:""}`)]},Qwe=async(t,{cwd:e=txe.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async o=>await Vwe(rxe(o,e))?nxe({directoryPath:o,files:r,extensions:n}):o))).flat(),exe=(t,{cwd:e=txe.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>Gwe(rxe(i,e))?nxe({directoryPath:i,files:r,extensions:n}):i),xY=t=>(t=[...new Set([t].flat())],Xlt(t),t),Qlt=t=>{if(!t)return;let e;try{e=Jlt.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},ixe=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:Zn(t.cwd)},Qlt(t.cwd),t),oxe=t=>async(e,r)=>t(xY(e),ixe(r)),BN=t=>(e,r)=>t(xY(e),ixe(r)),sxe=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?xY(e):[];return r&&n.push(Ywe),n},eut=async t=>{let e=sxe(t);return cxe(e.length>0&&await Jwe(e,t))},axe=t=>{let e=sxe(t);return cxe(e.length>0&&Xwe(e,t))},cxe=t=>{let e=new Set;return r=>{let n=m_.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},lxe=(t,e)=>t.flat().filter(r=>e(r)),uxe=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(o=>Yb(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},dxe=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),fxe=async(t,e)=>{let r=uxe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=dxe(i,n);return Promise.all(r.map(async s=>{let{patterns:a,options:c}=s;return[a,c.ignore]=await Promise.all([Qwe(a,o),Qwe(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},AY=(t,e)=>{let r=uxe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let o=dxe(i,n);return r.map(s=>{let{patterns:a,options:c}=s;return a=exe(a,o),c.ignore=exe(c.ignore,{cwd:n}),{patterns:a,options:c}})},pxe=oxe(async(t,e)=>{let[r,n]=await Promise.all([fxe(t,e),eut(e)]),i=await Promise.all(r.map(o=>(0,g_.default)(o.patterns,o.options)));return lxe(i,n)}),xlr=BN((t,e)=>{let r=AY(t,e),n=axe(e),i=r.map(o=>g_.default.sync(o.patterns,o.options));return lxe(i,n)}),Alr=BN((t,e)=>{let r=AY(t,e),n=axe(e),i=r.map(s=>g_.default.stream(s.patterns,s.options));return vY(i).filter(s=>n(s))}),Rlr=BN((t,e)=>t.some(r=>g_.default.isDynamicPattern(r,e))),Clr=oxe(fxe),Plr=BN(AY),{convertPathToPattern:Ilr}=g_.default;import rut from"process";import Kb from"path";import Ulr,{promises as qN}from"fs";import klr,{promises as tut}from"fs";async function hxe(t){try{return await tut.access(t),!0}catch{return!1}}var nut=(t,e,r)=>(e=Kb.resolve(t,e),r=Kb.resolve(t,r),{sourcePath:e,destinationPath:r}),iut=(t,e,r="Path")=>{if(!t||!e)throw new TypeError(`\`source${r}\` and \`destination${r}\` required`)},out=(t,e)=>{if(Kb.dirname(t)!==Kb.dirname(e))throw new Error("`source` and `destination` must be in the same directory")},sut=async(t,e,{overwrite:r=!0,cwd:n=rut.cwd(),directoryMode:i,validateDirectory:o=!1}={})=>{if(n&&({sourcePath:t,destinationPath:e}=nut(n,t,e)),o&&out(t,e),!r&&await hxe(e))throw new Error(`The destination file exists: ${e}`);await qN.mkdir(Kb.dirname(e),{recursive:!0,mode:i});try{await qN.rename(t,e)}catch(s){if(s.code==="EXDEV")await qN.copyFile(t,e),await qN.unlink(t);else throw s}};async function mxe(t,e,r){return iut(t,e),sut(t,e,r)}var RY=async function(t,e,r=!1){if(r)return mxe(t,e,{overwrite:!1});let{srcGlob:n,dest:i,...o}=await yxe(t,_xe(e));if(n&&i)return _Y(n,i,{...o,overwrite:!1})},Zb=async function(t){let{srcGlob:e,isDir:r,dest:n,...i}=await yxe(t,"");return e!==void 0&&!await lut(e,r,i)},lut=async function(t,e,r){return e?(await pxe(t,r)).filter(o=>FN(gxe(o))).length===0:!1},yxe=async function(t,e){let r=await uut(t);if(r===void 0)return{srcGlob:void 0,isDir:!1,cwd:""};let n=r.isDirectory(),i=gxe(t),o=_xe(t),s={srcGlob:i,dest:e,isDir:n,cwd:o,dot:!0};return n?{...s,srcGlob:`${i}/**`,dest:cut(e,i)}:s},uut=async t=>{try{return await aut.stat(t)}catch{return}};import{join as odt}from"path";import{stat as dut,lstat as Sxe,readdir as fut,realpath as put}from"fs/promises";import{Readable as hut}from"stream";import{resolve as Exe,relative as mut,join as gut,sep as _ut}from"path";var Oi={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},CY={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:Oi.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(CY);var wxe="READDIRP_RECURSIVE_ERROR",yut=new Set(["ENOENT","EPERM","EACCES","ELOOP",wxe]),vxe=[Oi.DIR_TYPE,Oi.EVERYTHING_TYPE,Oi.FILE_DIR_TYPE,Oi.FILE_TYPE],Sut=new Set([Oi.DIR_TYPE,Oi.EVERYTHING_TYPE,Oi.FILE_DIR_TYPE]),Eut=new Set([Oi.EVERYTHING_TYPE,Oi.FILE_DIR_TYPE,Oi.FILE_TYPE]),vut=t=>yut.has(t.code),but=process.platform==="win32",bxe=t=>!0,Txe=t=>{if(t===void 0)return bxe;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 bxe},PY=class extends hut{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...CY,...e},{root:n,type:i}=r;this._fileFilter=Txe(r.fileFilter),this._directoryFilter=Txe(r.directoryFilter);let o=r.lstat?Sxe:dut;but?this._stat=s=>o(s,{bigint:!0}):this._stat=o,this._maxDepth=r.depth??CY.depth,this._wantsDir=i?Sut.has(i):!1,this._wantsFile=i?Eut.has(i):!1,this._wantsEverything=i===Oi.EVERYTHING_TYPE,this._root=Exe(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 fut(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=Exe(gut(r,i));n={path:mut(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){vut(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 put(n),o=await Sxe(i);if(o.isFile())return"file";if(o.isDirectory()){let s=i.length;if(n.startsWith(i)&&n.substr(s,1)===_ut){let a=new Error(`Circular symlink detected: "${n}" points to "${i}"`);return a.code=wxe,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 Tut(t,e={}){let r=e.entryType||e.type;if(r==="both"&&(r=Oi.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&&!vxe.includes(r))throw new Error(`readdirp: Invalid type passed. Use one of ${vxe.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new PY(e)}function xxe(t,e={}){return new Promise((r,n)=>{let i=[];Tut(t,e).on("data",o=>i.push(o)).on("end",()=>r(i)).on("error",o=>n(o))})}import{mkdir as Dut,readFile as Nxe,rm as Lut,writeFile as Uut}from"fs/promises";import{existsSync as kxe}from"fs";import{dirname as Fut}from"path";var Axe=t=>{if(!(!Number.isInteger(t)||t<1))return Date.now()+t*1e3},Rxe=t=>t!==void 0&&Date.now()>t;import{createHash as Nut}from"crypto";import{createReadStream as kut}from"fs";import Aut from"process";import Rut from"path";import aur,{promises as Cxe}from"fs";import{fileURLToPath as Cut}from"url";var IY=class{value;next;constructor(e){this.value=e}},Jb=class{#e;#r;#t;constructor(){this.clear()}enqueue(e){let r=new IY(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 VN(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 Jb,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 GN=class extends Error{constructor(e){super(),this.value=e}},wut=async(t,e)=>e(await t),xut=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new GN(e[0]);return!1};async function OY(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let i=VN(r),o=[...t].map(a=>[a,i(wut,a,e)]),s=VN(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(o.map(a=>s(xut,a)))}catch(a){if(a instanceof GN)return a.value;throw a}}var Pxe={directory:"isDirectory",file:"isFile"};function Put(t){if(!Object.hasOwnProperty.call(Pxe,t))throw new Error(`Invalid type specified: ${t}`)}var Iut=(t,e)=>e[Pxe[t]](),Out=t=>t instanceof URL?Cut(t):t;async function Ixe(t,{cwd:e=Aut.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:i,preserveOrder:o}={}){Put(r),e=Out(e);let s=n?Cxe.stat:Cxe.lstat;return OY(t,async a=>{try{let c=await s(Rut.resolve(e,a));return Iut(r,c)}catch{return!1}},{concurrency:i,preserveOrder:o})}var Mut="sha1",Oxe=async function(t,e){if(e||t.length===0)return;let r=await Ixe(t);return r===void 0?void 0:await $ut(r)},$ut=async function(t){let e=kut(t,"utf8"),r=Nut(Mut,{encoding:"hex"});return e.pipe(r),await ch(r)};var Mxe=async function({cachePath:t,move:e,ttl:r,digests:n}){let i=HN(t),o=Axe(r),s=await Oxe(n,e),c=`${JSON.stringify({expires:o,hash:s},null,2)}
|
|
622
|
-
`,l=await zut({hash:s,manifestPath:i,manifestString:c});return{manifestInfo:{manifestPath:i,manifestString:c},identical:l}},zut=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!kxe(e)?!1:await Nxe(e,"utf8")===r},$xe=async function({manifestPath:t,manifestString:e}){await Dut(Fut(t),{recursive:!0}),await Uut(t,e)},Dxe=async function(t){let e=HN(t);await Lut(e,{force:!0,recursive:!0,maxRetries:3})},HN=function(t){return`${t}${Uxe}`},Lxe=function(t){return t.endsWith(Uxe)},Uxe=".netlify.cache.json",NY=async function(t){let e=HN(t);if(!kxe(e))return!1;let{expires:r}=await jut(t);return Rxe(r)},jut=async function(t){let e=HN(t),r=await Nxe(e,"utf-8");return JSON.parse(r)};import{homedir as Hut}from"os";import{resolve as Fxe,isAbsolute as Wut,join as Yut,sep as MY}from"path";import{normalize as But}from"path";import{existsSync as qut}from"fs";import Vut from"process";var kY=function(t){try{let e=Gut(t);return qut(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},Gut=function(t=Vut.cwd()){return But(t)};var Xb=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await Kut(t,r),i=await Qut({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:i}},Kut=async function(t,e){let r=await kY(e),n=Zut(t,r);return Jut(n,r),n},Zut=function(t,e){if(Wut(t))return Fxe(t);if(e!=="")return Fxe(e,t);throw new Error(`Current directory does not exist: ${e}`)},Jut=function(t,e){if(e!==""&&Xut(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},Xut=function(t,e){return`${e}${MY}`.startsWith(`${t}${MY}`)},Qut=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Ef({cacheDir:e,cwd:r}),{name:i,relPath:o}=await edt(t,r);return Yut(n,i,o)},edt=async function(t,e){let r=await $Y(e),n=tdt(t);return r.map(({name:i,base:o})=>ndt(i,o,n)).find(Boolean)},tdt=function(t){return t.replace(rdt,"\\")},rdt=/^[a-zA-Z]:\\/,ndt=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},$Y=async function(t){return[...await idt(t),{name:"home",base:Hut()},{name:"root",base:MY}]},idt=async function(t){let e=await kY(t);return e===""?[]:[{name:"cwd",base:e}]};var sdt=1,DY=async function({cacheDir:t,cwd:e,depth:r=sdt}={}){let n=await $Y(e),i=Ef({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>adt({name:a,base:c,cacheDir:i,depth:r})))).flat()},adt=async function({name:t,base:e,cacheDir:r,depth:n}){return(await xxe(`${r}/${t}`,{fileFilter:cdt,depth:n,type:"files_directories"})).map(({path:s})=>odt(e,s))},cdt=function({basename:t}){return!Lxe(t)};var ldt=async function(t,{move:e=zxe,ttl:r=pdt,digests:n=[],cacheDir:i,cwd:o}={}){let{srcPath:s,cachePath:a}=await Xb({path:t,cacheDir:i,cwdOpt:o});if(!await Zb(s))return!1;let{manifestInfo:c,identical:l}=await Mxe({cachePath:a,move:e,ttl:r,digests:n});return l||(await LY(a,{force:!0,recursive:!0,maxRetries:3}),await RY(s,a,e),await $xe(c)),!0},udt=async function(t,{move:e=zxe,cacheDir:r,cwd:n}={}){let{srcPath:i,cachePath:o}=await Xb({path:t,cacheDir:r,cwdOpt:n});return!await Zb(o)||await NY(o)?!1:(await LY(i,{force:!0,recursive:!0,maxRetries:3}),await RY(o,i,e),!0)},ddt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Xb({path:t,cacheDir:e,cwdOpt:r});return await Zb(n)?(await LY(n,{force:!0,recursive:!0,maxRetries:3}),await Dxe(n),!0):!1},fdt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Xb({path:t,cacheDir:e,cwdOpt:r});return await Zb(n)&&!await NY(n)},zxe=!1,pdt=void 0,WN=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(i=>t(i,...r)))).some(Boolean):t(e,...r)},hdt=WN.bind(null,ldt),mdt=WN.bind(null,udt),gdt=WN.bind(null,ddt),_dt=WN.bind(null,fdt),jxe=function(t){return{save:(e,r)=>hdt(e,{...t,...r}),restore:(e,r)=>mdt(e,{...t,...r}),remove:(e,r)=>gdt(e,{...t,...r}),has:(e,r)=>_dt(e,{...t,...r}),list:e=>DY({...t,...e}),getCacheDir:e=>Ef({...t,...e})}};var ydt=ce("opencode_session"),Sdt=async t=>{try{let e=await uO(t),{stdout:r}=await Sr(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 ydt.warn("Could not list opencode sessions",{error:e?.message}),[]}},UY=new Map,Bxe=t=>{let e=UY.get(t);if(e)return e;let r=Sdt(t).finally(()=>UY.delete(t));return UY.set(t,r),r},qxe=async t=>(await Bxe(t)).length>0,Vxe=async(t,e)=>e?(await Bxe(t)).some(r=>r.id===e):!1;var Lr=ce("native_session"),FY=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await _c.stat(yc.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),Rf=async({runnerId:t,sessionId:e,archive:r,nativeSessionId:n})=>{if(!r)return Lr.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:i,include:o}=r,s=!1;try{s=(await _c.stat(i)).isDirectory()}catch{}if(!s)return Lr.log(`Native session base dir ${i} not found, skipping`),null;let a=await FY(i,o);if(a.length===0)return Lr.log(`No native session history found under ${i}, skipping`),null;let c=yc.join(Gxe.tmpdir(),`native-session-${e}.zip`);try{await Sr("zip",["-r","-q","-X",c,...a],{cwd:i});let l=await _c.readFile(c);Lr.log(`Zipped native session (${l.length} bytes) from ${a.join(", ")}`,{nativeSessionId:n});let{upload_url:u,s3_key:d}=await toe(t,e);return await loe(u,l,{contentType:"application/zip"}),Lr.log("Successfully uploaded native session to S3"),d}catch(l){return Lr.error("Failed to archive/upload native session, continuing without it:",l),null}finally{await _c.rm(c,{force:!0}).catch(()=>{})}},Hxe=async(t,e,r=process.cwd())=>{if(e==="opencode")return qxe(r);if(!t)return!1;let{baseDir:n,include:i}=t,o=await FY(n,i);for(let s of o)if((await _c.readdir(yc.join(n,s)).catch(()=>[])).length>0)return!0;return!1},Edt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Wxe=async(t,e)=>{let r=await _c.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await Wxe(yc.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},Yxe=async(t,e,r,n=process.cwd())=>{if(r==="opencode")return Vxe(n,e);if(!t||!e)return!1;let i=new RegExp(`(^|[^a-zA-Z0-9])${Edt(e)}([^a-zA-Z0-9]|$)`),{baseDir:o,include:s}=t,a=await FY(o,s);for(let c of a)if(await Wxe(yc.join(o,c),i))return!0;return!1},Kxe=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return Lr.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,i=yc.join(Gxe.tmpdir(),`native-session-restore-${e}.zip`);try{let o=await roe(t,e);if(!o?.download_url)return Lr.log("No native session available to restore, skipping"),!1;let s=await coe(o.download_url);return await _c.writeFile(i,s),Lr.log(`Downloaded native session (${s.length} bytes) to ${i}`),await _c.mkdir(n,{recursive:!0}),await Sr("unzip",["-o","-q",i,"-d",n]),Lr.log(`Restored native session into ${n}`),!0}catch(o){return Lr.error("Failed to fetch/restore native session, continuing without it:",o),!1}finally{await _c.rm(i,{force:!0}).catch(()=>{})}},vdt="native-sessions",Zxe=(t,e)=>jxe({cacheDir:yc.join(e.dir,vdt),cwd:t}),Jxe=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await Zxe(r,e).restore(n.map(o=>yc.join(r,o)),{})?(Lr.log(`Restored native session from buildbot cache into ${r}`),!0):(Lr.log("No native session in buildbot cache, skipping restore"),!1)}catch(i){return Lr.error("Failed to restore native session from buildbot cache, continuing without it:",i),!1}},Qb=async({archive:t,cache:e,nativeSessionId:r})=>{if(!e?.dir||!t)return Lr.log("No buildbot cache configured for the native session, skipping cache seed",{nativeSessionId:r}),!1;let{baseDir:n,include:i}=t;try{return await Zxe(n,e).save(i.map(s=>yc.join(n,s)),{})?(Lr.log(`Saved native session to buildbot cache under ${e.dir}`,{nativeSessionId:r}),!0):(Lr.log("No native session history to save to buildbot cache, skipping"),!1)}catch(o){return Lr.error("Failed to save native session to buildbot cache, continuing:",o),!1}};var __=ce("inference_stage"),Xxe=5,fu=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(Cs())throw new Error("Shutdown in progress, aborting inference stage");__.log(`Running inference stage, attempt ${l} of ${Xxe}`);let b=!1,T=await $t(dt(),"inference-stage",async S=>{S?.setAttributes({"inference.attempt":l||1}),Nie();let w=!!(l&&l>1),I=await bdt(n,w,f),C=!!m&&!!d;C&&n.runner==="gemini"&&!await Dv(d)&&(C=!1);let N=I.viable||C;b=N,I.outcome!=="not_eligible"&&re.inc("inference.native_resume",1,{outcome:I.outcome,...I.source?{source:I.source}:{}});let k=n;if("prompt"in n&&n.answeredInteraction&&Ve().questionsEnabled){let x=n.answeredInteraction,O=N||w&&!!d,W=[x];if(!O){_.allAnswered??=DEe(n);let H=await _.allAnswered;H===null&&(_.allAnswered=void 0),H&&H.length>0&&(W=H.some(me=>me.refId===x.refId)?H:[...H,x])}k={...n,prompt:FEe(n.prompt,W)},!w&&!_.counted&&(_.counted=!0,__.log("Resuming session with answered questions",{sessionId:n.sessionId,interactionCount:W.length}),re.inc("inference.answer_resume",1,{fold:O?"latest":"all"}),UEe(x))}let{prompt:U}=await $t(dt(),"compose-prompt",async()=>await TEe({cliPath:r,config:k,buildErrorContext:Tdt(o),netlify:i,additionalContext:e,resumePrompt:N,preserveResultsFile:!!m})),v=`
|
|
622
|
+
`,l=await zut({hash:s,manifestPath:i,manifestString:c});return{manifestInfo:{manifestPath:i,manifestString:c},identical:l}},zut=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!kxe(e)?!1:await Nxe(e,"utf8")===r},$xe=async function({manifestPath:t,manifestString:e}){await Dut(Fut(t),{recursive:!0}),await Uut(t,e)},Dxe=async function(t){let e=HN(t);await Lut(e,{force:!0,recursive:!0,maxRetries:3})},HN=function(t){return`${t}${Uxe}`},Lxe=function(t){return t.endsWith(Uxe)},Uxe=".netlify.cache.json",NY=async function(t){let e=HN(t);if(!kxe(e))return!1;let{expires:r}=await jut(t);return Rxe(r)},jut=async function(t){let e=HN(t),r=await Nxe(e,"utf-8");return JSON.parse(r)};import{homedir as Hut}from"os";import{resolve as Fxe,isAbsolute as Wut,join as Yut,sep as MY}from"path";import{normalize as But}from"path";import{existsSync as qut}from"fs";import Vut from"process";var kY=function(t){try{let e=Gut(t);return qut(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},Gut=function(t=Vut.cwd()){return But(t)};var Xb=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await Kut(t,r),i=await Qut({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:i}},Kut=async function(t,e){let r=await kY(e),n=Zut(t,r);return Jut(n,r),n},Zut=function(t,e){if(Wut(t))return Fxe(t);if(e!=="")return Fxe(e,t);throw new Error(`Current directory does not exist: ${e}`)},Jut=function(t,e){if(e!==""&&Xut(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},Xut=function(t,e){return`${e}${MY}`.startsWith(`${t}${MY}`)},Qut=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Ef({cacheDir:e,cwd:r}),{name:i,relPath:o}=await edt(t,r);return Yut(n,i,o)},edt=async function(t,e){let r=await $Y(e),n=tdt(t);return r.map(({name:i,base:o})=>ndt(i,o,n)).find(Boolean)},tdt=function(t){return t.replace(rdt,"\\")},rdt=/^[a-zA-Z]:\\/,ndt=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},$Y=async function(t){return[...await idt(t),{name:"home",base:Hut()},{name:"root",base:MY}]},idt=async function(t){let e=await kY(t);return e===""?[]:[{name:"cwd",base:e}]};var sdt=1,DY=async function({cacheDir:t,cwd:e,depth:r=sdt}={}){let n=await $Y(e),i=Ef({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>adt({name:a,base:c,cacheDir:i,depth:r})))).flat()},adt=async function({name:t,base:e,cacheDir:r,depth:n}){return(await xxe(`${r}/${t}`,{fileFilter:cdt,depth:n,type:"files_directories"})).map(({path:s})=>odt(e,s))},cdt=function({basename:t}){return!Lxe(t)};var ldt=async function(t,{move:e=zxe,ttl:r=pdt,digests:n=[],cacheDir:i,cwd:o}={}){let{srcPath:s,cachePath:a}=await Xb({path:t,cacheDir:i,cwdOpt:o});if(!await Zb(s))return!1;let{manifestInfo:c,identical:l}=await Mxe({cachePath:a,move:e,ttl:r,digests:n});return l||(await LY(a,{force:!0,recursive:!0,maxRetries:3}),await RY(s,a,e),await $xe(c)),!0},udt=async function(t,{move:e=zxe,cacheDir:r,cwd:n}={}){let{srcPath:i,cachePath:o}=await Xb({path:t,cacheDir:r,cwdOpt:n});return!await Zb(o)||await NY(o)?!1:(await LY(i,{force:!0,recursive:!0,maxRetries:3}),await RY(o,i,e),!0)},ddt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Xb({path:t,cacheDir:e,cwdOpt:r});return await Zb(n)?(await LY(n,{force:!0,recursive:!0,maxRetries:3}),await Dxe(n),!0):!1},fdt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await Xb({path:t,cacheDir:e,cwdOpt:r});return await Zb(n)&&!await NY(n)},zxe=!1,pdt=void 0,WN=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(i=>t(i,...r)))).some(Boolean):t(e,...r)},hdt=WN.bind(null,ldt),mdt=WN.bind(null,udt),gdt=WN.bind(null,ddt),_dt=WN.bind(null,fdt),jxe=function(t){return{save:(e,r)=>hdt(e,{...t,...r}),restore:(e,r)=>mdt(e,{...t,...r}),remove:(e,r)=>gdt(e,{...t,...r}),has:(e,r)=>_dt(e,{...t,...r}),list:e=>DY({...t,...e}),getCacheDir:e=>Ef({...t,...e})}};var ydt=ce("opencode_session"),Sdt=async t=>{try{let e=await uO(t),{stdout:r}=await Sr(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 ydt.warn("Could not list opencode sessions",{error:e?.message}),[]}},UY=new Map,Bxe=t=>{let e=UY.get(t);if(e)return e;let r=Sdt(t).finally(()=>UY.delete(t));return UY.set(t,r),r},qxe=async t=>(await Bxe(t)).length>0,Vxe=async(t,e)=>e?(await Bxe(t)).some(r=>r.id===e):!1;var Lr=ce("native_session"),FY=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await _c.stat(yc.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),Rf=async({runnerId:t,sessionId:e,archive:r,nativeSessionId:n})=>{if(!r)return Lr.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:i,include:o}=r,s=!1;try{s=(await _c.stat(i)).isDirectory()}catch{}if(!s)return Lr.log(`Native session base dir ${i} not found, skipping`),null;let a=await FY(i,o);if(a.length===0)return Lr.log(`No native session history found under ${i}, skipping`),null;let c=yc.join(Gxe.tmpdir(),`native-session-${e}.zip`);try{await Sr("zip",["-r","-q","-X",c,...a],{cwd:i});let l=await _c.readFile(c);Lr.log(`Zipped native session (${l.length} bytes) from ${a.join(", ")}`,{nativeSessionId:n});let{upload_url:u,s3_key:d}=await toe(t,e);return await loe(u,l,{contentType:"application/zip"}),Lr.log("Successfully uploaded native session to S3"),d}catch(l){return Lr.error("Failed to archive/upload native session, continuing without it:",l),null}finally{await _c.rm(c,{force:!0}).catch(()=>{})}},Hxe=async(t,e,r=process.cwd())=>{if(e==="opencode")return qxe(r);if(!t)return!1;let{baseDir:n,include:i}=t,o=await FY(n,i);for(let s of o)if((await _c.readdir(yc.join(n,s)).catch(()=>[])).length>0)return!0;return!1},Edt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Wxe=async(t,e)=>{let r=await _c.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await Wxe(yc.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},Yxe=async(t,e,r,n=process.cwd())=>{if(r==="opencode")return Vxe(n,e);if(!t||!e)return!1;let i=new RegExp(`(^|[^a-zA-Z0-9])${Edt(e)}([^a-zA-Z0-9]|$)`),{baseDir:o,include:s}=t,a=await FY(o,s);for(let c of a)if(await Wxe(yc.join(o,c),i))return!0;return!1},Kxe=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return Lr.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,i=yc.join(Gxe.tmpdir(),`native-session-restore-${e}.zip`);try{let o=await roe(t,e);if(!o?.download_url)return Lr.log("No native session available to restore, skipping"),!1;let s=await coe(o.download_url);return await _c.writeFile(i,s),Lr.log(`Downloaded native session (${s.length} bytes) to ${i}`),await _c.mkdir(n,{recursive:!0}),await Sr("unzip",["-o","-q",i,"-d",n]),Lr.log(`Restored native session into ${n}`),!0}catch(o){return Lr.error("Failed to fetch/restore native session, continuing without it:",o),!1}finally{await _c.rm(i,{force:!0}).catch(()=>{})}},vdt="native-sessions",Zxe=(t,e)=>jxe({cacheDir:yc.join(e.dir,vdt),cwd:t}),Jxe=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await Zxe(r,e).restore(n.map(o=>yc.join(r,o)),{})?(Lr.log(`Restored native session from buildbot cache into ${r}`),!0):(Lr.log("No native session in buildbot cache, skipping restore"),!1)}catch(i){return Lr.error("Failed to restore native session from buildbot cache, continuing without it:",i),!1}},Qb=async({archive:t,cache:e,nativeSessionId:r})=>{if(!e?.dir||!t)return Lr.log("No buildbot cache configured for the native session, skipping cache seed",{nativeSessionId:r}),!1;let{baseDir:n,include:i}=t;try{return await Zxe(n,e).save(i.map(s=>yc.join(n,s)),{})?(Lr.log(`Saved native session to buildbot cache under ${e.dir}`,{nativeSessionId:r}),!0):(Lr.log("No native session history to save to buildbot cache, skipping"),!1)}catch(o){return Lr.error("Failed to save native session to buildbot cache, continuing:",o),!1}};var __=ce("inference_stage"),Xxe=5,fu=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(Cs())throw new Error("Shutdown in progress, aborting inference stage");__.log(`Running inference stage, attempt ${l} of ${Xxe}`);let b=!1,T=await $t(dt(),"inference-stage",async S=>{S?.setAttributes({"inference.attempt":l||1}),Nie();let w=!!(l&&l>1),I=await bdt({config:n,isRetry:w,cwd:f,resumeForCreditWrapUp:m}),C=!!m&&!!d;C&&n.runner==="gemini"&&!await Dv(d)&&(C=!1);let N=I.viable||C;b=N,I.outcome!=="not_eligible"&&re.inc("inference.native_resume",1,{outcome:I.outcome,...I.source?{source:I.source}:{}});let k=n;if("prompt"in n&&n.answeredInteraction&&Ve().questionsEnabled){let x=n.answeredInteraction,O=N||w&&!!d,W=[x];if(!O){_.allAnswered??=DEe(n);let H=await _.allAnswered;H===null&&(_.allAnswered=void 0),H&&H.length>0&&(W=H.some(me=>me.refId===x.refId)?H:[...H,x])}k={...n,prompt:FEe(n.prompt,W)},!w&&!_.counted&&(_.counted=!0,__.log("Resuming session with answered questions",{sessionId:n.sessionId,interactionCount:W.length}),re.inc("inference.answer_resume",1,{fold:O?"latest":"all"}),UEe(x))}let{prompt:U}=await $t(dt(),"compose-prompt",async()=>await TEe({cliPath:r,config:k,buildErrorContext:Tdt(o),netlify:i,additionalContext:e,resumePrompt:N,preserveResultsFile:!!m})),v=`
|
|
623
623
|
${u||""}
|
|
624
624
|
${U}
|
|
625
|
-
`.trim(),ee={...n,prompt:v},$=d??(N?I.sessionId:void 0),E=await $t(dt(),`run-${n.runner}`,async x=>{let O=rF();x?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":Fie(n.runner),"gen_ai.system":n.runner,...O?{"gen_ai.input.messages":FR("user",v)}:{}});let W=Date.now(),H=await s({aiGateway:c,config:ee,netlify:i,persistSteps:a,continueSession:w||N,priorAgentSessionId:$,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 x?.setAttributes({...O?{"gen_ai.output.messages":FR("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}:{}}),zie(H.steps??[],n.mode,W,me),H});return E.result&&(E.result=Kn(E.result)),E.error&&(E.error=Kn(E.error)),await a.flush(),E});if(T.aborted)return __.log("Inference turn was interrupted (credit wrap-up); skipping retry/error handling",{agentSessionId:T.agentSessionId}),{runnerResult:T,nativeResume:b};if(T.error){if(Cs()){let C=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(C,{agentSessionId:T.agentSessionId}),C}let S=T.providerFailure,w=CI(S);__.error("Runner failed",{stepsCount:T.steps.length,duration:T.duration,error:T.error,isRetryableError:T.isRetryableError,attempt:l||1,agentSessionId:T.agentSessionId,...S?{providerFailure:S,failureClass:w?.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:S?.status??"none",failure_class:w?.failureClass??"unclassified"});let I=w?.maxAttempts??Xxe;if(T.isRetryableError&&(!l||l<I))return __.log("Retrying inference stage"),await new Promise(N=>setTimeout(N,5e3)),{runnerResult:(await fu({...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(__.log("Do not retry inference stage"),T.error.toLowerCase().includes("usage exceeded")){let N=new Io(T.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);throw Object.assign(N,{agentSessionId:T.agentSessionId}),N}let C=T.isRetryableError||T.isProviderUnavailableError?new Zp(T.error):new Error(T.error);throw Object.assign(C,{agentSessionId:T.agentSessionId}),C}}return{runnerResult:T,nativeResume:b}},bdt=async(t,e,r=process.cwd())=>{if(e)return{viable:!1,outcome:"not_eligible"};let
|
|
625
|
+
`.trim(),ee={...n,prompt:v},$=d??(N?I.sessionId:void 0),E=await $t(dt(),`run-${n.runner}`,async x=>{let O=rF();x?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":Fie(n.runner),"gen_ai.system":n.runner,...O?{"gen_ai.input.messages":FR("user",v)}:{}});let W=Date.now(),H=await s({aiGateway:c,config:ee,netlify:i,persistSteps:a,continueSession:w||N,priorAgentSessionId:$,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 x?.setAttributes({...O?{"gen_ai.output.messages":FR("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}:{}}),zie(H.steps??[],n.mode,W,me),H});return E.result&&(E.result=Kn(E.result)),E.error&&(E.error=Kn(E.error)),await a.flush(),E});if(T.aborted)return __.log("Inference turn was interrupted (credit wrap-up); skipping retry/error handling",{agentSessionId:T.agentSessionId}),{runnerResult:T,nativeResume:b};if(T.error){if(Cs()){let C=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(C,{agentSessionId:T.agentSessionId}),C}let S=T.providerFailure,w=CI(S);__.error("Runner failed",{stepsCount:T.steps.length,duration:T.duration,error:T.error,isRetryableError:T.isRetryableError,attempt:l||1,agentSessionId:T.agentSessionId,...S?{providerFailure:S,failureClass:w?.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:S?.status??"none",failure_class:w?.failureClass??"unclassified"});let I=w?.maxAttempts??Xxe;if(T.isRetryableError&&(!l||l<I))return __.log("Retrying inference stage"),await new Promise(N=>setTimeout(N,5e3)),{runnerResult:(await fu({...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(__.log("Do not retry inference stage"),T.error.toLowerCase().includes("usage exceeded")){let N=new Io(T.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);throw Object.assign(N,{agentSessionId:T.agentSessionId}),N}let C=T.isRetryableError||T.isProviderUnavailableError?new Zp(T.error):new Error(T.error);throw Object.assign(C,{agentSessionId:T.agentSessionId}),C}}return{runnerResult:T,nativeResume:b}},bdt=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}=OEe(t);if(!o)return{viable:o,outcome:s};let a=i?.nativeSessionId,c=Gs(t.runner),l=async()=>a?t.runner==="gemini"?!!await PG(a):Yxe(c,a,t.runner,r):!1,u;if(PEe(t)&&await Hxe(c,t.runner,r))u="local";else if(t.fastInit&&Ve().warmNativeResumeEnabled&&await Jxe({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 Kxe({runnerId:t.id,sessionId:t.sessionId,archive:c}))return{viable:!1,outcome:"fetch_failed",source:u}}return t.runner==="gemini"&&a&&!await Dv(a)?{viable:!1,outcome:"sanitize_failed",source:u}:{viable:!0,sessionId:a,outcome:"resumed",source:u}},Tdt=t=>!t||t.length===0?"":`
|
|
626
626
|
Deploy failed. Here are the errors to review on the latest build:
|
|
627
627
|
|
|
628
628
|
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.
|