@netlify/agent-runner-cli 1.161.3 → 1.162.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +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
|
@@ -111,7 +111,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
111
111
|
`,LF:`
|
|
112
112
|
`,concatBytes:t$},Y$e=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},K$e={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Y$e};import{Buffer as Z$e}from"buffer";var Pre=(t,e)=>t?void 0:J$e.bind(void 0,e),J$e=function*(t,e){if(typeof e!="string"&&!jt(e)&&!Z$e.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Ore=(t,e)=>t?X$e.bind(void 0,e):Q$e.bind(void 0,e),X$e=function*(t,e){Nre(t,e),yield e},Q$e=function*(t,e){if(Nre(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Nre=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
113
113
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
114
|
-
if (condition) { yield value; }`)};import{Buffer as e1e}from"buffer";import{StringDecoder as t1e}from"string_decoder";var Px=(t,e,r)=>{if(r)return;if(t)return{transform:r1e.bind(void 0,new TextEncoder)};let n=new t1e(e);return{transform:n1e.bind(void 0,n),final:i1e.bind(void 0,n)}},r1e=function*(t,e){e1e.isBuffer(e)?yield ms(e):typeof e=="string"?yield t.encode(e):yield e},n1e=function*(t,e){yield jt(e)?t.write(e):e},i1e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as kre}from"util";var n$=kre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Ox=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=s1e}=e[r];for await(let i of n(t))yield*Ox(i,e,r+1)},Mre=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*o1e(r,Number(e),t)},o1e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Ox(n,r,e+1)},Dre=kre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),s1e=function*(t){yield t};var i$=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Lre=(t,e)=>[...e.flatMap(r=>[...Ul(r,t,0)]),...$_(t)],Ul=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=c1e}=e[r];for(let i of n(t))yield*Ul(i,e,r+1)},$_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*a1e(r,Number(e),t)},a1e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Ul(n,r,e+1)},c1e=function*(t){yield t};var o$=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Ure(t,s,o),l=$l(e),u=$l(r),d=l?n$.bind(void 0,Ox,a):i$.bind(void 0,Ul),f=l||u?n$.bind(void 0,Mre,a):i$.bind(void 0,$_),p=l||u?Dre.bind(void 0,a):void 0;return{stream:new l1e({writableObjectMode:n,writableHighWaterMark:$re(n),readableObjectMode:i,readableHighWaterMark:$re(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Nx=(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=Ure(s,r,a);t=Lre(c,t)}return t},Ure=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Pre(n,a)},Px(r,s,n),Ix(r,o,n,c),{transform:t,final:e},{transform:Ore(i,a)},Ire({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Fre=(t,e)=>{for(let r of u1e(t))d1e(t,r,e)},u1e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),d1e=(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 ${La[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>f1e(a,n));r.input=R_(s)},f1e=(t,e)=>{let r=Nx(t,e,"utf8",!0);return p1e(r),R_(r)},p1e=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 _1e,appendFileSync as y1e}from"fs";var kx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&yf(r,n)&&!Tn.has(e)&&h1e(n)&&(t.some(({type:i,value:o})=>i==="native"&&m1e.has(o))||t.every(({type:i})=>Xn.has(i))),h1e=t=>t===1||t===2,m1e=new Set(["pipe","overlapped"]),Bre=async(t,e,r,n)=>{for await(let i of t)g1e(e)||zre(i,r,n)},jre=(t,e,r)=>{for(let n of t)zre(n,e,r)},g1e=t=>t._readableState.pipes.length>0,zre=(t,e,r)=>{let n=WA(t);go({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Gre=({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)=>S1e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},S1e=({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=Vte(t,o,d),p=ms(f),{stdioItems:h,objectMode:m}=e[r],S=E1e([p],h,c,n),{serializedResult:E,finalResult:b=E}=v1e({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});T1e({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&b1e(E,h,i),A}catch(y){return n.error=y,A}},E1e=(t,e,r,n)=>{try{return Nx(t,e,r,!1)}catch(i){return n.error=i,t}},v1e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:R_(t)};let s=i7(t,r);return n[o]?{serializedResult:s,finalResult:r$(s,!i[o],e)}:{serializedResult:s}},T1e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!kx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=r$(t,!1,s);try{jre(a,e,n)}catch(c){r.error??=c}},b1e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Rx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?y1e(n,t):(r.add(o),_1e(n,t))}};var Vre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ys(e,r,"all")]:Array.isArray(e)?[ys(t,r,"all"),...e]:jt(t)&&jt(e)?dL([t,e]):`${t}${e}`};import{once as s$}from"events";var qre=async(t,e)=>{let[r,n]=await A1e(t);return e.isForcefullyTerminated??=!1,[r,n]},A1e=async t=>{let[e,r]=await Promise.allSettled([s$(t,"spawn"),s$(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Hre(t):r.value},Hre=async t=>{try{return await s$(t,"exit")}catch{return Hre(t)}},Wre=async t=>{let[e,r]=await t;if(!x1e(e,r)&&a$(e,r))throw new Pi;return[e,r]},x1e=(t,e)=>t===void 0&&e===void 0,a$=(t,e)=>t!==0||e!==null;var Yre=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=w1e(t,e,r),s=o?.code==="ETIMEDOUT",a=Gte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},w1e=(t,e,r)=>t!==void 0?t:a$(e,r)?new Pi:void 0;var Kre=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=C1e(t,e,r),d=O1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Cf(d,c,l)},C1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=KA(t,e,r),a=I1e(r),{file:c,commandArguments:l,options:u}=mx(t,e,a);P1e(u);let d=xre(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},I1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,P1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Mx("ipcInput"),t&&Mx("ipc: true"),r&&Mx("detached: true"),n&&Mx("cancelSignal")},Mx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},O1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=N1e({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}=Yre(c,r),{output:h,error:m=l}=Gre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,A)=>ys(b,r,A)),E=ys(Vre(h,r),r,"all");return M1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},N1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Fre(o,r);let a=k1e(r);return R1e(...gx(t,e,a))}catch(a){return Rf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},k1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:bx(e)}),M1e=({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?Ax({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):L_({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 vFe}from"events";import{spawn as TFe}from"child_process";import ene from"process";import{once as c$,on as D1e}from"events";var Zre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(vf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:lx(t)}),L1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),L1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ox(e,i);let o=Da(t,e,r),s=new AbortController;try{return await Promise.race([$1e(o,n,s),U1e(o,r,s),F1e(o,r,s)])}catch(a){throw Tf(t),a}finally{s.abort(),sx(e,i)}},$1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await c$(t,"message",{signal:r});return n}for await(let[n]of D1e(t,"message",{signal:r}))if(e(n))return n},U1e=async(t,e,{signal:r})=>{await c$(t,"disconnect",{signal:r}),Lee(e)},F1e=async(t,e,{signal:r})=>{let[n]=await c$(t,"strict:error",{signal:r});throw rx(n,e)};import{once as Xre,on as B1e}from"events";var Qre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>l$({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),l$=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{vf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:lx(t)}),ox(e,o);let s=Da(t,e,r),a=new AbortController,c={};return j1e(t,s,a),z1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),G1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},j1e=async(t,e,r)=>{try{await Xre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},z1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Xre(t,"strict:error",{signal:r.signal});n.error=rx(i,e),r.abort()}catch{}},G1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of B1e(r,"message",{signal:o.signal}))Jre(s),yield c}catch{Jre(s)}finally{o.abort(),sx(e,a),n||Tf(t),i&&await t}},Jre=({error:t})=>{if(t)throw t};var tne=(t,{ipc:e})=>{Object.assign(t,nne(t,!1,e))},rne=()=>{let t=ene,e=!0,r=ene.channel!==void 0;return{...nne(t,e,r),getCancelSignal:lte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},nne=(t,e,r)=>({sendMessage:px.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Zre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Qre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as V1e}from"child_process";import{PassThrough as q1e,Readable as H1e,Writable as W1e,Duplex as Y1e}from"stream";var ine=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{QL(n);let a=new V1e;K1e(a,n),Object.assign(a,{readable:Z1e,writable:J1e,duplex:X1e});let c=Rf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=Q1e(c,s,i);return{subprocess:a,promise:l}},K1e=(t,e)=>{let r=U_(),n=U_(),i=U_(),o=Array.from({length:e.length-3},U_),s=U_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},U_=()=>{let t=new q1e;return t.end(),t},Z1e=()=>new H1e({read(){}}),J1e=()=>new W1e({write(){}}),X1e=()=>new Y1e({read(){},write(){}}),Q1e=async(t,e,r)=>Cf(t,e,r);import{createReadStream as one,createWriteStream as sne}from"fs";import{Buffer as eUe}from"buffer";import{Readable as F_,Writable as tUe,Duplex as rUe}from"stream";var cne=(t,e)=>Cx(nUe,t,e,!1),B_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${La[t]}.`)},ane={fileNumber:B_,generator:o$,asyncGenerator:o$,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:rUe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},nUe={input:{...ane,fileUrl:({value:t})=>({stream:one(t)}),filePath:({value:{file:t}})=>({stream:one(t)}),webStream:({value:t})=>({stream:F_.fromWeb(t)}),iterable:({value:t})=>({stream:F_.from(t)}),asyncIterable:({value:t})=>({stream:F_.from(t)}),string:({value:t})=>({stream:F_.from(t)}),uint8Array:({value:t})=>({stream:F_.from(eUe.from(t))})},output:{...ane,fileUrl:({value:t})=>({stream:sne(t)}),filePath:({value:{file:t,append:e}})=>({stream:sne(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:tUe.fromWeb(t)}),iterable:B_,asyncIterable:B_,string:B_,uint8Array:B_}};import{on as iUe,once as lne}from"events";import{PassThrough as oUe,getDefaultHighWaterMark as sUe}from"stream";import{finished as fne}from"stream/promises";function Fl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)d$(i);let e=t.some(({readableObjectMode:i})=>i),r=aUe(t,e),n=new u$({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var aUe=(t,e)=>{if(t.length===0)return sUe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},u$=class extends oUe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(d$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=cUe(this,this.#e,this.#o);let r=dUe({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(d$(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)}},cUe=async(t,e,r)=>{Dx(t,une);let n=new AbortController;try{await Promise.race([lUe(t,n),uUe(t,e,r,n)])}finally{n.abort(),Dx(t,-une)}},lUe=async(t,{signal:e})=>{try{await fne(t,{signal:e,cleanup:!0})}catch(r){throw pne(t,r),r}},uUe=async(t,e,r,{signal:n})=>{for await(let[i]of iUe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},d$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},dUe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Dx(t,dne);let a=new AbortController;try{await Promise.race([fUe(o,e,a),pUe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),hUe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Dx(t,-dne)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?f$(t):mUe(t))},fUe=async(t,e,{signal:r})=>{try{await t,r.aborted||f$(e)}catch(n){r.aborted||pne(e,n)}},pUe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await fne(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;hne(s)?i.add(e):mne(t,s)}},hUe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await lne(t,i,{signal:o}),!t.readable)return lne(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},mUe=t=>{t.writable&&t.end()},pne=(t,e)=>{hne(e)?f$(t):mne(t,e)},hne=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",f$=t=>{(t.readable||t.writable)&&t.destroy()},mne=(t,e)=>{t.destroyed||(t.once("error",gUe),t.destroy(e))},gUe=()=>{},Dx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},une=2,dne=1;import{finished as gne}from"stream/promises";var Pf=(t,e)=>{t.pipe(e),_Ue(t,e),yUe(t,e)},_Ue=async(t,e)=>{if(!(Ii(t)||Ii(e))){try{await gne(t,{cleanup:!0,readable:!0,writable:!1})}catch{}p$(e)}},p$=t=>{t.writable&&t.end()},yUe=async(t,e)=>{if(!(Ii(t)||Ii(e))){try{await gne(e,{cleanup:!0,readable:!1,writable:!0})}catch{}h$(t)}},h$=t=>{t.readable&&t.destroy()};var _ne=(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})=>Xn.has(c)))SUe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Xn.has(c)))vUe({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]:Fl(o);Pf(s,i)}},SUe=(t,e,r,n)=>{r==="output"?Pf(t.stdio[n],e):Pf(e,t.stdio[n]);let i=EUe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},EUe=["stdin","stdout","stderr"],vUe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;TUe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},TUe=(t,{signal:e})=>{Ii(t)&&Dl(t,bUe,e)},bUe=2;import{addAbortListener as wUe}from"events";var Bl=[];Bl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Lx=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",m$=Symbol.for("signal-exit emitter"),g$=globalThis,AUe=Object.defineProperty.bind(Object),_$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(g$[m$])return g$[m$];AUe(g$,m$,{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}},$x=class{},xUe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),y$=class extends $x{onExit(){return()=>{}}load(){}unload(){}},S$=class extends $x{#e=E$.platform==="win32"?"SIGINT":"SIGHUP";#r=new _$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Bl)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(!Lx(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 Bl)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,Bl.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 Lx(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"&&Lx(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)}},E$=globalThis.process,{onExit:yne,load:Lvt,unload:$vt}=xUe(Lx(E$)?new S$(E$):new y$);var Sne=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=yne(()=>{t.kill()});wUe(n,()=>{i()})};var vne=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=YA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=RUe(r,n,i),{sourceStream:d,sourceError:f}=IUe(t,l),{options:p,fileDescriptors:h}=yo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},RUe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=CUe(t,e,...r),a=ix(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},CUe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Ene,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||lL(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]=UA(r,...n);return{destination:e(Ene)(i,o,s),pipeOptions:s}}if(yo.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}`)},Ene=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),IUe=(t,e)=>{try{return{sourceStream:bf(t,e)}}catch(r){return{sourceError:r}}};var bne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=PUe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw v$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},PUe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return h$(t),n;if(e!==void 0)return p$(r),e},v$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Rf({error:t,command:Tne,escapedCommand:Tne,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Tne="source.pipe(destination)";var Ane=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 OUe}from"stream/promises";var xne=(t,e,r)=>{let n=Ux.has(e)?kUe(t,e):NUe(t,e);return Dl(t,DUe,r.signal),Dl(e,LUe,r.signal),MUe(e),n},NUe=(t,e)=>{let r=Fl([t]);return Pf(r,e),Ux.set(e,r),r},kUe=(t,e)=>{let r=Ux.get(e);return r.add(t),r},MUe=async t=>{try{await OUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Ux.delete(t)},Ux=new WeakMap,DUe=2,LUe=1;import{aborted as $Ue}from"util";var wne=(t,e)=>t===void 0?[]:[UUe(t,e)],UUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await $Ue(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw v$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Fx=(t,...e)=>{if(Ot(e[0]))return Fx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=vne(t,...e),i=FUe({...n,destination:r});return i.pipe=Fx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},FUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=BUe(t,i);bne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=xne(e,o,d);return await Promise.race([Ane(u),...wne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},BUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as WUe}from"timers/promises";import{on as jUe}from"events";import{getDefaultHighWaterMark as zUe}from"stream";var Bx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return GUe(e,s),Cne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},GUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},T$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;VUe(e,s,t);let a=t.readableObjectMode&&!o;return Cne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},VUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Cne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=jUe(t,"data",{signal:e.signal,highWaterMark:Rne,highWatermark:Rne});return qUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},b$=zUe(!0),Rne=b$,qUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=HUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Ul(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*$_(a)}},HUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Px(t,r,!e),Ix(t,i,!n,{})].filter(Boolean);var Ine=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=YUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([KUe(t),d]);return}let f=e$(c,r),p=T$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([ZUe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},YUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!kx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=T$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Bre(a,t,r,o)},KUe=async t=>{await WUe(),t.readableFlowing===null&&t.resume()},ZUe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await Ex(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await vx(r,{maxBuffer:o})):await wf(r,{maxBuffer:o})}catch(a){return Pne(Bte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},A$=async t=>{try{return await t}catch(e){return Pne(e)}},Pne=({bufferedData:t})=>r7(t)?new Uint8Array(t):t;import{finished as JUe}from"stream/promises";var j_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=XUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],JUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||tFe(a,e,r,n)}finally{s.abort()}},XUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&QUe(t,r,n),n},QUe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{eFe(e,r),n.call(t,...i)}},eFe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},tFe=(t,e,r,n)=>{if(!rFe(t,e,r,n))throw t},rFe=(t,e,r,n=!0)=>r.propagating?One(t)||jx(t):(r.propagating=!0,x$(r,e)===n?One(t):jx(t)),x$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",jx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",One=t=>t?.code==="EPIPE";var Nne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>w$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),w$=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=j_(t,e,l);if(x$(l,e)){await u;return}let[d]=await Promise.all([Ine({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 kne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Fl([t,e].filter(Boolean)):void 0,Mne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>w$({...nFe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:iFe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),nFe=({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}},iFe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as oFe}from"events";var Dne=t=>yf(t,"ipc"),Lne=(t,e)=>{let r=WA(t);go({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var $ne=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Dne(o),a=gs(e,"ipc"),c=gs(r,"ipc");for await(let l of l$({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(jte(t,i,c),i.push(l)),s&&Lne(l,o);return i},Une=async(t,e)=>(await Promise.allSettled([t]),e);var Fne=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:S,controller:E})=>{let b=qre(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=Nne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),w=Mne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),I=[],O=$ne({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),N=sFe(m,t,A),R=aFe(h,A);try{return await Promise.race([Promise.all([{},Wre(b),Promise.all(y),w,O,Ste(t,d),...N,...R]),S,cFe(t,E),...hte(t,o,f,E),...Dee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...fte({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},b,Promise.all(y.map(_=>A$(_))),A$(w),Une(O,I),Promise.allSettled(N),Promise.allSettled(R)])}},sFe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:j_(n,i,r)),aFe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ni(o,{checkOpen:!1})&&!Ii(o)).map(({type:i,value:o,stream:s=o})=>j_(s,n,e,{isSameDirection:Xn.has(i),stopOnExit:i==="native"}))),cFe=async(t,{signal:e})=>{let[r]=await oFe(t,"error",{signal:e});throw r};var Bne=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),z_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=_o();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Of=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 lFe}from"stream";import{callbackify as uFe}from"util";import{finished as jne}from"stream/promises";var R$=async t=>{if(t!==void 0)try{await C$(t)}catch{}},zne=async t=>{if(t!==void 0)try{await I$(t)}catch{}},C$=async t=>{await jne(t,{cleanup:!0,readable:!1,writable:!0})},I$=async t=>{await jne(t,{cleanup:!0,readable:!0,writable:!1})},zx=async(t,e)=>{if(await t,e)throw e},Gx=(t,e,r)=>{r&&!jx(r)?t.destroy(r):e&&t.destroy()};var Gne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||Tn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=P$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=O$(a,s),{read:f,onStdoutDataDone:p}=N$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new lFe({read:f,destroy:uFe(M$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return k$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},P$=(t,e,r)=>{let n=bf(t,e),i=z_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},O$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:b$},N$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=_o(),s=Bx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){dFe(this,s,o)},onStdoutDataDone:o}},dFe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},k$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await I$(t),await n,await R$(i),await e,r.readable&&r.push(null)}catch(o){await R$(i),Vne(r,o)}},M$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Of(r,e)&&(Vne(t,n),await zx(e,n))},Vne=(t,e)=>{Gx(t,t.readable,e)};import{Writable as fFe}from"stream";import{callbackify as qne}from"util";var Hne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=D$(t,r,e),s=new fFe({...L$(n,t,i),destroy:qne(U$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return $$(n,s),s},D$=(t,e,r)=>{let n=ix(t,e),i=z_(r,n,"writableFinal"),o=z_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},L$=(t,e,r)=>({write:pFe.bind(void 0,t),final:qne(hFe.bind(void 0,t,e,r))}),pFe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},hFe=async(t,e,r)=>{await Of(r,e)&&(t.writable&&t.end(),await e)},$$=async(t,e,r)=>{try{await C$(t),e.writable&&e.end()}catch(n){await zne(r),Wne(e,n)}},U$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Of(r,e),await Of(n,e)&&(Wne(t,i),await zx(e,i))},Wne=(t,e)=>{Gx(t,t.writable,e)};import{Duplex as mFe}from"stream";import{callbackify as gFe}from"util";var Yne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||Tn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=P$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=D$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=O$(c,a),{read:S,onStdoutDataDone:E}=N$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new mFe({read:S,...L$(u,t,d),destroy:gFe(_Fe.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 k$({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),$$(u,b,c),b},_Fe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([M$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),U$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var F$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||Tn.has(e),s=bf(t,r),a=Bx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return yFe(a,s,t)},yFe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Kne=(t,{encoding:e})=>{let r=Bne();t.readable=Gne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Hne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Yne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=F$.bind(void 0,t,e),t[Symbol.asyncIterator]=F$.bind(void 0,t,e,{})};var Zne=(t,e)=>{for(let[r,n]of EFe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},SFe=(async()=>{})().constructor.prototype,EFe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(SFe,t)]);var Jne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=bFe(t,e,r),{subprocess:f,promise:p}=xFe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Fx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Zne(f,p),yo.set(f,{options:u,fileDescriptors:d}),f},bFe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=KA(t,e,r),{file:a,commandArguments:c,options:l}=mx(t,e,r),u=AFe(l),d=cne(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},AFe=({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}},xFe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=TFe(...gx(t,e,r))}catch(h){return ine({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;vFe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];_ne(c,a,l),Sne(c,r,l);let d={},f=_o();c.kill=kee.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=kne(c,r),Kne(c,r),tne(c,r);let p=wFe({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}},wFe=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,S]=await Fne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((y,w)=>ys(y,e,w)),b=ys(m,e,"all"),A=RFe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Cf(A,n,e)},RFe=({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?L_({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 So,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Ax({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Vx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,CFe(n,t[n],i)]));return{...t,...r}},CFe=(t,e,r)=>IFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,IFe=new Set(["env",...mL]);var $a=(t,e,r,n)=>{let i=(s,a,c)=>$a(s,a,r,c),o=(...s)=>PFe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},PFe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Vx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=OFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Kre(a,c,l):Jne(a,c,l,i)},OFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=c7(e)?l7(e,r):[e,...r],[s,a,c]=UA(...o),l=Vx(Vx(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 Xne=({file:t,commandArguments:e})=>eie(t,e),Qne=({file:t,commandArguments:e})=>({...eie(t,e),isSync:!0}),eie=(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]=NFe(t);return{file:r,commandArguments:n}},NFe=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(kFe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},kFe=/ +/g;var tie=(t,e,r)=>{t.sync=e(MFe,r),t.s=t.sync},rie=({options:t})=>nie(t),MFe=({options:t})=>({...nie(t),isSync:!0}),nie=t=>({options:{...DFe(t),...t}}),DFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},iie={preferLocal:!0};var oie=$a(()=>({})),wAt=$a(()=>({isSync:!0})),sie=$a(Xne),RAt=$a(Qne),CAt=$a(gte),IAt=$a(rie,{},iie,tie),{sendMessage:PAt,getOneMessage:OAt,getEachMessage:NAt,getCancelSignal:kAt}=rne();var aie=!1,cie=()=>{aie=!0},vo=()=>aie;var G_=null,lie=t=>(G_&&G_.destroy(),G_=new Ss({totalAllowedTime:t}),G_),uie=()=>G_;var Ss=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&&vo())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 PA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ce.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 die={name:"@netlify/agent-runner-cli",type:"module",version:"1.161.3",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: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.1.5","@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.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var FFe=$Fe(import.meta.url),BFe=Es.dirname(FFe),jFe=UFe(import.meta.url),Nf=ue("shell"),B$=new Set,fie={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=zFe(e,r),o={...fie,...i},s=oie(t,n,o);hie(s,o),_ie(s);let a=r?.idleTimeout;return a&&a>0&&gie(s,a),s},pie=(t,e)=>{let r={...fie,...e},n=sie(t,r);return hie(n,r),_ie(n),e?.idleTimeout&&e.idleTimeout>0&&gie(n,e.idleTimeout),n},zFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},hie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new __).pipe(vs.stdout),t.stderr?.pipe(new __).pipe(vs.stderr);return}t.stdout?.pipe(vs.stdout),t.stderr?.pipe(vs.stderr)},j$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vs.kill(-t.pid,e),Nf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Nf.error("Error killing process:",r),!1}},mie=t=>j$(t,"SIGKILL"),gie=(t,e)=>{let r=null,n=()=>{Nf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),j$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nf.log(`Force killing idle process ${t.pid}`),mie(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)},_ie=t=>{B$.add(t);let e=uie();if(e){let r=e.onTimesUp(()=>{Nf.log(`Global timer expired, killing process ${t.pid}`),j$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nf.log(`Force killing process ${t.pid} after timeout`),mie(t))},5e3)});t.on("exit",()=>{B$.delete(t),r()}),t.on("error",()=>{B$.delete(t),r()})}};function Hx(t,e){return!!ki(t,e)}function ki(t,e){if(!vs.env.NETLIFY_LOCAL_MODE)try{let i=jFe.resolve(die.name),o=Es.dirname(i);for(;o!==Es.dirname(o);){let s=Es.dirname(o);if(Es.basename(s)==="node_modules"){let a=Es.join(s,".bin",e);if(qx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(vs.env.NODE_PATH){let i=Es.join(vs.env.NODE_PATH,".bin",e);if(qx.existsSync(i))return i}let r=Es.join(t,"node_modules",".bin",e);if(qx.existsSync(r))return r;let n=Es.join(BFe,"..","node_modules",".bin",e);if(qx.existsSync(n))return n}var GFe=ue("utils"),VFe=t=>new Promise(e=>{setTimeout(e,t)});var z$=t=>{try{return new URL(t).hostname||null}catch{return null}},Wx=(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 VFe(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},Ua=(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},yie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):GFe.error("Could not parse JSON",n))}},qFe=t=>t.charAt(0).toUpperCase()+t.slice(1),To=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():qFe(e)).join(" ");function Ts(t,e){e&&t.log(`Skill invoked: ${e}`)}var Yx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Sie=(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 G$=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}},HFe=1e4,V$=(t,e=HFe)=>{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 WFe}from"crypto";import{createReadStream as YFe}from"fs";import Kx from"fs/promises";import Aie from"os";import Zx from"path";var Eie=ue("repo"),xie="runner-diffs-",wie=t=>`${xie}${t}-`,Rie=async t=>{let e=Aie.tmpdir(),r;try{r=await Kx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(xie)&&!n.startsWith(wie(t))).map(n=>Kx.rm(Zx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},nn=(t,e={})=>zt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Jx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Eie.info("Getting runner diffs");let n=await ZFe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=XFe(o);await QFe(h,r)}Eie.info("Changes after processing"),await H$(r);let s=await W$(o,r);if(await q$(s,r),i=await JFe(r),!i)return{hasChanges:!1,ignored:s};await nn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Kx.mkdtemp(Zx.join(Aie.tmpdir(),wie(t.sessionId))),c=async({from:h,to:m,fileName:S,binary:E})=>{let b=Zx.join(a,S);await nn([...E?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:y}=await Kx.stat(b);return{path:b,size:y}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await bie(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 Tie(d,h)||(f=h)}await bie(r),ce.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Tie(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},vie=async t=>{let e=WFe("sha256");for await(let r of YFe(t))e.update(r);return e.digest("hex")},Tie=async(t,e)=>t.size===e.size&&await vie(t.path)===await vie(e.path),bie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await nn(["reset","--soft","HEAD~1"],{cwd:t})},q$=async(t=[],e=process.cwd())=>{await nn(["add",".",...t],{cwd:e})},H$=async(t=process.cwd())=>{let e=await nn(["status","-s"],{cwd:t});return String(e.stdout??"")},Cie=/.. (.+)?\.log$/,KFe=[Cie],ZFe=async(t=process.cwd())=>{let e=await H$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
114
|
+
if (condition) { yield value; }`)};import{Buffer as e1e}from"buffer";import{StringDecoder as t1e}from"string_decoder";var Px=(t,e,r)=>{if(r)return;if(t)return{transform:r1e.bind(void 0,new TextEncoder)};let n=new t1e(e);return{transform:n1e.bind(void 0,n),final:i1e.bind(void 0,n)}},r1e=function*(t,e){e1e.isBuffer(e)?yield ms(e):typeof e=="string"?yield t.encode(e):yield e},n1e=function*(t,e){yield jt(e)?t.write(e):e},i1e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as kre}from"util";var n$=kre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Ox=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=s1e}=e[r];for await(let i of n(t))yield*Ox(i,e,r+1)},Mre=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*o1e(r,Number(e),t)},o1e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Ox(n,r,e+1)},Dre=kre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),s1e=function*(t){yield t};var i$=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Lre=(t,e)=>[...e.flatMap(r=>[...Ul(r,t,0)]),...$_(t)],Ul=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=c1e}=e[r];for(let i of n(t))yield*Ul(i,e,r+1)},$_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*a1e(r,Number(e),t)},a1e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Ul(n,r,e+1)},c1e=function*(t){yield t};var o$=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Ure(t,s,o),l=$l(e),u=$l(r),d=l?n$.bind(void 0,Ox,a):i$.bind(void 0,Ul),f=l||u?n$.bind(void 0,Mre,a):i$.bind(void 0,$_),p=l||u?Dre.bind(void 0,a):void 0;return{stream:new l1e({writableObjectMode:n,writableHighWaterMark:$re(n),readableObjectMode:i,readableHighWaterMark:$re(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Nx=(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=Ure(s,r,a);t=Lre(c,t)}return t},Ure=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Pre(n,a)},Px(r,s,n),Ix(r,o,n,c),{transform:t,final:e},{transform:Ore(i,a)},Ire({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Fre=(t,e)=>{for(let r of u1e(t))d1e(t,r,e)},u1e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),d1e=(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 ${La[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>f1e(a,n));r.input=R_(s)},f1e=(t,e)=>{let r=Nx(t,e,"utf8",!0);return p1e(r),R_(r)},p1e=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 _1e,appendFileSync as y1e}from"fs";var kx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&yf(r,n)&&!Tn.has(e)&&h1e(n)&&(t.some(({type:i,value:o})=>i==="native"&&m1e.has(o))||t.every(({type:i})=>Xn.has(i))),h1e=t=>t===1||t===2,m1e=new Set(["pipe","overlapped"]),Bre=async(t,e,r,n)=>{for await(let i of t)g1e(e)||zre(i,r,n)},jre=(t,e,r)=>{for(let n of t)zre(n,e,r)},g1e=t=>t._readableState.pipes.length>0,zre=(t,e,r)=>{let n=WA(t);go({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Gre=({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)=>S1e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},S1e=({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=Vte(t,o,d),p=ms(f),{stdioItems:h,objectMode:m}=e[r],S=E1e([p],h,c,n),{serializedResult:E,finalResult:b=E}=v1e({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});T1e({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?b:void 0;try{return n.error===void 0&&b1e(E,h,i),A}catch(y){return n.error=y,A}},E1e=(t,e,r,n)=>{try{return Nx(t,e,r,!1)}catch(i){return n.error=i,t}},v1e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:R_(t)};let s=i7(t,r);return n[o]?{serializedResult:s,finalResult:r$(s,!i[o],e)}:{serializedResult:s}},T1e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!kx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=r$(t,!1,s);try{jre(a,e,n)}catch(c){r.error??=c}},b1e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Rx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?y1e(n,t):(r.add(o),_1e(n,t))}};var Vre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ys(e,r,"all")]:Array.isArray(e)?[ys(t,r,"all"),...e]:jt(t)&&jt(e)?dL([t,e]):`${t}${e}`};import{once as s$}from"events";var qre=async(t,e)=>{let[r,n]=await A1e(t);return e.isForcefullyTerminated??=!1,[r,n]},A1e=async t=>{let[e,r]=await Promise.allSettled([s$(t,"spawn"),s$(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Hre(t):r.value},Hre=async t=>{try{return await s$(t,"exit")}catch{return Hre(t)}},Wre=async t=>{let[e,r]=await t;if(!x1e(e,r)&&a$(e,r))throw new Pi;return[e,r]},x1e=(t,e)=>t===void 0&&e===void 0,a$=(t,e)=>t!==0||e!==null;var Yre=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=w1e(t,e,r),s=o?.code==="ETIMEDOUT",a=Gte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},w1e=(t,e,r)=>t!==void 0?t:a$(e,r)?new Pi:void 0;var Kre=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=C1e(t,e,r),d=O1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Cf(d,c,l)},C1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=KA(t,e,r),a=I1e(r),{file:c,commandArguments:l,options:u}=mx(t,e,a);P1e(u);let d=xre(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},I1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,P1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Mx("ipcInput"),t&&Mx("ipc: true"),r&&Mx("detached: true"),n&&Mx("cancelSignal")},Mx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},O1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=N1e({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}=Yre(c,r),{output:h,error:m=l}=Gre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,A)=>ys(b,r,A)),E=ys(Vre(h,r),r,"all");return M1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},N1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Fre(o,r);let a=k1e(r);return R1e(...gx(t,e,a))}catch(a){return Rf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},k1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:bx(e)}),M1e=({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?Ax({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):L_({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 vFe}from"events";import{spawn as TFe}from"child_process";import ene from"process";import{once as c$,on as D1e}from"events";var Zre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(vf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:lx(t)}),L1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),L1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ox(e,i);let o=Da(t,e,r),s=new AbortController;try{return await Promise.race([$1e(o,n,s),U1e(o,r,s),F1e(o,r,s)])}catch(a){throw Tf(t),a}finally{s.abort(),sx(e,i)}},$1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await c$(t,"message",{signal:r});return n}for await(let[n]of D1e(t,"message",{signal:r}))if(e(n))return n},U1e=async(t,e,{signal:r})=>{await c$(t,"disconnect",{signal:r}),Lee(e)},F1e=async(t,e,{signal:r})=>{let[n]=await c$(t,"strict:error",{signal:r});throw rx(n,e)};import{once as Xre,on as B1e}from"events";var Qre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>l$({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),l$=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{vf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:lx(t)}),ox(e,o);let s=Da(t,e,r),a=new AbortController,c={};return j1e(t,s,a),z1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),G1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},j1e=async(t,e,r)=>{try{await Xre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},z1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Xre(t,"strict:error",{signal:r.signal});n.error=rx(i,e),r.abort()}catch{}},G1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of B1e(r,"message",{signal:o.signal}))Jre(s),yield c}catch{Jre(s)}finally{o.abort(),sx(e,a),n||Tf(t),i&&await t}},Jre=({error:t})=>{if(t)throw t};var tne=(t,{ipc:e})=>{Object.assign(t,nne(t,!1,e))},rne=()=>{let t=ene,e=!0,r=ene.channel!==void 0;return{...nne(t,e,r),getCancelSignal:lte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},nne=(t,e,r)=>({sendMessage:px.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Zre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Qre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as V1e}from"child_process";import{PassThrough as q1e,Readable as H1e,Writable as W1e,Duplex as Y1e}from"stream";var ine=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{QL(n);let a=new V1e;K1e(a,n),Object.assign(a,{readable:Z1e,writable:J1e,duplex:X1e});let c=Rf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=Q1e(c,s,i);return{subprocess:a,promise:l}},K1e=(t,e)=>{let r=U_(),n=U_(),i=U_(),o=Array.from({length:e.length-3},U_),s=U_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},U_=()=>{let t=new q1e;return t.end(),t},Z1e=()=>new H1e({read(){}}),J1e=()=>new W1e({write(){}}),X1e=()=>new Y1e({read(){},write(){}}),Q1e=async(t,e,r)=>Cf(t,e,r);import{createReadStream as one,createWriteStream as sne}from"fs";import{Buffer as eUe}from"buffer";import{Readable as F_,Writable as tUe,Duplex as rUe}from"stream";var cne=(t,e)=>Cx(nUe,t,e,!1),B_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${La[t]}.`)},ane={fileNumber:B_,generator:o$,asyncGenerator:o$,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:rUe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},nUe={input:{...ane,fileUrl:({value:t})=>({stream:one(t)}),filePath:({value:{file:t}})=>({stream:one(t)}),webStream:({value:t})=>({stream:F_.fromWeb(t)}),iterable:({value:t})=>({stream:F_.from(t)}),asyncIterable:({value:t})=>({stream:F_.from(t)}),string:({value:t})=>({stream:F_.from(t)}),uint8Array:({value:t})=>({stream:F_.from(eUe.from(t))})},output:{...ane,fileUrl:({value:t})=>({stream:sne(t)}),filePath:({value:{file:t,append:e}})=>({stream:sne(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:tUe.fromWeb(t)}),iterable:B_,asyncIterable:B_,string:B_,uint8Array:B_}};import{on as iUe,once as lne}from"events";import{PassThrough as oUe,getDefaultHighWaterMark as sUe}from"stream";import{finished as fne}from"stream/promises";function Fl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)d$(i);let e=t.some(({readableObjectMode:i})=>i),r=aUe(t,e),n=new u$({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var aUe=(t,e)=>{if(t.length===0)return sUe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},u$=class extends oUe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(d$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=cUe(this,this.#e,this.#o);let r=dUe({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(d$(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)}},cUe=async(t,e,r)=>{Dx(t,une);let n=new AbortController;try{await Promise.race([lUe(t,n),uUe(t,e,r,n)])}finally{n.abort(),Dx(t,-une)}},lUe=async(t,{signal:e})=>{try{await fne(t,{signal:e,cleanup:!0})}catch(r){throw pne(t,r),r}},uUe=async(t,e,r,{signal:n})=>{for await(let[i]of iUe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},d$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},dUe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Dx(t,dne);let a=new AbortController;try{await Promise.race([fUe(o,e,a),pUe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),hUe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Dx(t,-dne)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?f$(t):mUe(t))},fUe=async(t,e,{signal:r})=>{try{await t,r.aborted||f$(e)}catch(n){r.aborted||pne(e,n)}},pUe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await fne(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;hne(s)?i.add(e):mne(t,s)}},hUe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await lne(t,i,{signal:o}),!t.readable)return lne(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},mUe=t=>{t.writable&&t.end()},pne=(t,e)=>{hne(e)?f$(t):mne(t,e)},hne=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",f$=t=>{(t.readable||t.writable)&&t.destroy()},mne=(t,e)=>{t.destroyed||(t.once("error",gUe),t.destroy(e))},gUe=()=>{},Dx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},une=2,dne=1;import{finished as gne}from"stream/promises";var Pf=(t,e)=>{t.pipe(e),_Ue(t,e),yUe(t,e)},_Ue=async(t,e)=>{if(!(Ii(t)||Ii(e))){try{await gne(t,{cleanup:!0,readable:!0,writable:!1})}catch{}p$(e)}},p$=t=>{t.writable&&t.end()},yUe=async(t,e)=>{if(!(Ii(t)||Ii(e))){try{await gne(e,{cleanup:!0,readable:!1,writable:!0})}catch{}h$(t)}},h$=t=>{t.readable&&t.destroy()};var _ne=(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})=>Xn.has(c)))SUe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Xn.has(c)))vUe({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]:Fl(o);Pf(s,i)}},SUe=(t,e,r,n)=>{r==="output"?Pf(t.stdio[n],e):Pf(e,t.stdio[n]);let i=EUe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},EUe=["stdin","stdout","stderr"],vUe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;TUe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},TUe=(t,{signal:e})=>{Ii(t)&&Dl(t,bUe,e)},bUe=2;import{addAbortListener as wUe}from"events";var Bl=[];Bl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Lx=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",m$=Symbol.for("signal-exit emitter"),g$=globalThis,AUe=Object.defineProperty.bind(Object),_$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(g$[m$])return g$[m$];AUe(g$,m$,{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}},$x=class{},xUe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),y$=class extends $x{onExit(){return()=>{}}load(){}unload(){}},S$=class extends $x{#e=E$.platform==="win32"?"SIGINT":"SIGHUP";#r=new _$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Bl)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(!Lx(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 Bl)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,Bl.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 Lx(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"&&Lx(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)}},E$=globalThis.process,{onExit:yne,load:Lvt,unload:$vt}=xUe(Lx(E$)?new S$(E$):new y$);var Sne=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=yne(()=>{t.kill()});wUe(n,()=>{i()})};var vne=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=YA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=RUe(r,n,i),{sourceStream:d,sourceError:f}=IUe(t,l),{options:p,fileDescriptors:h}=yo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},RUe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=CUe(t,e,...r),a=ix(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},CUe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Ene,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||lL(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]=UA(r,...n);return{destination:e(Ene)(i,o,s),pipeOptions:s}}if(yo.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}`)},Ene=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),IUe=(t,e)=>{try{return{sourceStream:bf(t,e)}}catch(r){return{sourceError:r}}};var bne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=PUe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw v$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},PUe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return h$(t),n;if(e!==void 0)return p$(r),e},v$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Rf({error:t,command:Tne,escapedCommand:Tne,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Tne="source.pipe(destination)";var Ane=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 OUe}from"stream/promises";var xne=(t,e,r)=>{let n=Ux.has(e)?kUe(t,e):NUe(t,e);return Dl(t,DUe,r.signal),Dl(e,LUe,r.signal),MUe(e),n},NUe=(t,e)=>{let r=Fl([t]);return Pf(r,e),Ux.set(e,r),r},kUe=(t,e)=>{let r=Ux.get(e);return r.add(t),r},MUe=async t=>{try{await OUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Ux.delete(t)},Ux=new WeakMap,DUe=2,LUe=1;import{aborted as $Ue}from"util";var wne=(t,e)=>t===void 0?[]:[UUe(t,e)],UUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await $Ue(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw v$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Fx=(t,...e)=>{if(Ot(e[0]))return Fx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=vne(t,...e),i=FUe({...n,destination:r});return i.pipe=Fx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},FUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=BUe(t,i);bne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=xne(e,o,d);return await Promise.race([Ane(u),...wne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},BUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as WUe}from"timers/promises";import{on as jUe}from"events";import{getDefaultHighWaterMark as zUe}from"stream";var Bx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return GUe(e,s),Cne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},GUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},T$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;VUe(e,s,t);let a=t.readableObjectMode&&!o;return Cne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},VUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Cne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=jUe(t,"data",{signal:e.signal,highWaterMark:Rne,highWatermark:Rne});return qUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},b$=zUe(!0),Rne=b$,qUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=HUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Ul(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*$_(a)}},HUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Px(t,r,!e),Ix(t,i,!n,{})].filter(Boolean);var Ine=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=YUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([KUe(t),d]);return}let f=e$(c,r),p=T$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([ZUe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},YUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!kx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=T$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Bre(a,t,r,o)},KUe=async t=>{await WUe(),t.readableFlowing===null&&t.resume()},ZUe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await Ex(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await vx(r,{maxBuffer:o})):await wf(r,{maxBuffer:o})}catch(a){return Pne(Bte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},A$=async t=>{try{return await t}catch(e){return Pne(e)}},Pne=({bufferedData:t})=>r7(t)?new Uint8Array(t):t;import{finished as JUe}from"stream/promises";var j_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=XUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],JUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||tFe(a,e,r,n)}finally{s.abort()}},XUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&QUe(t,r,n),n},QUe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{eFe(e,r),n.call(t,...i)}},eFe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},tFe=(t,e,r,n)=>{if(!rFe(t,e,r,n))throw t},rFe=(t,e,r,n=!0)=>r.propagating?One(t)||jx(t):(r.propagating=!0,x$(r,e)===n?One(t):jx(t)),x$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",jx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",One=t=>t?.code==="EPIPE";var Nne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>w$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),w$=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=j_(t,e,l);if(x$(l,e)){await u;return}let[d]=await Promise.all([Ine({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 kne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Fl([t,e].filter(Boolean)):void 0,Mne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>w$({...nFe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:iFe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),nFe=({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}},iFe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as oFe}from"events";var Dne=t=>yf(t,"ipc"),Lne=(t,e)=>{let r=WA(t);go({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var $ne=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Dne(o),a=gs(e,"ipc"),c=gs(r,"ipc");for await(let l of l$({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(jte(t,i,c),i.push(l)),s&&Lne(l,o);return i},Une=async(t,e)=>(await Promise.allSettled([t]),e);var Fne=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:S,controller:E})=>{let b=qre(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},y=Nne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),w=Mne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),I=[],O=$ne({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),N=sFe(m,t,A),R=aFe(h,A);try{return await Promise.race([Promise.all([{},Wre(b),Promise.all(y),w,O,Ste(t,d),...N,...R]),S,cFe(t,E),...hte(t,o,f,E),...Dee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...fte({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},b,Promise.all(y.map(_=>A$(_))),A$(w),Une(O,I),Promise.allSettled(N),Promise.allSettled(R)])}},sFe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:j_(n,i,r)),aFe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ni(o,{checkOpen:!1})&&!Ii(o)).map(({type:i,value:o,stream:s=o})=>j_(s,n,e,{isSameDirection:Xn.has(i),stopOnExit:i==="native"}))),cFe=async(t,{signal:e})=>{let[r]=await oFe(t,"error",{signal:e});throw r};var Bne=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),z_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=_o();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Of=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 lFe}from"stream";import{callbackify as uFe}from"util";import{finished as jne}from"stream/promises";var R$=async t=>{if(t!==void 0)try{await C$(t)}catch{}},zne=async t=>{if(t!==void 0)try{await I$(t)}catch{}},C$=async t=>{await jne(t,{cleanup:!0,readable:!1,writable:!0})},I$=async t=>{await jne(t,{cleanup:!0,readable:!0,writable:!1})},zx=async(t,e)=>{if(await t,e)throw e},Gx=(t,e,r)=>{r&&!jx(r)?t.destroy(r):e&&t.destroy()};var Gne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||Tn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=P$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=O$(a,s),{read:f,onStdoutDataDone:p}=N$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new lFe({read:f,destroy:uFe(M$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return k$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},P$=(t,e,r)=>{let n=bf(t,e),i=z_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},O$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:b$},N$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=_o(),s=Bx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){dFe(this,s,o)},onStdoutDataDone:o}},dFe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},k$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await I$(t),await n,await R$(i),await e,r.readable&&r.push(null)}catch(o){await R$(i),Vne(r,o)}},M$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Of(r,e)&&(Vne(t,n),await zx(e,n))},Vne=(t,e)=>{Gx(t,t.readable,e)};import{Writable as fFe}from"stream";import{callbackify as qne}from"util";var Hne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=D$(t,r,e),s=new fFe({...L$(n,t,i),destroy:qne(U$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return $$(n,s),s},D$=(t,e,r)=>{let n=ix(t,e),i=z_(r,n,"writableFinal"),o=z_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},L$=(t,e,r)=>({write:pFe.bind(void 0,t),final:qne(hFe.bind(void 0,t,e,r))}),pFe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},hFe=async(t,e,r)=>{await Of(r,e)&&(t.writable&&t.end(),await e)},$$=async(t,e,r)=>{try{await C$(t),e.writable&&e.end()}catch(n){await zne(r),Wne(e,n)}},U$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Of(r,e),await Of(n,e)&&(Wne(t,i),await zx(e,i))},Wne=(t,e)=>{Gx(t,t.writable,e)};import{Duplex as mFe}from"stream";import{callbackify as gFe}from"util";var Yne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||Tn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=P$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=D$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=O$(c,a),{read:S,onStdoutDataDone:E}=N$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new mFe({read:S,...L$(u,t,d),destroy:gFe(_Fe.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 k$({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),$$(u,b,c),b},_Fe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([M$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),U$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var F$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||Tn.has(e),s=bf(t,r),a=Bx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return yFe(a,s,t)},yFe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Kne=(t,{encoding:e})=>{let r=Bne();t.readable=Gne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Hne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Yne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=F$.bind(void 0,t,e),t[Symbol.asyncIterator]=F$.bind(void 0,t,e,{})};var Zne=(t,e)=>{for(let[r,n]of EFe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},SFe=(async()=>{})().constructor.prototype,EFe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(SFe,t)]);var Jne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=bFe(t,e,r),{subprocess:f,promise:p}=xFe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Fx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Zne(f,p),yo.set(f,{options:u,fileDescriptors:d}),f},bFe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=KA(t,e,r),{file:a,commandArguments:c,options:l}=mx(t,e,r),u=AFe(l),d=cne(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},AFe=({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}},xFe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=TFe(...gx(t,e,r))}catch(h){return ine({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;vFe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];_ne(c,a,l),Sne(c,r,l);let d={},f=_o();c.kill=kee.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=kne(c,r),Kne(c,r),tne(c,r);let p=wFe({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}},wFe=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,S]=await Fne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((y,w)=>ys(y,e,w)),b=ys(m,e,"all"),A=RFe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Cf(A,n,e)},RFe=({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?L_({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 So,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Ax({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Vx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,CFe(n,t[n],i)]));return{...t,...r}},CFe=(t,e,r)=>IFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,IFe=new Set(["env",...mL]);var $a=(t,e,r,n)=>{let i=(s,a,c)=>$a(s,a,r,c),o=(...s)=>PFe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},PFe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Vx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=OFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Kre(a,c,l):Jne(a,c,l,i)},OFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=c7(e)?l7(e,r):[e,...r],[s,a,c]=UA(...o),l=Vx(Vx(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 Xne=({file:t,commandArguments:e})=>eie(t,e),Qne=({file:t,commandArguments:e})=>({...eie(t,e),isSync:!0}),eie=(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]=NFe(t);return{file:r,commandArguments:n}},NFe=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(kFe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},kFe=/ +/g;var tie=(t,e,r)=>{t.sync=e(MFe,r),t.s=t.sync},rie=({options:t})=>nie(t),MFe=({options:t})=>({...nie(t),isSync:!0}),nie=t=>({options:{...DFe(t),...t}}),DFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},iie={preferLocal:!0};var oie=$a(()=>({})),wAt=$a(()=>({isSync:!0})),sie=$a(Xne),RAt=$a(Qne),CAt=$a(gte),IAt=$a(rie,{},iie,tie),{sendMessage:PAt,getOneMessage:OAt,getEachMessage:NAt,getCancelSignal:kAt}=rne();var aie=!1,cie=()=>{aie=!0},vo=()=>aie;var G_=null,lie=t=>(G_&&G_.destroy(),G_=new Ss({totalAllowedTime:t}),G_),uie=()=>G_;var Ss=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&&vo())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 PA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ce.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 die={name:"@netlify/agent-runner-cli",type:"module",version:"1.162.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: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.1.5","@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.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var FFe=$Fe(import.meta.url),BFe=Es.dirname(FFe),jFe=UFe(import.meta.url),Nf=ue("shell"),B$=new Set,fie={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=zFe(e,r),o={...fie,...i},s=oie(t,n,o);hie(s,o),_ie(s);let a=r?.idleTimeout;return a&&a>0&&gie(s,a),s},pie=(t,e)=>{let r={...fie,...e},n=sie(t,r);return hie(n,r),_ie(n),e?.idleTimeout&&e.idleTimeout>0&&gie(n,e.idleTimeout),n},zFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},hie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new __).pipe(vs.stdout),t.stderr?.pipe(new __).pipe(vs.stderr);return}t.stdout?.pipe(vs.stdout),t.stderr?.pipe(vs.stderr)},j$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vs.kill(-t.pid,e),Nf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Nf.error("Error killing process:",r),!1}},mie=t=>j$(t,"SIGKILL"),gie=(t,e)=>{let r=null,n=()=>{Nf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),j$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nf.log(`Force killing idle process ${t.pid}`),mie(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)},_ie=t=>{B$.add(t);let e=uie();if(e){let r=e.onTimesUp(()=>{Nf.log(`Global timer expired, killing process ${t.pid}`),j$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nf.log(`Force killing process ${t.pid} after timeout`),mie(t))},5e3)});t.on("exit",()=>{B$.delete(t),r()}),t.on("error",()=>{B$.delete(t),r()})}};function Hx(t,e){return!!ki(t,e)}function ki(t,e){if(!vs.env.NETLIFY_LOCAL_MODE)try{let i=jFe.resolve(die.name),o=Es.dirname(i);for(;o!==Es.dirname(o);){let s=Es.dirname(o);if(Es.basename(s)==="node_modules"){let a=Es.join(s,".bin",e);if(qx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(vs.env.NODE_PATH){let i=Es.join(vs.env.NODE_PATH,".bin",e);if(qx.existsSync(i))return i}let r=Es.join(t,"node_modules",".bin",e);if(qx.existsSync(r))return r;let n=Es.join(BFe,"..","node_modules",".bin",e);if(qx.existsSync(n))return n}var GFe=ue("utils"),VFe=t=>new Promise(e=>{setTimeout(e,t)});var z$=t=>{try{return new URL(t).hostname||null}catch{return null}},Wx=(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 VFe(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},Ua=(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},yie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):GFe.error("Could not parse JSON",n))}},qFe=t=>t.charAt(0).toUpperCase()+t.slice(1),To=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():qFe(e)).join(" ");function Ts(t,e){e&&t.log(`Skill invoked: ${e}`)}var Yx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Sie=(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 G$=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}},HFe=1e4,V$=(t,e=HFe)=>{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 WFe}from"crypto";import{createReadStream as YFe}from"fs";import Kx from"fs/promises";import Aie from"os";import Zx from"path";var Eie=ue("repo"),xie="runner-diffs-",wie=t=>`${xie}${t}-`,Rie=async t=>{let e=Aie.tmpdir(),r;try{r=await Kx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(xie)&&!n.startsWith(wie(t))).map(n=>Kx.rm(Zx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},nn=(t,e={})=>zt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Jx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Eie.info("Getting runner diffs");let n=await ZFe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=XFe(o);await QFe(h,r)}Eie.info("Changes after processing"),await H$(r);let s=await W$(o,r);if(await q$(s,r),i=await JFe(r),!i)return{hasChanges:!1,ignored:s};await nn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Kx.mkdtemp(Zx.join(Aie.tmpdir(),wie(t.sessionId))),c=async({from:h,to:m,fileName:S,binary:E})=>{let b=Zx.join(a,S);await nn([...E?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:y}=await Kx.stat(b);return{path:b,size:y}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await bie(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 Tie(d,h)||(f=h)}await bie(r),ce.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await Tie(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},vie=async t=>{let e=WFe("sha256");for await(let r of YFe(t))e.update(r);return e.digest("hex")},Tie=async(t,e)=>t.size===e.size&&await vie(t.path)===await vie(e.path),bie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await nn(["reset","--soft","HEAD~1"],{cwd:t})},q$=async(t=[],e=process.cwd())=>{await nn(["add",".",...t],{cwd:e})},H$=async(t=process.cwd())=>{let e=await nn(["status","-s"],{cwd:t});return String(e.stdout??"")},Cie=/.. (.+)?\.log$/,KFe=[Cie],ZFe=async(t=process.cwd())=>{let e=await H$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
115
115
|
`).filter(i=>KFe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},JFe=async(t=process.cwd())=>{try{return await nn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},V_=async(t=process.cwd())=>{let{stdout:e}=await nn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Iie=async(t=process.cwd())=>{let{stdout:e}=await nn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},W$=async(t,e=process.cwd())=>{t||=await H$(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(`
|
|
116
116
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${Zx.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Cie)?.[1];o&&n.push(`:!${o}.log`)}),n},Pie=async(t=process.cwd())=>{await nn(["reset","--hard","HEAD"],{cwd:t})},Oie=async(t=process.cwd())=>{let e=await nn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
117
117
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},XFe=t=>{let e=t.split(`
|
|
@@ -555,8 +555,8 @@ Deploy failed. Here are the errors to review on the latest build:
|
|
|
555
555
|
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.
|
|
556
556
|
|
|
557
557
|
${t.pop()}
|
|
558
|
-
`;var lm=ue("deploy"),Y8e=t=>t===""||/[\s"\\]/u.test(t)?JSON.stringify(t):t,rge=async t=>await dt(Ke(),"create-preview-deploy",async e=>K8e(t,e)),K8e=async({netlify:t,hasRepo:e,skipBuild:r,message:n="Agent Preview",deploySubdomain:i,cliPath:o,filter:s,prodDeploy:a},
|
|
559
|
-
Preview deploy created successfully:`,{deployId:
|
|
558
|
+
`;var lm=ue("deploy"),Y8e=t=>t===""||/[\s"\\]/u.test(t)?JSON.stringify(t):t,rge=async t=>await dt(Ke(),"create-preview-deploy",async e=>K8e(t,e)),K8e=async({netlify:t,hasRepo:e,skipBuild:r,message:n="Agent Preview",deploySubdomain:i,cliPath:o,filter:s,prodDeploy:a,agentRunnerId:c,agentRunnerSessionId:l},u)=>{try{let d=["deploy","--message",n,"--json","--verbose",a?"--prod":"--draft"];lm.log("Deploy: Uploading source zip"),d.push("--upload-source-zip"),i&&!a&&d.push("--alias",i),s&&d.push("--filter",s),r?(lm.log("Deploy: Skipping build"),d.push("--no-build")):d.push("--context",a?"production":"deploy-preview");let f=o||"netlify";lm.log(`Running: ${f} ${d.map(Y8e).join(" ")}`),u?.setAttributes({cmd:f,args:d});let p={};c&&(p.NETLIFY_AGENT_RUNNER_ID=c),l&&(p.NETLIFY_AGENT_RUNNER_SESSION_ID=l);let h=await t.utils.run(f,d,{stdio:["ignore","pipe","pipe"],env:{...process.env,NETLIFY_DEPLOY_SOURCE:"agent_runner",...p}});h.stderr&&lm.log(String(h.stderr));let m=JSON.parse(String(h.stdout??"").trim());u?.setAttributes({success:!0,deployId:m.deploy_id,deployUrl:m.deploy_url,siteId:m.site_id}),lm.log(`
|
|
559
|
+
Preview deploy created successfully:`,{deployId:m.deploy_id,deployUrl:m.deploy_url,siteId:m.site_id});let S={deployId:m.deploy_id,previewUrl:m.deploy_url,logsUrl:m.logs,siteId:m.site_id};return e||(S.sourceZipFilename=m.source_zip_filename),S}catch(d){throw lm.error("Failed to create preview deploy via CLI:",d),u?.setAttributes({success:!1,error:d.message}),d}};import nge from"fs";import xV from"path";var ige=(t=process.cwd())=>{let e=xV.join(t,fr,vQ);return{hasNetlifyForm:nge.existsSync(xV.join(e,"netlify-forms")),hasNetlifyIdentity:nge.existsSync(xV.join(e,"netlify-identity"))}};var Gi=ue("deploy_stage"),WI=async t=>await dt(Ke(),"run-deploy-stage",async()=>Z8e(t)),Z8e=async({cliPath:t,config:e,context:r,result:n,filter:i,isRetry:o,deploySubdomain:s})=>{if(e.mode==="ask")return{hasChanges:!1,previewInfo:null,isProdDeploy:!1,hasNetlifyForm:!1,hasNetlifyIdentity:!1};let a=await dt(Ke(),"get-runner-diffs",async()=>await Jx({config:e,isRetry:o}));if(Gi.info("Resolved git",{hasChanges:a.hasChanges,ignored:a.ignored??[]}),!a.hasChanges&&e.mode!=="redeploy"&&!e.pendingUndeployedChanges)return{hasChanges:!1,previewInfo:null,isProdDeploy:!1,hasNetlifyForm:!1,hasNetlifyIdentity:!1};let c=a.hasChanges?a.diff:void 0,l=a.hasChanges?a.resultDiff:void 0,u=a.hasChanges?a.diffBinary:void 0,d=a.hasChanges?a.resultDiffBinary:void 0,f=a.hasChanges||e.mode==="redeploy",{hasNetlifyForm:p,hasNetlifyIdentity:h}=ige();if(p||h){let A={};p&&(Gi.log("Detected Netlify Forms enablement \u2014 enabling early"),A.has_netlify_form=!0),h&&(Gi.log("Detected Netlify Identity enablement \u2014 enabling early"),A.has_netlify_identity=!0);try{await vr(e.id,e.sessionId,A)}catch(y){Gi.warn("Failed to send early feature enablement (continuing):",y)}}let m=n!==void 0&&(f||e.mode==="redeploy"||!!e.pendingUndeployedChanges);Gi.log("Deploy condition check:",{resultUndefined:n===void 0,resultType:typeof n,hasChanges:f,isRedeploy:e.mode==="redeploy",pendingUndeployedChanges:!!e.pendingUndeployedChanges,wouldCreateDeploy:m});let S=Rw(e.mode),E=null,b;if(m)try{let A;try{let y=await dt(Ke(),"get-runner-session",async()=>await MA(e.id,e.sessionId));y?.title&&(A=y.title)}catch(y){Gi.warn("Failed to fetch session title, using fallback message:",y.message)}if(await vr(e.id,e.sessionId,{steps:[{title:S?"Deploying project":"Deploying preview",category:W.Deployment}]}),E=await rge({cliPath:t,netlify:r,hasRepo:e.hasRepo,message:A,skipBuild:!1,deploySubdomain:s,filter:i,prodDeploy:S,agentRunnerId:e.id,agentRunnerSessionId:e.sessionId}),S)try{await Nie()?Gi.log("Pushed workspace commits to origin"):Gi.log("Skipped origin push (no origin remote or detached HEAD)")}catch(y){b=y instanceof Error?y.message:String(y),Gi.warn("Failed to push workspace commits to origin (continuing):",y)}}catch(A){if(vo())throw A;return Gi.warn("Failed to create preview deploy (continuing with agent run):",A),{diff:c,resultDiff:l,hasChanges:f,previewInfo:null,diffBinary:u,resultDiffBinary:d,deployError:A instanceof Error?A.message:String(A),isProdDeploy:S,hasNetlifyForm:p,hasNetlifyIdentity:h}}return Gi.log("Git status",{hasDiff:!!c,hasChanges:f}),{diff:c,resultDiff:l,hasChanges:f,previewInfo:E,diffBinary:u,resultDiffBinary:d,gitPushError:b,isProdDeploy:S,hasNetlifyForm:p,hasNetlifyIdentity:h}};import{readFile as YI}from"fs/promises";var Mn=ue("cleanup_stage"),wV=async t=>await dt(Ke(),"cleanup-stage",async()=>J8e(t)),oge=1024*1024*12,RV=async({config:t,diff:e,diffBinary:r,resultDiff:n,resultDiffBinary:i})=>{let o={diff_produced:!0};try{Mn.log("Getting pre-signed URLs for diff upload");let s=await BQ(t.id,t.sessionId),a=[],c=r||e;c&&a.push(sL(s.result.upload_url,c.path,{size:c.size,base64:!!r}).then(()=>{o.result_diff_s3_key=s.result.s3_key,Mn.log("Successfully uploaded result_diff to S3")}));let l=i||n;l&&a.push(sL(s.cumulative.upload_url,l.path,{size:l.size,base64:!!i}).then(()=>{o.cumulative_diff_s3_key=s.cumulative.s3_key,Mn.log("Successfully uploaded cumulative_diff to S3")})),Mn.log(`Uploading ${a.length} diff(s) to S3 in parallel`),await Promise.all(a)}catch(s){Mn.error("S3 upload failed, falling back to inline diffs:",s);let a=(e?.size??0)+v_(r?.size??0)+(n?.size??0)+v_(i?.size??0);if(a>oge){let c=`Diffs of ${a} bytes exceed the maximum combined inline size of ${oge} bytes.`;throw Mn.error(c),new Error(c)}o.result_diff=e?await YI(e.path,"utf8"):void 0,o.result_diff_binary=r?(await YI(r.path)).toString("base64"):void 0,(n||i)&&(o.cumulative_diff=n?await YI(n.path,"utf8"):void 0,o.cumulative_diff_binary=i?(await YI(i.path)).toString("base64"):void 0)}if(n||i)try{Mn.log("Updating agent runner with cumulative diff"),await dt(Ke(),"update-runner",async()=>{await kA(t.id,o.cumulative_diff_s3_key?{result_diff_s3_key:o.cumulative_diff_s3_key}:{result_diff:o.cumulative_diff,result_diff_binary:o.cumulative_diff_binary})})}catch(s){Mn.warn("Failed to record cumulative diff on the runner (session fields still set):",s)}return o},J8e=async({config:t,diff:e,result:r,duration:n,resultDiff:i,diffBinary:o,resultDiffBinary:s,previewInfo:a,isProdDeploy:c,hasNetlifyForm:l,hasNetlifyIdentity:u,nativeSessionArchive:d,nativeSessionId:f,finalAgentConfig:p,creditWrapUp:h})=>{let m={result:r||"Done",duration:n};(p||h)&&(m.metadata={...p?{final_agent_config:p}:{},...h?{credit_wrap_up:!0}:{}}),LQ(t,m.result,p,h),a&&a.deployId&&(m.deploy_id=a.deployId),a&&a.sourceZipFilename&&(m.result_zip_file_name=a.sourceZipFilename),c&&a&&a.deployId&&(m.is_published=!0),f&&(m.native_session_id=f),l&&(m.has_netlify_form=!0),u&&(m.has_netlify_identity=!0),t.mode!=="ask"&&(e||o||i||s)?Object.assign(m,await RV({config:t,diff:e,diffBinary:o,resultDiff:i,resultDiffBinary:s})):Mn.log("No diffs to upload");let E=await dt(Ke(),"upload-native-session",()=>ju({runnerId:t.id,sessionId:t.sessionId,archive:d,nativeSessionId:f}));return E&&(m.native_session_s3_key=E),$e().warmNativeResumeEnabled&&await dt(Ke(),"save-native-session-cache",()=>am({archive:d,cache:t.cache,nativeSessionId:f})),Mn.log("Updated agent runner with result"),await LA(async()=>await dt(Ke(),"update-runner-session",()=>vr(t.id,t.sessionId,m)),{maxRetries:3,baseDelay:1e3,onRetry:(b,A)=>{Mn.error(`Error updating agent runner session (attempt ${b}):`,A),Mn.log("Retrying...")}}),Mn.log("Finished updating agent runner with result"),{sessionUpdate:m}};import X8e from"fs";import Q8e from"path";import eZe from"process";var CV=ue("db_migrations"),tZe=new Set(["drizzle.config.ts","drizzle.config.js","drizzle.config.mjs"]),KI=async t=>await PA({stage:"db-migrations"},()=>dt(Ke(),"db-migrations",async e=>{let r=t.cwd||eZe.cwd();if(!(await sge("@netlify/database",r)||await sge("@netlify/db",r)))return e?.setAttributes({skipped:!0,reason:"@netlify/database is not installed"}),ce.inc("db_migrations.run",1,{outcome:"skipped",reason:"no_module"}),{skipped:!0};let i=[...tZe].find(o=>X8e.existsSync(Q8e.join(r,o)));if(!i)return e?.setAttributes({skipped:!0,reason:"no drizzle config found"}),ce.inc("db_migrations.run",1,{outcome:"skipped",reason:"no_config"}),{skipped:!0};e?.setAttributes({configFile:i}),CV.log(`Found ${i}, running drizzle-kit generate to ensure migrations are up to date`);try{let o=await zt("npx",["drizzle-kit","generate"],{cwd:r,stdio:["ignore","pipe","pipe"]});return o.stdout&&CV.log(String(o.stdout)),e?.setAttributes({success:!0}),ce.inc("db_migrations.run",1,{outcome:"success"}),{skipped:!1}}catch(o){let s=rZe(o);return CV.warn("drizzle-kit generate failed:",s),e?.setAttributes({success:!1,error:s}),ce.inc("db_migrations.run",1,{outcome:"failure"}),{skipped:!1,error:s}}})),sge=async(t,e)=>{try{return await pie(`node -e "require.resolve('${t}')"`,{cwd:e,stdio:"ignore"}),!0}catch{return!1}},rZe=t=>{if(t&&typeof t=="object"){let e=[];if("stderr"in t&&t.stderr&&e.push(String(t.stderr)),"stdout"in t&&t.stdout&&e.push(String(t.stdout)),e.length>0)return e.join(`
|
|
560
560
|
`)}return t instanceof Error?t.message:String(t)};var IV=ue("migration_state"),ZI=async({cliPath:t,cwd:e})=>{let r;try{let n=await zt(t,["db","status","--json"],{cwd:e,stdio:["ignore","pipe","pipe"]});r=n.stdout?String(n.stdout):""}catch(n){let i=n;throw IV.warn("`netlify db status --json` failed",{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}),n}IV.log("`netlify db status --json` output",{stdout:r});try{return JSON.parse(r)}catch(n){throw IV.warn("Failed to parse `netlify db status --json` output",{stdout:r,error:String(n)}),n}},age=()=>["## Netlify Database","","A Netlify Database (managed Postgres) is available for this site.","It will be provisioned automatically on first connection.","No migrations have been applied yet \u2014 this is a fresh database.","","Use `@netlify/database` with Drizzle ORM for persistent data storage.","Define your schema in `db/schema.ts` and migrations will be generated automatically at deploy time.","Read the `netlify-database` skill for setup instructions."].join(`
|
|
561
561
|
`),cge=t=>{if(t.applied.length===0&&t.pending.length===0)return null;let e=["## CRITICAL: Current Netlify Database state",""];if(t.applied.length>0){e.push("The following migrations are **already applied** to your preview database branch. They are immutable:","");for(let r of t.applied)e.push(`- ${r.name}`);e.push("","**Never delete, rename, or edit an applied migration file.** Doing so will break the deploy \u2014 the","platform requires every migration applied to the branch to exist on disk with its original content. If","you think an applied migration is wrong, roll forward with a NEW migration that corrects whatever it","did. That's always safe; deletion isn't.")}else e.push("No migrations are applied to your preview database branch yet.");if(t.pending.length>0){e.push(""),e.push("The following migration files exist on disk but have NOT yet been applied:","");for(let r of t.pending)e.push(`- ${r.name}`);e.push("","Pending files can be modified or deleted freely \u2014 use `netlify db migrations reset` to remove them","cleanly, then regenerate via `npx drizzle-kit generate` if you want a replacement.")}return e.join(`
|
|
562
562
|
`)},lge=t=>{let e=[];return t.missingOnDisk.length>0&&e.push("You deleted the following migration file(s) that are already applied to the preview database branch:",...t.missingOnDisk.map(r=>`- ${r.name}`),"","Applied migrations cannot be removed \u2014 the deploy will fail because the platform requires every applied","migration to exist on disk with its original content. Please revise your work:","","1. Restore the deleted file(s) by running `netlify db migrations pull --force`, which overwrites the"," local migrations directory with the authoritative state of the branch. Note this also wipes any"," unapplied migration files you generated this session \u2014 regenerate them via `npx drizzle-kit generate`"," afterwards if you still need them (your `db/schema.ts` edits aren't affected by the pull).","2. If the underlying problem is that an applied migration is wrong, add a NEW migration on top that"," corrects whatever it did (drop a column, rename a table, etc.). Do not touch the original."),t.outOfOrder.length>0&&(e.length>0&&e.push(""),e.push("The following pending migration file(s) have a version prefix that sorts BEFORE migrations already","applied to the branch, so the platform will reject them on deploy:",...t.outOfOrder.map(r=>`- ${r.name} (version ${r.version} \u2264 applied max ${r.maxApplied})`),"","Delete these out-of-order files (use `netlify db migrations reset` \u2014 it only removes unapplied files),","then run `npx drizzle-kit generate` to produce a replacement whose version sorts after the applied","migrations.")),e.length===0?null:e.join(`
|
package/dist/bin.js
CHANGED
|
@@ -599,7 +599,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
599
599
|
`,LF:`
|
|
600
600
|
`,concatBytes:C3},qSt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},BSt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:qSt};import{Buffer as zSt}from"buffer";var $Te=(t,e)=>t?void 0:VSt.bind(void 0,e),VSt=function*(t,e){if(typeof e!="string"&&!$r(e)&&!zSt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},LTe=(t,e)=>t?HSt.bind(void 0,e):GSt.bind(void 0,e),HSt=function*(t,e){DTe(t,e),yield e},GSt=function*(t,e){if(DTe(t,e),typeof e!="string"&&!$r(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},DTe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
601
601
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
602
|
-
if (condition) { yield value; }`)};import{Buffer as WSt}from"buffer";import{StringDecoder as YSt}from"string_decoder";var NC=(t,e,r)=>{if(r)return;if(t)return{transform:KSt.bind(void 0,new TextEncoder)};let n=new YSt(e);return{transform:JSt.bind(void 0,n),final:ZSt.bind(void 0,n)}},KSt=function*(t,e){WSt.isBuffer(e)?yield Tc(e):typeof e=="string"?yield t.encode(e):yield e},JSt=function*(t,e){yield $r(e)?t.write(e):e},ZSt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as MTe}from"util";var k3=MTe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),kC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QSt}=e[r];for await(let i of n(t))yield*kC(i,e,r+1)},UTe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XSt(r,Number(e),t)},XSt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*kC(n,r,e+1)},FTe=MTe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),QSt=function*(t){yield t};var $3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},jTe=(t,e)=>[...e.flatMap(r=>[...Jf(r,t,0)]),...eT(t)],Jf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=tEt}=e[r];for(let i of n(t))yield*Jf(i,e,r+1)},eT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*eEt(r,Number(e),t)},eEt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Jf(n,r,e+1)},tEt=function*(t){yield t};var L3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=BTe(t,o,s),l=Kf(e),u=Kf(r),d=l?k3.bind(void 0,kC,a):$3.bind(void 0,Jf),f=l||u?k3.bind(void 0,UTe,a):$3.bind(void 0,eT),p=l||u?FTe.bind(void 0,a):void 0;return{stream:new rEt({writableObjectMode:n,writableHighWaterMark:qTe(n),readableObjectMode:i,readableHighWaterMark:qTe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},$C=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=BTe(o,r,a);t=jTe(c,t)}return t},BTe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:$Te(n,a)},NC(r,o,n),CC(r,s,n,c),{transform:t,final:e},{transform:LTe(i,a)},kTe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var zTe=(t,e)=>{for(let r of nEt(t))iEt(t,r,e)},nEt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),iEt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Iu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>sEt(a,n));r.input=Vb(o)},sEt=(t,e)=>{let r=$C(t,e,"utf8",!0);return oEt(r),Vb(r)},oEt=t=>{let e=t.find(r=>typeof r!="string"&&!$r(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 uEt,appendFileSync as dEt}from"fs";var LC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&jg(r,n)&&!qi.has(e)&&aEt(n)&&(t.some(({type:i,value:s})=>i==="native"&&cEt.has(s))||t.every(({type:i})=>ws.has(i))),aEt=t=>t===1||t===2,cEt=new Set(["pipe","overlapped"]),VTe=async(t,e,r,n)=>{for await(let i of t)lEt(e)||GTe(i,r,n)},HTe=(t,e,r)=>{for(let n of t)GTe(n,e,r)},lEt=t=>t._readableState.pipes.length>0,GTe=(t,e,r)=>{let n=KP(t);na({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var WTe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>fEt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},fEt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Ybe(t,s,d),p=Tc(f),{stdioItems:h,objectMode:m}=e[r],_=pEt([p],h,c,n),{serializedResult:y,finalResult:v=y}=hEt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});mEt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&gEt(y,h,i),S}catch(g){return n.error=g,S}},pEt=(t,e,r,n)=>{try{return $C(t,e,r,!1)}catch(i){return n.error=i,t}},hEt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Vb(t)};let o=cEe(t,r);return n[s]?{serializedResult:o,finalResult:N3(o,!i[s],e)}:{serializedResult:o}},mEt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!LC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=N3(t,!1,o);try{HTe(a,e,n)}catch(c){r.error??=c}},gEt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?dEt(n,t):(r.add(s),uEt(n,t))}};var YTe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ac(e,r,"all")]:Array.isArray(e)?[Ac(t,r,"all"),...e]:$r(t)&&$r(e)?q6([t,e]):`${t}${e}`};import{once as D3}from"events";var KTe=async(t,e)=>{let[r,n]=await _Et(t);return e.isForcefullyTerminated??=!1,[r,n]},_Et=async t=>{let[e,r]=await Promise.allSettled([D3(t,"spawn"),D3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?JTe(t):r.value},JTe=async t=>{try{return await D3(t,"exit")}catch{return JTe(t)}},ZTe=async t=>{let[e,r]=await t;if(!yEt(e,r)&&M3(e,r))throw new ro;return[e,r]},yEt=(t,e)=>t===void 0&&e===void 0,M3=(t,e)=>t!==0||e!==null;var XTe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=SEt(t,e,r),o=s?.code==="ETIMEDOUT",a=Wbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},SEt=(t,e,r)=>t!==void 0?t:M3(e,r)?new ro:void 0;var QTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=vEt(t,e,r),d=wEt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Jg(d,c,l)},vEt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=ZP(t,e,r),a=bEt(r),{file:c,commandArguments:l,options:u}=_C(t,e,a);TEt(u);let d=OTe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},bEt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,TEt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&DC("ipcInput"),t&&DC("ipc: true"),r&&DC("detached: true"),n&&DC("cancelSignal")},DC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},wEt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=REt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=XTe(c,r),{output:h,error:m=l}=WTe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>Ac(v,r,S)),y=Ac(YTe(h,r),r,"all");return xEt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},REt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{zTe(s,r);let a=AEt(r);return EEt(...yC(t,e,a))}catch(a){return Kg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},AEt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RC(e)}),xEt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?AC({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Qb({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as hbt}from"events";import{spawn as mbt}from"child_process";import iwe from"process";import{once as U3,on as IEt}from"events";var ewe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(zg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:dC(t)}),OEt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),OEt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{aC(e,i);let s=xu(t,e,r),o=new AbortController;try{return await Promise.race([PEt(s,n,o),CEt(s,r,o),NEt(s,r,o)])}catch(a){throw Vg(t),a}finally{o.abort(),cC(e,i)}},PEt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await U3(t,"message",{signal:r});return n}for await(let[n]of IEt(t,"message",{signal:r}))if(e(n))return n},CEt=async(t,e,{signal:r})=>{await U3(t,"disconnect",{signal:r}),jve(e)},NEt=async(t,e,{signal:r})=>{let[n]=await U3(t,"strict:error",{signal:r});throw iC(n,e)};import{once as rwe,on as kEt}from"events";var nwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>F3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),F3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{zg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:dC(t)}),aC(e,s);let o=xu(t,e,r),a=new AbortController,c={};return $Et(t,o,a),LEt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),DEt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},$Et=async(t,e,r)=>{try{await rwe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},LEt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await rwe(t,"strict:error",{signal:r.signal});n.error=iC(i,e),r.abort()}catch{}},DEt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of kEt(r,"message",{signal:s.signal}))twe(o),yield c}catch{twe(o)}finally{s.abort(),cC(e,a),n||Vg(t),i&&await t}},twe=({error:t})=>{if(t)throw t};var swe=(t,{ipc:e})=>{Object.assign(t,awe(t,!1,e))},owe=()=>{let t=iwe,e=!0,r=iwe.channel!==void 0;return{...awe(t,e,r),getCancelSignal:pbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},awe=(t,e,r)=>({sendMessage:mC.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ewe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:nwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as MEt}from"child_process";import{PassThrough as UEt,Readable as FEt,Writable as jEt,Duplex as qEt}from"stream";var cwe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{O3(n);let a=new MEt;BEt(a,n),Object.assign(a,{readable:zEt,writable:VEt,duplex:HEt});let c=Kg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=GEt(c,o,i);return{subprocess:a,promise:l}},BEt=(t,e)=>{let r=tT(),n=tT(),i=tT(),s=Array.from({length:e.length-3},tT),o=tT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},tT=()=>{let t=new UEt;return t.end(),t},zEt=()=>new FEt({read(){}}),VEt=()=>new jEt({write(){}}),HEt=()=>new qEt({read(){},write(){}}),GEt=async(t,e,r)=>Jg(t,e,r);import{createReadStream as lwe,createWriteStream as uwe}from"fs";import{Buffer as WEt}from"buffer";import{Readable as rT,Writable as YEt,Duplex as KEt}from"stream";var fwe=(t,e)=>PC(JEt,t,e,!1),nT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Iu[t]}.`)},dwe={fileNumber:nT,generator:L3,asyncGenerator:L3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:KEt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},JEt={input:{...dwe,fileUrl:({value:t})=>({stream:lwe(t)}),filePath:({value:{file:t}})=>({stream:lwe(t)}),webStream:({value:t})=>({stream:rT.fromWeb(t)}),iterable:({value:t})=>({stream:rT.from(t)}),asyncIterable:({value:t})=>({stream:rT.from(t)}),string:({value:t})=>({stream:rT.from(t)}),uint8Array:({value:t})=>({stream:rT.from(WEt.from(t))})},output:{...dwe,fileUrl:({value:t})=>({stream:uwe(t)}),filePath:({value:{file:t,append:e}})=>({stream:uwe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:YEt.fromWeb(t)}),iterable:nT,asyncIterable:nT,string:nT,uint8Array:nT}};import{on as ZEt,once as pwe}from"events";import{PassThrough as XEt,getDefaultHighWaterMark as QEt}from"stream";import{finished as gwe}from"stream/promises";function Zf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)q3(i);let e=t.some(({readableObjectMode:i})=>i),r=evt(t,e),n=new j3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var evt=(t,e)=>{if(t.length===0)return QEt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},j3=class extends XEt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(q3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=tvt(this,this.#e,this.#s);let r=ivt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(q3(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)}},tvt=async(t,e,r)=>{MC(t,hwe);let n=new AbortController;try{await Promise.race([rvt(t,n),nvt(t,e,r,n)])}finally{n.abort(),MC(t,-hwe)}},rvt=async(t,{signal:e})=>{try{await gwe(t,{signal:e,cleanup:!0})}catch(r){throw _we(t,r),r}},nvt=async(t,e,r,{signal:n})=>{for await(let[i]of ZEt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},q3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ivt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{MC(t,mwe);let a=new AbortController;try{await Promise.race([svt(s,e,a),ovt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),avt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),MC(t,-mwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?B3(t):cvt(t))},svt=async(t,e,{signal:r})=>{try{await t,r.aborted||B3(e)}catch(n){r.aborted||_we(e,n)}},ovt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await gwe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;ywe(o)?i.add(e):Swe(t,o)}},avt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await pwe(t,i,{signal:s}),!t.readable)return pwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},cvt=t=>{t.writable&&t.end()},_we=(t,e)=>{ywe(e)?B3(t):Swe(t,e)},ywe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",B3=t=>{(t.readable||t.writable)&&t.destroy()},Swe=(t,e)=>{t.destroyed||(t.once("error",lvt),t.destroy(e))},lvt=()=>{},MC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},hwe=2,mwe=1;import{finished as Ewe}from"stream/promises";var Xg=(t,e)=>{t.pipe(e),uvt(t,e),dvt(t,e)},uvt=async(t,e)=>{if(!(to(t)||to(e))){try{await Ewe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}z3(e)}},z3=t=>{t.writable&&t.end()},dvt=async(t,e)=>{if(!(to(t)||to(e))){try{await Ewe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}V3(t)}},V3=t=>{t.readable&&t.destroy()};var vwe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>ws.has(c)))fvt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!ws.has(c)))hvt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Zf(s);Xg(o,i)}},fvt=(t,e,r,n)=>{r==="output"?Xg(t.stdio[n],e):Xg(e,t.stdio[n]);let i=pvt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},pvt=["stdin","stdout","stderr"],hvt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;mvt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},mvt=(t,{signal:e})=>{to(t)&&Wf(t,gvt,e)},gvt=2;import{addAbortListener as Svt}from"events";var Xf=[];Xf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Xf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Xf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var UC=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",H3=Symbol.for("signal-exit emitter"),G3=globalThis,_vt=Object.defineProperty.bind(Object),W3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(G3[H3])return G3[H3];_vt(G3,H3,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},FC=class{},yvt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Y3=class extends FC{onExit(){return()=>{}}load(){}unload(){}},K3=class extends FC{#e=J3.platform==="win32"?"SIGINT":"SIGHUP";#r=new W3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Xf)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!UC(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Xf)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Xf.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return UC(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&UC(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)}},J3=globalThis.process,{onExit:bwe,load:Iur,unload:Our}=yvt(UC(J3)?new K3(J3):new Y3);var Twe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=bwe(()=>{t.kill()});Svt(n,()=>{i()})};var Rwe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=JP(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Evt(r,n,i),{sourceStream:d,sourceError:f}=bvt(t,l),{options:p,fileDescriptors:h}=sa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},Evt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=vvt(t,e,...r),a=oC(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},vvt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(wwe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||F6(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=jP(r,...n);return{destination:e(wwe)(i,s,o),pipeOptions:o}}if(sa.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}`)},wwe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),bvt=(t,e)=>{try{return{sourceStream:Hg(t,e)}}catch(r){return{sourceError:r}}};var xwe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Tvt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw Z3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Tvt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return V3(t),n;if(e!==void 0)return z3(r),e},Z3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Kg({error:t,command:Awe,escapedCommand:Awe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Awe="source.pipe(destination)";var Iwe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as wvt}from"stream/promises";var Owe=(t,e,r)=>{let n=jC.has(e)?Avt(t,e):Rvt(t,e);return Wf(t,Ivt,r.signal),Wf(e,Ovt,r.signal),xvt(e),n},Rvt=(t,e)=>{let r=Zf([t]);return Xg(r,e),jC.set(e,r),r},Avt=(t,e)=>{let r=jC.get(e);return r.add(t),r},xvt=async t=>{try{await wvt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jC.delete(t)},jC=new WeakMap,Ivt=2,Ovt=1;import{aborted as Pvt}from"util";var Pwe=(t,e)=>t===void 0?[]:[Cvt(t,e)],Cvt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Pvt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw Z3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var qC=(t,...e)=>{if(Er(e[0]))return qC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Rwe(t,...e),i=Nvt({...n,destination:r});return i.pipe=qC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Nvt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=kvt(t,i);xwe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Owe(e,s,d);return await Promise.race([Iwe(u),...Pwe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},kvt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as jvt}from"timers/promises";import{on as $vt}from"events";import{getDefaultHighWaterMark as Lvt}from"stream";var BC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Dvt(e,o),Nwe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Dvt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},X3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;Mvt(e,o,t);let a=t.readableObjectMode&&!s;return Nwe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Mvt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Nwe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=$vt(t,"data",{signal:e.signal,highWaterMark:Cwe,highWatermark:Cwe});return Uvt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},Q3=Lvt(!0),Cwe=Q3,Uvt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=Fvt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Jf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*eT(a)}},Fvt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NC(t,r,!e),CC(t,i,!n,{})].filter(Boolean);var kwe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=qvt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([Bvt(t),d]);return}let f=P3(c,r),p=X3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zvt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},qvt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!LC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=X3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await VTe(a,t,r,s)},Bvt=async t=>{await jvt(),t.readableFlowing===null&&t.resume()},zvt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await bC(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await TC(r,{maxBuffer:s})):await Yg(r,{maxBuffer:s})}catch(a){return $we(Vbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},eW=async t=>{try{return await t}catch(e){return $we(e)}},$we=({bufferedData:t})=>oEe(t)?new Uint8Array(t):t;import{finished as Vvt}from"stream/promises";var iT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=Hvt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Vvt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Yvt(a,e,r,n)}finally{o.abort()}},Hvt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Gvt(t,r,n),n},Gvt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Wvt(e,r),n.call(t,...i)}},Wvt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Yvt=(t,e,r,n)=>{if(!Kvt(t,e,r,n))throw t},Kvt=(t,e,r,n=!0)=>r.propagating?Lwe(t)||zC(t):(r.propagating=!0,tW(r,e)===n?Lwe(t):zC(t)),tW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",zC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Lwe=t=>t?.code==="EPIPE";var Dwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>rW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),rW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=iT(t,e,l);if(tW(l,e)){await u;return}let[d]=await Promise.all([kwe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Mwe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Zf([t,e].filter(Boolean)):void 0,Uwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>rW({...Jvt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Zvt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Jvt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},Zvt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Xvt}from"events";var Fwe=t=>jg(t,"ipc"),jwe=(t,e)=>{let r=KP(t);na({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var qwe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Fwe(s),a=wc(e,"ipc"),c=wc(r,"ipc");for await(let l of F3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Hbe(t,i,c),i.push(l)),o&&jwe(l,s);return i},Bwe=async(t,e)=>(await Promise.allSettled([t]),e);var zwe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=KTe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Dwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),T=Uwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),O=[],x=qwe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),A=Qvt(m,t,S),I=ebt(h,S);try{return await Promise.race([Promise.all([{},ZTe(v),Promise.all(g),T,x,Tbe(t,d),...A,...I]),_,tbt(t,y),...ybe(t,s,f,y),...Fve({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...gbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(R){return f.terminationReason??="other",Promise.all([{error:R},v,Promise.all(g.map(b=>eW(b))),eW(T),Bwe(x,O),Promise.allSettled(A),Promise.allSettled(I)])}},Qvt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:iT(n,i,r)),ebt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>io(s,{checkOpen:!1})&&!to(s)).map(({type:i,value:s,stream:o=s})=>iT(o,n,e,{isSameDirection:ws.has(i),stopOnExit:i==="native"}))),tbt=async(t,{signal:e})=>{let[r]=await Xvt(t,"error",{signal:e});throw r};var Vwe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),sT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ia();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Qg=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as rbt}from"stream";import{callbackify as nbt}from"util";import{finished as Hwe}from"stream/promises";var nW=async t=>{if(t!==void 0)try{await iW(t)}catch{}},Gwe=async t=>{if(t!==void 0)try{await sW(t)}catch{}},iW=async t=>{await Hwe(t,{cleanup:!0,readable:!1,writable:!0})},sW=async t=>{await Hwe(t,{cleanup:!0,readable:!0,writable:!1})},VC=async(t,e)=>{if(await t,e)throw e},HC=(t,e,r)=>{r&&!zC(r)?t.destroy(r):e&&t.destroy()};var Wwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||qi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=oW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=aW(a,o),{read:f,onStdoutDataDone:p}=cW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new rbt({read:f,destroy:nbt(uW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return lW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},oW=(t,e,r)=>{let n=Hg(t,e),i=sT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},aW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:Q3},cW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ia(),o=BC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){ibt(this,o,s)},onStdoutDataDone:s}},ibt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},lW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await sW(t),await n,await nW(i),await e,r.readable&&r.push(null)}catch(s){await nW(i),Ywe(r,s)}},uW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qg(r,e)&&(Ywe(t,n),await VC(e,n))},Ywe=(t,e)=>{HC(t,t.readable,e)};import{Writable as sbt}from"stream";import{callbackify as Kwe}from"util";var Jwe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=dW(t,r,e),o=new sbt({...fW(n,t,i),destroy:Kwe(hW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return pW(n,o),o},dW=(t,e,r)=>{let n=oC(t,e),i=sT(r,n,"writableFinal"),s=sT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},fW=(t,e,r)=>({write:obt.bind(void 0,t),final:Kwe(abt.bind(void 0,t,e,r))}),obt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},abt=async(t,e,r)=>{await Qg(r,e)&&(t.writable&&t.end(),await e)},pW=async(t,e,r)=>{try{await iW(t),e.writable&&e.end()}catch(n){await Gwe(r),Zwe(e,n)}},hW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Qg(r,e),await Qg(n,e)&&(Zwe(t,i),await VC(e,i))},Zwe=(t,e)=>{HC(t,t.writable,e)};import{Duplex as cbt}from"stream";import{callbackify as lbt}from"util";var Xwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||qi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=oW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=dW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=aW(c,a),{read:_,onStdoutDataDone:y}=cW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new cbt({read:_,...fW(u,t,d),destroy:lbt(ubt.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 lW({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),pW(u,v,c),v},ubt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([uW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),hW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var mW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||qi.has(e),o=Hg(t,r),a=BC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return dbt(a,o,t)},dbt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Qwe=(t,{encoding:e})=>{let r=Vwe();t.readable=Wwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Jwe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Xwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=mW.bind(void 0,t,e),t[Symbol.asyncIterator]=mW.bind(void 0,t,e,{})};var e0e=(t,e)=>{for(let[r,n]of pbt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},fbt=(async()=>{})().constructor.prototype,pbt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(fbt,t)]);var t0e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=gbt(t,e,r),{subprocess:f,promise:p}=ybt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=qC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),e0e(f,p),sa.set(f,{options:u,fileDescriptors:d}),f},gbt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=ZP(t,e,r),{file:a,commandArguments:c,options:l}=_C(t,e,r),u=_bt(l),d=fwe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_bt=({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}},ybt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=mbt(...yC(t,e,r))}catch(h){return cwe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;hbt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];vwe(c,a,l),Twe(c,r,l);let d={},f=ia();c.kill=Mve.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Mwe(c,r),Qwe(c,r),swe(c,r);let p=Sbt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},Sbt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await zwe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,T)=>Ac(g,e,T)),v=Ac(m,e,"all"),S=Ebt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Jg(S,n,e)},Ebt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Qb({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof oa,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):AC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var GC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,vbt(n,t[n],i)]));return{...t,...r}},vbt=(t,e,r)=>bbt.has(t)&&Er(e)&&Er(r)?{...e,...r}:r,bbt=new Set(["env",...H6]);var Ou=(t,e,r,n)=>{let i=(o,a,c)=>Ou(o,a,r,c),s=(...o)=>Tbt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},Tbt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Er(s))return i(t,GC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=wbt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?QTe(a,c,l):t0e(a,c,l,i)},wbt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=fEe(e)?pEe(e,r):[e,...r],[o,a,c]=jP(...s),l=GC(GC(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var r0e=({file:t,commandArguments:e})=>i0e(t,e),n0e=({file:t,commandArguments:e})=>({...i0e(t,e),isSync:!0}),i0e=(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]=Rbt(t);return{file:r,commandArguments:n}},Rbt=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(Abt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Abt=/ +/g;var s0e=(t,e,r)=>{t.sync=e(xbt,r),t.s=t.sync},o0e=({options:t})=>a0e(t),xbt=({options:t})=>({...a0e(t),isSync:!0}),a0e=t=>({options:{...Ibt(t),...t}}),Ibt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},c0e={preferLocal:!0};var l0e=Ou(()=>({})),ypr=Ou(()=>({isSync:!0})),u0e=Ou(r0e),Spr=Ou(n0e),Epr=Ou(Ebe),vpr=Ou(o0e,{},c0e,s0e),{sendMessage:bpr,getOneMessage:Tpr,getEachMessage:wpr,getCancelSignal:Rpr}=owe();import{Transform as Obt}from"stream";var Pbt=["NETLIFY_AI_GATEWAY_KEY"];function Cbt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...Pbt])]}function Nbt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function kbt(){let e=Cbt().map(r=>process.env[r]).filter(r=>!(!r||Nbt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Rs(t){if(typeof t!="string")return t;let e=kbt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp($bt(n),"g");r=r.replace(i,"******")}),r}function $bt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var oT=class extends Obt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Rs(i);n(null,s)}},WC=Symbol("maskedWrite");function d0e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[WC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Rs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WC]=!0,process.stdout.write=r}if(!process.stderr.write[WC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Rs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WC]=!0,process.stderr.write=r}}}var f0e=!1,p0e=()=>{f0e=!0},vi=()=>f0e;var aT=null,h0e=t=>(aT&&aT.destroy(),aT=new xc({totalAllowedTime:t}),aT),m0e=()=>aT;var xc=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&vi())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await UP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{he.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var g0e={name:"@netlify/agent-runner-cli",type:"module",version:"1.161.3",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: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.1.5","@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.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var Ubt=Dbt(import.meta.url),Fbt=Ic.dirname(Ubt),jbt=Mbt(import.meta.url),e_=_e("shell"),gW=new Set,_0e={preferLocal:!0},gn=(t,e,r)=>{let[n,i]=qbt(e,r),s={..._0e,...i},o=l0e(t,n,s);S0e(o,s),b0e(o);let a=r?.idleTimeout;return a&&a>0&&v0e(o,a),o},y0e=(t,e)=>{let r={..._0e,...e},n=u0e(t,r);return S0e(n,r),b0e(n),e?.idleTimeout&&e.idleTimeout>0&&v0e(n,e.idleTimeout),n},qbt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},S0e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Oc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new oT).pipe(Oc.stdout),t.stderr?.pipe(new oT).pipe(Oc.stderr);return}t.stdout?.pipe(Oc.stdout),t.stderr?.pipe(Oc.stderr)},_W=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Oc.kill(-t.pid,e),e_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return e_.error("Error killing process:",r),!1}},E0e=t=>_W(t,"SIGKILL"),v0e=(t,e)=>{let r=null,n=()=>{e_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),_W(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(e_.log(`Force killing idle process ${t.pid}`),E0e(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},b0e=t=>{gW.add(t);let e=m0e();if(e){let r=e.onTimesUp(()=>{e_.log(`Global timer expired, killing process ${t.pid}`),_W(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(e_.log(`Force killing process ${t.pid} after timeout`),E0e(t))},5e3)});t.on("exit",()=>{gW.delete(t),r()}),t.on("error",()=>{gW.delete(t),r()})}};function ca(t,e){if(!Oc.env.NETLIFY_LOCAL_MODE)try{let i=jbt.resolve(g0e.name),s=Ic.dirname(i);for(;s!==Ic.dirname(s);){let o=Ic.dirname(s);if(Ic.basename(o)==="node_modules"){let a=Ic.join(o,".bin",e);if(YC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Oc.env.NODE_PATH){let i=Ic.join(Oc.env.NODE_PATH,".bin",e);if(YC.existsSync(i))return i}let r=Ic.join(t,"node_modules",".bin",e);if(YC.existsSync(r))return r;let n=Ic.join(Fbt,"..","node_modules",".bin",e);if(YC.existsSync(n))return n}import _D from"process";import{fileURLToPath as mDt}from"url";import{createRequire as gDt}from"module";import s0 from"path";import{readFileSync as _Dt}from"fs";var Bbt="__netlify__getTracer",zbt="__netlify__shutdownTracers",yt=(t,e)=>globalThis[Bbt]?.(t,e),T0e=async()=>globalThis[zbt]?.();function cT(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as lDt}from"timers/promises";Ne();import Vwt from"process";Ne();var pTt=(t,e)=>{e.recordException(t),e.setStatus({code:Nn.ERROR})};var Nc=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=gRe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>_Re(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=gRe(r,n,i),c=this._tracer.startSpan(e,s,o);return _Re(c,s,a)}};function gRe(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??jt.active(),{opts:n,ctx:i,fn:s}}function _Re(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:pTt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ne();var a_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var ZW=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=xRe(e),n._asyncAttributesPending=e.filter(([i,s])=>a_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(a_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=xRe(this._rawAttributes),this._schemaUrl=hTt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,a_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&le.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(a_(n)){le.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=mTt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function XW(t,e){return ZW.FromAttributeList(Object.entries(t),e)}function xRe(t){return t.map(([e,r])=>a_(r)?[e,r.catch(n=>{le.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function hTt(t){if(typeof t=="string"||t===void 0)return t;le.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function mTt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;le.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var ET=class{emit(e){}enabled(){return!1}},IRe=new ET;var vT=Symbol.for("io.opentelemetry.js.api.logs"),c_=globalThis;function ORe(t,e,r){return n=>n===t?e:r}var QW=1;var eY=class{getLogger(e,r,n){return new ET}},_N=new eY;var yN=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):IRe}};var bT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new yN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:_N}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var SN=class t{constructor(){this._proxyLoggerProvider=new bT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return c_[vT]?this.getLoggerProvider():(c_[vT]=ORe(QW,e,_N),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=c_[vT])===null||e===void 0?void 0:e.call(c_,QW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete c_[vT],this._proxyLoggerProvider=new bT}};var PRe=SN.getInstance();function CRe(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function NRe(t){t.forEach(e=>e.disable())}function tY(t){let e=t.tracerProvider||xt.getTracerProvider(),r=t.meterProvider||ST.getMeterProvider(),n=t.loggerProvider||PRe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return CRe(i,e,r,n),()=>{NRe(i)}}Ne();var gTt=Hr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function kRe(t){return t.getValue(gTt)===!0}var l_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(l_||(l_={}));Ne();var rY="[_0-9a-z-*/]",_Tt=`[a-z]${rY}{0,255}`,yTt=`[a-z0-9]${rY}{0,240}@[a-z]${rY}{0,13}`,STt=new RegExp(`^(?:${_Tt}|${yTt})$`),ETt=/^[ -~]{0,255}[!-~]$/,vTt=/,|=/;function nY(t){return STt.test(t)}function iY(t){return ETt.test(t)&&!vTt.test(t)}var bTt=32,$Re=512,LRe=",",DRe="=",EN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!nY(e)||!iY(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>$Re)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=LRe+e),e=`${n[0]}${DRe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(LRe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(DRe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!nY(a)||!iY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>$Re)&&(r.set(a,c),n=l,r.size>=bTt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var vN="traceparent",bN="tracestate",TTt="00",wTt="(?!ff)[\\da-f]{2}",RTt="(?![0]{32})[\\da-f]{32}",ATt="(?![0]{16})[\\da-f]{16}",xTt="[\\da-f]{2}",ITt=new RegExp(`^\\s?(${wTt})-(${RTt})-(${ATt})-(${xTt})(-.*)?\\s?$`);function MRe(t){let e=ITt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Nu=class{inject(e,r,n){let i=xt.getSpanContext(e);if(!i||kRe(e)||!bi(i))return;let s=`${TTt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||hr.NONE).toString(16)}`;n.set(r,vN,s),i.traceState&&n.set(r,bN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,vN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=MRe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,bN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new EN(typeof c=="string"?c:void 0)}return xt.setSpanContext(e,o)}fields(){return[vN,bN]}};var TN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var TT=class{_isCalled=!1;_deferred=new TN;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var hk=Bn(zY(),1);Ne();var SIe=t=>{throw TypeError(t)},WY=(t,e,r)=>e.has(t)||SIe("Cannot "+r),pk=(t,e,r)=>(WY(t,e,"read from private field"),r?r.call(t):e.get(t)),VY=(t,e,r)=>e.has(t)?SIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),gIe=(t,e,r,n)=>(WY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),zwt=(t,e,r)=>(WY(t,e,"access private method"),r),_Ie="__netlify__getTracer",Hwt="__netlify__shutdownTracers",Gwt="__nfOTLPTrace",UT,FT,GY,EIe,Wwt=class{constructor(){VY(this,GY),VY(this,UT),VY(this,FT),gIe(this,UT,new TT(zwt(this,GY,EIe),this)),gIe(this,FT,le.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(pk(this,FT).debug(`export ${t.length.toString()} spans`),pk(this,UT).isCalled){e({code:l_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Gwt,JSON.stringify(Ywt(t))),e({code:l_.SUCCESS})}shutdown(){return pk(this,UT).call()}};UT=new WeakMap;FT=new WeakMap;GY=new WeakSet;EIe=function(){return pk(this,FT).debug("Shutting down"),Promise.resolve()};function Ywt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:fk(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||so.SERVER,startTimeUnixNano:HY(e.startTime),endTimeUnixNano:HY(e.endTime),attributes:fk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:HY(n.time),attributes:fk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:fk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function fk(t){return Object.keys(t).map(e=>vIe(e,t[e]))}function vIe(t,e){return{key:t,value:bIe(e)}}function bIe(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(bIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>vIe(r,n))}}:{}}function HY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var yIe={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},TIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,_Ie))return;let e=Vwt.version.slice(1),r=XW({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[Kwt()],i=new hk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Nu});let s=t.instrumentations??[];tY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,_Ie,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Nc(xt.getTracer(a,c)):new Nc(xt.getTracer(yIe.name,yIe.version))}}),Object.defineProperty(globalThis,Hwt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Kwt=()=>new hk.SimpleSpanProcessor(new Wwt);Ne();var jT=Bn(zY(),1);Ne();import*as mk from"diagnostics_channel";var wIe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Nn.ERROR:Nn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Nc?t:new Nc(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){mk.subscribe(t,e);let r=()=>mk.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:so.CLIENT},jt.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Nn.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var YDe=Bn(GDe(),1);var mD=_e("tracing"),WDe=8e3,uDt=5e3,i0=async(t=uDt)=>{try{await Promise.race([T0e(),lDt(t)])}catch(e){mD.warn("Failed to flush tracers on shutdown",e)}},KDe=async(t,e,r)=>{if(!yt()){let n=[new jT.SimpleSpanProcessor(new YJ),new jT.SimpleSpanProcessor(new YDe.OTLPTraceExporter({url:r.exporterUrl}))];await TIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new wIe({skipHeaders:!0})]})}return r.traceparent?(Qn.setGlobalPropagator(new Nu),Qn.extract(jt.active(),{traceparent:r.traceparent,isRemote:!0})):jt.active()};function zt(t,e,r){return mD.log(`\u23F3 TRACE: ${e} starting...`),cT(t,e,r)}var YJ=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";mD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&mD.log(` \u274C Error: ${e.status.message}`)}};function KJ(){return Be().captureLlmContentEnabled}function JDe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function gD(t,e,r){let n={role:t,parts:[{type:"text",content:Rs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var dDt=new Set([Q.Task,Q.RunCommand,Q.Explore,Q.FileRead,Q.FileWrite,Q.Notebook,Q.Web,Q.Todo,Q.Skill,Q.Tool,Q.Memorize,Q.Deployment,Q.SiteGeneration]);function ZDe(t,e,r,n){if(!t.length)return;let i=yt();if(!i)return;let s=KJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&dDt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>WDe?`${a.message.slice(0,WDe)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Rs(_)}:{"gen_ai.output.messages":gD("assistant",_)}:{}}}).end(u)})}import{readdir as fDt,rm as pDt}from"fs/promises";import{join as hDt}from"path";async function XDe(t,e=[]){let n=(await fDt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>pDt(hDt(t,i),{recursive:!0,force:!0})))}var ad=({mode:t,sessionCreditLimit:e})=>t==="create"&&e!=null&&e<=300;var yDt=s0.dirname(mDt(import.meta.url)),QDe=gDt(import.meta.url),SDt=s0.resolve(yDt,"scripts/scaffold.js"),EDt="scripts/scaffold.js",vDt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,JJ=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},bDt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),TDt=t=>{let e=JJ(t);return e==="node"||e.endsWith("/node")},rl=t=>{if(typeof t!="string")return!1;let e=t.match(vDt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&bDt(JJ(e[r]));)r+=1;if(r>=e.length||!TDt(e[r]))return!1;let n=e[r+1];return n?JJ(n).includes(EDt):!1},Ey=_e("create_stage"),eMe="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",wDt=`${eMe}
|
|
602
|
+
if (condition) { yield value; }`)};import{Buffer as WSt}from"buffer";import{StringDecoder as YSt}from"string_decoder";var NC=(t,e,r)=>{if(r)return;if(t)return{transform:KSt.bind(void 0,new TextEncoder)};let n=new YSt(e);return{transform:JSt.bind(void 0,n),final:ZSt.bind(void 0,n)}},KSt=function*(t,e){WSt.isBuffer(e)?yield Tc(e):typeof e=="string"?yield t.encode(e):yield e},JSt=function*(t,e){yield $r(e)?t.write(e):e},ZSt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as MTe}from"util";var k3=MTe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),kC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=QSt}=e[r];for await(let i of n(t))yield*kC(i,e,r+1)},UTe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*XSt(r,Number(e),t)},XSt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*kC(n,r,e+1)},FTe=MTe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),QSt=function*(t){yield t};var $3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},jTe=(t,e)=>[...e.flatMap(r=>[...Jf(r,t,0)]),...eT(t)],Jf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=tEt}=e[r];for(let i of n(t))yield*Jf(i,e,r+1)},eT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*eEt(r,Number(e),t)},eEt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Jf(n,r,e+1)},tEt=function*(t){yield t};var L3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=BTe(t,o,s),l=Kf(e),u=Kf(r),d=l?k3.bind(void 0,kC,a):$3.bind(void 0,Jf),f=l||u?k3.bind(void 0,UTe,a):$3.bind(void 0,eT),p=l||u?FTe.bind(void 0,a):void 0;return{stream:new rEt({writableObjectMode:n,writableHighWaterMark:qTe(n),readableObjectMode:i,readableHighWaterMark:qTe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},$C=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=BTe(o,r,a);t=jTe(c,t)}return t},BTe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:$Te(n,a)},NC(r,o,n),CC(r,s,n,c),{transform:t,final:e},{transform:LTe(i,a)},kTe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var zTe=(t,e)=>{for(let r of nEt(t))iEt(t,r,e)},nEt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),iEt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Iu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>sEt(a,n));r.input=Vb(o)},sEt=(t,e)=>{let r=$C(t,e,"utf8",!0);return oEt(r),Vb(r)},oEt=t=>{let e=t.find(r=>typeof r!="string"&&!$r(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 uEt,appendFileSync as dEt}from"fs";var LC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&jg(r,n)&&!qi.has(e)&&aEt(n)&&(t.some(({type:i,value:s})=>i==="native"&&cEt.has(s))||t.every(({type:i})=>ws.has(i))),aEt=t=>t===1||t===2,cEt=new Set(["pipe","overlapped"]),VTe=async(t,e,r,n)=>{for await(let i of t)lEt(e)||GTe(i,r,n)},HTe=(t,e,r)=>{for(let n of t)GTe(n,e,r)},lEt=t=>t._readableState.pipes.length>0,GTe=(t,e,r)=>{let n=KP(t);na({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var WTe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>fEt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},fEt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Ybe(t,s,d),p=Tc(f),{stdioItems:h,objectMode:m}=e[r],_=pEt([p],h,c,n),{serializedResult:y,finalResult:v=y}=hEt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});mEt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&gEt(y,h,i),S}catch(g){return n.error=g,S}},pEt=(t,e,r,n)=>{try{return $C(t,e,r,!1)}catch(i){return n.error=i,t}},hEt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Vb(t)};let o=cEe(t,r);return n[s]?{serializedResult:o,finalResult:N3(o,!i[s],e)}:{serializedResult:o}},mEt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!LC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=N3(t,!1,o);try{HTe(a,e,n)}catch(c){r.error??=c}},gEt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?dEt(n,t):(r.add(s),uEt(n,t))}};var YTe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ac(e,r,"all")]:Array.isArray(e)?[Ac(t,r,"all"),...e]:$r(t)&&$r(e)?q6([t,e]):`${t}${e}`};import{once as D3}from"events";var KTe=async(t,e)=>{let[r,n]=await _Et(t);return e.isForcefullyTerminated??=!1,[r,n]},_Et=async t=>{let[e,r]=await Promise.allSettled([D3(t,"spawn"),D3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?JTe(t):r.value},JTe=async t=>{try{return await D3(t,"exit")}catch{return JTe(t)}},ZTe=async t=>{let[e,r]=await t;if(!yEt(e,r)&&M3(e,r))throw new ro;return[e,r]},yEt=(t,e)=>t===void 0&&e===void 0,M3=(t,e)=>t!==0||e!==null;var XTe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=SEt(t,e,r),o=s?.code==="ETIMEDOUT",a=Wbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},SEt=(t,e,r)=>t!==void 0?t:M3(e,r)?new ro:void 0;var QTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=vEt(t,e,r),d=wEt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Jg(d,c,l)},vEt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=ZP(t,e,r),a=bEt(r),{file:c,commandArguments:l,options:u}=_C(t,e,a);TEt(u);let d=OTe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},bEt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,TEt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&DC("ipcInput"),t&&DC("ipc: true"),r&&DC("detached: true"),n&&DC("cancelSignal")},DC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},wEt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=REt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=XTe(c,r),{output:h,error:m=l}=WTe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>Ac(v,r,S)),y=Ac(YTe(h,r),r,"all");return xEt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},REt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{zTe(s,r);let a=AEt(r);return EEt(...yC(t,e,a))}catch(a){return Kg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},AEt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RC(e)}),xEt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?AC({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Qb({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as hbt}from"events";import{spawn as mbt}from"child_process";import iwe from"process";import{once as U3,on as IEt}from"events";var ewe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(zg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:dC(t)}),OEt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),OEt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{aC(e,i);let s=xu(t,e,r),o=new AbortController;try{return await Promise.race([PEt(s,n,o),CEt(s,r,o),NEt(s,r,o)])}catch(a){throw Vg(t),a}finally{o.abort(),cC(e,i)}},PEt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await U3(t,"message",{signal:r});return n}for await(let[n]of IEt(t,"message",{signal:r}))if(e(n))return n},CEt=async(t,e,{signal:r})=>{await U3(t,"disconnect",{signal:r}),jve(e)},NEt=async(t,e,{signal:r})=>{let[n]=await U3(t,"strict:error",{signal:r});throw iC(n,e)};import{once as rwe,on as kEt}from"events";var nwe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>F3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),F3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{zg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:dC(t)}),aC(e,s);let o=xu(t,e,r),a=new AbortController,c={};return $Et(t,o,a),LEt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),DEt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},$Et=async(t,e,r)=>{try{await rwe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},LEt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await rwe(t,"strict:error",{signal:r.signal});n.error=iC(i,e),r.abort()}catch{}},DEt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of kEt(r,"message",{signal:s.signal}))twe(o),yield c}catch{twe(o)}finally{s.abort(),cC(e,a),n||Vg(t),i&&await t}},twe=({error:t})=>{if(t)throw t};var swe=(t,{ipc:e})=>{Object.assign(t,awe(t,!1,e))},owe=()=>{let t=iwe,e=!0,r=iwe.channel!==void 0;return{...awe(t,e,r),getCancelSignal:pbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},awe=(t,e,r)=>({sendMessage:mC.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ewe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:nwe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as MEt}from"child_process";import{PassThrough as UEt,Readable as FEt,Writable as jEt,Duplex as qEt}from"stream";var cwe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{O3(n);let a=new MEt;BEt(a,n),Object.assign(a,{readable:zEt,writable:VEt,duplex:HEt});let c=Kg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=GEt(c,o,i);return{subprocess:a,promise:l}},BEt=(t,e)=>{let r=tT(),n=tT(),i=tT(),s=Array.from({length:e.length-3},tT),o=tT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},tT=()=>{let t=new UEt;return t.end(),t},zEt=()=>new FEt({read(){}}),VEt=()=>new jEt({write(){}}),HEt=()=>new qEt({read(){},write(){}}),GEt=async(t,e,r)=>Jg(t,e,r);import{createReadStream as lwe,createWriteStream as uwe}from"fs";import{Buffer as WEt}from"buffer";import{Readable as rT,Writable as YEt,Duplex as KEt}from"stream";var fwe=(t,e)=>PC(JEt,t,e,!1),nT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Iu[t]}.`)},dwe={fileNumber:nT,generator:L3,asyncGenerator:L3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:KEt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},JEt={input:{...dwe,fileUrl:({value:t})=>({stream:lwe(t)}),filePath:({value:{file:t}})=>({stream:lwe(t)}),webStream:({value:t})=>({stream:rT.fromWeb(t)}),iterable:({value:t})=>({stream:rT.from(t)}),asyncIterable:({value:t})=>({stream:rT.from(t)}),string:({value:t})=>({stream:rT.from(t)}),uint8Array:({value:t})=>({stream:rT.from(WEt.from(t))})},output:{...dwe,fileUrl:({value:t})=>({stream:uwe(t)}),filePath:({value:{file:t,append:e}})=>({stream:uwe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:YEt.fromWeb(t)}),iterable:nT,asyncIterable:nT,string:nT,uint8Array:nT}};import{on as ZEt,once as pwe}from"events";import{PassThrough as XEt,getDefaultHighWaterMark as QEt}from"stream";import{finished as gwe}from"stream/promises";function Zf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)q3(i);let e=t.some(({readableObjectMode:i})=>i),r=evt(t,e),n=new j3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var evt=(t,e)=>{if(t.length===0)return QEt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},j3=class extends XEt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(q3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=tvt(this,this.#e,this.#s);let r=ivt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(q3(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)}},tvt=async(t,e,r)=>{MC(t,hwe);let n=new AbortController;try{await Promise.race([rvt(t,n),nvt(t,e,r,n)])}finally{n.abort(),MC(t,-hwe)}},rvt=async(t,{signal:e})=>{try{await gwe(t,{signal:e,cleanup:!0})}catch(r){throw _we(t,r),r}},nvt=async(t,e,r,{signal:n})=>{for await(let[i]of ZEt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},q3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ivt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{MC(t,mwe);let a=new AbortController;try{await Promise.race([svt(s,e,a),ovt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),avt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),MC(t,-mwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?B3(t):cvt(t))},svt=async(t,e,{signal:r})=>{try{await t,r.aborted||B3(e)}catch(n){r.aborted||_we(e,n)}},ovt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await gwe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;ywe(o)?i.add(e):Swe(t,o)}},avt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await pwe(t,i,{signal:s}),!t.readable)return pwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},cvt=t=>{t.writable&&t.end()},_we=(t,e)=>{ywe(e)?B3(t):Swe(t,e)},ywe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",B3=t=>{(t.readable||t.writable)&&t.destroy()},Swe=(t,e)=>{t.destroyed||(t.once("error",lvt),t.destroy(e))},lvt=()=>{},MC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},hwe=2,mwe=1;import{finished as Ewe}from"stream/promises";var Xg=(t,e)=>{t.pipe(e),uvt(t,e),dvt(t,e)},uvt=async(t,e)=>{if(!(to(t)||to(e))){try{await Ewe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}z3(e)}},z3=t=>{t.writable&&t.end()},dvt=async(t,e)=>{if(!(to(t)||to(e))){try{await Ewe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}V3(t)}},V3=t=>{t.readable&&t.destroy()};var vwe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>ws.has(c)))fvt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!ws.has(c)))hvt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Zf(s);Xg(o,i)}},fvt=(t,e,r,n)=>{r==="output"?Xg(t.stdio[n],e):Xg(e,t.stdio[n]);let i=pvt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},pvt=["stdin","stdout","stderr"],hvt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;mvt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},mvt=(t,{signal:e})=>{to(t)&&Wf(t,gvt,e)},gvt=2;import{addAbortListener as Svt}from"events";var Xf=[];Xf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Xf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Xf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var UC=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",H3=Symbol.for("signal-exit emitter"),G3=globalThis,_vt=Object.defineProperty.bind(Object),W3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(G3[H3])return G3[H3];_vt(G3,H3,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},FC=class{},yvt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Y3=class extends FC{onExit(){return()=>{}}load(){}unload(){}},K3=class extends FC{#e=J3.platform==="win32"?"SIGINT":"SIGHUP";#r=new W3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Xf)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!UC(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Xf)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Xf.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return UC(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&UC(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)}},J3=globalThis.process,{onExit:bwe,load:Iur,unload:Our}=yvt(UC(J3)?new K3(J3):new Y3);var Twe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=bwe(()=>{t.kill()});Svt(n,()=>{i()})};var Rwe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=JP(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Evt(r,n,i),{sourceStream:d,sourceError:f}=bvt(t,l),{options:p,fileDescriptors:h}=sa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},Evt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=vvt(t,e,...r),a=oC(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},vvt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(wwe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||F6(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=jP(r,...n);return{destination:e(wwe)(i,s,o),pipeOptions:o}}if(sa.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}`)},wwe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),bvt=(t,e)=>{try{return{sourceStream:Hg(t,e)}}catch(r){return{sourceError:r}}};var xwe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Tvt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw Z3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Tvt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return V3(t),n;if(e!==void 0)return z3(r),e},Z3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Kg({error:t,command:Awe,escapedCommand:Awe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Awe="source.pipe(destination)";var Iwe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as wvt}from"stream/promises";var Owe=(t,e,r)=>{let n=jC.has(e)?Avt(t,e):Rvt(t,e);return Wf(t,Ivt,r.signal),Wf(e,Ovt,r.signal),xvt(e),n},Rvt=(t,e)=>{let r=Zf([t]);return Xg(r,e),jC.set(e,r),r},Avt=(t,e)=>{let r=jC.get(e);return r.add(t),r},xvt=async t=>{try{await wvt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jC.delete(t)},jC=new WeakMap,Ivt=2,Ovt=1;import{aborted as Pvt}from"util";var Pwe=(t,e)=>t===void 0?[]:[Cvt(t,e)],Cvt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Pvt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw Z3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var qC=(t,...e)=>{if(Er(e[0]))return qC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Rwe(t,...e),i=Nvt({...n,destination:r});return i.pipe=qC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Nvt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=kvt(t,i);xwe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Owe(e,s,d);return await Promise.race([Iwe(u),...Pwe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},kvt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as jvt}from"timers/promises";import{on as $vt}from"events";import{getDefaultHighWaterMark as Lvt}from"stream";var BC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Dvt(e,o),Nwe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Dvt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},X3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;Mvt(e,o,t);let a=t.readableObjectMode&&!s;return Nwe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Mvt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Nwe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=$vt(t,"data",{signal:e.signal,highWaterMark:Cwe,highWatermark:Cwe});return Uvt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},Q3=Lvt(!0),Cwe=Q3,Uvt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=Fvt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Jf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*eT(a)}},Fvt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NC(t,r,!e),CC(t,i,!n,{})].filter(Boolean);var kwe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=qvt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([Bvt(t),d]);return}let f=P3(c,r),p=X3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zvt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},qvt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!LC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=X3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await VTe(a,t,r,s)},Bvt=async t=>{await jvt(),t.readableFlowing===null&&t.resume()},zvt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await bC(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await TC(r,{maxBuffer:s})):await Yg(r,{maxBuffer:s})}catch(a){return $we(Vbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},eW=async t=>{try{return await t}catch(e){return $we(e)}},$we=({bufferedData:t})=>oEe(t)?new Uint8Array(t):t;import{finished as Vvt}from"stream/promises";var iT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=Hvt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Vvt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Yvt(a,e,r,n)}finally{o.abort()}},Hvt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Gvt(t,r,n),n},Gvt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Wvt(e,r),n.call(t,...i)}},Wvt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Yvt=(t,e,r,n)=>{if(!Kvt(t,e,r,n))throw t},Kvt=(t,e,r,n=!0)=>r.propagating?Lwe(t)||zC(t):(r.propagating=!0,tW(r,e)===n?Lwe(t):zC(t)),tW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",zC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Lwe=t=>t?.code==="EPIPE";var Dwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>rW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),rW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=iT(t,e,l);if(tW(l,e)){await u;return}let[d]=await Promise.all([kwe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Mwe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Zf([t,e].filter(Boolean)):void 0,Uwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>rW({...Jvt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Zvt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Jvt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},Zvt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Xvt}from"events";var Fwe=t=>jg(t,"ipc"),jwe=(t,e)=>{let r=KP(t);na({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var qwe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Fwe(s),a=wc(e,"ipc"),c=wc(r,"ipc");for await(let l of F3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Hbe(t,i,c),i.push(l)),o&&jwe(l,s);return i},Bwe=async(t,e)=>(await Promise.allSettled([t]),e);var zwe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=KTe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Dwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),T=Uwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),O=[],x=qwe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:O,verboseInfo:p}),A=Qvt(m,t,S),I=ebt(h,S);try{return await Promise.race([Promise.all([{},ZTe(v),Promise.all(g),T,x,Tbe(t,d),...A,...I]),_,tbt(t,y),...ybe(t,s,f,y),...Fve({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...gbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(R){return f.terminationReason??="other",Promise.all([{error:R},v,Promise.all(g.map(b=>eW(b))),eW(T),Bwe(x,O),Promise.allSettled(A),Promise.allSettled(I)])}},Qvt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:iT(n,i,r)),ebt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>io(s,{checkOpen:!1})&&!to(s)).map(({type:i,value:s,stream:o=s})=>iT(o,n,e,{isSameDirection:ws.has(i),stopOnExit:i==="native"}))),tbt=async(t,{signal:e})=>{let[r]=await Xvt(t,"error",{signal:e});throw r};var Vwe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),sT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ia();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Qg=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as rbt}from"stream";import{callbackify as nbt}from"util";import{finished as Hwe}from"stream/promises";var nW=async t=>{if(t!==void 0)try{await iW(t)}catch{}},Gwe=async t=>{if(t!==void 0)try{await sW(t)}catch{}},iW=async t=>{await Hwe(t,{cleanup:!0,readable:!1,writable:!0})},sW=async t=>{await Hwe(t,{cleanup:!0,readable:!0,writable:!1})},VC=async(t,e)=>{if(await t,e)throw e},HC=(t,e,r)=>{r&&!zC(r)?t.destroy(r):e&&t.destroy()};var Wwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||qi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=oW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=aW(a,o),{read:f,onStdoutDataDone:p}=cW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new rbt({read:f,destroy:nbt(uW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return lW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},oW=(t,e,r)=>{let n=Hg(t,e),i=sT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},aW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:Q3},cW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ia(),o=BC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){ibt(this,o,s)},onStdoutDataDone:s}},ibt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},lW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await sW(t),await n,await nW(i),await e,r.readable&&r.push(null)}catch(s){await nW(i),Ywe(r,s)}},uW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qg(r,e)&&(Ywe(t,n),await VC(e,n))},Ywe=(t,e)=>{HC(t,t.readable,e)};import{Writable as sbt}from"stream";import{callbackify as Kwe}from"util";var Jwe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=dW(t,r,e),o=new sbt({...fW(n,t,i),destroy:Kwe(hW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return pW(n,o),o},dW=(t,e,r)=>{let n=oC(t,e),i=sT(r,n,"writableFinal"),s=sT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},fW=(t,e,r)=>({write:obt.bind(void 0,t),final:Kwe(abt.bind(void 0,t,e,r))}),obt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},abt=async(t,e,r)=>{await Qg(r,e)&&(t.writable&&t.end(),await e)},pW=async(t,e,r)=>{try{await iW(t),e.writable&&e.end()}catch(n){await Gwe(r),Zwe(e,n)}},hW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Qg(r,e),await Qg(n,e)&&(Zwe(t,i),await VC(e,i))},Zwe=(t,e)=>{HC(t,t.writable,e)};import{Duplex as cbt}from"stream";import{callbackify as lbt}from"util";var Xwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||qi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=oW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=dW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=aW(c,a),{read:_,onStdoutDataDone:y}=cW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new cbt({read:_,...fW(u,t,d),destroy:lbt(ubt.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 lW({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),pW(u,v,c),v},ubt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([uW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),hW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var mW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||qi.has(e),o=Hg(t,r),a=BC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return dbt(a,o,t)},dbt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Qwe=(t,{encoding:e})=>{let r=Vwe();t.readable=Wwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Jwe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Xwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=mW.bind(void 0,t,e),t[Symbol.asyncIterator]=mW.bind(void 0,t,e,{})};var e0e=(t,e)=>{for(let[r,n]of pbt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},fbt=(async()=>{})().constructor.prototype,pbt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(fbt,t)]);var t0e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=gbt(t,e,r),{subprocess:f,promise:p}=ybt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=qC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),e0e(f,p),sa.set(f,{options:u,fileDescriptors:d}),f},gbt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=ZP(t,e,r),{file:a,commandArguments:c,options:l}=_C(t,e,r),u=_bt(l),d=fwe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_bt=({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}},ybt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=mbt(...yC(t,e,r))}catch(h){return cwe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;hbt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];vwe(c,a,l),Twe(c,r,l);let d={},f=ia();c.kill=Mve.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Mwe(c,r),Qwe(c,r),swe(c,r);let p=Sbt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},Sbt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await zwe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,T)=>Ac(g,e,T)),v=Ac(m,e,"all"),S=Ebt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Jg(S,n,e)},Ebt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Qb({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof oa,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):AC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var GC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,vbt(n,t[n],i)]));return{...t,...r}},vbt=(t,e,r)=>bbt.has(t)&&Er(e)&&Er(r)?{...e,...r}:r,bbt=new Set(["env",...H6]);var Ou=(t,e,r,n)=>{let i=(o,a,c)=>Ou(o,a,r,c),s=(...o)=>Tbt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},Tbt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Er(s))return i(t,GC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=wbt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?QTe(a,c,l):t0e(a,c,l,i)},wbt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=fEe(e)?pEe(e,r):[e,...r],[o,a,c]=jP(...s),l=GC(GC(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var r0e=({file:t,commandArguments:e})=>i0e(t,e),n0e=({file:t,commandArguments:e})=>({...i0e(t,e),isSync:!0}),i0e=(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]=Rbt(t);return{file:r,commandArguments:n}},Rbt=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(Abt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Abt=/ +/g;var s0e=(t,e,r)=>{t.sync=e(xbt,r),t.s=t.sync},o0e=({options:t})=>a0e(t),xbt=({options:t})=>({...a0e(t),isSync:!0}),a0e=t=>({options:{...Ibt(t),...t}}),Ibt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},c0e={preferLocal:!0};var l0e=Ou(()=>({})),ypr=Ou(()=>({isSync:!0})),u0e=Ou(r0e),Spr=Ou(n0e),Epr=Ou(Ebe),vpr=Ou(o0e,{},c0e,s0e),{sendMessage:bpr,getOneMessage:Tpr,getEachMessage:wpr,getCancelSignal:Rpr}=owe();import{Transform as Obt}from"stream";var Pbt=["NETLIFY_AI_GATEWAY_KEY"];function Cbt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...Pbt])]}function Nbt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function kbt(){let e=Cbt().map(r=>process.env[r]).filter(r=>!(!r||Nbt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Rs(t){if(typeof t!="string")return t;let e=kbt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp($bt(n),"g");r=r.replace(i,"******")}),r}function $bt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var oT=class extends Obt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Rs(i);n(null,s)}},WC=Symbol("maskedWrite");function d0e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[WC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Rs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WC]=!0,process.stdout.write=r}if(!process.stderr.write[WC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Rs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[WC]=!0,process.stderr.write=r}}}var f0e=!1,p0e=()=>{f0e=!0},vi=()=>f0e;var aT=null,h0e=t=>(aT&&aT.destroy(),aT=new xc({totalAllowedTime:t}),aT),m0e=()=>aT;var xc=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&vi())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await UP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{he.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var g0e={name:"@netlify/agent-runner-cli",type:"module",version:"1.162.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: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.1.5","@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.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var Ubt=Dbt(import.meta.url),Fbt=Ic.dirname(Ubt),jbt=Mbt(import.meta.url),e_=_e("shell"),gW=new Set,_0e={preferLocal:!0},gn=(t,e,r)=>{let[n,i]=qbt(e,r),s={..._0e,...i},o=l0e(t,n,s);S0e(o,s),b0e(o);let a=r?.idleTimeout;return a&&a>0&&v0e(o,a),o},y0e=(t,e)=>{let r={..._0e,...e},n=u0e(t,r);return S0e(n,r),b0e(n),e?.idleTimeout&&e.idleTimeout>0&&v0e(n,e.idleTimeout),n},qbt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},S0e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Oc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new oT).pipe(Oc.stdout),t.stderr?.pipe(new oT).pipe(Oc.stderr);return}t.stdout?.pipe(Oc.stdout),t.stderr?.pipe(Oc.stderr)},_W=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Oc.kill(-t.pid,e),e_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return e_.error("Error killing process:",r),!1}},E0e=t=>_W(t,"SIGKILL"),v0e=(t,e)=>{let r=null,n=()=>{e_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),_W(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(e_.log(`Force killing idle process ${t.pid}`),E0e(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},b0e=t=>{gW.add(t);let e=m0e();if(e){let r=e.onTimesUp(()=>{e_.log(`Global timer expired, killing process ${t.pid}`),_W(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(e_.log(`Force killing process ${t.pid} after timeout`),E0e(t))},5e3)});t.on("exit",()=>{gW.delete(t),r()}),t.on("error",()=>{gW.delete(t),r()})}};function ca(t,e){if(!Oc.env.NETLIFY_LOCAL_MODE)try{let i=jbt.resolve(g0e.name),s=Ic.dirname(i);for(;s!==Ic.dirname(s);){let o=Ic.dirname(s);if(Ic.basename(o)==="node_modules"){let a=Ic.join(o,".bin",e);if(YC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Oc.env.NODE_PATH){let i=Ic.join(Oc.env.NODE_PATH,".bin",e);if(YC.existsSync(i))return i}let r=Ic.join(t,"node_modules",".bin",e);if(YC.existsSync(r))return r;let n=Ic.join(Fbt,"..","node_modules",".bin",e);if(YC.existsSync(n))return n}import _D from"process";import{fileURLToPath as mDt}from"url";import{createRequire as gDt}from"module";import s0 from"path";import{readFileSync as _Dt}from"fs";var Bbt="__netlify__getTracer",zbt="__netlify__shutdownTracers",yt=(t,e)=>globalThis[Bbt]?.(t,e),T0e=async()=>globalThis[zbt]?.();function cT(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as lDt}from"timers/promises";Ne();import Vwt from"process";Ne();var pTt=(t,e)=>{e.recordException(t),e.setStatus({code:Nn.ERROR})};var Nc=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=gRe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>_Re(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=gRe(r,n,i),c=this._tracer.startSpan(e,s,o);return _Re(c,s,a)}};function gRe(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??jt.active(),{opts:n,ctx:i,fn:s}}function _Re(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:pTt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ne();var a_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var ZW=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=xRe(e),n._asyncAttributesPending=e.filter(([i,s])=>a_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(a_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=xRe(this._rawAttributes),this._schemaUrl=hTt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,a_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&le.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(a_(n)){le.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=mTt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function XW(t,e){return ZW.FromAttributeList(Object.entries(t),e)}function xRe(t){return t.map(([e,r])=>a_(r)?[e,r.catch(n=>{le.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function hTt(t){if(typeof t=="string"||t===void 0)return t;le.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function mTt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;le.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var ET=class{emit(e){}enabled(){return!1}},IRe=new ET;var vT=Symbol.for("io.opentelemetry.js.api.logs"),c_=globalThis;function ORe(t,e,r){return n=>n===t?e:r}var QW=1;var eY=class{getLogger(e,r,n){return new ET}},_N=new eY;var yN=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):IRe}};var bT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new yN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:_N}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var SN=class t{constructor(){this._proxyLoggerProvider=new bT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return c_[vT]?this.getLoggerProvider():(c_[vT]=ORe(QW,e,_N),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=c_[vT])===null||e===void 0?void 0:e.call(c_,QW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete c_[vT],this._proxyLoggerProvider=new bT}};var PRe=SN.getInstance();function CRe(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function NRe(t){t.forEach(e=>e.disable())}function tY(t){let e=t.tracerProvider||xt.getTracerProvider(),r=t.meterProvider||ST.getMeterProvider(),n=t.loggerProvider||PRe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return CRe(i,e,r,n),()=>{NRe(i)}}Ne();var gTt=Hr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function kRe(t){return t.getValue(gTt)===!0}var l_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(l_||(l_={}));Ne();var rY="[_0-9a-z-*/]",_Tt=`[a-z]${rY}{0,255}`,yTt=`[a-z0-9]${rY}{0,240}@[a-z]${rY}{0,13}`,STt=new RegExp(`^(?:${_Tt}|${yTt})$`),ETt=/^[ -~]{0,255}[!-~]$/,vTt=/,|=/;function nY(t){return STt.test(t)}function iY(t){return ETt.test(t)&&!vTt.test(t)}var bTt=32,$Re=512,LRe=",",DRe="=",EN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!nY(e)||!iY(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>$Re)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=LRe+e),e=`${n[0]}${DRe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(LRe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(DRe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!nY(a)||!iY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>$Re)&&(r.set(a,c),n=l,r.size>=bTt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var vN="traceparent",bN="tracestate",TTt="00",wTt="(?!ff)[\\da-f]{2}",RTt="(?![0]{32})[\\da-f]{32}",ATt="(?![0]{16})[\\da-f]{16}",xTt="[\\da-f]{2}",ITt=new RegExp(`^\\s?(${wTt})-(${RTt})-(${ATt})-(${xTt})(-.*)?\\s?$`);function MRe(t){let e=ITt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Nu=class{inject(e,r,n){let i=xt.getSpanContext(e);if(!i||kRe(e)||!bi(i))return;let s=`${TTt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||hr.NONE).toString(16)}`;n.set(r,vN,s),i.traceState&&n.set(r,bN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,vN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=MRe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,bN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new EN(typeof c=="string"?c:void 0)}return xt.setSpanContext(e,o)}fields(){return[vN,bN]}};var TN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var TT=class{_isCalled=!1;_deferred=new TN;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var hk=Bn(zY(),1);Ne();var SIe=t=>{throw TypeError(t)},WY=(t,e,r)=>e.has(t)||SIe("Cannot "+r),pk=(t,e,r)=>(WY(t,e,"read from private field"),r?r.call(t):e.get(t)),VY=(t,e,r)=>e.has(t)?SIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),gIe=(t,e,r,n)=>(WY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),zwt=(t,e,r)=>(WY(t,e,"access private method"),r),_Ie="__netlify__getTracer",Hwt="__netlify__shutdownTracers",Gwt="__nfOTLPTrace",UT,FT,GY,EIe,Wwt=class{constructor(){VY(this,GY),VY(this,UT),VY(this,FT),gIe(this,UT,new TT(zwt(this,GY,EIe),this)),gIe(this,FT,le.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(pk(this,FT).debug(`export ${t.length.toString()} spans`),pk(this,UT).isCalled){e({code:l_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Gwt,JSON.stringify(Ywt(t))),e({code:l_.SUCCESS})}shutdown(){return pk(this,UT).call()}};UT=new WeakMap;FT=new WeakMap;GY=new WeakSet;EIe=function(){return pk(this,FT).debug("Shutting down"),Promise.resolve()};function Ywt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:fk(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||so.SERVER,startTimeUnixNano:HY(e.startTime),endTimeUnixNano:HY(e.endTime),attributes:fk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:HY(n.time),attributes:fk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:fk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function fk(t){return Object.keys(t).map(e=>vIe(e,t[e]))}function vIe(t,e){return{key:t,value:bIe(e)}}function bIe(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(bIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>vIe(r,n))}}:{}}function HY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var yIe={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},TIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,_Ie))return;let e=Vwt.version.slice(1),r=XW({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[Kwt()],i=new hk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Nu});let s=t.instrumentations??[];tY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,_Ie,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Nc(xt.getTracer(a,c)):new Nc(xt.getTracer(yIe.name,yIe.version))}}),Object.defineProperty(globalThis,Hwt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Kwt=()=>new hk.SimpleSpanProcessor(new Wwt);Ne();var jT=Bn(zY(),1);Ne();import*as mk from"diagnostics_channel";var wIe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Nn.ERROR:Nn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Nc?t:new Nc(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){mk.subscribe(t,e);let r=()=>mk.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:so.CLIENT},jt.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Nn.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var YDe=Bn(GDe(),1);var mD=_e("tracing"),WDe=8e3,uDt=5e3,i0=async(t=uDt)=>{try{await Promise.race([T0e(),lDt(t)])}catch(e){mD.warn("Failed to flush tracers on shutdown",e)}},KDe=async(t,e,r)=>{if(!yt()){let n=[new jT.SimpleSpanProcessor(new YJ),new jT.SimpleSpanProcessor(new YDe.OTLPTraceExporter({url:r.exporterUrl}))];await TIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new wIe({skipHeaders:!0})]})}return r.traceparent?(Qn.setGlobalPropagator(new Nu),Qn.extract(jt.active(),{traceparent:r.traceparent,isRemote:!0})):jt.active()};function zt(t,e,r){return mD.log(`\u23F3 TRACE: ${e} starting...`),cT(t,e,r)}var YJ=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";mD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&mD.log(` \u274C Error: ${e.status.message}`)}};function KJ(){return Be().captureLlmContentEnabled}function JDe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function gD(t,e,r){let n={role:t,parts:[{type:"text",content:Rs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var dDt=new Set([Q.Task,Q.RunCommand,Q.Explore,Q.FileRead,Q.FileWrite,Q.Notebook,Q.Web,Q.Todo,Q.Skill,Q.Tool,Q.Memorize,Q.Deployment,Q.SiteGeneration]);function ZDe(t,e,r,n){if(!t.length)return;let i=yt();if(!i)return;let s=KJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&dDt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>WDe?`${a.message.slice(0,WDe)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Rs(_)}:{"gen_ai.output.messages":gD("assistant",_)}:{}}}).end(u)})}import{readdir as fDt,rm as pDt}from"fs/promises";import{join as hDt}from"path";async function XDe(t,e=[]){let n=(await fDt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>pDt(hDt(t,i),{recursive:!0,force:!0})))}var ad=({mode:t,sessionCreditLimit:e})=>t==="create"&&e!=null&&e<=300;var yDt=s0.dirname(mDt(import.meta.url)),QDe=gDt(import.meta.url),SDt=s0.resolve(yDt,"scripts/scaffold.js"),EDt="scripts/scaffold.js",vDt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,JJ=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},bDt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),TDt=t=>{let e=JJ(t);return e==="node"||e.endsWith("/node")},rl=t=>{if(typeof t!="string")return!1;let e=t.match(vDt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&bDt(JJ(e[r]));)r+=1;if(r>=e.length||!TDt(e[r]))return!1;let n=e[r+1];return n?JJ(n).includes(EDt):!1},Ey=_e("create_stage"),eMe="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",wDt=`${eMe}
|
|
603
603
|
|
|
604
604
|
Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,RDt=`${eMe}
|
|
605
605
|
|
|
@@ -937,8 +937,8 @@ Deploy failed. Here are the errors to review on the latest build:
|
|
|
937
937
|
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.
|
|
938
938
|
|
|
939
939
|
${t.pop()}
|
|
940
|
-
`;var jS=_e("deploy"),qHt=t=>t===""||/[\s"\\]/u.test(t)?JSON.stringify(t):t,WBe=async t=>await zt(yt(),"create-preview-deploy",async e=>BHt(t,e)),BHt=async({netlify:t,hasRepo:e,skipBuild:r,message:n="Agent Preview",deploySubdomain:i,cliPath:s,filter:o,prodDeploy:a},
|
|
941
|
-
Preview deploy created successfully:`,{deployId:
|
|
940
|
+
`;var jS=_e("deploy"),qHt=t=>t===""||/[\s"\\]/u.test(t)?JSON.stringify(t):t,WBe=async t=>await zt(yt(),"create-preview-deploy",async e=>BHt(t,e)),BHt=async({netlify:t,hasRepo:e,skipBuild:r,message:n="Agent Preview",deploySubdomain:i,cliPath:s,filter:o,prodDeploy:a,agentRunnerId:c,agentRunnerSessionId:l},u)=>{try{let d=["deploy","--message",n,"--json","--verbose",a?"--prod":"--draft"];jS.log("Deploy: Uploading source zip"),d.push("--upload-source-zip"),i&&!a&&d.push("--alias",i),o&&d.push("--filter",o),r?(jS.log("Deploy: Skipping build"),d.push("--no-build")):d.push("--context",a?"production":"deploy-preview");let f=s||"netlify";jS.log(`Running: ${f} ${d.map(qHt).join(" ")}`),u?.setAttributes({cmd:f,args:d});let p={};c&&(p.NETLIFY_AGENT_RUNNER_ID=c),l&&(p.NETLIFY_AGENT_RUNNER_SESSION_ID=l);let h=await t.utils.run(f,d,{stdio:["ignore","pipe","pipe"],env:{...process.env,NETLIFY_DEPLOY_SOURCE:"agent_runner",...p}});h.stderr&&jS.log(String(h.stderr));let m=JSON.parse(String(h.stdout??"").trim());u?.setAttributes({success:!0,deployId:m.deploy_id,deployUrl:m.deploy_url,siteId:m.site_id}),jS.log(`
|
|
941
|
+
Preview deploy created successfully:`,{deployId:m.deploy_id,deployUrl:m.deploy_url,siteId:m.site_id});let _={deployId:m.deploy_id,previewUrl:m.deploy_url,logsUrl:m.logs,siteId:m.site_id};return e||(_.sourceZipFilename=m.source_zip_filename),_}catch(d){throw jS.error("Failed to create preview deploy via CLI:",d),u?.setAttributes({success:!1,error:d.message}),d}};import YBe from"fs";import VQ from"path";var KBe=(t=process.cwd())=>{let e=VQ.join(t,sn,Ete);return{hasNetlifyForm:YBe.existsSync(VQ.join(e,"netlify-forms")),hasNetlifyIdentity:YBe.existsSync(VQ.join(e,"netlify-identity"))}};var No=_e("deploy_stage"),s1=async t=>await zt(yt(),"run-deploy-stage",async()=>zHt(t)),zHt=async({cliPath:t,config:e,context:r,result:n,filter:i,isRetry:s,deploySubdomain:o})=>{if(e.mode==="ask")return{hasChanges:!1,previewInfo:null,isProdDeploy:!1,hasNetlifyForm:!1,hasNetlifyIdentity:!1};let a=await zt(yt(),"get-runner-diffs",async()=>await cM({config:e,isRetry:s}));if(No.info("Resolved git",{hasChanges:a.hasChanges,ignored:a.ignored??[]}),!a.hasChanges&&e.mode!=="redeploy"&&!e.pendingUndeployedChanges)return{hasChanges:!1,previewInfo:null,isProdDeploy:!1,hasNetlifyForm:!1,hasNetlifyIdentity:!1};let c=a.hasChanges?a.diff:void 0,l=a.hasChanges?a.resultDiff:void 0,u=a.hasChanges?a.diffBinary:void 0,d=a.hasChanges?a.resultDiffBinary:void 0,f=a.hasChanges||e.mode==="redeploy",{hasNetlifyForm:p,hasNetlifyIdentity:h}=KBe();if(p||h){let S={};p&&(No.log("Detected Netlify Forms enablement \u2014 enabling early"),S.has_netlify_form=!0),h&&(No.log("Detected Netlify Identity enablement \u2014 enabling early"),S.has_netlify_identity=!0);try{await Dn(e.id,e.sessionId,S)}catch(g){No.warn("Failed to send early feature enablement (continuing):",g)}}let m=n!==void 0&&(f||e.mode==="redeploy"||!!e.pendingUndeployedChanges);No.log("Deploy condition check:",{resultUndefined:n===void 0,resultType:typeof n,hasChanges:f,isRedeploy:e.mode==="redeploy",pendingUndeployedChanges:!!e.pendingUndeployedChanges,wouldCreateDeploy:m});let _=ZI(e.mode),y=null,v;if(m)try{let S;try{let g=await zt(yt(),"get-runner-session",async()=>await rM(e.id,e.sessionId));g?.title&&(S=g.title)}catch(g){No.warn("Failed to fetch session title, using fallback message:",g.message)}if(await Dn(e.id,e.sessionId,{steps:[{title:_?"Deploying project":"Deploying preview",category:Q.Deployment}]}),y=await WBe({cliPath:t,netlify:r,hasRepo:e.hasRepo,message:S,skipBuild:!1,deploySubdomain:o,filter:i,prodDeploy:_,agentRunnerId:e.id,agentRunnerSessionId:e.sessionId}),_)try{await uUe()?No.log("Pushed workspace commits to origin"):No.log("Skipped origin push (no origin remote or detached HEAD)")}catch(g){v=g instanceof Error?g.message:String(g),No.warn("Failed to push workspace commits to origin (continuing):",g)}}catch(S){if(vi())throw S;return No.warn("Failed to create preview deploy (continuing with agent run):",S),{diff:c,resultDiff:l,hasChanges:f,previewInfo:null,diffBinary:u,resultDiffBinary:d,deployError:S instanceof Error?S.message:String(S),isProdDeploy:_,hasNetlifyForm:p,hasNetlifyIdentity:h}}return No.log("Git status",{hasDiff:!!c,hasChanges:f}),{diff:c,resultDiff:l,hasChanges:f,previewInfo:y,diffBinary:u,resultDiffBinary:d,gitPushError:v,isProdDeploy:_,hasNetlifyForm:p,hasNetlifyIdentity:h}};import{readFile as o1}from"fs/promises";var rs=_e("cleanup_stage"),HQ=async t=>await zt(yt(),"cleanup-stage",async()=>VHt(t)),JBe=1024*1024*12,GQ=async({config:t,diff:e,diffBinary:r,resultDiff:n,resultDiffBinary:i})=>{let s={diff_produced:!0};try{rs.log("Getting pre-signed URLs for diff upload");let o=await M1e(t.id,t.sessionId),a=[],c=r||e;c&&a.push(QZ(o.result.upload_url,c.path,{size:c.size,base64:!!r}).then(()=>{s.result_diff_s3_key=o.result.s3_key,rs.log("Successfully uploaded result_diff to S3")}));let l=i||n;l&&a.push(QZ(o.cumulative.upload_url,l.path,{size:l.size,base64:!!i}).then(()=>{s.cumulative_diff_s3_key=o.cumulative.s3_key,rs.log("Successfully uploaded cumulative_diff to S3")})),rs.log(`Uploading ${a.length} diff(s) to S3 in parallel`),await Promise.all(a)}catch(o){rs.error("S3 upload failed, falling back to inline diffs:",o);let a=(e?.size??0)+M0(r?.size??0)+(n?.size??0)+M0(i?.size??0);if(a>JBe){let c=`Diffs of ${a} bytes exceed the maximum combined inline size of ${JBe} bytes.`;throw rs.error(c),new Error(c)}s.result_diff=e?await o1(e.path,"utf8"):void 0,s.result_diff_binary=r?(await o1(r.path)).toString("base64"):void 0,(n||i)&&(s.cumulative_diff=n?await o1(n.path,"utf8"):void 0,s.cumulative_diff_binary=i?(await o1(i.path)).toString("base64"):void 0)}if(n||i)try{rs.log("Updating agent runner with cumulative diff"),await zt(yt(),"update-runner",async()=>{await tM(t.id,s.cumulative_diff_s3_key?{result_diff_s3_key:s.cumulative_diff_s3_key}:{result_diff:s.cumulative_diff,result_diff_binary:s.cumulative_diff_binary})})}catch(o){rs.warn("Failed to record cumulative diff on the runner (session fields still set):",o)}return s},VHt=async({config:t,diff:e,result:r,duration:n,resultDiff:i,diffBinary:s,resultDiffBinary:o,previewInfo:a,isProdDeploy:c,hasNetlifyForm:l,hasNetlifyIdentity:u,nativeSessionArchive:d,nativeSessionId:f,finalAgentConfig:p,creditWrapUp:h})=>{let m={result:r||"Done",duration:n};(p||h)&&(m.metadata={...p?{final_agent_config:p}:{},...h?{credit_wrap_up:!0}:{}}),k1e(t,m.result,p,h),a&&a.deployId&&(m.deploy_id=a.deployId),a&&a.sourceZipFilename&&(m.result_zip_file_name=a.sourceZipFilename),c&&a&&a.deployId&&(m.is_published=!0),f&&(m.native_session_id=f),l&&(m.has_netlify_form=!0),u&&(m.has_netlify_identity=!0),t.mode!=="ask"&&(e||s||i||o)?Object.assign(m,await GQ({config:t,diff:e,diffBinary:s,resultDiff:i,resultDiffBinary:o})):rs.log("No diffs to upload");let y=await zt(yt(),"upload-native-session",()=>Sh({runnerId:t.id,sessionId:t.sessionId,archive:d,nativeSessionId:f}));return y&&(m.native_session_s3_key=y),Be().warmNativeResumeEnabled&&await zt(yt(),"save-native-session-cache",()=>US({archive:d,cache:t.cache,nativeSessionId:f})),rs.log("Updated agent runner with result"),await iM(async()=>await zt(yt(),"update-runner-session",()=>Dn(t.id,t.sessionId,m)),{maxRetries:3,baseDelay:1e3,onRetry:(v,S)=>{rs.error(`Error updating agent runner session (attempt ${v}):`,S),rs.log("Retrying...")}}),rs.log("Finished updating agent runner with result"),{sessionUpdate:m}};import HHt from"fs";import GHt from"path";import WHt from"process";var WQ=_e("db_migrations"),YHt=new Set(["drizzle.config.ts","drizzle.config.js","drizzle.config.mjs"]),a1=async t=>await UP({stage:"db-migrations"},()=>zt(yt(),"db-migrations",async e=>{let r=t.cwd||WHt.cwd();if(!(await ZBe("@netlify/database",r)||await ZBe("@netlify/db",r)))return e?.setAttributes({skipped:!0,reason:"@netlify/database is not installed"}),he.inc("db_migrations.run",1,{outcome:"skipped",reason:"no_module"}),{skipped:!0};let i=[...YHt].find(s=>HHt.existsSync(GHt.join(r,s)));if(!i)return e?.setAttributes({skipped:!0,reason:"no drizzle config found"}),he.inc("db_migrations.run",1,{outcome:"skipped",reason:"no_config"}),{skipped:!0};e?.setAttributes({configFile:i}),WQ.log(`Found ${i}, running drizzle-kit generate to ensure migrations are up to date`);try{let s=await gn("npx",["drizzle-kit","generate"],{cwd:r,stdio:["ignore","pipe","pipe"]});return s.stdout&&WQ.log(String(s.stdout)),e?.setAttributes({success:!0}),he.inc("db_migrations.run",1,{outcome:"success"}),{skipped:!1}}catch(s){let o=KHt(s);return WQ.warn("drizzle-kit generate failed:",o),e?.setAttributes({success:!1,error:o}),he.inc("db_migrations.run",1,{outcome:"failure"}),{skipped:!1,error:o}}})),ZBe=async(t,e)=>{try{return await y0e(`node -e "require.resolve('${t}')"`,{cwd:e,stdio:"ignore"}),!0}catch{return!1}},KHt=t=>{if(t&&typeof t=="object"){let e=[];if("stderr"in t&&t.stderr&&e.push(String(t.stderr)),"stdout"in t&&t.stdout&&e.push(String(t.stdout)),e.length>0)return e.join(`
|
|
942
942
|
`)}return t instanceof Error?t.message:String(t)};var YQ=_e("migration_state"),c1=async({cliPath:t,cwd:e})=>{let r;try{let n=await gn(t,["db","status","--json"],{cwd:e,stdio:["ignore","pipe","pipe"]});r=n.stdout?String(n.stdout):""}catch(n){let i=n;throw YQ.warn("`netlify db status --json` failed",{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}),n}YQ.log("`netlify db status --json` output",{stdout:r});try{return JSON.parse(r)}catch(n){throw YQ.warn("Failed to parse `netlify db status --json` output",{stdout:r,error:String(n)}),n}},XBe=()=>["## Netlify Database","","A Netlify Database (managed Postgres) is available for this site.","It will be provisioned automatically on first connection.","No migrations have been applied yet \u2014 this is a fresh database.","","Use `@netlify/database` with Drizzle ORM for persistent data storage.","Define your schema in `db/schema.ts` and migrations will be generated automatically at deploy time.","Read the `netlify-database` skill for setup instructions."].join(`
|
|
943
943
|
`),QBe=t=>{if(t.applied.length===0&&t.pending.length===0)return null;let e=["## CRITICAL: Current Netlify Database state",""];if(t.applied.length>0){e.push("The following migrations are **already applied** to your preview database branch. They are immutable:","");for(let r of t.applied)e.push(`- ${r.name}`);e.push("","**Never delete, rename, or edit an applied migration file.** Doing so will break the deploy \u2014 the","platform requires every migration applied to the branch to exist on disk with its original content. If","you think an applied migration is wrong, roll forward with a NEW migration that corrects whatever it","did. That's always safe; deletion isn't.")}else e.push("No migrations are applied to your preview database branch yet.");if(t.pending.length>0){e.push(""),e.push("The following migration files exist on disk but have NOT yet been applied:","");for(let r of t.pending)e.push(`- ${r.name}`);e.push("","Pending files can be modified or deleted freely \u2014 use `netlify db migrations reset` to remove them","cleanly, then regenerate via `npx drizzle-kit generate` if you want a replacement.")}return e.join(`
|
|
944
944
|
`)},eze=t=>{let e=[];return t.missingOnDisk.length>0&&e.push("You deleted the following migration file(s) that are already applied to the preview database branch:",...t.missingOnDisk.map(r=>`- ${r.name}`),"","Applied migrations cannot be removed \u2014 the deploy will fail because the platform requires every applied","migration to exist on disk with its original content. Please revise your work:","","1. Restore the deleted file(s) by running `netlify db migrations pull --force`, which overwrites the"," local migrations directory with the authoritative state of the branch. Note this also wipes any"," unapplied migration files you generated this session \u2014 regenerate them via `npx drizzle-kit generate`"," afterwards if you still need them (your `db/schema.ts` edits aren't affected by the pull).","2. If the underlying problem is that an applied migration is wrong, add a NEW migration on top that"," corrects whatever it did (drop a column, rename a table, etc.). Do not touch the original."),t.outOfOrder.length>0&&(e.length>0&&e.push(""),e.push("The following pending migration file(s) have a version prefix that sorts BEFORE migrations already","applied to the branch, so the platform will reject them on deploy:",...t.outOfOrder.map(r=>`- ${r.name} (version ${r.version} \u2264 applied max ${r.maxApplied})`),"","Delete these out-of-order files (use `netlify db migrations reset` \u2014 it only removes unapplied files),","then run `npx drizzle-kit generate` to produce a replacement whose version sorts after the applied","migrations.")),e.length===0?null:e.join(`
|
package/dist/index.js
CHANGED
|
@@ -110,7 +110,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
110
110
|
`,LF:`
|
|
111
111
|
`,concatBytes:KL},N$e=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},k$e={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:N$e};import{Buffer as M$e}from"buffer";var Sre=(t,e)=>t?void 0:D$e.bind(void 0,e),D$e=function*(t,e){if(typeof e!="string"&&!jt(e)&&!M$e.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Ere=(t,e)=>t?L$e.bind(void 0,e):$$e.bind(void 0,e),L$e=function*(t,e){vre(t,e),yield e},$$e=function*(t,e){if(vre(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},vre=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
112
112
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
113
|
-
if (condition) { yield value; }`)};import{Buffer as U$e}from"buffer";import{StringDecoder as F$e}from"string_decoder";var xx=(t,e,r)=>{if(r)return;if(t)return{transform:B$e.bind(void 0,new TextEncoder)};let n=new F$e(e);return{transform:j$e.bind(void 0,n),final:z$e.bind(void 0,n)}},B$e=function*(t,e){U$e.isBuffer(e)?yield fs(e):typeof e=="string"?yield t.encode(e):yield e},j$e=function*(t,e){yield jt(e)?t.write(e):e},z$e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Tre}from"util";var JL=Tre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),wx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=V$e}=e[r];for await(let i of n(t))yield*wx(i,e,r+1)},bre=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*G$e(r,Number(e),t)},G$e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*wx(n,r,e+1)},Are=Tre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),V$e=function*(t){yield t};var XL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},xre=(t,e)=>[...e.flatMap(r=>[...Dl(r,t,0)]),...M_(t)],Dl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=H$e}=e[r];for(let i of n(t))yield*Dl(i,e,r+1)},M_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*q$e(r,Number(e),t)},q$e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Dl(n,r,e+1)},H$e=function*(t){yield t};var QL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Rre(t,s,o),l=Ml(e),u=Ml(r),d=l?JL.bind(void 0,wx,a):XL.bind(void 0,Dl),f=l||u?JL.bind(void 0,bre,a):XL.bind(void 0,M_),p=l||u?Are.bind(void 0,a):void 0;return{stream:new W$e({writableObjectMode:n,writableHighWaterMark:wre(n),readableObjectMode:i,readableHighWaterMark:wre(i),transform(m,y,v){d([m,c,0],this,v)},flush(m){f([c],this,m)},destroy:p})}},Rx=(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=Rre(s,r,a);t=xre(c,t)}return t},Rre=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Sre(n,a)},xx(r,s,n),Ax(r,o,n,c),{transform:t,final:e},{transform:Ere(i,a)},yre({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Cre=(t,e)=>{for(let r of Y$e(t))K$e(t,r,e)},Y$e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),K$e=(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 ${ka[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Z$e(a,n));r.input=A_(s)},Z$e=(t,e)=>{let r=Rx(t,e,"utf8",!0);return J$e(r),A_(r)},J$e=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 t1e,appendFileSync as r1e}from"fs";var Cx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&mf(r,n)&&!En.has(e)&&X$e(n)&&(t.some(({type:i,value:o})=>i==="native"&&Q$e.has(o))||t.every(({type:i})=>Kn.has(i))),X$e=t=>t===1||t===2,Q$e=new Set(["pipe","overlapped"]),Ire=async(t,e,r,n)=>{for await(let i of t)e1e(e)||Ore(i,r,n)},Pre=(t,e,r)=>{for(let n of t)Ore(n,e,r)},e1e=t=>t._readableState.pipes.length>0,Ore=(t,e,r)=>{let n=zA(t);fo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Nre=({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)=>n1e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},n1e=({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=kte(t,o,d),p=fs(f),{stdioItems:h,objectMode:m}=e[r],y=i1e([p],h,c,n),{serializedResult:v,finalResult:b=v}=o1e({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});s1e({serializedResult:v,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?b:void 0;try{return n.error===void 0&&a1e(v,h,i),x}catch(S){return n.error=S,x}},i1e=(t,e,r,n)=>{try{return Rx(t,e,r,!1)}catch(i){return n.error=i,t}},o1e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:A_(t)};let s=WQ(t,r);return n[o]?{serializedResult:s,finalResult:ZL(s,!i[o],e)}:{serializedResult:s}},s1e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Cx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=ZL(t,!1,s);try{Pre(a,e,n)}catch(c){r.error??=c}},a1e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Tx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?r1e(n,t):(r.add(o),t1e(n,t))}};var kre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ms(e,r,"all")]:Array.isArray(e)?[ms(t,r,"all"),...e]:jt(t)&&jt(e)?oL([t,e]):`${t}${e}`};import{once as e$}from"events";var Mre=async(t,e)=>{let[r,n]=await c1e(t);return e.isForcefullyTerminated??=!1,[r,n]},c1e=async t=>{let[e,r]=await Promise.allSettled([e$(t,"spawn"),e$(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Dre(t):r.value},Dre=async t=>{try{return await e$(t,"exit")}catch{return Dre(t)}},Lre=async t=>{let[e,r]=await t;if(!l1e(e,r)&&t$(e,r))throw new Ri;return[e,r]},l1e=(t,e)=>t===void 0&&e===void 0,t$=(t,e)=>t!==0||e!==null;var $re=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=u1e(t,e,r),s=o?.code==="ETIMEDOUT",a=Nte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},u1e=(t,e,r)=>t!==void 0?t:t$(e,r)?new Ri:void 0;var Ure=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=f1e(t,e,r),d=m1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return xf(d,c,l)},f1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=VA(t,e,r),a=p1e(r),{file:c,commandArguments:l,options:u}=ux(t,e,a);h1e(u);let d=hre(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},p1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,h1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Ix("ipcInput"),t&&Ix("ipc: true"),r&&Ix("detached: true"),n&&Ix("cancelSignal")},Ix=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},m1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=g1e({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}=$re(c,r),{output:h,error:m=l}=Nre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((b,x)=>ms(b,r,x)),v=ms(kre(h,r),r,"all");return y1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:v,options:r,command:n,escapedCommand:i,startTime:a})},g1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Cre(o,r);let a=_1e(r);return d1e(...dx(t,e,a))}catch(a){return Af({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},_1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:yx(e)}),y1e=({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?Sx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):k_({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 oFe}from"events";import{spawn as sFe}from"child_process";import Gre from"process";import{once as r$,on as S1e}from"events";var Fre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(yf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ix(t)}),E1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),E1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ex(e,i);let o=Na(t,e,r),s=new AbortController;try{return await Promise.race([v1e(o,n,s),T1e(o,r,s),b1e(o,r,s)])}catch(a){throw Sf(t),a}finally{s.abort(),tx(e,i)}},v1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await r$(t,"message",{signal:r});return n}for await(let[n]of S1e(t,"message",{signal:r}))if(e(n))return n},T1e=async(t,e,{signal:r})=>{await r$(t,"disconnect",{signal:r}),xee(e)},b1e=async(t,e,{signal:r})=>{let[n]=await r$(t,"strict:error",{signal:r});throw JA(n,e)};import{once as jre,on as A1e}from"events";var zre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>n$({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),n$=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{yf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ix(t)}),ex(e,o);let s=Na(t,e,r),a=new AbortController,c={};return x1e(t,s,a),w1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),R1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},x1e=async(t,e,r)=>{try{await jre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},w1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await jre(t,"strict:error",{signal:r.signal});n.error=JA(i,e),r.abort()}catch{}},R1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of A1e(r,"message",{signal:o.signal}))Bre(s),yield c}catch{Bre(s)}finally{o.abort(),tx(e,a),n||Sf(t),i&&await t}},Bre=({error:t})=>{if(t)throw t};var Vre=(t,{ipc:e})=>{Object.assign(t,Hre(t,!1,e))},qre=()=>{let t=Gre,e=!0,r=Gre.channel!==void 0;return{...Hre(t,e,r),getCancelSignal:Xee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Hre=(t,e,r)=>({sendMessage:cx.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Fre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:zre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as C1e}from"child_process";import{PassThrough as I1e,Readable as P1e,Writable as O1e,Duplex as N1e}from"stream";var Wre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{WL(n);let a=new C1e;k1e(a,n),Object.assign(a,{readable:M1e,writable:D1e,duplex:L1e});let c=Af({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=$1e(c,s,i);return{subprocess:a,promise:l}},k1e=(t,e)=>{let r=D_(),n=D_(),i=D_(),o=Array.from({length:e.length-3},D_),s=D_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},D_=()=>{let t=new I1e;return t.end(),t},M1e=()=>new P1e({read(){}}),D1e=()=>new O1e({write(){}}),L1e=()=>new N1e({read(){},write(){}}),$1e=async(t,e,r)=>xf(t,e,r);import{createReadStream as Yre,createWriteStream as Kre}from"fs";import{Buffer as U1e}from"buffer";import{Readable as L_,Writable as F1e,Duplex as B1e}from"stream";var Jre=(t,e)=>bx(j1e,t,e,!1),$_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ka[t]}.`)},Zre={fileNumber:$_,generator:QL,asyncGenerator:QL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:B1e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},j1e={input:{...Zre,fileUrl:({value:t})=>({stream:Yre(t)}),filePath:({value:{file:t}})=>({stream:Yre(t)}),webStream:({value:t})=>({stream:L_.fromWeb(t)}),iterable:({value:t})=>({stream:L_.from(t)}),asyncIterable:({value:t})=>({stream:L_.from(t)}),string:({value:t})=>({stream:L_.from(t)}),uint8Array:({value:t})=>({stream:L_.from(U1e.from(t))})},output:{...Zre,fileUrl:({value:t})=>({stream:Kre(t)}),filePath:({value:{file:t,append:e}})=>({stream:Kre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:F1e.fromWeb(t)}),iterable:$_,asyncIterable:$_,string:$_,uint8Array:$_}};import{on as z1e,once as Xre}from"events";import{PassThrough as G1e,getDefaultHighWaterMark as V1e}from"stream";import{finished as tne}from"stream/promises";function Ll(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)o$(i);let e=t.some(({readableObjectMode:i})=>i),r=q1e(t,e),n=new i$({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var q1e=(t,e)=>{if(t.length===0)return V1e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},i$=class extends G1e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(o$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=H1e(this,this.#e,this.#o);let r=K1e({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(o$(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)}},H1e=async(t,e,r)=>{Px(t,Qre);let n=new AbortController;try{await Promise.race([W1e(t,n),Y1e(t,e,r,n)])}finally{n.abort(),Px(t,-Qre)}},W1e=async(t,{signal:e})=>{try{await tne(t,{signal:e,cleanup:!0})}catch(r){throw rne(t,r),r}},Y1e=async(t,e,r,{signal:n})=>{for await(let[i]of z1e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},o$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},K1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Px(t,ene);let a=new AbortController;try{await Promise.race([Z1e(o,e,a),J1e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),X1e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Px(t,-ene)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?s$(t):Q1e(t))},Z1e=async(t,e,{signal:r})=>{try{await t,r.aborted||s$(e)}catch(n){r.aborted||rne(e,n)}},J1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await tne(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;nne(s)?i.add(e):ine(t,s)}},X1e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Xre(t,i,{signal:o}),!t.readable)return Xre(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Q1e=t=>{t.writable&&t.end()},rne=(t,e)=>{nne(e)?s$(t):ine(t,e)},nne=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",s$=t=>{(t.readable||t.writable)&&t.destroy()},ine=(t,e)=>{t.destroyed||(t.once("error",eUe),t.destroy(e))},eUe=()=>{},Px=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Qre=2,ene=1;import{finished as one}from"stream/promises";var Rf=(t,e)=>{t.pipe(e),tUe(t,e),rUe(t,e)},tUe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await one(t,{cleanup:!0,readable:!0,writable:!1})}catch{}a$(e)}},a$=t=>{t.writable&&t.end()},rUe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await one(e,{cleanup:!0,readable:!1,writable:!0})}catch{}c$(t)}},c$=t=>{t.readable&&t.destroy()};var sne=(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})=>Kn.has(c)))nUe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Kn.has(c)))oUe({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]:Ll(o);Rf(s,i)}},nUe=(t,e,r,n)=>{r==="output"?Rf(t.stdio[n],e):Rf(e,t.stdio[n]);let i=iUe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},iUe=["stdin","stdout","stderr"],oUe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;sUe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},sUe=(t,{signal:e})=>{wi(t)&&Nl(t,aUe,e)},aUe=2;import{addAbortListener as uUe}from"events";var $l=[];$l.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&$l.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&$l.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Ox=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",l$=Symbol.for("signal-exit emitter"),u$=globalThis,cUe=Object.defineProperty.bind(Object),d$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(u$[l$])return u$[l$];cUe(u$,l$,{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}},Nx=class{},lUe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),f$=class extends Nx{onExit(){return()=>{}}load(){}unload(){}},p$=class extends Nx{#e=h$.platform==="win32"?"SIGINT":"SIGHUP";#r=new d$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of $l)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(!Ox(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 $l)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,$l.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 Ox(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"&&Ox(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)}},h$=globalThis.process,{onExit:ane,load:Svt,unload:Evt}=lUe(Ox(h$)?new p$(h$):new f$);var cne=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ane(()=>{t.kill()});uUe(n,()=>{i()})};var une=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=GA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=dUe(r,n,i),{sourceStream:d,sourceError:f}=pUe(t,l),{options:p,fileDescriptors:h}=ho.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},dUe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=fUe(t,e,...r),a=QA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},fUe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(lne,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||nL(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]=kA(r,...n);return{destination:e(lne)(i,o,s),pipeOptions:s}}if(ho.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}`)},lne=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),pUe=(t,e)=>{try{return{sourceStream:Ef(t,e)}}catch(r){return{sourceError:r}}};var fne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=hUe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw m$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},hUe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return c$(t),n;if(e!==void 0)return a$(r),e},m$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Af({error:t,command:dne,escapedCommand:dne,fileDescriptors:e,options:r,startTime:n,isSync:!1}),dne="source.pipe(destination)";var pne=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 mUe}from"stream/promises";var hne=(t,e,r)=>{let n=kx.has(e)?_Ue(t,e):gUe(t,e);return Nl(t,SUe,r.signal),Nl(e,EUe,r.signal),yUe(e),n},gUe=(t,e)=>{let r=Ll([t]);return Rf(r,e),kx.set(e,r),r},_Ue=(t,e)=>{let r=kx.get(e);return r.add(t),r},yUe=async t=>{try{await mUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kx.delete(t)},kx=new WeakMap,SUe=2,EUe=1;import{aborted as vUe}from"util";var mne=(t,e)=>t===void 0?[]:[TUe(t,e)],TUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await vUe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw m$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Mx=(t,...e)=>{if(Ot(e[0]))return Mx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=une(t,...e),i=bUe({...n,destination:r});return i.pipe=Mx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},bUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=AUe(t,i);fne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=hne(e,o,d);return await Promise.race([pne(u),...mne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},AUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as OUe}from"timers/promises";import{on as xUe}from"events";import{getDefaultHighWaterMark as wUe}from"stream";var Dx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return RUe(e,s),_ne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},RUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},g$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;CUe(e,s,t);let a=t.readableObjectMode&&!o;return _ne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},CUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_ne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=xUe(t,"data",{signal:e.signal,highWaterMark:gne,highWatermark:gne});return IUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},_$=wUe(!0),gne=_$,IUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=PUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Dl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*M_(a)}},PUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[xx(t,r,!e),Ax(t,i,!n,{})].filter(Boolean);var yne=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=NUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([kUe(t),d]);return}let f=YL(c,r),p=g$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([MUe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},NUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Cx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=g$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Ire(a,t,r,o)},kUe=async t=>{await OUe(),t.readableFlowing===null&&t.resume()},MUe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await mx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await gx(r,{maxBuffer:o})):await bf(r,{maxBuffer:o})}catch(a){return Sne(Ite({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},y$=async t=>{try{return await t}catch(e){return Sne(e)}},Sne=({bufferedData:t})=>qQ(t)?new Uint8Array(t):t;import{finished as DUe}from"stream/promises";var U_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=LUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],DUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||FUe(a,e,r,n)}finally{s.abort()}},LUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&$Ue(t,r,n),n},$Ue=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{UUe(e,r),n.call(t,...i)}},UUe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},FUe=(t,e,r,n)=>{if(!BUe(t,e,r,n))throw t},BUe=(t,e,r,n=!0)=>r.propagating?Ene(t)||Lx(t):(r.propagating=!0,S$(r,e)===n?Ene(t):Lx(t)),S$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Lx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ene=t=>t?.code==="EPIPE";var vne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>E$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),E$=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=U_(t,e,l);if(S$(l,e)){await u;return}let[d]=await Promise.all([yne({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 Tne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ll([t,e].filter(Boolean)):void 0,bne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>E$({...jUe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:zUe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),jUe=({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}},zUe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as GUe}from"events";var Ane=t=>mf(t,"ipc"),xne=(t,e)=>{let r=zA(t);fo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var wne=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ane(o),a=ps(e,"ipc"),c=ps(r,"ipc");for await(let l of n$({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Pte(t,i,c),i.push(l)),s&&xne(l,o);return i},Rne=async(t,e)=>(await Promise.allSettled([t]),e);var Cne=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:y,controller:v})=>{let b=Mre(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=vne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),I=bne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),P=[],L=wne({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),D=VUe(m,t,x),R=qUe(h,x);try{return await Promise.race([Promise.all([{},Lre(b),Promise.all(S),I,L,cte(t,d),...D,...R]),y,HUe(t,v),...nte(t,o,f,v),...Aee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:v}),...tte({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:v})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},b,Promise.all(S.map(_=>y$(_))),y$(I),Rne(L,P),Promise.allSettled(D),Promise.allSettled(R)])}},VUe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:U_(n,i,r)),qUe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ii(o,{checkOpen:!1})&&!wi(o)).map(({type:i,value:o,stream:s=o})=>U_(s,n,e,{isSameDirection:Kn.has(i),stopOnExit:i==="native"}))),HUe=async(t,{signal:e})=>{let[r]=await GUe(t,"error",{signal:e});throw r};var Ine=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),F_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=po();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Cf=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 WUe}from"stream";import{callbackify as YUe}from"util";import{finished as Pne}from"stream/promises";var v$=async t=>{if(t!==void 0)try{await T$(t)}catch{}},One=async t=>{if(t!==void 0)try{await b$(t)}catch{}},T$=async t=>{await Pne(t,{cleanup:!0,readable:!1,writable:!0})},b$=async t=>{await Pne(t,{cleanup:!0,readable:!0,writable:!1})},$x=async(t,e)=>{if(await t,e)throw e},Ux=(t,e,r)=>{r&&!Lx(r)?t.destroy(r):e&&t.destroy()};var Nne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||En.has(r),{subprocessStdout:a,waitReadableDestroy:c}=A$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=x$(a,s),{read:f,onStdoutDataDone:p}=w$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new WUe({read:f,destroy:YUe(C$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return R$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},A$=(t,e,r)=>{let n=Ef(t,e),i=F_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},x$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:_$},w$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=po(),s=Dx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){KUe(this,s,o)},onStdoutDataDone:o}},KUe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},R$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await b$(t),await n,await v$(i),await e,r.readable&&r.push(null)}catch(o){await v$(i),kne(r,o)}},C$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Cf(r,e)&&(kne(t,n),await $x(e,n))},kne=(t,e)=>{Ux(t,t.readable,e)};import{Writable as ZUe}from"stream";import{callbackify as Mne}from"util";var Dne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=I$(t,r,e),s=new ZUe({...P$(n,t,i),destroy:Mne(N$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return O$(n,s),s},I$=(t,e,r)=>{let n=QA(t,e),i=F_(r,n,"writableFinal"),o=F_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},P$=(t,e,r)=>({write:JUe.bind(void 0,t),final:Mne(XUe.bind(void 0,t,e,r))}),JUe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},XUe=async(t,e,r)=>{await Cf(r,e)&&(t.writable&&t.end(),await e)},O$=async(t,e,r)=>{try{await T$(t),e.writable&&e.end()}catch(n){await One(r),Lne(e,n)}},N$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Cf(r,e),await Cf(n,e)&&(Lne(t,i),await $x(e,i))},Lne=(t,e)=>{Ux(t,t.writable,e)};import{Duplex as QUe}from"stream";import{callbackify as eFe}from"util";var $ne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||En.has(r),{subprocessStdout:c,waitReadableDestroy:l}=A$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=I$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=x$(c,a),{read:y,onStdoutDataDone:v}=w$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new QUe({read:y,...P$(u,t,d),destroy:eFe(tFe.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 R$({subprocessStdout:c,onStdoutDataDone:v,readable:b,subprocess:t,subprocessStdin:u}),O$(u,b,c),b},tFe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([C$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),N$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var k$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||En.has(e),s=Ef(t,r),a=Dx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return rFe(a,s,t)},rFe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Une=(t,{encoding:e})=>{let r=Ine();t.readable=Nne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Dne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=$ne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=k$.bind(void 0,t,e),t[Symbol.asyncIterator]=k$.bind(void 0,t,e,{})};var Fne=(t,e)=>{for(let[r,n]of iFe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},nFe=(async()=>{})().constructor.prototype,iFe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(nFe,t)]);var Bne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=aFe(t,e,r),{subprocess:f,promise:p}=lFe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Mx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Fne(f,p),ho.set(f,{options:u,fileDescriptors:d}),f},aFe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=VA(t,e,r),{file:a,commandArguments:c,options:l}=ux(t,e,r),u=cFe(l),d=Jre(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},cFe=({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}},lFe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=sFe(...dx(t,e,r))}catch(h){return Wre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;oFe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];sne(c,a,l),cne(c,r,l);let d={},f=po();c.kill=Tee.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Tne(c,r),Une(c,r),Vre(c,r);let p=uFe({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}},uFe=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,y]=await Cne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let v=h.map((S,I)=>ms(S,e,I)),b=ms(m,e,"all"),x=dFe({errorInfo:d,exitCode:f,signal:p,stdio:v,all:b,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return xf(x,n,e)},dFe=({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?k_({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 mo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Sx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Fx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,fFe(n,t[n],i)]));return{...t,...r}},fFe=(t,e,r)=>pFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,pFe=new Set(["env",...lL]);var Ma=(t,e,r,n)=>{let i=(s,a,c)=>Ma(s,a,r,c),o=(...s)=>hFe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},hFe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Fx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=mFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Ure(a,c,l):Bne(a,c,l,i)},mFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=JQ(e)?XQ(e,r):[e,...r],[s,a,c]=kA(...o),l=Fx(Fx(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 jne=({file:t,commandArguments:e})=>Gne(t,e),zne=({file:t,commandArguments:e})=>({...Gne(t,e),isSync:!0}),Gne=(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]=gFe(t);return{file:r,commandArguments:n}},gFe=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(_Fe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},_Fe=/ +/g;var Vne=(t,e,r)=>{t.sync=e(yFe,r),t.s=t.sync},qne=({options:t})=>Hne(t),yFe=({options:t})=>({...Hne(t),isSync:!0}),Hne=t=>({options:{...SFe(t),...t}}),SFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Wne={preferLocal:!0};var Yne=Ma(()=>({})),lAt=Ma(()=>({isSync:!0})),Kne=Ma(jne),uAt=Ma(zne),dAt=Ma(ote),fAt=Ma(qne,{},Wne,Vne),{sendMessage:pAt,getOneMessage:hAt,getEachMessage:mAt,getCancelSignal:gAt}=qre();var Zne=!1,Jne=()=>{Zne=!0},_o=()=>Zne;var B_=null,Xne=t=>(B_&&B_.destroy(),B_=new gs({totalAllowedTime:t}),B_),Qne=()=>B_;var gs=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&&_o())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 xA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ce.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 eie={name:"@netlify/agent-runner-cli",type:"module",version:"1.161.3",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: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.1.5","@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.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var bFe=vFe(import.meta.url),AFe=_s.dirname(bFe),xFe=TFe(import.meta.url),If=fe("shell"),M$=new Set,tie={preferLocal:!0},fr=(t,e,r)=>{let[n,i]=wFe(e,r),o={...tie,...i},s=Yne(t,n,o);nie(s,o),sie(s);let a=r?.idleTimeout;return a&&a>0&&oie(s,a),s},rie=(t,e)=>{let r={...tie,...e},n=Kne(t,r);return nie(n,r),sie(n),e?.idleTimeout&&e.idleTimeout>0&&oie(n,e.idleTimeout),n},wFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},nie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(ys.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new h_).pipe(ys.stdout),t.stderr?.pipe(new h_).pipe(ys.stderr);return}t.stdout?.pipe(ys.stdout),t.stderr?.pipe(ys.stderr)},D$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ys.kill(-t.pid,e),If.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return If.error("Error killing process:",r),!1}},iie=t=>D$(t,"SIGKILL"),oie=(t,e)=>{let r=null,n=()=>{If.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),D$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(If.log(`Force killing idle process ${t.pid}`),iie(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)},sie=t=>{M$.add(t);let e=Qne();if(e){let r=e.onTimesUp(()=>{If.log(`Global timer expired, killing process ${t.pid}`),D$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(If.log(`Force killing process ${t.pid} after timeout`),iie(t))},5e3)});t.on("exit",()=>{M$.delete(t),r()}),t.on("error",()=>{M$.delete(t),r()})}};function yo(t,e){if(!ys.env.NETLIFY_LOCAL_MODE)try{let i=xFe.resolve(eie.name),o=_s.dirname(i);for(;o!==_s.dirname(o);){let s=_s.dirname(o);if(_s.basename(s)==="node_modules"){let a=_s.join(s,".bin",e);if(Bx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ys.env.NODE_PATH){let i=_s.join(ys.env.NODE_PATH,".bin",e);if(Bx.existsSync(i))return i}let r=_s.join(t,"node_modules",".bin",e);if(Bx.existsSync(r))return r;let n=_s.join(AFe,"..","node_modules",".bin",e);if(Bx.existsSync(n))return n}var RFe=fe("utils"),CFe=t=>new Promise(e=>{setTimeout(e,t)});var L$=t=>{try{return new URL(t).hostname||null}catch{return null}},jx=(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 CFe(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},Da=(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},aie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):RFe.error("Could not parse JSON",n))}},IFe=t=>t.charAt(0).toUpperCase()+t.slice(1),So=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():IFe(e)).join(" ");function Ss(t,e){e&&t.log(`Skill invoked: ${e}`)}var zx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),cie=(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 $$=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}},PFe=1e4,U$=(t,e=PFe)=>{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 OFe}from"crypto";import{createReadStream as NFe}from"fs";import Gx from"fs/promises";import pie from"os";import Vx from"path";var lie=fe("repo"),hie="runner-diffs-",mie=t=>`${hie}${t}-`,gie=async t=>{let e=pie.tmpdir(),r;try{r=await Gx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(hie)&&!n.startsWith(mie(t))).map(n=>Gx.rm(Vx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},en=(t,e={})=>fr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),qx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{lie.info("Getting runner diffs");let n=await MFe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=LFe(o);await $Fe(h,r)}lie.info("Changes after processing"),await B$(r);let s=await z$(o,r);if(await F$(s,r),i=await DFe(r),!i)return{hasChanges:!1,ignored:s};await en(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Gx.mkdtemp(Vx.join(pie.tmpdir(),mie(t.sessionId))),c=async({from:h,to:m,fileName:y,binary:v})=>{let b=Vx.join(a,y);await en([...v?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await Gx.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 fie(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 die(d,h)||(f=h)}await fie(r),ce.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await die(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},uie=async t=>{let e=OFe("sha256");for await(let r of NFe(t))e.update(r);return e.digest("hex")},die=async(t,e)=>t.size===e.size&&await uie(t.path)===await uie(e.path),fie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await en(["reset","--soft","HEAD~1"],{cwd:t})},F$=async(t=[],e=process.cwd())=>{await en(["add",".",...t],{cwd:e})},B$=async(t=process.cwd())=>{let e=await en(["status","-s"],{cwd:t});return String(e.stdout??"")},_ie=/.. (.+)?\.log$/,kFe=[_ie],MFe=async(t=process.cwd())=>{let e=await B$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
113
|
+
if (condition) { yield value; }`)};import{Buffer as U$e}from"buffer";import{StringDecoder as F$e}from"string_decoder";var xx=(t,e,r)=>{if(r)return;if(t)return{transform:B$e.bind(void 0,new TextEncoder)};let n=new F$e(e);return{transform:j$e.bind(void 0,n),final:z$e.bind(void 0,n)}},B$e=function*(t,e){U$e.isBuffer(e)?yield fs(e):typeof e=="string"?yield t.encode(e):yield e},j$e=function*(t,e){yield jt(e)?t.write(e):e},z$e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Tre}from"util";var JL=Tre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),wx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=V$e}=e[r];for await(let i of n(t))yield*wx(i,e,r+1)},bre=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*G$e(r,Number(e),t)},G$e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*wx(n,r,e+1)},Are=Tre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),V$e=function*(t){yield t};var XL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},xre=(t,e)=>[...e.flatMap(r=>[...Dl(r,t,0)]),...M_(t)],Dl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=H$e}=e[r];for(let i of n(t))yield*Dl(i,e,r+1)},M_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*q$e(r,Number(e),t)},q$e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Dl(n,r,e+1)},H$e=function*(t){yield t};var QL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Rre(t,s,o),l=Ml(e),u=Ml(r),d=l?JL.bind(void 0,wx,a):XL.bind(void 0,Dl),f=l||u?JL.bind(void 0,bre,a):XL.bind(void 0,M_),p=l||u?Are.bind(void 0,a):void 0;return{stream:new W$e({writableObjectMode:n,writableHighWaterMark:wre(n),readableObjectMode:i,readableHighWaterMark:wre(i),transform(m,y,v){d([m,c,0],this,v)},flush(m){f([c],this,m)},destroy:p})}},Rx=(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=Rre(s,r,a);t=xre(c,t)}return t},Rre=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Sre(n,a)},xx(r,s,n),Ax(r,o,n,c),{transform:t,final:e},{transform:Ere(i,a)},yre({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Cre=(t,e)=>{for(let r of Y$e(t))K$e(t,r,e)},Y$e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),K$e=(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 ${ka[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Z$e(a,n));r.input=A_(s)},Z$e=(t,e)=>{let r=Rx(t,e,"utf8",!0);return J$e(r),A_(r)},J$e=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 t1e,appendFileSync as r1e}from"fs";var Cx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&mf(r,n)&&!En.has(e)&&X$e(n)&&(t.some(({type:i,value:o})=>i==="native"&&Q$e.has(o))||t.every(({type:i})=>Kn.has(i))),X$e=t=>t===1||t===2,Q$e=new Set(["pipe","overlapped"]),Ire=async(t,e,r,n)=>{for await(let i of t)e1e(e)||Ore(i,r,n)},Pre=(t,e,r)=>{for(let n of t)Ore(n,e,r)},e1e=t=>t._readableState.pipes.length>0,Ore=(t,e,r)=>{let n=zA(t);fo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Nre=({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)=>n1e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},n1e=({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=kte(t,o,d),p=fs(f),{stdioItems:h,objectMode:m}=e[r],y=i1e([p],h,c,n),{serializedResult:v,finalResult:b=v}=o1e({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});s1e({serializedResult:v,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?b:void 0;try{return n.error===void 0&&a1e(v,h,i),x}catch(S){return n.error=S,x}},i1e=(t,e,r,n)=>{try{return Rx(t,e,r,!1)}catch(i){return n.error=i,t}},o1e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:A_(t)};let s=WQ(t,r);return n[o]?{serializedResult:s,finalResult:ZL(s,!i[o],e)}:{serializedResult:s}},s1e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Cx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=ZL(t,!1,s);try{Pre(a,e,n)}catch(c){r.error??=c}},a1e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Tx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?r1e(n,t):(r.add(o),t1e(n,t))}};var kre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ms(e,r,"all")]:Array.isArray(e)?[ms(t,r,"all"),...e]:jt(t)&&jt(e)?oL([t,e]):`${t}${e}`};import{once as e$}from"events";var Mre=async(t,e)=>{let[r,n]=await c1e(t);return e.isForcefullyTerminated??=!1,[r,n]},c1e=async t=>{let[e,r]=await Promise.allSettled([e$(t,"spawn"),e$(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Dre(t):r.value},Dre=async t=>{try{return await e$(t,"exit")}catch{return Dre(t)}},Lre=async t=>{let[e,r]=await t;if(!l1e(e,r)&&t$(e,r))throw new Ri;return[e,r]},l1e=(t,e)=>t===void 0&&e===void 0,t$=(t,e)=>t!==0||e!==null;var $re=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=u1e(t,e,r),s=o?.code==="ETIMEDOUT",a=Nte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},u1e=(t,e,r)=>t!==void 0?t:t$(e,r)?new Ri:void 0;var Ure=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=f1e(t,e,r),d=m1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return xf(d,c,l)},f1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=VA(t,e,r),a=p1e(r),{file:c,commandArguments:l,options:u}=ux(t,e,a);h1e(u);let d=hre(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},p1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,h1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Ix("ipcInput"),t&&Ix("ipc: true"),r&&Ix("detached: true"),n&&Ix("cancelSignal")},Ix=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},m1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=g1e({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}=$re(c,r),{output:h,error:m=l}=Nre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((b,x)=>ms(b,r,x)),v=ms(kre(h,r),r,"all");return y1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:v,options:r,command:n,escapedCommand:i,startTime:a})},g1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Cre(o,r);let a=_1e(r);return d1e(...dx(t,e,a))}catch(a){return Af({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},_1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:yx(e)}),y1e=({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?Sx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):k_({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 oFe}from"events";import{spawn as sFe}from"child_process";import Gre from"process";import{once as r$,on as S1e}from"events";var Fre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(yf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ix(t)}),E1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),E1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ex(e,i);let o=Na(t,e,r),s=new AbortController;try{return await Promise.race([v1e(o,n,s),T1e(o,r,s),b1e(o,r,s)])}catch(a){throw Sf(t),a}finally{s.abort(),tx(e,i)}},v1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await r$(t,"message",{signal:r});return n}for await(let[n]of S1e(t,"message",{signal:r}))if(e(n))return n},T1e=async(t,e,{signal:r})=>{await r$(t,"disconnect",{signal:r}),xee(e)},b1e=async(t,e,{signal:r})=>{let[n]=await r$(t,"strict:error",{signal:r});throw JA(n,e)};import{once as jre,on as A1e}from"events";var zre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>n$({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),n$=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{yf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ix(t)}),ex(e,o);let s=Na(t,e,r),a=new AbortController,c={};return x1e(t,s,a),w1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),R1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},x1e=async(t,e,r)=>{try{await jre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},w1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await jre(t,"strict:error",{signal:r.signal});n.error=JA(i,e),r.abort()}catch{}},R1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of A1e(r,"message",{signal:o.signal}))Bre(s),yield c}catch{Bre(s)}finally{o.abort(),tx(e,a),n||Sf(t),i&&await t}},Bre=({error:t})=>{if(t)throw t};var Vre=(t,{ipc:e})=>{Object.assign(t,Hre(t,!1,e))},qre=()=>{let t=Gre,e=!0,r=Gre.channel!==void 0;return{...Hre(t,e,r),getCancelSignal:Xee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Hre=(t,e,r)=>({sendMessage:cx.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Fre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:zre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as C1e}from"child_process";import{PassThrough as I1e,Readable as P1e,Writable as O1e,Duplex as N1e}from"stream";var Wre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{WL(n);let a=new C1e;k1e(a,n),Object.assign(a,{readable:M1e,writable:D1e,duplex:L1e});let c=Af({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=$1e(c,s,i);return{subprocess:a,promise:l}},k1e=(t,e)=>{let r=D_(),n=D_(),i=D_(),o=Array.from({length:e.length-3},D_),s=D_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},D_=()=>{let t=new I1e;return t.end(),t},M1e=()=>new P1e({read(){}}),D1e=()=>new O1e({write(){}}),L1e=()=>new N1e({read(){},write(){}}),$1e=async(t,e,r)=>xf(t,e,r);import{createReadStream as Yre,createWriteStream as Kre}from"fs";import{Buffer as U1e}from"buffer";import{Readable as L_,Writable as F1e,Duplex as B1e}from"stream";var Jre=(t,e)=>bx(j1e,t,e,!1),$_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ka[t]}.`)},Zre={fileNumber:$_,generator:QL,asyncGenerator:QL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:B1e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},j1e={input:{...Zre,fileUrl:({value:t})=>({stream:Yre(t)}),filePath:({value:{file:t}})=>({stream:Yre(t)}),webStream:({value:t})=>({stream:L_.fromWeb(t)}),iterable:({value:t})=>({stream:L_.from(t)}),asyncIterable:({value:t})=>({stream:L_.from(t)}),string:({value:t})=>({stream:L_.from(t)}),uint8Array:({value:t})=>({stream:L_.from(U1e.from(t))})},output:{...Zre,fileUrl:({value:t})=>({stream:Kre(t)}),filePath:({value:{file:t,append:e}})=>({stream:Kre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:F1e.fromWeb(t)}),iterable:$_,asyncIterable:$_,string:$_,uint8Array:$_}};import{on as z1e,once as Xre}from"events";import{PassThrough as G1e,getDefaultHighWaterMark as V1e}from"stream";import{finished as tne}from"stream/promises";function Ll(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)o$(i);let e=t.some(({readableObjectMode:i})=>i),r=q1e(t,e),n=new i$({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var q1e=(t,e)=>{if(t.length===0)return V1e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},i$=class extends G1e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(o$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=H1e(this,this.#e,this.#o);let r=K1e({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(o$(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)}},H1e=async(t,e,r)=>{Px(t,Qre);let n=new AbortController;try{await Promise.race([W1e(t,n),Y1e(t,e,r,n)])}finally{n.abort(),Px(t,-Qre)}},W1e=async(t,{signal:e})=>{try{await tne(t,{signal:e,cleanup:!0})}catch(r){throw rne(t,r),r}},Y1e=async(t,e,r,{signal:n})=>{for await(let[i]of z1e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},o$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},K1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Px(t,ene);let a=new AbortController;try{await Promise.race([Z1e(o,e,a),J1e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),X1e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Px(t,-ene)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?s$(t):Q1e(t))},Z1e=async(t,e,{signal:r})=>{try{await t,r.aborted||s$(e)}catch(n){r.aborted||rne(e,n)}},J1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await tne(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;nne(s)?i.add(e):ine(t,s)}},X1e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Xre(t,i,{signal:o}),!t.readable)return Xre(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Q1e=t=>{t.writable&&t.end()},rne=(t,e)=>{nne(e)?s$(t):ine(t,e)},nne=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",s$=t=>{(t.readable||t.writable)&&t.destroy()},ine=(t,e)=>{t.destroyed||(t.once("error",eUe),t.destroy(e))},eUe=()=>{},Px=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Qre=2,ene=1;import{finished as one}from"stream/promises";var Rf=(t,e)=>{t.pipe(e),tUe(t,e),rUe(t,e)},tUe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await one(t,{cleanup:!0,readable:!0,writable:!1})}catch{}a$(e)}},a$=t=>{t.writable&&t.end()},rUe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await one(e,{cleanup:!0,readable:!1,writable:!0})}catch{}c$(t)}},c$=t=>{t.readable&&t.destroy()};var sne=(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})=>Kn.has(c)))nUe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Kn.has(c)))oUe({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]:Ll(o);Rf(s,i)}},nUe=(t,e,r,n)=>{r==="output"?Rf(t.stdio[n],e):Rf(e,t.stdio[n]);let i=iUe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},iUe=["stdin","stdout","stderr"],oUe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;sUe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},sUe=(t,{signal:e})=>{wi(t)&&Nl(t,aUe,e)},aUe=2;import{addAbortListener as uUe}from"events";var $l=[];$l.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&$l.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&$l.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Ox=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",l$=Symbol.for("signal-exit emitter"),u$=globalThis,cUe=Object.defineProperty.bind(Object),d$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(u$[l$])return u$[l$];cUe(u$,l$,{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}},Nx=class{},lUe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),f$=class extends Nx{onExit(){return()=>{}}load(){}unload(){}},p$=class extends Nx{#e=h$.platform==="win32"?"SIGINT":"SIGHUP";#r=new d$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of $l)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(!Ox(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 $l)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,$l.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 Ox(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"&&Ox(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)}},h$=globalThis.process,{onExit:ane,load:Svt,unload:Evt}=lUe(Ox(h$)?new p$(h$):new f$);var cne=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ane(()=>{t.kill()});uUe(n,()=>{i()})};var une=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=GA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=dUe(r,n,i),{sourceStream:d,sourceError:f}=pUe(t,l),{options:p,fileDescriptors:h}=ho.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},dUe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=fUe(t,e,...r),a=QA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},fUe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(lne,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||nL(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]=kA(r,...n);return{destination:e(lne)(i,o,s),pipeOptions:s}}if(ho.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}`)},lne=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),pUe=(t,e)=>{try{return{sourceStream:Ef(t,e)}}catch(r){return{sourceError:r}}};var fne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=hUe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw m$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},hUe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return c$(t),n;if(e!==void 0)return a$(r),e},m$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Af({error:t,command:dne,escapedCommand:dne,fileDescriptors:e,options:r,startTime:n,isSync:!1}),dne="source.pipe(destination)";var pne=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 mUe}from"stream/promises";var hne=(t,e,r)=>{let n=kx.has(e)?_Ue(t,e):gUe(t,e);return Nl(t,SUe,r.signal),Nl(e,EUe,r.signal),yUe(e),n},gUe=(t,e)=>{let r=Ll([t]);return Rf(r,e),kx.set(e,r),r},_Ue=(t,e)=>{let r=kx.get(e);return r.add(t),r},yUe=async t=>{try{await mUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kx.delete(t)},kx=new WeakMap,SUe=2,EUe=1;import{aborted as vUe}from"util";var mne=(t,e)=>t===void 0?[]:[TUe(t,e)],TUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await vUe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw m$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Mx=(t,...e)=>{if(Ot(e[0]))return Mx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=une(t,...e),i=bUe({...n,destination:r});return i.pipe=Mx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},bUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=AUe(t,i);fne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=hne(e,o,d);return await Promise.race([pne(u),...mne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},AUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as OUe}from"timers/promises";import{on as xUe}from"events";import{getDefaultHighWaterMark as wUe}from"stream";var Dx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return RUe(e,s),_ne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},RUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},g$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;CUe(e,s,t);let a=t.readableObjectMode&&!o;return _ne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},CUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},_ne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=xUe(t,"data",{signal:e.signal,highWaterMark:gne,highWatermark:gne});return IUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},_$=wUe(!0),gne=_$,IUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=PUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Dl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*M_(a)}},PUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[xx(t,r,!e),Ax(t,i,!n,{})].filter(Boolean);var yne=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=NUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([kUe(t),d]);return}let f=YL(c,r),p=g$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([MUe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},NUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Cx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=g$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Ire(a,t,r,o)},kUe=async t=>{await OUe(),t.readableFlowing===null&&t.resume()},MUe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await mx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await gx(r,{maxBuffer:o})):await bf(r,{maxBuffer:o})}catch(a){return Sne(Ite({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},y$=async t=>{try{return await t}catch(e){return Sne(e)}},Sne=({bufferedData:t})=>qQ(t)?new Uint8Array(t):t;import{finished as DUe}from"stream/promises";var U_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=LUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],DUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||FUe(a,e,r,n)}finally{s.abort()}},LUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&$Ue(t,r,n),n},$Ue=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{UUe(e,r),n.call(t,...i)}},UUe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},FUe=(t,e,r,n)=>{if(!BUe(t,e,r,n))throw t},BUe=(t,e,r,n=!0)=>r.propagating?Ene(t)||Lx(t):(r.propagating=!0,S$(r,e)===n?Ene(t):Lx(t)),S$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Lx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Ene=t=>t?.code==="EPIPE";var vne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>E$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),E$=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=U_(t,e,l);if(S$(l,e)){await u;return}let[d]=await Promise.all([yne({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 Tne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ll([t,e].filter(Boolean)):void 0,bne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>E$({...jUe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:zUe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),jUe=({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}},zUe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as GUe}from"events";var Ane=t=>mf(t,"ipc"),xne=(t,e)=>{let r=zA(t);fo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var wne=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ane(o),a=ps(e,"ipc"),c=ps(r,"ipc");for await(let l of n$({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Pte(t,i,c),i.push(l)),s&&xne(l,o);return i},Rne=async(t,e)=>(await Promise.allSettled([t]),e);var Cne=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:y,controller:v})=>{let b=Mre(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=vne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),I=bne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),P=[],L=wne({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),D=VUe(m,t,x),R=qUe(h,x);try{return await Promise.race([Promise.all([{},Lre(b),Promise.all(S),I,L,cte(t,d),...D,...R]),y,HUe(t,v),...nte(t,o,f,v),...Aee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:v}),...tte({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:v})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},b,Promise.all(S.map(_=>y$(_))),y$(I),Rne(L,P),Promise.allSettled(D),Promise.allSettled(R)])}},VUe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:U_(n,i,r)),qUe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ii(o,{checkOpen:!1})&&!wi(o)).map(({type:i,value:o,stream:s=o})=>U_(s,n,e,{isSameDirection:Kn.has(i),stopOnExit:i==="native"}))),HUe=async(t,{signal:e})=>{let[r]=await GUe(t,"error",{signal:e});throw r};var Ine=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),F_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=po();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Cf=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 WUe}from"stream";import{callbackify as YUe}from"util";import{finished as Pne}from"stream/promises";var v$=async t=>{if(t!==void 0)try{await T$(t)}catch{}},One=async t=>{if(t!==void 0)try{await b$(t)}catch{}},T$=async t=>{await Pne(t,{cleanup:!0,readable:!1,writable:!0})},b$=async t=>{await Pne(t,{cleanup:!0,readable:!0,writable:!1})},$x=async(t,e)=>{if(await t,e)throw e},Ux=(t,e,r)=>{r&&!Lx(r)?t.destroy(r):e&&t.destroy()};var Nne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||En.has(r),{subprocessStdout:a,waitReadableDestroy:c}=A$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=x$(a,s),{read:f,onStdoutDataDone:p}=w$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new WUe({read:f,destroy:YUe(C$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return R$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},A$=(t,e,r)=>{let n=Ef(t,e),i=F_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},x$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:_$},w$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=po(),s=Dx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){KUe(this,s,o)},onStdoutDataDone:o}},KUe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},R$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await b$(t),await n,await v$(i),await e,r.readable&&r.push(null)}catch(o){await v$(i),kne(r,o)}},C$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Cf(r,e)&&(kne(t,n),await $x(e,n))},kne=(t,e)=>{Ux(t,t.readable,e)};import{Writable as ZUe}from"stream";import{callbackify as Mne}from"util";var Dne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=I$(t,r,e),s=new ZUe({...P$(n,t,i),destroy:Mne(N$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return O$(n,s),s},I$=(t,e,r)=>{let n=QA(t,e),i=F_(r,n,"writableFinal"),o=F_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},P$=(t,e,r)=>({write:JUe.bind(void 0,t),final:Mne(XUe.bind(void 0,t,e,r))}),JUe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},XUe=async(t,e,r)=>{await Cf(r,e)&&(t.writable&&t.end(),await e)},O$=async(t,e,r)=>{try{await T$(t),e.writable&&e.end()}catch(n){await One(r),Lne(e,n)}},N$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Cf(r,e),await Cf(n,e)&&(Lne(t,i),await $x(e,i))},Lne=(t,e)=>{Ux(t,t.writable,e)};import{Duplex as QUe}from"stream";import{callbackify as eFe}from"util";var $ne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||En.has(r),{subprocessStdout:c,waitReadableDestroy:l}=A$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=I$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=x$(c,a),{read:y,onStdoutDataDone:v}=w$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new QUe({read:y,...P$(u,t,d),destroy:eFe(tFe.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 R$({subprocessStdout:c,onStdoutDataDone:v,readable:b,subprocess:t,subprocessStdin:u}),O$(u,b,c),b},tFe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([C$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),N$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var k$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||En.has(e),s=Ef(t,r),a=Dx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return rFe(a,s,t)},rFe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Une=(t,{encoding:e})=>{let r=Ine();t.readable=Nne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Dne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=$ne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=k$.bind(void 0,t,e),t[Symbol.asyncIterator]=k$.bind(void 0,t,e,{})};var Fne=(t,e)=>{for(let[r,n]of iFe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},nFe=(async()=>{})().constructor.prototype,iFe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(nFe,t)]);var Bne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=aFe(t,e,r),{subprocess:f,promise:p}=lFe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Mx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Fne(f,p),ho.set(f,{options:u,fileDescriptors:d}),f},aFe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=VA(t,e,r),{file:a,commandArguments:c,options:l}=ux(t,e,r),u=cFe(l),d=Jre(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},cFe=({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}},lFe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=sFe(...dx(t,e,r))}catch(h){return Wre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;oFe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];sne(c,a,l),cne(c,r,l);let d={},f=po();c.kill=Tee.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Tne(c,r),Une(c,r),Vre(c,r);let p=uFe({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}},uFe=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,y]=await Cne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let v=h.map((S,I)=>ms(S,e,I)),b=ms(m,e,"all"),x=dFe({errorInfo:d,exitCode:f,signal:p,stdio:v,all:b,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return xf(x,n,e)},dFe=({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?k_({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 mo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Sx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Fx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,fFe(n,t[n],i)]));return{...t,...r}},fFe=(t,e,r)=>pFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,pFe=new Set(["env",...lL]);var Ma=(t,e,r,n)=>{let i=(s,a,c)=>Ma(s,a,r,c),o=(...s)=>hFe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},hFe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Fx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=mFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Ure(a,c,l):Bne(a,c,l,i)},mFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=JQ(e)?XQ(e,r):[e,...r],[s,a,c]=kA(...o),l=Fx(Fx(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 jne=({file:t,commandArguments:e})=>Gne(t,e),zne=({file:t,commandArguments:e})=>({...Gne(t,e),isSync:!0}),Gne=(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]=gFe(t);return{file:r,commandArguments:n}},gFe=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(_Fe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},_Fe=/ +/g;var Vne=(t,e,r)=>{t.sync=e(yFe,r),t.s=t.sync},qne=({options:t})=>Hne(t),yFe=({options:t})=>({...Hne(t),isSync:!0}),Hne=t=>({options:{...SFe(t),...t}}),SFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Wne={preferLocal:!0};var Yne=Ma(()=>({})),lAt=Ma(()=>({isSync:!0})),Kne=Ma(jne),uAt=Ma(zne),dAt=Ma(ote),fAt=Ma(qne,{},Wne,Vne),{sendMessage:pAt,getOneMessage:hAt,getEachMessage:mAt,getCancelSignal:gAt}=qre();var Zne=!1,Jne=()=>{Zne=!0},_o=()=>Zne;var B_=null,Xne=t=>(B_&&B_.destroy(),B_=new gs({totalAllowedTime:t}),B_),Qne=()=>B_;var gs=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&&_o())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 xA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ce.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 eie={name:"@netlify/agent-runner-cli",type:"module",version:"1.162.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: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.1.5","@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.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var bFe=vFe(import.meta.url),AFe=_s.dirname(bFe),xFe=TFe(import.meta.url),If=fe("shell"),M$=new Set,tie={preferLocal:!0},fr=(t,e,r)=>{let[n,i]=wFe(e,r),o={...tie,...i},s=Yne(t,n,o);nie(s,o),sie(s);let a=r?.idleTimeout;return a&&a>0&&oie(s,a),s},rie=(t,e)=>{let r={...tie,...e},n=Kne(t,r);return nie(n,r),sie(n),e?.idleTimeout&&e.idleTimeout>0&&oie(n,e.idleTimeout),n},wFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},nie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(ys.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new h_).pipe(ys.stdout),t.stderr?.pipe(new h_).pipe(ys.stderr);return}t.stdout?.pipe(ys.stdout),t.stderr?.pipe(ys.stderr)},D$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ys.kill(-t.pid,e),If.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return If.error("Error killing process:",r),!1}},iie=t=>D$(t,"SIGKILL"),oie=(t,e)=>{let r=null,n=()=>{If.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),D$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(If.log(`Force killing idle process ${t.pid}`),iie(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)},sie=t=>{M$.add(t);let e=Qne();if(e){let r=e.onTimesUp(()=>{If.log(`Global timer expired, killing process ${t.pid}`),D$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(If.log(`Force killing process ${t.pid} after timeout`),iie(t))},5e3)});t.on("exit",()=>{M$.delete(t),r()}),t.on("error",()=>{M$.delete(t),r()})}};function yo(t,e){if(!ys.env.NETLIFY_LOCAL_MODE)try{let i=xFe.resolve(eie.name),o=_s.dirname(i);for(;o!==_s.dirname(o);){let s=_s.dirname(o);if(_s.basename(s)==="node_modules"){let a=_s.join(s,".bin",e);if(Bx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ys.env.NODE_PATH){let i=_s.join(ys.env.NODE_PATH,".bin",e);if(Bx.existsSync(i))return i}let r=_s.join(t,"node_modules",".bin",e);if(Bx.existsSync(r))return r;let n=_s.join(AFe,"..","node_modules",".bin",e);if(Bx.existsSync(n))return n}var RFe=fe("utils"),CFe=t=>new Promise(e=>{setTimeout(e,t)});var L$=t=>{try{return new URL(t).hostname||null}catch{return null}},jx=(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 CFe(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},Da=(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},aie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):RFe.error("Could not parse JSON",n))}},IFe=t=>t.charAt(0).toUpperCase()+t.slice(1),So=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():IFe(e)).join(" ");function Ss(t,e){e&&t.log(`Skill invoked: ${e}`)}var zx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),cie=(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 $$=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}},PFe=1e4,U$=(t,e=PFe)=>{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 OFe}from"crypto";import{createReadStream as NFe}from"fs";import Gx from"fs/promises";import pie from"os";import Vx from"path";var lie=fe("repo"),hie="runner-diffs-",mie=t=>`${hie}${t}-`,gie=async t=>{let e=pie.tmpdir(),r;try{r=await Gx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(hie)&&!n.startsWith(mie(t))).map(n=>Gx.rm(Vx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},en=(t,e={})=>fr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),qx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{lie.info("Getting runner diffs");let n=await MFe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=LFe(o);await $Fe(h,r)}lie.info("Changes after processing"),await B$(r);let s=await z$(o,r);if(await F$(s,r),i=await DFe(r),!i)return{hasChanges:!1,ignored:s};await en(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Gx.mkdtemp(Vx.join(pie.tmpdir(),mie(t.sessionId))),c=async({from:h,to:m,fileName:y,binary:v})=>{let b=Vx.join(a,y);await en([...v?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await Gx.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 fie(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 die(d,h)||(f=h)}await fie(r),ce.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await die(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},uie=async t=>{let e=OFe("sha256");for await(let r of NFe(t))e.update(r);return e.digest("hex")},die=async(t,e)=>t.size===e.size&&await uie(t.path)===await uie(e.path),fie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await en(["reset","--soft","HEAD~1"],{cwd:t})},F$=async(t=[],e=process.cwd())=>{await en(["add",".",...t],{cwd:e})},B$=async(t=process.cwd())=>{let e=await en(["status","-s"],{cwd:t});return String(e.stdout??"")},_ie=/.. (.+)?\.log$/,kFe=[_ie],MFe=async(t=process.cwd())=>{let e=await B$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
114
114
|
`).filter(i=>kFe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},DFe=async(t=process.cwd())=>{try{return await en(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},j$=async(t=process.cwd())=>{let{stdout:e}=await en(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},yie=async(t=process.cwd())=>{let{stdout:e}=await en(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},z$=async(t,e=process.cwd())=>{t||=await B$(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(`
|
|
115
115
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${Vx.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(_ie)?.[1];o&&n.push(`:!${o}.log`)}),n},Sie=async(t=process.cwd())=>{await en(["reset","--hard","HEAD"],{cwd:t})},Eie=async(t=process.cwd())=>{let e=await en(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
116
116
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},LFe=t=>{let e=t.split(`
|
|
@@ -554,8 +554,8 @@ Deploy failed. Here are the errors to review on the latest build:
|
|
|
554
554
|
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.
|
|
555
555
|
|
|
556
556
|
${t.pop()}
|
|
557
|
-
`;var sm=fe("deploy"),k8e=t=>t===""||/[\s"\\]/u.test(t)?JSON.stringify(t):t,qme=async t=>await dt(Ke(),"create-preview-deploy",async e=>M8e(t,e)),M8e=async({netlify:t,hasRepo:e,skipBuild:r,message:n="Agent Preview",deploySubdomain:i,cliPath:o,filter:s,prodDeploy:a},
|
|
558
|
-
Preview deploy created successfully:`,{deployId:
|
|
557
|
+
`;var sm=fe("deploy"),k8e=t=>t===""||/[\s"\\]/u.test(t)?JSON.stringify(t):t,qme=async t=>await dt(Ke(),"create-preview-deploy",async e=>M8e(t,e)),M8e=async({netlify:t,hasRepo:e,skipBuild:r,message:n="Agent Preview",deploySubdomain:i,cliPath:o,filter:s,prodDeploy:a,agentRunnerId:c,agentRunnerSessionId:l},u)=>{try{let d=["deploy","--message",n,"--json","--verbose",a?"--prod":"--draft"];sm.log("Deploy: Uploading source zip"),d.push("--upload-source-zip"),i&&!a&&d.push("--alias",i),s&&d.push("--filter",s),r?(sm.log("Deploy: Skipping build"),d.push("--no-build")):d.push("--context",a?"production":"deploy-preview");let f=o||"netlify";sm.log(`Running: ${f} ${d.map(k8e).join(" ")}`),u?.setAttributes({cmd:f,args:d});let p={};c&&(p.NETLIFY_AGENT_RUNNER_ID=c),l&&(p.NETLIFY_AGENT_RUNNER_SESSION_ID=l);let h=await t.utils.run(f,d,{stdio:["ignore","pipe","pipe"],env:{...process.env,NETLIFY_DEPLOY_SOURCE:"agent_runner",...p}});h.stderr&&sm.log(String(h.stderr));let m=JSON.parse(String(h.stdout??"").trim());u?.setAttributes({success:!0,deployId:m.deploy_id,deployUrl:m.deploy_url,siteId:m.site_id}),sm.log(`
|
|
558
|
+
Preview deploy created successfully:`,{deployId:m.deploy_id,deployUrl:m.deploy_url,siteId:m.site_id});let y={deployId:m.deploy_id,previewUrl:m.deploy_url,logsUrl:m.logs,siteId:m.site_id};return e||(y.sourceZipFilename=m.source_zip_filename),y}catch(d){throw sm.error("Failed to create preview deploy via CLI:",d),u?.setAttributes({success:!1,error:d.message}),d}};import Hme from"fs";import SV from"path";var Wme=(t=process.cwd())=>{let e=SV.join(t,dr,lQ);return{hasNetlifyForm:Hme.existsSync(SV.join(e,"netlify-forms")),hasNetlifyIdentity:Hme.existsSync(SV.join(e,"netlify-identity"))}};var Fi=fe("deploy_stage"),jI=async t=>await dt(Ke(),"run-deploy-stage",async()=>D8e(t)),D8e=async({cliPath:t,config:e,context:r,result:n,filter:i,isRetry:o,deploySubdomain:s})=>{if(e.mode==="ask")return{hasChanges:!1,previewInfo:null,isProdDeploy:!1,hasNetlifyForm:!1,hasNetlifyIdentity:!1};let a=await dt(Ke(),"get-runner-diffs",async()=>await qx({config:e,isRetry:o}));if(Fi.info("Resolved git",{hasChanges:a.hasChanges,ignored:a.ignored??[]}),!a.hasChanges&&e.mode!=="redeploy"&&!e.pendingUndeployedChanges)return{hasChanges:!1,previewInfo:null,isProdDeploy:!1,hasNetlifyForm:!1,hasNetlifyIdentity:!1};let c=a.hasChanges?a.diff:void 0,l=a.hasChanges?a.resultDiff:void 0,u=a.hasChanges?a.diffBinary:void 0,d=a.hasChanges?a.resultDiffBinary:void 0,f=a.hasChanges||e.mode==="redeploy",{hasNetlifyForm:p,hasNetlifyIdentity:h}=Wme();if(p||h){let x={};p&&(Fi.log("Detected Netlify Forms enablement \u2014 enabling early"),x.has_netlify_form=!0),h&&(Fi.log("Detected Netlify Identity enablement \u2014 enabling early"),x.has_netlify_identity=!0);try{await vr(e.id,e.sessionId,x)}catch(S){Fi.warn("Failed to send early feature enablement (continuing):",S)}}let m=n!==void 0&&(f||e.mode==="redeploy"||!!e.pendingUndeployedChanges);Fi.log("Deploy condition check:",{resultUndefined:n===void 0,resultType:typeof n,hasChanges:f,isRedeploy:e.mode==="redeploy",pendingUndeployedChanges:!!e.pendingUndeployedChanges,wouldCreateDeploy:m});let y=vw(e.mode),v=null,b;if(m)try{let x;try{let S=await dt(Ke(),"get-runner-session",async()=>await IA(e.id,e.sessionId));S?.title&&(x=S.title)}catch(S){Fi.warn("Failed to fetch session title, using fallback message:",S.message)}if(await vr(e.id,e.sessionId,{steps:[{title:y?"Deploying project":"Deploying preview",category:W.Deployment}]}),v=await qme({cliPath:t,netlify:r,hasRepo:e.hasRepo,message:x,skipBuild:!1,deploySubdomain:s,filter:i,prodDeploy:y,agentRunnerId:e.id,agentRunnerSessionId:e.sessionId}),y)try{await vie()?Fi.log("Pushed workspace commits to origin"):Fi.log("Skipped origin push (no origin remote or detached HEAD)")}catch(S){b=S instanceof Error?S.message:String(S),Fi.warn("Failed to push workspace commits to origin (continuing):",S)}}catch(x){if(_o())throw x;return Fi.warn("Failed to create preview deploy (continuing with agent run):",x),{diff:c,resultDiff:l,hasChanges:f,previewInfo:null,diffBinary:u,resultDiffBinary:d,deployError:x instanceof Error?x.message:String(x),isProdDeploy:y,hasNetlifyForm:p,hasNetlifyIdentity:h}}return Fi.log("Git status",{hasDiff:!!c,hasChanges:f}),{diff:c,resultDiff:l,hasChanges:f,previewInfo:v,diffBinary:u,resultDiffBinary:d,gitPushError:b,isProdDeploy:y,hasNetlifyForm:p,hasNetlifyIdentity:h}};import{readFile as zI}from"fs/promises";var Nn=fe("cleanup_stage"),EV=async t=>await dt(Ke(),"cleanup-stage",async()=>L8e(t)),Yme=1024*1024*12,vV=async({config:t,diff:e,diffBinary:r,resultDiff:n,resultDiffBinary:i})=>{let o={diff_produced:!0};try{Nn.log("Getting pre-signed URLs for diff upload");let s=await IQ(t.id,t.sessionId),a=[],c=r||e;c&&a.push(eL(s.result.upload_url,c.path,{size:c.size,base64:!!r}).then(()=>{o.result_diff_s3_key=s.result.s3_key,Nn.log("Successfully uploaded result_diff to S3")}));let l=i||n;l&&a.push(eL(s.cumulative.upload_url,l.path,{size:l.size,base64:!!i}).then(()=>{o.cumulative_diff_s3_key=s.cumulative.s3_key,Nn.log("Successfully uploaded cumulative_diff to S3")})),Nn.log(`Uploading ${a.length} diff(s) to S3 in parallel`),await Promise.all(a)}catch(s){Nn.error("S3 upload failed, falling back to inline diffs:",s);let a=(e?.size??0)+y_(r?.size??0)+(n?.size??0)+y_(i?.size??0);if(a>Yme){let c=`Diffs of ${a} bytes exceed the maximum combined inline size of ${Yme} bytes.`;throw Nn.error(c),new Error(c)}o.result_diff=e?await zI(e.path,"utf8"):void 0,o.result_diff_binary=r?(await zI(r.path)).toString("base64"):void 0,(n||i)&&(o.cumulative_diff=n?await zI(n.path,"utf8"):void 0,o.cumulative_diff_binary=i?(await zI(i.path)).toString("base64"):void 0)}if(n||i)try{Nn.log("Updating agent runner with cumulative diff"),await dt(Ke(),"update-runner",async()=>{await CA(t.id,o.cumulative_diff_s3_key?{result_diff_s3_key:o.cumulative_diff_s3_key}:{result_diff:o.cumulative_diff,result_diff_binary:o.cumulative_diff_binary})})}catch(s){Nn.warn("Failed to record cumulative diff on the runner (session fields still set):",s)}return o},L8e=async({config:t,diff:e,result:r,duration:n,resultDiff:i,diffBinary:o,resultDiffBinary:s,previewInfo:a,isProdDeploy:c,hasNetlifyForm:l,hasNetlifyIdentity:u,nativeSessionArchive:d,nativeSessionId:f,finalAgentConfig:p,creditWrapUp:h})=>{let m={result:r||"Done",duration:n};(p||h)&&(m.metadata={...p?{final_agent_config:p}:{},...h?{credit_wrap_up:!0}:{}}),xQ(t,m.result,p,h),a&&a.deployId&&(m.deploy_id=a.deployId),a&&a.sourceZipFilename&&(m.result_zip_file_name=a.sourceZipFilename),c&&a&&a.deployId&&(m.is_published=!0),f&&(m.native_session_id=f),l&&(m.has_netlify_form=!0),u&&(m.has_netlify_identity=!0),t.mode!=="ask"&&(e||o||i||s)?Object.assign(m,await vV({config:t,diff:e,diffBinary:o,resultDiff:i,resultDiffBinary:s})):Nn.log("No diffs to upload");let v=await dt(Ke(),"upload-native-session",()=>Uu({runnerId:t.id,sessionId:t.sessionId,archive:d,nativeSessionId:f}));return v&&(m.native_session_s3_key=v),$e().warmNativeResumeEnabled&&await dt(Ke(),"save-native-session-cache",()=>im({archive:d,cache:t.cache,nativeSessionId:f})),Nn.log("Updated agent runner with result"),await OA(async()=>await dt(Ke(),"update-runner-session",()=>vr(t.id,t.sessionId,m)),{maxRetries:3,baseDelay:1e3,onRetry:(b,x)=>{Nn.error(`Error updating agent runner session (attempt ${b}):`,x),Nn.log("Retrying...")}}),Nn.log("Finished updating agent runner with result"),{sessionUpdate:m}};import $8e from"fs";import U8e from"path";import F8e from"process";var TV=fe("db_migrations"),B8e=new Set(["drizzle.config.ts","drizzle.config.js","drizzle.config.mjs"]),GI=async t=>await xA({stage:"db-migrations"},()=>dt(Ke(),"db-migrations",async e=>{let r=t.cwd||F8e.cwd();if(!(await Kme("@netlify/database",r)||await Kme("@netlify/db",r)))return e?.setAttributes({skipped:!0,reason:"@netlify/database is not installed"}),ce.inc("db_migrations.run",1,{outcome:"skipped",reason:"no_module"}),{skipped:!0};let i=[...B8e].find(o=>$8e.existsSync(U8e.join(r,o)));if(!i)return e?.setAttributes({skipped:!0,reason:"no drizzle config found"}),ce.inc("db_migrations.run",1,{outcome:"skipped",reason:"no_config"}),{skipped:!0};e?.setAttributes({configFile:i}),TV.log(`Found ${i}, running drizzle-kit generate to ensure migrations are up to date`);try{let o=await fr("npx",["drizzle-kit","generate"],{cwd:r,stdio:["ignore","pipe","pipe"]});return o.stdout&&TV.log(String(o.stdout)),e?.setAttributes({success:!0}),ce.inc("db_migrations.run",1,{outcome:"success"}),{skipped:!1}}catch(o){let s=j8e(o);return TV.warn("drizzle-kit generate failed:",s),e?.setAttributes({success:!1,error:s}),ce.inc("db_migrations.run",1,{outcome:"failure"}),{skipped:!1,error:s}}})),Kme=async(t,e)=>{try{return await rie(`node -e "require.resolve('${t}')"`,{cwd:e,stdio:"ignore"}),!0}catch{return!1}},j8e=t=>{if(t&&typeof t=="object"){let e=[];if("stderr"in t&&t.stderr&&e.push(String(t.stderr)),"stdout"in t&&t.stdout&&e.push(String(t.stdout)),e.length>0)return e.join(`
|
|
559
559
|
`)}return t instanceof Error?t.message:String(t)};var bV=fe("migration_state"),VI=async({cliPath:t,cwd:e})=>{let r;try{let n=await fr(t,["db","status","--json"],{cwd:e,stdio:["ignore","pipe","pipe"]});r=n.stdout?String(n.stdout):""}catch(n){let i=n;throw bV.warn("`netlify db status --json` failed",{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}),n}bV.log("`netlify db status --json` output",{stdout:r});try{return JSON.parse(r)}catch(n){throw bV.warn("Failed to parse `netlify db status --json` output",{stdout:r,error:String(n)}),n}},Zme=()=>["## Netlify Database","","A Netlify Database (managed Postgres) is available for this site.","It will be provisioned automatically on first connection.","No migrations have been applied yet \u2014 this is a fresh database.","","Use `@netlify/database` with Drizzle ORM for persistent data storage.","Define your schema in `db/schema.ts` and migrations will be generated automatically at deploy time.","Read the `netlify-database` skill for setup instructions."].join(`
|
|
560
560
|
`),Jme=t=>{if(t.applied.length===0&&t.pending.length===0)return null;let e=["## CRITICAL: Current Netlify Database state",""];if(t.applied.length>0){e.push("The following migrations are **already applied** to your preview database branch. They are immutable:","");for(let r of t.applied)e.push(`- ${r.name}`);e.push("","**Never delete, rename, or edit an applied migration file.** Doing so will break the deploy \u2014 the","platform requires every migration applied to the branch to exist on disk with its original content. If","you think an applied migration is wrong, roll forward with a NEW migration that corrects whatever it","did. That's always safe; deletion isn't.")}else e.push("No migrations are applied to your preview database branch yet.");if(t.pending.length>0){e.push(""),e.push("The following migration files exist on disk but have NOT yet been applied:","");for(let r of t.pending)e.push(`- ${r.name}`);e.push("","Pending files can be modified or deleted freely \u2014 use `netlify db migrations reset` to remove them","cleanly, then regenerate via `npx drizzle-kit generate` if you want a replacement.")}return e.join(`
|
|
561
561
|
`)},Xme=t=>{let e=[];return t.missingOnDisk.length>0&&e.push("You deleted the following migration file(s) that are already applied to the preview database branch:",...t.missingOnDisk.map(r=>`- ${r.name}`),"","Applied migrations cannot be removed \u2014 the deploy will fail because the platform requires every applied","migration to exist on disk with its original content. Please revise your work:","","1. Restore the deleted file(s) by running `netlify db migrations pull --force`, which overwrites the"," local migrations directory with the authoritative state of the branch. Note this also wipes any"," unapplied migration files you generated this session \u2014 regenerate them via `npx drizzle-kit generate`"," afterwards if you still need them (your `db/schema.ts` edits aren't affected by the pull).","2. If the underlying problem is that an applied migration is wrong, add a NEW migration on top that"," corrects whatever it did (drop a column, rename a table, etc.). Do not touch the original."),t.outOfOrder.length>0&&(e.length>0&&e.push(""),e.push("The following pending migration file(s) have a version prefix that sorts BEFORE migrations already","applied to the branch, so the platform will reject them on deploy:",...t.outOfOrder.map(r=>`- ${r.name} (version ${r.version} \u2264 applied max ${r.maxApplied})`),"","Delete these out-of-order files (use `netlify db migrations reset` \u2014 it only removes unapplied files),","then run `npx drizzle-kit generate` to produce a replacement whose version sorts after the applied","migrations.")),e.length===0?null:e.join(`
|