@netlify/agent-runner-cli 1.159.3 → 1.159.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +2 -2
- package/dist/bin.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -99,7 +99,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
99
99
|
`,LF:`
|
|
100
100
|
`,concatBytes:XL},D$e=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},L$e={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:D$e};import{Buffer as $$e}from"buffer";var Are=(t,e)=>t?void 0:U$e.bind(void 0,e),U$e=function*(t,e){if(typeof e!="string"&&!jt(e)&&!$$e.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},xre=(t,e)=>t?F$e.bind(void 0,e):B$e.bind(void 0,e),F$e=function*(t,e){wre(t,e),yield e},B$e=function*(t,e){if(wre(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},wre=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
101
101
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
102
|
-
if (condition) { yield value; }`)};import{Buffer as j$e}from"buffer";import{StringDecoder as z$e}from"string_decoder";var wx=(t,e,r)=>{if(r)return;if(t)return{transform:G$e.bind(void 0,new TextEncoder)};let n=new z$e(e);return{transform:q$e.bind(void 0,n),final:V$e.bind(void 0,n)}},G$e=function*(t,e){j$e.isBuffer(e)?yield ps(e):typeof e=="string"?yield t.encode(e):yield e},q$e=function*(t,e){yield jt(e)?t.write(e):e},V$e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Rre}from"util";var e$=Rre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Rx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=W$e}=e[r];for await(let i of n(t))yield*Rx(i,e,r+1)},Ire=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*H$e(r,Number(e),t)},H$e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Rx(n,r,e+1)},Cre=Rre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),W$e=function*(t){yield t};var t$=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Pre=(t,e)=>[...e.flatMap(r=>[...Ll(r,t,0)]),...M_(t)],Ll=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=K$e}=e[r];for(let i of n(t))yield*Ll(i,e,r+1)},M_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Y$e(r,Number(e),t)},Y$e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Ll(n,r,e+1)},K$e=function*(t){yield t};var r$=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Nre(t,s,o),l=Dl(e),u=Dl(r),d=l?e$.bind(void 0,Rx,a):t$.bind(void 0,Ll),f=l||u?e$.bind(void 0,Ire,a):t$.bind(void 0,M_),p=l||u?Cre.bind(void 0,a):void 0;return{stream:new Z$e({writableObjectMode:n,writableHighWaterMark:Ore(n),readableObjectMode:i,readableHighWaterMark:Ore(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Ix=(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=Nre(s,r,a);t=Pre(c,t)}return t},Nre=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Are(n,a)},wx(r,s,n),xx(r,o,n,c),{transform:t,final:e},{transform:xre(i,a)},bre({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var kre=(t,e)=>{for(let r of J$e(t))X$e(t,r,e)},J$e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),X$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 ${Da[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Q$e(a,n));r.input=A_(s)},Q$e=(t,e)=>{let r=Ix(t,e,"utf8",!0);return e1e(r),A_(r)},e1e=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 i1e,appendFileSync as o1e}from"fs";var Cx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&mf(r,n)&&!En.has(e)&&t1e(n)&&(t.some(({type:i,value:o})=>i==="native"&&r1e.has(o))||t.every(({type:i})=>Zn.has(i))),t1e=t=>t===1||t===2,r1e=new Set(["pipe","overlapped"]),Mre=async(t,e,r,n)=>{for await(let i of t)n1e(e)||Lre(i,r,n)},Dre=(t,e,r)=>{for(let n of t)Lre(n,e,r)},n1e=t=>t._readableState.pipes.length>0,Lre=(t,e,r)=>{let n=GA(t);ho({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var $re=({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=Ute(t,o,d),p=ps(f),{stdioItems:h,objectMode:m}=e[r],S=a1e([p],h,c,n),{serializedResult:E,finalResult:b=E}=c1e({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});l1e({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&&u1e(E,h,i),A}catch(_){return n.error=_,A}},a1e=(t,e,r,n)=>{try{return Ix(t,e,r,!1)}catch(i){return n.error=i,t}},c1e=({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=XQ(t,r);return n[o]?{serializedResult:s,finalResult:QL(s,!i[o],e)}:{serializedResult:s}},l1e=({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=QL(t,!1,s);try{Dre(a,e,n)}catch(c){r.error??=c}},u1e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>bx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?o1e(n,t):(r.add(o),i1e(n,t))}};var Ure=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,gs(e,r,"all")]:Array.isArray(e)?[gs(t,r,"all"),...e]:jt(t)&&jt(e)?cL([t,e]):`${t}${e}`};import{once as n$}from"events";var Fre=async(t,e)=>{let[r,n]=await d1e(t);return e.isForcefullyTerminated??=!1,[r,n]},d1e=async t=>{let[e,r]=await Promise.allSettled([n$(t,"spawn"),n$(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Bre(t):r.value},Bre=async t=>{try{return await n$(t,"exit")}catch{return Bre(t)}},jre=async t=>{let[e,r]=await t;if(!f1e(e,r)&&i$(e,r))throw new Ii;return[e,r]},f1e=(t,e)=>t===void 0&&e===void 0,i$=(t,e)=>t!==0||e!==null;var zre=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=p1e(t,e,r),s=o?.code==="ETIMEDOUT",a=$te(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},p1e=(t,e,r)=>t!==void 0?t:i$(e,r)?new Ii:void 0;var Gre=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=m1e(t,e,r),d=y1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return xf(d,c,l)},m1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=VA(t,e,r),a=g1e(r),{file:c,commandArguments:l,options:u}=dx(t,e,a);_1e(u);let d=Sre(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},g1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,_1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Px("ipcInput"),t&&Px("ipc: true"),r&&Px("detached: true"),n&&Px("cancelSignal")},Px=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},y1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=S1e({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}=zre(c,r),{output:h,error:m=l}=$re({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,A)=>gs(b,r,A)),E=gs(Ure(h,r),r,"all");return v1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},S1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{kre(o,r);let a=E1e(r);return h1e(...fx(t,e,a))}catch(a){return Af({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},E1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:Sx(e)}),v1e=({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?Ex({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 cFe}from"events";import{spawn as lFe}from"child_process";import Yre from"process";import{once as o$,on as T1e}from"events";var qre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(yf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ox(t)}),b1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),b1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{tx(e,i);let o=Ma(t,e,r),s=new AbortController;try{return await Promise.race([A1e(o,n,s),x1e(o,r,s),w1e(o,r,s)])}catch(a){throw Sf(t),a}finally{s.abort(),rx(e,i)}},A1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await o$(t,"message",{signal:r});return n}for await(let[n]of T1e(t,"message",{signal:r}))if(e(n))return n},x1e=async(t,e,{signal:r})=>{await o$(t,"disconnect",{signal:r}),Pee(e)},w1e=async(t,e,{signal:r})=>{let[n]=await o$(t,"strict:error",{signal:r});throw XA(n,e)};import{once as Hre,on as R1e}from"events";var Wre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>s$({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),s$=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{yf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ox(t)}),tx(e,o);let s=Ma(t,e,r),a=new AbortController,c={};return I1e(t,s,a),C1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),P1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},I1e=async(t,e,r)=>{try{await Hre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},C1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Hre(t,"strict:error",{signal:r.signal});n.error=XA(i,e),r.abort()}catch{}},P1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of R1e(r,"message",{signal:o.signal}))Vre(s),yield c}catch{Vre(s)}finally{o.abort(),rx(e,a),n||Sf(t),i&&await t}},Vre=({error:t})=>{if(t)throw t};var Kre=(t,{ipc:e})=>{Object.assign(t,Jre(t,!1,e))},Zre=()=>{let t=Yre,e=!0,r=Yre.channel!==void 0;return{...Jre(t,e,r),getCancelSignal:nte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Jre=(t,e,r)=>({sendMessage:lx.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:qre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Wre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as O1e}from"child_process";import{PassThrough as N1e,Readable as k1e,Writable as M1e,Duplex as D1e}from"stream";var Xre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ZL(n);let a=new O1e;L1e(a,n),Object.assign(a,{readable:$1e,writable:U1e,duplex:F1e});let c=Af({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=B1e(c,s,i);return{subprocess:a,promise:l}},L1e=(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 N1e;return t.end(),t},$1e=()=>new k1e({read(){}}),U1e=()=>new M1e({write(){}}),F1e=()=>new D1e({read(){},write(){}}),B1e=async(t,e,r)=>xf(t,e,r);import{createReadStream as Qre,createWriteStream as ene}from"fs";import{Buffer as j1e}from"buffer";import{Readable as L_,Writable as z1e,Duplex as G1e}from"stream";var rne=(t,e)=>Ax(q1e,t,e,!1),$_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Da[t]}.`)},tne={fileNumber:$_,generator:r$,asyncGenerator:r$,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:G1e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},q1e={input:{...tne,fileUrl:({value:t})=>({stream:Qre(t)}),filePath:({value:{file:t}})=>({stream:Qre(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(j1e.from(t))})},output:{...tne,fileUrl:({value:t})=>({stream:ene(t)}),filePath:({value:{file:t,append:e}})=>({stream:ene(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:z1e.fromWeb(t)}),iterable:$_,asyncIterable:$_,string:$_,uint8Array:$_}};import{on as V1e,once as nne}from"events";import{PassThrough as H1e,getDefaultHighWaterMark as W1e}from"stream";import{finished as sne}from"stream/promises";function $l(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)c$(i);let e=t.some(({readableObjectMode:i})=>i),r=Y1e(t,e),n=new a$({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Y1e=(t,e)=>{if(t.length===0)return W1e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},a$=class extends H1e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(c$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=K1e(this,this.#e,this.#o);let r=X1e({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(c$(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)}},K1e=async(t,e,r)=>{Ox(t,ine);let n=new AbortController;try{await Promise.race([Z1e(t,n),J1e(t,e,r,n)])}finally{n.abort(),Ox(t,-ine)}},Z1e=async(t,{signal:e})=>{try{await sne(t,{signal:e,cleanup:!0})}catch(r){throw ane(t,r),r}},J1e=async(t,e,r,{signal:n})=>{for await(let[i]of V1e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},c$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},X1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Ox(t,one);let a=new AbortController;try{await Promise.race([Q1e(o,e,a),eUe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),tUe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Ox(t,-one)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?l$(t):rUe(t))},Q1e=async(t,e,{signal:r})=>{try{await t,r.aborted||l$(e)}catch(n){r.aborted||ane(e,n)}},eUe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await sne(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;cne(s)?i.add(e):lne(t,s)}},tUe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await nne(t,i,{signal:o}),!t.readable)return nne(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},rUe=t=>{t.writable&&t.end()},ane=(t,e)=>{cne(e)?l$(t):lne(t,e)},cne=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",l$=t=>{(t.readable||t.writable)&&t.destroy()},lne=(t,e)=>{t.destroyed||(t.once("error",nUe),t.destroy(e))},nUe=()=>{},Ox=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ine=2,one=1;import{finished as une}from"stream/promises";var Rf=(t,e)=>{t.pipe(e),iUe(t,e),oUe(t,e)},iUe=async(t,e)=>{if(!(Ri(t)||Ri(e))){try{await une(t,{cleanup:!0,readable:!0,writable:!1})}catch{}u$(e)}},u$=t=>{t.writable&&t.end()},oUe=async(t,e)=>{if(!(Ri(t)||Ri(e))){try{await une(e,{cleanup:!0,readable:!1,writable:!0})}catch{}d$(t)}},d$=t=>{t.readable&&t.destroy()};var dne=(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})=>Zn.has(c)))sUe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zn.has(c)))cUe({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]:$l(o);Rf(s,i)}},sUe=(t,e,r,n)=>{r==="output"?Rf(t.stdio[n],e):Rf(e,t.stdio[n]);let i=aUe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},aUe=["stdin","stdout","stderr"],cUe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;lUe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},lUe=(t,{signal:e})=>{Ri(t)&&kl(t,uUe,e)},uUe=2;import{addAbortListener as pUe}from"events";var Ul=[];Ul.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ul.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ul.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Nx=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",f$=Symbol.for("signal-exit emitter"),p$=globalThis,dUe=Object.defineProperty.bind(Object),h$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(p$[f$])return p$[f$];dUe(p$,f$,{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}},kx=class{},fUe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),m$=class extends kx{onExit(){return()=>{}}load(){}unload(){}},g$=class extends kx{#e=_$.platform==="win32"?"SIGINT":"SIGHUP";#r=new h$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ul)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(!Nx(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 Ul)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,Ul.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 Nx(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"&&Nx(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)}},_$=globalThis.process,{onExit:fne,load:Svt,unload:Evt}=fUe(Nx(_$)?new g$(_$):new m$);var pne=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=fne(()=>{t.kill()});pUe(n,()=>{i()})};var mne=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=qA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=hUe(r,n,i),{sourceStream:d,sourceError:f}=gUe(t,l),{options:p,fileDescriptors:h}=go.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},hUe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=mUe(t,e,...r),a=ex(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},mUe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(hne,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||sL(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]=MA(r,...n);return{destination:e(hne)(i,o,s),pipeOptions:s}}if(go.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}`)},hne=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),gUe=(t,e)=>{try{return{sourceStream:Ef(t,e)}}catch(r){return{sourceError:r}}};var _ne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=_Ue({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw y$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},_Ue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return d$(t),n;if(e!==void 0)return u$(r),e},y$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Af({error:t,command:gne,escapedCommand:gne,fileDescriptors:e,options:r,startTime:n,isSync:!1}),gne="source.pipe(destination)";var yne=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 yUe}from"stream/promises";var Sne=(t,e,r)=>{let n=Mx.has(e)?EUe(t,e):SUe(t,e);return kl(t,TUe,r.signal),kl(e,bUe,r.signal),vUe(e),n},SUe=(t,e)=>{let r=$l([t]);return Rf(r,e),Mx.set(e,r),r},EUe=(t,e)=>{let r=Mx.get(e);return r.add(t),r},vUe=async t=>{try{await yUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Mx.delete(t)},Mx=new WeakMap,TUe=2,bUe=1;import{aborted as AUe}from"util";var Ene=(t,e)=>t===void 0?[]:[xUe(t,e)],xUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await AUe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw y$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Dx=(t,...e)=>{if(Ot(e[0]))return Dx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=mne(t,...e),i=wUe({...n,destination:r});return i.pipe=Dx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},wUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=RUe(t,i);_ne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Sne(e,o,d);return await Promise.race([yne(u),...Ene(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},RUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as MUe}from"timers/promises";import{on as IUe}from"events";import{getDefaultHighWaterMark as CUe}from"stream";var Lx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return PUe(e,s),Tne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},PUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},S$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;OUe(e,s,t);let a=t.readableObjectMode&&!o;return Tne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},OUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Tne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=IUe(t,"data",{signal:e.signal,highWaterMark:vne,highWatermark:vne});return NUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},E$=CUe(!0),vne=E$,NUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=kUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Ll(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*M_(a)}},kUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[wx(t,r,!e),xx(t,i,!n,{})].filter(Boolean);var bne=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=DUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([LUe(t),d]);return}let f=JL(c,r),p=S$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([$Ue({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},DUe=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=S$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Mre(a,t,r,o)},LUe=async t=>{await MUe(),t.readableFlowing===null&&t.resume()},$Ue=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await gx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await _x(r,{maxBuffer:o})):await bf(r,{maxBuffer:o})}catch(a){return Ane(Mte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},v$=async t=>{try{return await t}catch(e){return Ane(e)}},Ane=({bufferedData:t})=>ZQ(t)?new Uint8Array(t):t;import{finished as UUe}from"stream/promises";var U_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=FUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],UUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||zUe(a,e,r,n)}finally{s.abort()}},FUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&BUe(t,r,n),n},BUe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{jUe(e,r),n.call(t,...i)}},jUe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},zUe=(t,e,r,n)=>{if(!GUe(t,e,r,n))throw t},GUe=(t,e,r,n=!0)=>r.propagating?xne(t)||$x(t):(r.propagating=!0,T$(r,e)===n?xne(t):$x(t)),T$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",$x=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",xne=t=>t?.code==="EPIPE";var wne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>b$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),b$=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(T$(l,e)){await u;return}let[d]=await Promise.all([bne({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 Rne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?$l([t,e].filter(Boolean)):void 0,Ine=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>b$({...qUe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:VUe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),qUe=({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}},VUe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as HUe}from"events";var Cne=t=>mf(t,"ipc"),Pne=(t,e)=>{let r=GA(t);ho({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var One=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Cne(o),a=hs(e,"ipc"),c=hs(r,"ipc");for await(let l of s$({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Dte(t,i,c),i.push(l)),s&&Pne(l,o);return i},Nne=async(t,e)=>(await Promise.allSettled([t]),e);var kne=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=Fre(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},_=wne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),P=Ine({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),w=[],C=One({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),N=WUe(m,t,A),O=YUe(h,A);try{return await Promise.race([Promise.all([{},jre(b),Promise.all(_),P,C,pte(t,d),...N,...O]),S,KUe(t,E),...cte(t,o,f,E),...Cee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...ste({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},b,Promise.all(_.map(y=>v$(y))),v$(P),Nne(C,w),Promise.allSettled(N),Promise.allSettled(O)])}},WUe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:U_(n,i,r)),YUe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Pi(o,{checkOpen:!1})&&!Ri(o)).map(({type:i,value:o,stream:s=o})=>U_(s,n,e,{isSameDirection:Zn.has(i),stopOnExit:i==="native"}))),KUe=async(t,{signal:e})=>{let[r]=await HUe(t,"error",{signal:e});throw r};var Mne=()=>({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=mo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},If=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 ZUe}from"stream";import{callbackify as JUe}from"util";import{finished as Dne}from"stream/promises";var A$=async t=>{if(t!==void 0)try{await x$(t)}catch{}},Lne=async t=>{if(t!==void 0)try{await w$(t)}catch{}},x$=async t=>{await Dne(t,{cleanup:!0,readable:!1,writable:!0})},w$=async t=>{await Dne(t,{cleanup:!0,readable:!0,writable:!1})},Ux=async(t,e)=>{if(await t,e)throw e},Fx=(t,e,r)=>{r&&!$x(r)?t.destroy(r):e&&t.destroy()};var $ne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||En.has(r),{subprocessStdout:a,waitReadableDestroy:c}=R$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=I$(a,s),{read:f,onStdoutDataDone:p}=C$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new ZUe({read:f,destroy:JUe(O$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return P$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},R$=(t,e,r)=>{let n=Ef(t,e),i=F_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},I$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:E$},C$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=mo(),s=Lx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){XUe(this,s,o)},onStdoutDataDone:o}},XUe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},P$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await w$(t),await n,await A$(i),await e,r.readable&&r.push(null)}catch(o){await A$(i),Une(r,o)}},O$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await If(r,e)&&(Une(t,n),await Ux(e,n))},Une=(t,e)=>{Fx(t,t.readable,e)};import{Writable as QUe}from"stream";import{callbackify as Fne}from"util";var Bne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=N$(t,r,e),s=new QUe({...k$(n,t,i),destroy:Fne(D$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return M$(n,s),s},N$=(t,e,r)=>{let n=ex(t,e),i=F_(r,n,"writableFinal"),o=F_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},k$=(t,e,r)=>({write:eFe.bind(void 0,t),final:Fne(tFe.bind(void 0,t,e,r))}),eFe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},tFe=async(t,e,r)=>{await If(r,e)&&(t.writable&&t.end(),await e)},M$=async(t,e,r)=>{try{await x$(t),e.writable&&e.end()}catch(n){await Lne(r),jne(e,n)}},D$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await If(r,e),await If(n,e)&&(jne(t,i),await Ux(e,i))},jne=(t,e)=>{Fx(t,t.writable,e)};import{Duplex as rFe}from"stream";import{callbackify as nFe}from"util";var zne=({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}=R$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=N$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=I$(c,a),{read:S,onStdoutDataDone:E}=C$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new rFe({read:S,...k$(u,t,d),destroy:nFe(iFe.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 P$({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),M$(u,b,c),b},iFe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([O$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),D$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var L$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||En.has(e),s=Ef(t,r),a=Lx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return oFe(a,s,t)},oFe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Gne=(t,{encoding:e})=>{let r=Mne();t.readable=$ne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Bne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=zne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=L$.bind(void 0,t,e),t[Symbol.asyncIterator]=L$.bind(void 0,t,e,{})};var qne=(t,e)=>{for(let[r,n]of aFe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},sFe=(async()=>{})().constructor.prototype,aFe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(sFe,t)]);var Vne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=uFe(t,e,r),{subprocess:f,promise:p}=fFe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Dx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),qne(f,p),go.set(f,{options:u,fileDescriptors:d}),f},uFe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=VA(t,e,r),{file:a,commandArguments:c,options:l}=dx(t,e,r),u=dFe(l),d=rne(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},dFe=({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}},fFe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=lFe(...fx(t,e,r))}catch(h){return Xre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;cFe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];dne(c,a,l),pne(c,r,l);let d={},f=mo();c.kill=Ree.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Rne(c,r),Gne(c,r),Kre(c,r);let p=pFe({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}},pFe=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 kne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((_,P)=>gs(_,e,P)),b=gs(m,e,"all"),A=hFe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return xf(A,n,e)},hFe=({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 _o,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Ex({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Bx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,mFe(n,t[n],i)]));return{...t,...r}},mFe=(t,e,r)=>gFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,gFe=new Set(["env",...fL]);var La=(t,e,r,n)=>{let i=(s,a,c)=>La(s,a,r,c),o=(...s)=>_Fe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},_Fe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Bx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=yFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Gre(a,c,l):Vne(a,c,l,i)},yFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=r7(e)?n7(e,r):[e,...r],[s,a,c]=MA(...o),l=Bx(Bx(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 Hne=({file:t,commandArguments:e})=>Yne(t,e),Wne=({file:t,commandArguments:e})=>({...Yne(t,e),isSync:!0}),Yne=(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]=SFe(t);return{file:r,commandArguments:n}},SFe=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(EFe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},EFe=/ +/g;var Kne=(t,e,r)=>{t.sync=e(vFe,r),t.s=t.sync},Zne=({options:t})=>Jne(t),vFe=({options:t})=>({...Jne(t),isSync:!0}),Jne=t=>({options:{...TFe(t),...t}}),TFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Xne={preferLocal:!0};var Qne=La(()=>({})),lAt=La(()=>({isSync:!0})),eie=La(Hne),uAt=La(Wne),dAt=La(ute),fAt=La(Zne,{},Xne,Kne),{sendMessage:pAt,getOneMessage:hAt,getEachMessage:mAt,getCancelSignal:gAt}=Zre();var tie=!1,rie=()=>{tie=!0},So=()=>tie;var B_=null,nie=t=>(B_&&B_.destroy(),B_=new _s({totalAllowedTime:t}),B_),iie=()=>B_;var _s=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&&So())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 wA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{le.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 oie={name:"@netlify/agent-runner-cli",type:"module",version:"1.159.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.4","@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 wFe=AFe(import.meta.url),RFe=ys.dirname(wFe),IFe=xFe(import.meta.url),Cf=ue("shell"),$$=new Set,sie={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=CFe(e,r),o={...sie,...i},s=Qne(t,n,o);cie(s,o),die(s);let a=r?.idleTimeout;return a&&a>0&&uie(s,a),s},aie=(t,e)=>{let r={...sie,...e},n=eie(t,r);return cie(n,r),die(n),e?.idleTimeout&&e.idleTimeout>0&&uie(n,e.idleTimeout),n},CFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},cie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ss.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new h_).pipe(Ss.stdout),t.stderr?.pipe(new h_).pipe(Ss.stderr);return}t.stdout?.pipe(Ss.stdout),t.stderr?.pipe(Ss.stderr)},U$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ss.kill(-t.pid,e),Cf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Cf.error("Error killing process:",r),!1}},lie=t=>U$(t,"SIGKILL"),uie=(t,e)=>{let r=null,n=()=>{Cf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),U$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Cf.log(`Force killing idle process ${t.pid}`),lie(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)},die=t=>{$$.add(t);let e=iie();if(e){let r=e.onTimesUp(()=>{Cf.log(`Global timer expired, killing process ${t.pid}`),U$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Cf.log(`Force killing process ${t.pid} after timeout`),lie(t))},5e3)});t.on("exit",()=>{$$.delete(t),r()}),t.on("error",()=>{$$.delete(t),r()})}};function zx(t,e){return!!Oi(t,e)}function Oi(t,e){if(!Ss.env.NETLIFY_LOCAL_MODE)try{let i=IFe.resolve(oie.name),o=ys.dirname(i);for(;o!==ys.dirname(o);){let s=ys.dirname(o);if(ys.basename(s)==="node_modules"){let a=ys.join(s,".bin",e);if(jx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ss.env.NODE_PATH){let i=ys.join(Ss.env.NODE_PATH,".bin",e);if(jx.existsSync(i))return i}let r=ys.join(t,"node_modules",".bin",e);if(jx.existsSync(r))return r;let n=ys.join(RFe,"..","node_modules",".bin",e);if(jx.existsSync(n))return n}var PFe=ue("utils"),OFe=t=>new Promise(e=>{setTimeout(e,t)});var F$=t=>{try{return new URL(t).hostname||null}catch{return null}},Gx=(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 OFe(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},$a=(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},fie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):PFe.error("Could not parse JSON",n))}},NFe=t=>t.charAt(0).toUpperCase()+t.slice(1),Eo=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():NFe(e)).join(" ");function Es(t,e){e&&t.log(`Skill invoked: ${e}`)}var qx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),pie=(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 B$=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}},kFe=1e4,j$=(t,e=kFe)=>{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 MFe}from"crypto";import{createReadStream as DFe}from"fs";import Vx from"fs/promises";import yie from"os";import Hx from"path";var hie=ue("repo"),Sie="runner-diffs-",Eie=t=>`${Sie}${t}-`,vie=async t=>{let e=yie.tmpdir(),r;try{r=await Vx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Sie)&&!n.startsWith(Eie(t))).map(n=>Vx.rm(Hx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},tn=(t,e={})=>zt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Wx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{hie.info("Getting runner diffs");let n=await $Fe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=FFe(o);await BFe(h,r)}hie.info("Changes after processing"),await G$(r);let s=await q$(o,r);if(await z$(s,r),i=await UFe(r),!i)return{hasChanges:!1,ignored:s};await tn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Vx.mkdtemp(Hx.join(yie.tmpdir(),Eie(t.sessionId))),c=async({from:h,to:m,fileName:S,binary:E})=>{let b=Hx.join(a,S);await tn([...E?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:_}=await Vx.stat(b);return{path:b,size:_}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await _ie(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 gie(d,h)||(f=h)}await _ie(r),le.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await gie(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},mie=async t=>{let e=MFe("sha256");for await(let r of DFe(t))e.update(r);return e.digest("hex")},gie=async(t,e)=>t.size===e.size&&await mie(t.path)===await mie(e.path),_ie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await tn(["reset","--soft","HEAD~1"],{cwd:t})},z$=async(t=[],e=process.cwd())=>{await tn(["add",".",...t],{cwd:e})},G$=async(t=process.cwd())=>{let e=await tn(["status","-s"],{cwd:t});return String(e.stdout??"")},Tie=/.. (.+)?\.log$/,LFe=[Tie],$Fe=async(t=process.cwd())=>{let e=await G$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
|
+
if (condition) { yield value; }`)};import{Buffer as j$e}from"buffer";import{StringDecoder as z$e}from"string_decoder";var wx=(t,e,r)=>{if(r)return;if(t)return{transform:G$e.bind(void 0,new TextEncoder)};let n=new z$e(e);return{transform:q$e.bind(void 0,n),final:V$e.bind(void 0,n)}},G$e=function*(t,e){j$e.isBuffer(e)?yield ps(e):typeof e=="string"?yield t.encode(e):yield e},q$e=function*(t,e){yield jt(e)?t.write(e):e},V$e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Rre}from"util";var e$=Rre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Rx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=W$e}=e[r];for await(let i of n(t))yield*Rx(i,e,r+1)},Ire=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*H$e(r,Number(e),t)},H$e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Rx(n,r,e+1)},Cre=Rre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),W$e=function*(t){yield t};var t$=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Pre=(t,e)=>[...e.flatMap(r=>[...Ll(r,t,0)]),...M_(t)],Ll=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=K$e}=e[r];for(let i of n(t))yield*Ll(i,e,r+1)},M_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Y$e(r,Number(e),t)},Y$e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Ll(n,r,e+1)},K$e=function*(t){yield t};var r$=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Nre(t,s,o),l=Dl(e),u=Dl(r),d=l?e$.bind(void 0,Rx,a):t$.bind(void 0,Ll),f=l||u?e$.bind(void 0,Ire,a):t$.bind(void 0,M_),p=l||u?Cre.bind(void 0,a):void 0;return{stream:new Z$e({writableObjectMode:n,writableHighWaterMark:Ore(n),readableObjectMode:i,readableHighWaterMark:Ore(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Ix=(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=Nre(s,r,a);t=Pre(c,t)}return t},Nre=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Are(n,a)},wx(r,s,n),xx(r,o,n,c),{transform:t,final:e},{transform:xre(i,a)},bre({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var kre=(t,e)=>{for(let r of J$e(t))X$e(t,r,e)},J$e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),X$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 ${Da[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Q$e(a,n));r.input=A_(s)},Q$e=(t,e)=>{let r=Ix(t,e,"utf8",!0);return e1e(r),A_(r)},e1e=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 i1e,appendFileSync as o1e}from"fs";var Cx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&mf(r,n)&&!En.has(e)&&t1e(n)&&(t.some(({type:i,value:o})=>i==="native"&&r1e.has(o))||t.every(({type:i})=>Zn.has(i))),t1e=t=>t===1||t===2,r1e=new Set(["pipe","overlapped"]),Mre=async(t,e,r,n)=>{for await(let i of t)n1e(e)||Lre(i,r,n)},Dre=(t,e,r)=>{for(let n of t)Lre(n,e,r)},n1e=t=>t._readableState.pipes.length>0,Lre=(t,e,r)=>{let n=GA(t);ho({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var $re=({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=Ute(t,o,d),p=ps(f),{stdioItems:h,objectMode:m}=e[r],S=a1e([p],h,c,n),{serializedResult:E,finalResult:b=E}=c1e({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});l1e({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&&u1e(E,h,i),A}catch(_){return n.error=_,A}},a1e=(t,e,r,n)=>{try{return Ix(t,e,r,!1)}catch(i){return n.error=i,t}},c1e=({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=XQ(t,r);return n[o]?{serializedResult:s,finalResult:QL(s,!i[o],e)}:{serializedResult:s}},l1e=({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=QL(t,!1,s);try{Dre(a,e,n)}catch(c){r.error??=c}},u1e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>bx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?o1e(n,t):(r.add(o),i1e(n,t))}};var Ure=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,gs(e,r,"all")]:Array.isArray(e)?[gs(t,r,"all"),...e]:jt(t)&&jt(e)?cL([t,e]):`${t}${e}`};import{once as n$}from"events";var Fre=async(t,e)=>{let[r,n]=await d1e(t);return e.isForcefullyTerminated??=!1,[r,n]},d1e=async t=>{let[e,r]=await Promise.allSettled([n$(t,"spawn"),n$(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Bre(t):r.value},Bre=async t=>{try{return await n$(t,"exit")}catch{return Bre(t)}},jre=async t=>{let[e,r]=await t;if(!f1e(e,r)&&i$(e,r))throw new Ii;return[e,r]},f1e=(t,e)=>t===void 0&&e===void 0,i$=(t,e)=>t!==0||e!==null;var zre=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=p1e(t,e,r),s=o?.code==="ETIMEDOUT",a=$te(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},p1e=(t,e,r)=>t!==void 0?t:i$(e,r)?new Ii:void 0;var Gre=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=m1e(t,e,r),d=y1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return xf(d,c,l)},m1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=VA(t,e,r),a=g1e(r),{file:c,commandArguments:l,options:u}=dx(t,e,a);_1e(u);let d=Sre(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},g1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,_1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Px("ipcInput"),t&&Px("ipc: true"),r&&Px("detached: true"),n&&Px("cancelSignal")},Px=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},y1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=S1e({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}=zre(c,r),{output:h,error:m=l}=$re({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,A)=>gs(b,r,A)),E=gs(Ure(h,r),r,"all");return v1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},S1e=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{kre(o,r);let a=E1e(r);return h1e(...fx(t,e,a))}catch(a){return Af({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},E1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:Sx(e)}),v1e=({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?Ex({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 cFe}from"events";import{spawn as lFe}from"child_process";import Yre from"process";import{once as o$,on as T1e}from"events";var qre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(yf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ox(t)}),b1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),b1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{tx(e,i);let o=Ma(t,e,r),s=new AbortController;try{return await Promise.race([A1e(o,n,s),x1e(o,r,s),w1e(o,r,s)])}catch(a){throw Sf(t),a}finally{s.abort(),rx(e,i)}},A1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await o$(t,"message",{signal:r});return n}for await(let[n]of T1e(t,"message",{signal:r}))if(e(n))return n},x1e=async(t,e,{signal:r})=>{await o$(t,"disconnect",{signal:r}),Pee(e)},w1e=async(t,e,{signal:r})=>{let[n]=await o$(t,"strict:error",{signal:r});throw XA(n,e)};import{once as Hre,on as R1e}from"events";var Wre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>s$({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),s$=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{yf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ox(t)}),tx(e,o);let s=Ma(t,e,r),a=new AbortController,c={};return I1e(t,s,a),C1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),P1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},I1e=async(t,e,r)=>{try{await Hre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},C1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Hre(t,"strict:error",{signal:r.signal});n.error=XA(i,e),r.abort()}catch{}},P1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of R1e(r,"message",{signal:o.signal}))Vre(s),yield c}catch{Vre(s)}finally{o.abort(),rx(e,a),n||Sf(t),i&&await t}},Vre=({error:t})=>{if(t)throw t};var Kre=(t,{ipc:e})=>{Object.assign(t,Jre(t,!1,e))},Zre=()=>{let t=Yre,e=!0,r=Yre.channel!==void 0;return{...Jre(t,e,r),getCancelSignal:nte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Jre=(t,e,r)=>({sendMessage:lx.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:qre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Wre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as O1e}from"child_process";import{PassThrough as N1e,Readable as k1e,Writable as M1e,Duplex as D1e}from"stream";var Xre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ZL(n);let a=new O1e;L1e(a,n),Object.assign(a,{readable:$1e,writable:U1e,duplex:F1e});let c=Af({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=B1e(c,s,i);return{subprocess:a,promise:l}},L1e=(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 N1e;return t.end(),t},$1e=()=>new k1e({read(){}}),U1e=()=>new M1e({write(){}}),F1e=()=>new D1e({read(){},write(){}}),B1e=async(t,e,r)=>xf(t,e,r);import{createReadStream as Qre,createWriteStream as ene}from"fs";import{Buffer as j1e}from"buffer";import{Readable as L_,Writable as z1e,Duplex as G1e}from"stream";var rne=(t,e)=>Ax(q1e,t,e,!1),$_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Da[t]}.`)},tne={fileNumber:$_,generator:r$,asyncGenerator:r$,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:G1e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},q1e={input:{...tne,fileUrl:({value:t})=>({stream:Qre(t)}),filePath:({value:{file:t}})=>({stream:Qre(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(j1e.from(t))})},output:{...tne,fileUrl:({value:t})=>({stream:ene(t)}),filePath:({value:{file:t,append:e}})=>({stream:ene(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:z1e.fromWeb(t)}),iterable:$_,asyncIterable:$_,string:$_,uint8Array:$_}};import{on as V1e,once as nne}from"events";import{PassThrough as H1e,getDefaultHighWaterMark as W1e}from"stream";import{finished as sne}from"stream/promises";function $l(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)c$(i);let e=t.some(({readableObjectMode:i})=>i),r=Y1e(t,e),n=new a$({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Y1e=(t,e)=>{if(t.length===0)return W1e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},a$=class extends H1e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(c$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=K1e(this,this.#e,this.#o);let r=X1e({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(c$(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)}},K1e=async(t,e,r)=>{Ox(t,ine);let n=new AbortController;try{await Promise.race([Z1e(t,n),J1e(t,e,r,n)])}finally{n.abort(),Ox(t,-ine)}},Z1e=async(t,{signal:e})=>{try{await sne(t,{signal:e,cleanup:!0})}catch(r){throw ane(t,r),r}},J1e=async(t,e,r,{signal:n})=>{for await(let[i]of V1e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},c$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},X1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Ox(t,one);let a=new AbortController;try{await Promise.race([Q1e(o,e,a),eUe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),tUe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Ox(t,-one)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?l$(t):rUe(t))},Q1e=async(t,e,{signal:r})=>{try{await t,r.aborted||l$(e)}catch(n){r.aborted||ane(e,n)}},eUe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await sne(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;cne(s)?i.add(e):lne(t,s)}},tUe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await nne(t,i,{signal:o}),!t.readable)return nne(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},rUe=t=>{t.writable&&t.end()},ane=(t,e)=>{cne(e)?l$(t):lne(t,e)},cne=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",l$=t=>{(t.readable||t.writable)&&t.destroy()},lne=(t,e)=>{t.destroyed||(t.once("error",nUe),t.destroy(e))},nUe=()=>{},Ox=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ine=2,one=1;import{finished as une}from"stream/promises";var Rf=(t,e)=>{t.pipe(e),iUe(t,e),oUe(t,e)},iUe=async(t,e)=>{if(!(Ri(t)||Ri(e))){try{await une(t,{cleanup:!0,readable:!0,writable:!1})}catch{}u$(e)}},u$=t=>{t.writable&&t.end()},oUe=async(t,e)=>{if(!(Ri(t)||Ri(e))){try{await une(e,{cleanup:!0,readable:!1,writable:!0})}catch{}d$(t)}},d$=t=>{t.readable&&t.destroy()};var dne=(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})=>Zn.has(c)))sUe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zn.has(c)))cUe({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]:$l(o);Rf(s,i)}},sUe=(t,e,r,n)=>{r==="output"?Rf(t.stdio[n],e):Rf(e,t.stdio[n]);let i=aUe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},aUe=["stdin","stdout","stderr"],cUe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;lUe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},lUe=(t,{signal:e})=>{Ri(t)&&kl(t,uUe,e)},uUe=2;import{addAbortListener as pUe}from"events";var Ul=[];Ul.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ul.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ul.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Nx=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",f$=Symbol.for("signal-exit emitter"),p$=globalThis,dUe=Object.defineProperty.bind(Object),h$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(p$[f$])return p$[f$];dUe(p$,f$,{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}},kx=class{},fUe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),m$=class extends kx{onExit(){return()=>{}}load(){}unload(){}},g$=class extends kx{#e=_$.platform==="win32"?"SIGINT":"SIGHUP";#r=new h$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ul)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(!Nx(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 Ul)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,Ul.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 Nx(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"&&Nx(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)}},_$=globalThis.process,{onExit:fne,load:Svt,unload:Evt}=fUe(Nx(_$)?new g$(_$):new m$);var pne=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=fne(()=>{t.kill()});pUe(n,()=>{i()})};var mne=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=qA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=hUe(r,n,i),{sourceStream:d,sourceError:f}=gUe(t,l),{options:p,fileDescriptors:h}=go.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},hUe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=mUe(t,e,...r),a=ex(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},mUe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(hne,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||sL(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]=MA(r,...n);return{destination:e(hne)(i,o,s),pipeOptions:s}}if(go.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}`)},hne=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),gUe=(t,e)=>{try{return{sourceStream:Ef(t,e)}}catch(r){return{sourceError:r}}};var _ne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=_Ue({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw y$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},_Ue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return d$(t),n;if(e!==void 0)return u$(r),e},y$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Af({error:t,command:gne,escapedCommand:gne,fileDescriptors:e,options:r,startTime:n,isSync:!1}),gne="source.pipe(destination)";var yne=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 yUe}from"stream/promises";var Sne=(t,e,r)=>{let n=Mx.has(e)?EUe(t,e):SUe(t,e);return kl(t,TUe,r.signal),kl(e,bUe,r.signal),vUe(e),n},SUe=(t,e)=>{let r=$l([t]);return Rf(r,e),Mx.set(e,r),r},EUe=(t,e)=>{let r=Mx.get(e);return r.add(t),r},vUe=async t=>{try{await yUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Mx.delete(t)},Mx=new WeakMap,TUe=2,bUe=1;import{aborted as AUe}from"util";var Ene=(t,e)=>t===void 0?[]:[xUe(t,e)],xUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await AUe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw y$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Dx=(t,...e)=>{if(Ot(e[0]))return Dx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=mne(t,...e),i=wUe({...n,destination:r});return i.pipe=Dx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},wUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=RUe(t,i);_ne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Sne(e,o,d);return await Promise.race([yne(u),...Ene(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},RUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as MUe}from"timers/promises";import{on as IUe}from"events";import{getDefaultHighWaterMark as CUe}from"stream";var Lx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return PUe(e,s),Tne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},PUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},S$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;OUe(e,s,t);let a=t.readableObjectMode&&!o;return Tne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},OUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Tne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=IUe(t,"data",{signal:e.signal,highWaterMark:vne,highWatermark:vne});return NUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},E$=CUe(!0),vne=E$,NUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=kUe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Ll(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*M_(a)}},kUe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[wx(t,r,!e),xx(t,i,!n,{})].filter(Boolean);var bne=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=DUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([LUe(t),d]);return}let f=JL(c,r),p=S$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([$Ue({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},DUe=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=S$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Mre(a,t,r,o)},LUe=async t=>{await MUe(),t.readableFlowing===null&&t.resume()},$Ue=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await gx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await _x(r,{maxBuffer:o})):await bf(r,{maxBuffer:o})}catch(a){return Ane(Mte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},v$=async t=>{try{return await t}catch(e){return Ane(e)}},Ane=({bufferedData:t})=>ZQ(t)?new Uint8Array(t):t;import{finished as UUe}from"stream/promises";var U_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=FUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],UUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||zUe(a,e,r,n)}finally{s.abort()}},FUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&BUe(t,r,n),n},BUe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{jUe(e,r),n.call(t,...i)}},jUe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},zUe=(t,e,r,n)=>{if(!GUe(t,e,r,n))throw t},GUe=(t,e,r,n=!0)=>r.propagating?xne(t)||$x(t):(r.propagating=!0,T$(r,e)===n?xne(t):$x(t)),T$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",$x=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",xne=t=>t?.code==="EPIPE";var wne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>b$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),b$=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(T$(l,e)){await u;return}let[d]=await Promise.all([bne({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 Rne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?$l([t,e].filter(Boolean)):void 0,Ine=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>b$({...qUe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:VUe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),qUe=({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}},VUe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as HUe}from"events";var Cne=t=>mf(t,"ipc"),Pne=(t,e)=>{let r=GA(t);ho({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var One=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Cne(o),a=hs(e,"ipc"),c=hs(r,"ipc");for await(let l of s$({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Dte(t,i,c),i.push(l)),s&&Pne(l,o);return i},Nne=async(t,e)=>(await Promise.allSettled([t]),e);var kne=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=Fre(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},_=wne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),P=Ine({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),w=[],C=One({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),N=WUe(m,t,A),O=YUe(h,A);try{return await Promise.race([Promise.all([{},jre(b),Promise.all(_),P,C,pte(t,d),...N,...O]),S,KUe(t,E),...cte(t,o,f,E),...Cee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...ste({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},b,Promise.all(_.map(y=>v$(y))),v$(P),Nne(C,w),Promise.allSettled(N),Promise.allSettled(O)])}},WUe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:U_(n,i,r)),YUe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Pi(o,{checkOpen:!1})&&!Ri(o)).map(({type:i,value:o,stream:s=o})=>U_(s,n,e,{isSameDirection:Zn.has(i),stopOnExit:i==="native"}))),KUe=async(t,{signal:e})=>{let[r]=await HUe(t,"error",{signal:e});throw r};var Mne=()=>({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=mo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},If=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 ZUe}from"stream";import{callbackify as JUe}from"util";import{finished as Dne}from"stream/promises";var A$=async t=>{if(t!==void 0)try{await x$(t)}catch{}},Lne=async t=>{if(t!==void 0)try{await w$(t)}catch{}},x$=async t=>{await Dne(t,{cleanup:!0,readable:!1,writable:!0})},w$=async t=>{await Dne(t,{cleanup:!0,readable:!0,writable:!1})},Ux=async(t,e)=>{if(await t,e)throw e},Fx=(t,e,r)=>{r&&!$x(r)?t.destroy(r):e&&t.destroy()};var $ne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||En.has(r),{subprocessStdout:a,waitReadableDestroy:c}=R$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=I$(a,s),{read:f,onStdoutDataDone:p}=C$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new ZUe({read:f,destroy:JUe(O$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return P$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},R$=(t,e,r)=>{let n=Ef(t,e),i=F_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},I$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:E$},C$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=mo(),s=Lx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){XUe(this,s,o)},onStdoutDataDone:o}},XUe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},P$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await w$(t),await n,await A$(i),await e,r.readable&&r.push(null)}catch(o){await A$(i),Une(r,o)}},O$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await If(r,e)&&(Une(t,n),await Ux(e,n))},Une=(t,e)=>{Fx(t,t.readable,e)};import{Writable as QUe}from"stream";import{callbackify as Fne}from"util";var Bne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=N$(t,r,e),s=new QUe({...k$(n,t,i),destroy:Fne(D$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return M$(n,s),s},N$=(t,e,r)=>{let n=ex(t,e),i=F_(r,n,"writableFinal"),o=F_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},k$=(t,e,r)=>({write:eFe.bind(void 0,t),final:Fne(tFe.bind(void 0,t,e,r))}),eFe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},tFe=async(t,e,r)=>{await If(r,e)&&(t.writable&&t.end(),await e)},M$=async(t,e,r)=>{try{await x$(t),e.writable&&e.end()}catch(n){await Lne(r),jne(e,n)}},D$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await If(r,e),await If(n,e)&&(jne(t,i),await Ux(e,i))},jne=(t,e)=>{Fx(t,t.writable,e)};import{Duplex as rFe}from"stream";import{callbackify as nFe}from"util";var zne=({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}=R$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=N$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=I$(c,a),{read:S,onStdoutDataDone:E}=C$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new rFe({read:S,...k$(u,t,d),destroy:nFe(iFe.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 P$({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),M$(u,b,c),b},iFe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([O$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),D$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var L$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||En.has(e),s=Ef(t,r),a=Lx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return oFe(a,s,t)},oFe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Gne=(t,{encoding:e})=>{let r=Mne();t.readable=$ne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Bne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=zne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=L$.bind(void 0,t,e),t[Symbol.asyncIterator]=L$.bind(void 0,t,e,{})};var qne=(t,e)=>{for(let[r,n]of aFe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},sFe=(async()=>{})().constructor.prototype,aFe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(sFe,t)]);var Vne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=uFe(t,e,r),{subprocess:f,promise:p}=fFe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Dx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),qne(f,p),go.set(f,{options:u,fileDescriptors:d}),f},uFe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=VA(t,e,r),{file:a,commandArguments:c,options:l}=dx(t,e,r),u=dFe(l),d=rne(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},dFe=({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}},fFe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=lFe(...fx(t,e,r))}catch(h){return Xre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;cFe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];dne(c,a,l),pne(c,r,l);let d={},f=mo();c.kill=Ree.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Rne(c,r),Gne(c,r),Kre(c,r);let p=pFe({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}},pFe=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 kne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((_,P)=>gs(_,e,P)),b=gs(m,e,"all"),A=hFe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return xf(A,n,e)},hFe=({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 _o,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Ex({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Bx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,mFe(n,t[n],i)]));return{...t,...r}},mFe=(t,e,r)=>gFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,gFe=new Set(["env",...fL]);var La=(t,e,r,n)=>{let i=(s,a,c)=>La(s,a,r,c),o=(...s)=>_Fe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},_Fe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Bx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=yFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Gre(a,c,l):Vne(a,c,l,i)},yFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=r7(e)?n7(e,r):[e,...r],[s,a,c]=MA(...o),l=Bx(Bx(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 Hne=({file:t,commandArguments:e})=>Yne(t,e),Wne=({file:t,commandArguments:e})=>({...Yne(t,e),isSync:!0}),Yne=(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]=SFe(t);return{file:r,commandArguments:n}},SFe=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(EFe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},EFe=/ +/g;var Kne=(t,e,r)=>{t.sync=e(vFe,r),t.s=t.sync},Zne=({options:t})=>Jne(t),vFe=({options:t})=>({...Jne(t),isSync:!0}),Jne=t=>({options:{...TFe(t),...t}}),TFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Xne={preferLocal:!0};var Qne=La(()=>({})),lAt=La(()=>({isSync:!0})),eie=La(Hne),uAt=La(Wne),dAt=La(ute),fAt=La(Zne,{},Xne,Kne),{sendMessage:pAt,getOneMessage:hAt,getEachMessage:mAt,getCancelSignal:gAt}=Zre();var tie=!1,rie=()=>{tie=!0},So=()=>tie;var B_=null,nie=t=>(B_&&B_.destroy(),B_=new _s({totalAllowedTime:t}),B_),iie=()=>B_;var _s=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&&So())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 wA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{le.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 oie={name:"@netlify/agent-runner-cli",type:"module",version:"1.159.4",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.4","@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 wFe=AFe(import.meta.url),RFe=ys.dirname(wFe),IFe=xFe(import.meta.url),Cf=ue("shell"),$$=new Set,sie={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=CFe(e,r),o={...sie,...i},s=Qne(t,n,o);cie(s,o),die(s);let a=r?.idleTimeout;return a&&a>0&&uie(s,a),s},aie=(t,e)=>{let r={...sie,...e},n=eie(t,r);return cie(n,r),die(n),e?.idleTimeout&&e.idleTimeout>0&&uie(n,e.idleTimeout),n},CFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},cie=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ss.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new h_).pipe(Ss.stdout),t.stderr?.pipe(new h_).pipe(Ss.stderr);return}t.stdout?.pipe(Ss.stdout),t.stderr?.pipe(Ss.stderr)},U$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ss.kill(-t.pid,e),Cf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Cf.error("Error killing process:",r),!1}},lie=t=>U$(t,"SIGKILL"),uie=(t,e)=>{let r=null,n=()=>{Cf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),U$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Cf.log(`Force killing idle process ${t.pid}`),lie(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)},die=t=>{$$.add(t);let e=iie();if(e){let r=e.onTimesUp(()=>{Cf.log(`Global timer expired, killing process ${t.pid}`),U$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Cf.log(`Force killing process ${t.pid} after timeout`),lie(t))},5e3)});t.on("exit",()=>{$$.delete(t),r()}),t.on("error",()=>{$$.delete(t),r()})}};function zx(t,e){return!!Oi(t,e)}function Oi(t,e){if(!Ss.env.NETLIFY_LOCAL_MODE)try{let i=IFe.resolve(oie.name),o=ys.dirname(i);for(;o!==ys.dirname(o);){let s=ys.dirname(o);if(ys.basename(s)==="node_modules"){let a=ys.join(s,".bin",e);if(jx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ss.env.NODE_PATH){let i=ys.join(Ss.env.NODE_PATH,".bin",e);if(jx.existsSync(i))return i}let r=ys.join(t,"node_modules",".bin",e);if(jx.existsSync(r))return r;let n=ys.join(RFe,"..","node_modules",".bin",e);if(jx.existsSync(n))return n}var PFe=ue("utils"),OFe=t=>new Promise(e=>{setTimeout(e,t)});var F$=t=>{try{return new URL(t).hostname||null}catch{return null}},Gx=(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 OFe(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},$a=(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},fie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):PFe.error("Could not parse JSON",n))}},NFe=t=>t.charAt(0).toUpperCase()+t.slice(1),Eo=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():NFe(e)).join(" ");function Es(t,e){e&&t.log(`Skill invoked: ${e}`)}var qx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),pie=(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 B$=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}},kFe=1e4,j$=(t,e=kFe)=>{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 MFe}from"crypto";import{createReadStream as DFe}from"fs";import Vx from"fs/promises";import yie from"os";import Hx from"path";var hie=ue("repo"),Sie="runner-diffs-",Eie=t=>`${Sie}${t}-`,vie=async t=>{let e=yie.tmpdir(),r;try{r=await Vx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(Sie)&&!n.startsWith(Eie(t))).map(n=>Vx.rm(Hx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},tn=(t,e={})=>zt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Wx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{hie.info("Getting runner diffs");let n=await $Fe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=FFe(o);await BFe(h,r)}hie.info("Changes after processing"),await G$(r);let s=await q$(o,r);if(await z$(s,r),i=await UFe(r),!i)return{hasChanges:!1,ignored:s};await tn(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Vx.mkdtemp(Hx.join(yie.tmpdir(),Eie(t.sessionId))),c=async({from:h,to:m,fileName:S,binary:E})=>{let b=Hx.join(a,S);await tn([...E?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:_}=await Vx.stat(b);return{path:b,size:_}},l=await c({from:t.runSha,to:"HEAD",fileName:"session.patch"});if(i=l.size>0,!i)return await _ie(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 gie(d,h)||(f=h)}await _ie(r),le.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await gie(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},mie=async t=>{let e=MFe("sha256");for await(let r of DFe(t))e.update(r);return e.digest("hex")},gie=async(t,e)=>t.size===e.size&&await mie(t.path)===await mie(e.path),_ie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await tn(["reset","--soft","HEAD~1"],{cwd:t})},z$=async(t=[],e=process.cwd())=>{await tn(["add",".",...t],{cwd:e})},G$=async(t=process.cwd())=>{let e=await tn(["status","-s"],{cwd:t});return String(e.stdout??"")},Tie=/.. (.+)?\.log$/,LFe=[Tie],$Fe=async(t=process.cwd())=>{let e=await G$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
103
103
|
`).filter(i=>LFe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},UFe=async(t=process.cwd())=>{try{return await tn(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},j_=async(t=process.cwd())=>{let{stdout:e}=await tn(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},bie=async(t=process.cwd())=>{let{stdout:e}=await tn(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},q$=async(t,e=process.cwd())=>{t||=await G$(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(`
|
|
104
104
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${Hx.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Tie)?.[1];o&&n.push(`:!${o}.log`)}),n},Aie=async(t=process.cwd())=>{await tn(["reset","--hard","HEAD"],{cwd:t})},xie=async(t=process.cwd())=>{let e=await tn(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
105
105
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},FFe=t=>{let e=t.split(`
|
|
@@ -216,7 +216,7 @@ A: ${i}`).join(`
|
|
|
216
216
|
`),[Mze,e,Dze].filter(Boolean).join(" ")].filter(Boolean).join(`
|
|
217
217
|
|
|
218
218
|
`);import P2 from"path";import Fze from"fs/promises";var O2=ue("agent-output-utils");async function ic({initialResult:t,agentName:e,hasError:r}){let n="",i=P2.join(process.cwd(),dr,us);try{let o=await Fze.readFile(i,"utf-8");o&&(n=o,O2.log(`Pulled result from ${P2.relative(process.cwd(),i)}`))}catch{O2.log(`No results file found at ${P2.relative(process.cwd(),i)}`)}return n||(!t&&!r?`${e} has finished working on task.`:t||void 0)}var Bze=[/^API Error:\s*\d{3}/i,/^\d{3}\s*status code/i,/^API request failed:\s*\d{3}/i,/^API Error: The socket connection was closed/i,/^overloaded_error/i];function uI(t){let e=t.trim();return Bze.some(r=>r.test(e))?"Encountered a temporary issue \u2014 the agent will attempt to continue.":t}var Ace=256*1024,xce=t=>`
|
|
219
|
-
\u2026 [truncated ${t} characters]`;function wce(t){if(t.length<=Ace)return t;let e=xce(t.length).length,r=t.slice(0,Ace-e);return`${r}${xce(t.length-r.length)}`}function Rce(t){return t.includes("usage exceeded")?!1:t.includes("insufficient credits")||t.includes("openrouter.ai/settings/credits")}function oc({error:t,agentName:e}){let r=t&&typeof t=="object"?JSON.stringify(t):t,n=r?.replace(/\s+/g," ").trim().toLowerCase()||"",i="";return n?.includes("ai gateway is not available for your account")||n?.includes("ai gateway is not enabled for your account")?i="AI Gateway is currently not available on your account. Please confirm your account meets the criteria for using Agent Runners and AI Gateway and that your account has remaining AI Gateway inference credits available. Reach out to Netlify support if this is unexpected.":n?.includes("error when talking to gemini api")?i="Gemini's API is currently having issues. Please try again or use a different available agent while Google resolves the issue.":(n?.includes("connection closed prematurely")||n?.includes("499")&&e.toLowerCase().includes("gemini"))&&(i=`The ${e} models were currently overloaded. Please try again or use a different available agent.`),n?.includes("request timed out")&&(i=`The ${e} API request's have timed out. Please try again or use a different available agent.`),(n?.includes("network error")||n?.includes("socket connection was closed"))&&(i=`The ${e} agent is having network issues. Please try again or use a different available agent.`),n?.includes("503")&&!n?.includes("usage exceeded")&&(i=`The ${e} API is currently experiencing high load. Retrying automatically...`),(n?.includes("529")||n?.includes("overloaded_error"))&&(i=`The ${e} API is currently overloaded. Retrying automatically...`),n?.includes("at capacity")&&(i=`The ${e} model is currently at capacity. Retrying automatically...`),(n?.includes("there's an issue with the selected model")||n?.includes("is not available for")&&n?.includes("provider"))&&(i=`The ${e} model is temporarily unavailable. Please try again later or use a different available agent.`),Rce(n)&&(i=`${e} is temporarily unavailable. Please use a different available agent.`),i&&O2.log(`Providing updated error messsage: ${i}, replacing original error: ${r}`),i||r||void 0}function sc(t){if(!t)return!1;let r=(t&&typeof t=="object"?JSON.stringify(t):t)?.replace(/\s+/g," ").trim().toLowerCase()||"";return r?.includes("error when talking to gemini api")||r?.includes("499")||r?.includes("connection closed prematurely")||r?.includes("socket connection was closed")||r?.includes("request timed out")||r?.includes("network error")?!0:r?.includes("usage exceeded")?!1:!!(r?.includes("503")||r?.includes("529")||r?.includes("overloaded_error")||r?.includes("at capacity"))}function ac(t){if(!t)return!1;let e=t.replace(/\s+/g," ").trim().toLowerCase();return!!(e.includes("there's an issue with the selected model")||e.includes("is not available for")&&e.includes("provider")||Rce(e))}import dI from"process";import{fileURLToPath as Vze}from"url";import{createRequire as Hze}from"module";import fI from"path";import{readdir as jze,rm as zze}from"fs/promises";import{join as Gze}from"path";async function Ice(t,e=[]){let n=(await jze(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>zze(Gze(t,i),{recursive:!0,force:!0})))}var qze=700,Cce=t=>{if(t.mode!=="create")return!1;if(t.accountType===m_)return!0;let{enforcedAICreditsRemaining:e}=t;return e!=null&&e<=qze};var Wze=fI.dirname(Vze(import.meta.url)),Pce=Hze(import.meta.url),Yze=fI.resolve(Wze,"scripts/scaffold.js"),Kze="scripts/scaffold.js",Zze=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,N2=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},Jze=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),Xze=t=>{let e=N2(t);return e==="node"||e.endsWith("/node")},ks=t=>{if(typeof t!="string")return!1;let e=t.match(Zze)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&Jze(N2(e[r]));)r+=1;if(r>=e.length||!Xze(e[r]))return!1;let n=e[r+1];return n?N2(n).includes(Kze):!1},Bp=ue("create_stage"),Oce="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.",Qze=`${Oce}
|
|
219
|
+
\u2026 [truncated ${t} characters]`;function wce(t){if(t.length<=Ace)return t;let e=xce(t.length).length,r=t.slice(0,Ace-e);return`${r}${xce(t.length-r.length)}`}function Rce(t){return t.includes("usage exceeded")?!1:t.includes("insufficient credits")||t.includes("openrouter.ai/settings/credits")}function oc({error:t,agentName:e}){let r=t&&typeof t=="object"?JSON.stringify(t):t,n=r?.replace(/\s+/g," ").trim().toLowerCase()||"",i="";return n?.includes("ai gateway is not available for your account")||n?.includes("ai gateway is not enabled for your account")?i="AI Gateway is currently not available on your account. Please confirm your account meets the criteria for using Agent Runners and AI Gateway and that your account has remaining AI Gateway inference credits available. Reach out to Netlify support if this is unexpected.":n?.includes("error when talking to gemini api")?i="Gemini's API is currently having issues. Please try again or use a different available agent while Google resolves the issue.":(n?.includes("connection closed prematurely")||n?.includes("499")&&e.toLowerCase().includes("gemini"))&&(i=`The ${e} models were currently overloaded. Please try again or use a different available agent.`),n?.includes("request timed out")&&(i=`The ${e} API request's have timed out. Please try again or use a different available agent.`),(n?.includes("network error")||n?.includes("socket connection was closed"))&&(i=`The ${e} agent is having network issues. Please try again or use a different available agent.`),(n?.includes("econnreset")||n?.includes("fetch failed"))&&(i=`The ${e} agent hit a temporary connection issue. Retrying automatically...`),n?.includes("503")&&!n?.includes("usage exceeded")&&(i=`The ${e} API is currently experiencing high load. Retrying automatically...`),(n?.includes("529")||n?.includes("overloaded_error"))&&(i=`The ${e} API is currently overloaded. Retrying automatically...`),n?.includes("at capacity")&&(i=`The ${e} model is currently at capacity. Retrying automatically...`),(n?.includes("there's an issue with the selected model")||n?.includes("is not available for")&&n?.includes("provider"))&&(i=`The ${e} model is temporarily unavailable. Please try again later or use a different available agent.`),Rce(n)&&(i=`${e} is temporarily unavailable. Please use a different available agent.`),i&&O2.log(`Providing updated error messsage: ${i}, replacing original error: ${r}`),i||r||void 0}function sc(t){if(!t)return!1;let r=(t&&typeof t=="object"?JSON.stringify(t):t)?.replace(/\s+/g," ").trim().toLowerCase()||"";return r?.includes("error when talking to gemini api")||r?.includes("499")||r?.includes("connection closed prematurely")||r?.includes("socket connection was closed")||r?.includes("request timed out")||r?.includes("network error")||r?.includes("econnreset")||r?.includes("fetch failed")?!0:r?.includes("usage exceeded")?!1:!!(r?.includes("503")||r?.includes("529")||r?.includes("overloaded_error")||r?.includes("at capacity"))}function ac(t){if(!t)return!1;let e=t.replace(/\s+/g," ").trim().toLowerCase();return!!(e.includes("there's an issue with the selected model")||e.includes("is not available for")&&e.includes("provider")||Rce(e))}import dI from"process";import{fileURLToPath as Vze}from"url";import{createRequire as Hze}from"module";import fI from"path";import{readdir as jze,rm as zze}from"fs/promises";import{join as Gze}from"path";async function Ice(t,e=[]){let n=(await jze(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>zze(Gze(t,i),{recursive:!0,force:!0})))}var qze=700,Cce=t=>{if(t.mode!=="create")return!1;if(t.accountType===m_)return!0;let{enforcedAICreditsRemaining:e}=t;return e!=null&&e<=qze};var Wze=fI.dirname(Vze(import.meta.url)),Pce=Hze(import.meta.url),Yze=fI.resolve(Wze,"scripts/scaffold.js"),Kze="scripts/scaffold.js",Zze=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,N2=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},Jze=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),Xze=t=>{let e=N2(t);return e==="node"||e.endsWith("/node")},ks=t=>{if(typeof t!="string")return!1;let e=t.match(Zze)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&Jze(N2(e[r]));)r+=1;if(r>=e.length||!Xze(e[r]))return!1;let n=e[r+1];return n?N2(n).includes(Kze):!1},Bp=ue("create_stage"),Oce="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.",Qze=`${Oce}
|
|
220
220
|
|
|
221
221
|
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.`,eGe=`${Oce}
|
|
222
222
|
|
package/dist/bin.js
CHANGED
|
@@ -545,7 +545,7 @@ A: ${i}`).join(`
|
|
|
545
545
|
`),r=!0}}),i=>{r||n.send(i,e,t,s=>{if(s&&!r){let o=s.code??s.message;jf.stderr.write(`[metrics] UDP send to ${t}:${e} failed: ${o}
|
|
546
546
|
`),r=!0}})}},N6=()=>{},KSe=()=>!!jf.env.VITEST,JSe=()=>({enabled:!!jf.env.HOST_NODE_IP&&!KSe()}),qht=()=>{if(KSe())return N6;let t=jf.env.HOST_NODE_IP;if(!t)return N6;let e=jf.env.DD_AGENT_PORT,r=e===void 0?Mht:Number(e);return!Number.isInteger(r)||r<=0||r>65535?(jf.stderr.write(`[metrics] DD_AGENT_PORT="${e}" is not a valid port; metrics disabled
|
|
547
547
|
`),N6):jht(t,r)},Bht=(t=qht())=>({inc(e,r=1,n={}){t(Fb(e,r,"c",jb(n)))},gauge(e,r,n={}){t(Fb(e,r,"g",jb(n)))},histogram(e,r,n={}){t(Fb(e,r,"h",jb(n)))},timing(e,r,n={}){t(Fb(e,r,"ms",jb(n)))},distribution(e,r,n={}){t(Fb(e,r,"d",jb(n)))}}),ge=Bht(),L6=({previewDeployed:t,hadFailedAttempts:e})=>{ge.inc("deploy.final_outcome",1,{outcome:t?e?"recovered":"success":"no_preview"})},Su=(t,e={})=>{let r=t.input_tokens??0,n=t.output_tokens??0,i=t.reasoning_output_tokens??0,s=t.cache_creation_input_tokens??0,o=t.cache_read_input_tokens??0;ge.distribution("inference.tokens",r,{...e,kind:"input"}),ge.distribution("inference.tokens",n,{...e,kind:"output"}),ge.distribution("inference.tokens",i,{...e,kind:"reasoning"});let a=t.total_tokens??r+n+i+s+o;ge.distribution("inference.tokens.total",a,e)};import D6 from"path";import zht from"fs/promises";var M6=ye("agent-output-utils");async function Eu({initialResult:t,agentName:e,hasError:r}){let n="",i=D6.join(process.cwd(),rn,Ga);try{let s=await zht.readFile(i,"utf-8");s&&(n=s,M6.log(`Pulled result from ${D6.relative(process.cwd(),i)}`))}catch{M6.log(`No results file found at ${D6.relative(process.cwd(),i)}`)}return n||(!t&&!r?`${e} has finished working on task.`:t||void 0)}var Vht=[/^API Error:\s*\d{3}/i,/^\d{3}\s*status code/i,/^API request failed:\s*\d{3}/i,/^API Error: The socket connection was closed/i,/^overloaded_error/i];function $P(t){let e=t.trim();return Vht.some(r=>r.test(e))?"Encountered a temporary issue \u2014 the agent will attempt to continue.":t}var ZSe=256*1024,XSe=t=>`
|
|
548
|
-
\u2026 [truncated ${t} characters]`;function QSe(t){if(t.length<=ZSe)return t;let e=XSe(t.length).length,r=t.slice(0,ZSe-e);return`${r}${XSe(t.length-r.length)}`}function eEe(t){return t.includes("usage exceeded")?!1:t.includes("insufficient credits")||t.includes("openrouter.ai/settings/credits")}function vu({error:t,agentName:e}){let r=t&&typeof t=="object"?JSON.stringify(t):t,n=r?.replace(/\s+/g," ").trim().toLowerCase()||"",i="";return n?.includes("ai gateway is not available for your account")||n?.includes("ai gateway is not enabled for your account")?i="AI Gateway is currently not available on your account. Please confirm your account meets the criteria for using Agent Runners and AI Gateway and that your account has remaining AI Gateway inference credits available. Reach out to Netlify support if this is unexpected.":n?.includes("error when talking to gemini api")?i="Gemini's API is currently having issues. Please try again or use a different available agent while Google resolves the issue.":(n?.includes("connection closed prematurely")||n?.includes("499")&&e.toLowerCase().includes("gemini"))&&(i=`The ${e} models were currently overloaded. Please try again or use a different available agent.`),n?.includes("request timed out")&&(i=`The ${e} API request's have timed out. Please try again or use a different available agent.`),(n?.includes("network error")||n?.includes("socket connection was closed"))&&(i=`The ${e} agent is having network issues. Please try again or use a different available agent.`),n?.includes("503")&&!n?.includes("usage exceeded")&&(i=`The ${e} API is currently experiencing high load. Retrying automatically...`),(n?.includes("529")||n?.includes("overloaded_error"))&&(i=`The ${e} API is currently overloaded. Retrying automatically...`),n?.includes("at capacity")&&(i=`The ${e} model is currently at capacity. Retrying automatically...`),(n?.includes("there's an issue with the selected model")||n?.includes("is not available for")&&n?.includes("provider"))&&(i=`The ${e} model is temporarily unavailable. Please try again later or use a different available agent.`),eEe(n)&&(i=`${e} is temporarily unavailable. Please use a different available agent.`),i&&M6.log(`Providing updated error messsage: ${i}, replacing original error: ${r}`),i||r||void 0}function bu(t){if(!t)return!1;let r=(t&&typeof t=="object"?JSON.stringify(t):t)?.replace(/\s+/g," ").trim().toLowerCase()||"";return r?.includes("error when talking to gemini api")||r?.includes("499")||r?.includes("connection closed prematurely")||r?.includes("socket connection was closed")||r?.includes("request timed out")||r?.includes("network error")?!0:r?.includes("usage exceeded")?!1:!!(r?.includes("503")||r?.includes("529")||r?.includes("overloaded_error")||r?.includes("at capacity"))}function Tu(t){if(!t)return!1;let e=t.replace(/\s+/g," ").trim().toLowerCase();return!!(e.includes("there's an issue with the selected model")||e.includes("is not available for")&&e.includes("provider")||eEe(e))}import Pc from"process";import Oc from"path";import zC from"fs";import{fileURLToPath as Tbt}from"url";import{createRequire as wbt}from"module";function Sr(t){if(typeof t!="object"||t===null)return!1;let e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}import{fileURLToPath as Hht}from"url";var Lg=(t,e)=>{let r=F6(Ght(t));if(typeof r!="string")throw new TypeError(`${e} must be a string or a file URL: ${r}.`);return r},Ght=t=>U6(t)?t.toString():t,U6=t=>typeof t!="string"&&t&&Object.getPrototypeOf(t)===String.prototype,F6=t=>t instanceof URL?Hht(t):t;var LP=(t,e=[],r={})=>{let n=Lg(t,"First argument"),[i,s]=Sr(e)?[[],e]:[e,r];if(!Array.isArray(i))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${i}`);if(i.some(c=>typeof c=="object"&&c!==null))throw new TypeError(`Second argument must be an array of strings: ${i}`);let o=i.map(String),a=o.find(c=>c.includes("\0"));if(a!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${a}`);if(!Sr(s))throw new TypeError(`Last argument must be an options object: ${s}`);return[n,o,s]};import{ChildProcess as Qht}from"child_process";import{StringDecoder as Wht}from"string_decoder";var{toString:tEe}=Object.prototype,rEe=t=>tEe.call(t)==="[object ArrayBuffer]",kr=t=>tEe.call(t)==="[object Uint8Array]",wc=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),Yht=new TextEncoder,nEe=t=>Yht.encode(t),Kht=new TextDecoder,DP=t=>Kht.decode(t),iEe=(t,e)=>Jht(t,e).join(""),Jht=(t,e)=>{if(e==="utf8"&&t.every(s=>typeof s=="string"))return t;let r=new Wht(e),n=t.map(s=>typeof s=="string"?nEe(s):s).map(s=>r.write(s)),i=r.end();return i===""?n:[...n,i]},qb=t=>t.length===1&&kr(t[0])?t[0]:j6(Zht(t)),Zht=t=>t.map(e=>typeof e=="string"?nEe(e):e),j6=t=>{let e=new Uint8Array(Xht(t)),r=0;for(let n of t)e.set(n,r),r+=n.length;return e},Xht=t=>{let e=0;for(let r of t)e+=r.length;return e};var cEe=t=>Array.isArray(t)&&Array.isArray(t.raw),lEe=(t,e)=>{let r=[];for(let[s,o]of t.entries())r=emt({templates:t,expressions:e,tokens:r,index:s,template:o});if(r.length===0)throw new TypeError("Template script must not be empty");let[n,...i]=r;return[n,i,{}]},emt=({templates:t,expressions:e,tokens:r,index:n,template:i})=>{if(i===void 0)throw new TypeError(`Invalid backslash sequence: ${t.raw[n]}`);let{nextTokens:s,leadingWhitespaces:o,trailingWhitespaces:a}=tmt(i,t.raw[n]),c=oEe(r,s,o);if(n===e.length)return c;let l=e[n],u=Array.isArray(l)?l.map(d=>aEe(d)):[aEe(l)];return oEe(c,u,a)},tmt=(t,e)=>{if(e.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let r=[],n=0,i=sEe.has(e[0]);for(let o=0,a=0;o<t.length;o+=1,a+=1){let c=e[a];if(sEe.has(c))n!==o&&r.push(t.slice(n,o)),n=o+1;else if(c==="\\"){let l=e[a+1];l===`
|
|
548
|
+
\u2026 [truncated ${t} characters]`;function QSe(t){if(t.length<=ZSe)return t;let e=XSe(t.length).length,r=t.slice(0,ZSe-e);return`${r}${XSe(t.length-r.length)}`}function eEe(t){return t.includes("usage exceeded")?!1:t.includes("insufficient credits")||t.includes("openrouter.ai/settings/credits")}function vu({error:t,agentName:e}){let r=t&&typeof t=="object"?JSON.stringify(t):t,n=r?.replace(/\s+/g," ").trim().toLowerCase()||"",i="";return n?.includes("ai gateway is not available for your account")||n?.includes("ai gateway is not enabled for your account")?i="AI Gateway is currently not available on your account. Please confirm your account meets the criteria for using Agent Runners and AI Gateway and that your account has remaining AI Gateway inference credits available. Reach out to Netlify support if this is unexpected.":n?.includes("error when talking to gemini api")?i="Gemini's API is currently having issues. Please try again or use a different available agent while Google resolves the issue.":(n?.includes("connection closed prematurely")||n?.includes("499")&&e.toLowerCase().includes("gemini"))&&(i=`The ${e} models were currently overloaded. Please try again or use a different available agent.`),n?.includes("request timed out")&&(i=`The ${e} API request's have timed out. Please try again or use a different available agent.`),(n?.includes("network error")||n?.includes("socket connection was closed"))&&(i=`The ${e} agent is having network issues. Please try again or use a different available agent.`),(n?.includes("econnreset")||n?.includes("fetch failed"))&&(i=`The ${e} agent hit a temporary connection issue. Retrying automatically...`),n?.includes("503")&&!n?.includes("usage exceeded")&&(i=`The ${e} API is currently experiencing high load. Retrying automatically...`),(n?.includes("529")||n?.includes("overloaded_error"))&&(i=`The ${e} API is currently overloaded. Retrying automatically...`),n?.includes("at capacity")&&(i=`The ${e} model is currently at capacity. Retrying automatically...`),(n?.includes("there's an issue with the selected model")||n?.includes("is not available for")&&n?.includes("provider"))&&(i=`The ${e} model is temporarily unavailable. Please try again later or use a different available agent.`),eEe(n)&&(i=`${e} is temporarily unavailable. Please use a different available agent.`),i&&M6.log(`Providing updated error messsage: ${i}, replacing original error: ${r}`),i||r||void 0}function bu(t){if(!t)return!1;let r=(t&&typeof t=="object"?JSON.stringify(t):t)?.replace(/\s+/g," ").trim().toLowerCase()||"";return r?.includes("error when talking to gemini api")||r?.includes("499")||r?.includes("connection closed prematurely")||r?.includes("socket connection was closed")||r?.includes("request timed out")||r?.includes("network error")||r?.includes("econnreset")||r?.includes("fetch failed")?!0:r?.includes("usage exceeded")?!1:!!(r?.includes("503")||r?.includes("529")||r?.includes("overloaded_error")||r?.includes("at capacity"))}function Tu(t){if(!t)return!1;let e=t.replace(/\s+/g," ").trim().toLowerCase();return!!(e.includes("there's an issue with the selected model")||e.includes("is not available for")&&e.includes("provider")||eEe(e))}import Pc from"process";import Oc from"path";import zC from"fs";import{fileURLToPath as Tbt}from"url";import{createRequire as wbt}from"module";function Sr(t){if(typeof t!="object"||t===null)return!1;let e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}import{fileURLToPath as Hht}from"url";var Lg=(t,e)=>{let r=F6(Ght(t));if(typeof r!="string")throw new TypeError(`${e} must be a string or a file URL: ${r}.`);return r},Ght=t=>U6(t)?t.toString():t,U6=t=>typeof t!="string"&&t&&Object.getPrototypeOf(t)===String.prototype,F6=t=>t instanceof URL?Hht(t):t;var LP=(t,e=[],r={})=>{let n=Lg(t,"First argument"),[i,s]=Sr(e)?[[],e]:[e,r];if(!Array.isArray(i))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${i}`);if(i.some(c=>typeof c=="object"&&c!==null))throw new TypeError(`Second argument must be an array of strings: ${i}`);let o=i.map(String),a=o.find(c=>c.includes("\0"));if(a!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${a}`);if(!Sr(s))throw new TypeError(`Last argument must be an options object: ${s}`);return[n,o,s]};import{ChildProcess as Qht}from"child_process";import{StringDecoder as Wht}from"string_decoder";var{toString:tEe}=Object.prototype,rEe=t=>tEe.call(t)==="[object ArrayBuffer]",kr=t=>tEe.call(t)==="[object Uint8Array]",wc=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),Yht=new TextEncoder,nEe=t=>Yht.encode(t),Kht=new TextDecoder,DP=t=>Kht.decode(t),iEe=(t,e)=>Jht(t,e).join(""),Jht=(t,e)=>{if(e==="utf8"&&t.every(s=>typeof s=="string"))return t;let r=new Wht(e),n=t.map(s=>typeof s=="string"?nEe(s):s).map(s=>r.write(s)),i=r.end();return i===""?n:[...n,i]},qb=t=>t.length===1&&kr(t[0])?t[0]:j6(Zht(t)),Zht=t=>t.map(e=>typeof e=="string"?nEe(e):e),j6=t=>{let e=new Uint8Array(Xht(t)),r=0;for(let n of t)e.set(n,r),r+=n.length;return e},Xht=t=>{let e=0;for(let r of t)e+=r.length;return e};var cEe=t=>Array.isArray(t)&&Array.isArray(t.raw),lEe=(t,e)=>{let r=[];for(let[s,o]of t.entries())r=emt({templates:t,expressions:e,tokens:r,index:s,template:o});if(r.length===0)throw new TypeError("Template script must not be empty");let[n,...i]=r;return[n,i,{}]},emt=({templates:t,expressions:e,tokens:r,index:n,template:i})=>{if(i===void 0)throw new TypeError(`Invalid backslash sequence: ${t.raw[n]}`);let{nextTokens:s,leadingWhitespaces:o,trailingWhitespaces:a}=tmt(i,t.raw[n]),c=oEe(r,s,o);if(n===e.length)return c;let l=e[n],u=Array.isArray(l)?l.map(d=>aEe(d)):[aEe(l)];return oEe(c,u,a)},tmt=(t,e)=>{if(e.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let r=[],n=0,i=sEe.has(e[0]);for(let o=0,a=0;o<t.length;o+=1,a+=1){let c=e[a];if(sEe.has(c))n!==o&&r.push(t.slice(n,o)),n=o+1;else if(c==="\\"){let l=e[a+1];l===`
|
|
549
549
|
`?(o-=1,a+=1):l==="u"&&e[a+2]==="{"?a=e.indexOf("}",a+3):a+=rmt[l]??1}}let s=n===t.length;return s||r.push(t.slice(n)),{nextTokens:r,leadingWhitespaces:i,trailingWhitespaces:s}},sEe=new Set([" "," ","\r",`
|
|
550
550
|
`]),rmt={x:3,u:5},oEe=(t,e,r)=>r||t.length===0||e.length===0?[...t,...e]:[...t.slice(0,-1),`${t.at(-1)}${e[0]}`,...e.slice(1)],aEe=t=>{let e=typeof t;if(e==="string")return t;if(e==="number")return String(t);if(Sr(t)&&("stdout"in t||"isMaxBuffer"in t))return nmt(t);throw t instanceof Qht||Object.prototype.toString.call(t)==="[object Promise]"?new TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}."):new TypeError(`Unexpected "${e}" in template expression`)},nmt=({stdout:t})=>{if(typeof t=="string")return t;if(kr(t))return DP(t);throw t===void 0?new TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`):new TypeError(`Unexpected "${typeof t}" stdout in template expression`)};import{spawnSync as aEt}from"child_process";import{debuglog as imt}from"util";import q6 from"process";var ro=t=>MP.includes(t),MP=[q6.stdin,q6.stdout,q6.stderr],bs=["stdin","stdout","stderr"],UP=t=>bs[t]??`stdio[${t}]`;var dEe=t=>{let e={...t};for(let r of V6)e[r]=B6(t,r);return e},B6=(t,e)=>{let r=Array.from({length:smt(t)+1}),n=omt(t[e],r,e);return dmt(n,e)},smt=({stdio:t})=>Array.isArray(t)?Math.max(t.length,bs.length):bs.length,omt=(t,e,r)=>Sr(t)?amt(t,e,r):e.fill(t),amt=(t,e,r)=>{for(let n of Object.keys(t).sort(cmt))for(let i of lmt(n,r,e))e[i]=t[n];return e},cmt=(t,e)=>uEe(t)<uEe(e)?1:-1,uEe=t=>t==="stdout"||t==="stderr"?0:t==="all"?2:1,lmt=(t,e,r)=>{if(t==="ipc")return[r.length-1];let n=z6(t);if(n===void 0||n===0)throw new TypeError(`"${e}.${t}" is invalid.
|
|
551
551
|
It must be "${e}.stdout", "${e}.stderr", "${e}.all", "${e}.ipc", or "${e}.fd3", "${e}.fd4" (and so on).`);if(n>=r.length)throw new TypeError(`"${e}.${t}" is invalid: that file descriptor does not exist.
|
|
@@ -587,7 +587,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
587
587
|
`,LF:`
|
|
588
588
|
`,concatBytes:P3},ISt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},OSt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:ISt};import{Buffer as PSt}from"buffer";var PTe=(t,e)=>t?void 0:CSt.bind(void 0,e),CSt=function*(t,e){if(typeof e!="string"&&!kr(e)&&!PSt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},CTe=(t,e)=>t?NSt.bind(void 0,e):kSt.bind(void 0,e),NSt=function*(t,e){NTe(t,e),yield e},kSt=function*(t,e){if(NTe(t,e),typeof e!="string"&&!kr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},NTe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
589
589
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
590
|
-
if (condition) { yield value; }`)};import{Buffer as $St}from"buffer";import{StringDecoder as LSt}from"string_decoder";var xC=(t,e,r)=>{if(r)return;if(t)return{transform:DSt.bind(void 0,new TextEncoder)};let n=new LSt(e);return{transform:MSt.bind(void 0,n),final:USt.bind(void 0,n)}},DSt=function*(t,e){$St.isBuffer(e)?yield wc(e):typeof e=="string"?yield t.encode(e):yield e},MSt=function*(t,e){yield kr(e)?t.write(e):e},USt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as kTe}from"util";var N3=kTe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),IC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=jSt}=e[r];for await(let i of n(t))yield*IC(i,e,r+1)},$Te=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*FSt(r,Number(e),t)},FSt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*IC(n,r,e+1)},LTe=kTe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),jSt=function*(t){yield t};var k3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},DTe=(t,e)=>[...e.flatMap(r=>[...Hf(r,t,0)]),...Zb(t)],Hf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=BSt}=e[r];for(let i of n(t))yield*Hf(i,e,r+1)},Zb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*qSt(r,Number(e),t)},qSt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Hf(n,r,e+1)},BSt=function*(t){yield t};var $3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=UTe(t,o,s),l=Vf(e),u=Vf(r),d=l?N3.bind(void 0,IC,a):k3.bind(void 0,Hf),f=l||u?N3.bind(void 0,$Te,a):k3.bind(void 0,Zb),p=l||u?LTe.bind(void 0,a):void 0;return{stream:new zSt({writableObjectMode:n,writableHighWaterMark:MTe(n),readableObjectMode:i,readableHighWaterMark:MTe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},OC=(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=UTe(o,r,a);t=DTe(c,t)}return t},UTe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:PTe(n,a)},xC(r,o,n),RC(r,s,n,c),{transform:t,final:e},{transform:CTe(i,a)},OTe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var FTe=(t,e)=>{for(let r of VSt(t))HSt(t,r,e)},VSt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),HSt=(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 ${Ru[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>GSt(a,n));r.input=qb(o)},GSt=(t,e)=>{let r=OC(t,e,"utf8",!0);return WSt(r),qb(r)},WSt=t=>{let e=t.find(r=>typeof r!="string"&&!kr(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 ZSt,appendFileSync as XSt}from"fs";var PC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Mg(r,n)&&!ji.has(e)&&YSt(n)&&(t.some(({type:i,value:s})=>i==="native"&&KSt.has(s))||t.every(({type:i})=>Ts.has(i))),YSt=t=>t===1||t===2,KSt=new Set(["pipe","overlapped"]),jTe=async(t,e,r,n)=>{for await(let i of t)JSt(e)||BTe(i,r,n)},qTe=(t,e,r)=>{for(let n of t)BTe(n,e,r)},JSt=t=>t._readableState.pipes.length>0,BTe=(t,e,r)=>{let n=VP(t);na({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var zTe=({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)=>QSt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},QSt=({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=Vbe(t,s,d),p=wc(f),{stdioItems:h,objectMode:m}=e[r],_=eEt([p],h,c,n),{serializedResult:y,finalResult:v=y}=tEt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});rEt({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&&nEt(y,h,i),S}catch(g){return n.error=g,S}},eEt=(t,e,r,n)=>{try{return OC(t,e,r,!1)}catch(i){return n.error=i,t}},tEt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qb(t)};let o=iEe(t,r);return n[s]?{serializedResult:o,finalResult:C3(o,!i[s],e)}:{serializedResult:o}},rEt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!PC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=C3(t,!1,o);try{qTe(a,e,n)}catch(c){r.error??=c}},nEt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>wC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?XSt(n,t):(r.add(s),ZSt(n,t))}};var VTe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,xc(e,r,"all")]:Array.isArray(e)?[xc(t,r,"all"),...e]:kr(t)&&kr(e)?j6([t,e]):`${t}${e}`};import{once as L3}from"events";var HTe=async(t,e)=>{let[r,n]=await iEt(t);return e.isForcefullyTerminated??=!1,[r,n]},iEt=async t=>{let[e,r]=await Promise.allSettled([L3(t,"spawn"),L3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?GTe(t):r.value},GTe=async t=>{try{return await L3(t,"exit")}catch{return GTe(t)}},WTe=async t=>{let[e,r]=await t;if(!sEt(e,r)&&D3(e,r))throw new no;return[e,r]},sEt=(t,e)=>t===void 0&&e===void 0,D3=(t,e)=>t!==0||e!==null;var YTe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=oEt(t,e,r),o=s?.code==="ETIMEDOUT",a=zbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},oEt=(t,e,r)=>t!==void 0?t:D3(e,r)?new no:void 0;var KTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=cEt(t,e,r),d=dEt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Wg(d,c,l)},cEt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=GP(t,e,r),a=lEt(r),{file:c,commandArguments:l,options:u}=fC(t,e,a);uEt(u);let d=ATe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},lEt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,uEt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&CC("ipcInput"),t&&CC("ipc: true"),r&&CC("detached: true"),n&&CC("cancelSignal")},CC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},dEt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=fEt({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}=YTe(c,r),{output:h,error:m=l}=zTe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>xc(v,r,S)),y=xc(VTe(h,r),r,"all");return hEt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},fEt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{FTe(s,r);let a=pEt(r);return aEt(...pC(t,e,a))}catch(a){return Gg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},pEt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:EC(e)}),hEt=({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?vC({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Jb({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 tbt}from"events";import{spawn as rbt}from"child_process";import ewe from"process";import{once as M3,on as mEt}from"events";var JTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(jg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:oC(t)}),gEt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),gEt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{rC(e,i);let s=Au(t,e,r),o=new AbortController;try{return await Promise.race([_Et(s,n,o),yEt(s,r,o),SEt(s,r,o)])}catch(a){throw qg(t),a}finally{o.abort(),nC(e,i)}},_Et=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await M3(t,"message",{signal:r});return n}for await(let[n]of mEt(t,"message",{signal:r}))if(e(n))return n},yEt=async(t,e,{signal:r})=>{await M3(t,"disconnect",{signal:r}),Dve(e)},SEt=async(t,e,{signal:r})=>{let[n]=await M3(t,"strict:error",{signal:r});throw QP(n,e)};import{once as XTe,on as EEt}from"events";var QTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>U3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),U3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{jg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:oC(t)}),rC(e,s);let o=Au(t,e,r),a=new AbortController,c={};return vEt(t,o,a),bEt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),TEt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},vEt=async(t,e,r)=>{try{await XTe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},bEt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await XTe(t,"strict:error",{signal:r.signal});n.error=QP(i,e),r.abort()}catch{}},TEt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of EEt(r,"message",{signal:s.signal}))ZTe(o),yield c}catch{ZTe(o)}finally{s.abort(),nC(e,a),n||qg(t),i&&await t}},ZTe=({error:t})=>{if(t)throw t};var twe=(t,{ipc:e})=>{Object.assign(t,nwe(t,!1,e))},rwe=()=>{let t=ewe,e=!0,r=ewe.channel!==void 0;return{...nwe(t,e,r),getCancelSignal:lbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},nwe=(t,e,r)=>({sendMessage:uC.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:JTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:QTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as wEt}from"child_process";import{PassThrough as AEt,Readable as REt,Writable as xEt,Duplex as IEt}from"stream";var iwe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{I3(n);let a=new wEt;OEt(a,n),Object.assign(a,{readable:PEt,writable:CEt,duplex:NEt});let c=Gg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=kEt(c,o,i);return{subprocess:a,promise:l}},OEt=(t,e)=>{let r=Xb(),n=Xb(),i=Xb(),s=Array.from({length:e.length-3},Xb),o=Xb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Xb=()=>{let t=new AEt;return t.end(),t},PEt=()=>new REt({read(){}}),CEt=()=>new xEt({write(){}}),NEt=()=>new IEt({read(){},write(){}}),kEt=async(t,e,r)=>Wg(t,e,r);import{createReadStream as swe,createWriteStream as owe}from"fs";import{Buffer as $Et}from"buffer";import{Readable as Qb,Writable as LEt,Duplex as DEt}from"stream";var cwe=(t,e)=>AC(MEt,t,e,!1),eT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ru[t]}.`)},awe={fileNumber:eT,generator:$3,asyncGenerator:$3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:DEt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},MEt={input:{...awe,fileUrl:({value:t})=>({stream:swe(t)}),filePath:({value:{file:t}})=>({stream:swe(t)}),webStream:({value:t})=>({stream:Qb.fromWeb(t)}),iterable:({value:t})=>({stream:Qb.from(t)}),asyncIterable:({value:t})=>({stream:Qb.from(t)}),string:({value:t})=>({stream:Qb.from(t)}),uint8Array:({value:t})=>({stream:Qb.from($Et.from(t))})},output:{...awe,fileUrl:({value:t})=>({stream:owe(t)}),filePath:({value:{file:t,append:e}})=>({stream:owe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:LEt.fromWeb(t)}),iterable:eT,asyncIterable:eT,string:eT,uint8Array:eT}};import{on as UEt,once as lwe}from"events";import{PassThrough as FEt,getDefaultHighWaterMark as jEt}from"stream";import{finished as fwe}from"stream/promises";function Gf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)j3(i);let e=t.some(({readableObjectMode:i})=>i),r=qEt(t,e),n=new F3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var qEt=(t,e)=>{if(t.length===0)return jEt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},F3=class extends FEt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(j3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=BEt(this,this.#e,this.#s);let r=HEt({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(j3(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)}},BEt=async(t,e,r)=>{NC(t,uwe);let n=new AbortController;try{await Promise.race([zEt(t,n),VEt(t,e,r,n)])}finally{n.abort(),NC(t,-uwe)}},zEt=async(t,{signal:e})=>{try{await fwe(t,{signal:e,cleanup:!0})}catch(r){throw pwe(t,r),r}},VEt=async(t,e,r,{signal:n})=>{for await(let[i]of UEt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},j3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},HEt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{NC(t,dwe);let a=new AbortController;try{await Promise.race([GEt(s,e,a),WEt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),YEt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),NC(t,-dwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?q3(t):KEt(t))},GEt=async(t,e,{signal:r})=>{try{await t,r.aborted||q3(e)}catch(n){r.aborted||pwe(e,n)}},WEt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await fwe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;hwe(o)?i.add(e):mwe(t,o)}},YEt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await lwe(t,i,{signal:s}),!t.readable)return lwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},KEt=t=>{t.writable&&t.end()},pwe=(t,e)=>{hwe(e)?q3(t):mwe(t,e)},hwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",q3=t=>{(t.readable||t.writable)&&t.destroy()},mwe=(t,e)=>{t.destroyed||(t.once("error",JEt),t.destroy(e))},JEt=()=>{},NC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},uwe=2,dwe=1;import{finished as gwe}from"stream/promises";var Kg=(t,e)=>{t.pipe(e),ZEt(t,e),XEt(t,e)},ZEt=async(t,e)=>{if(!(ro(t)||ro(e))){try{await gwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}B3(e)}},B3=t=>{t.writable&&t.end()},XEt=async(t,e)=>{if(!(ro(t)||ro(e))){try{await gwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}z3(t)}},z3=t=>{t.readable&&t.destroy()};var _we=(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})=>Ts.has(c)))QEt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ts.has(c)))tvt({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]:Gf(s);Kg(o,i)}},QEt=(t,e,r,n)=>{r==="output"?Kg(t.stdio[n],e):Kg(e,t.stdio[n]);let i=evt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},evt=["stdin","stdout","stderr"],tvt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;rvt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},rvt=(t,{signal:e})=>{ro(t)&&Bf(t,nvt,e)},nvt=2;import{addAbortListener as ovt}from"events";var Wf=[];Wf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Wf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Wf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var kC=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",V3=Symbol.for("signal-exit emitter"),H3=globalThis,ivt=Object.defineProperty.bind(Object),G3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(H3[V3])return H3[V3];ivt(H3,V3,{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}},$C=class{},svt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),W3=class extends $C{onExit(){return()=>{}}load(){}unload(){}},Y3=class extends $C{#e=K3.platform==="win32"?"SIGINT":"SIGHUP";#r=new G3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Wf)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(!kC(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 Wf)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,Wf.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 kC(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"&&kC(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)}},K3=globalThis.process,{onExit:ywe,load:pur,unload:hur}=svt(kC(K3)?new Y3(K3):new W3);var Swe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ywe(()=>{t.kill()});ovt(n,()=>{i()})};var vwe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=HP(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=avt(r,n,i),{sourceStream:d,sourceError:f}=lvt(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}},avt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=cvt(t,e,...r),a=tC(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},cvt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Ewe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||U6(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]=LP(r,...n);return{destination:e(Ewe)(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}`)},Ewe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),lvt=(t,e)=>{try{return{sourceStream:Bg(t,e)}}catch(r){return{sourceError:r}}};var Twe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=uvt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw J3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},uvt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return z3(t),n;if(e!==void 0)return B3(r),e},J3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Gg({error:t,command:bwe,escapedCommand:bwe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),bwe="source.pipe(destination)";var wwe=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 dvt}from"stream/promises";var Awe=(t,e,r)=>{let n=LC.has(e)?pvt(t,e):fvt(t,e);return Bf(t,mvt,r.signal),Bf(e,gvt,r.signal),hvt(e),n},fvt=(t,e)=>{let r=Gf([t]);return Kg(r,e),LC.set(e,r),r},pvt=(t,e)=>{let r=LC.get(e);return r.add(t),r},hvt=async t=>{try{await dvt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}LC.delete(t)},LC=new WeakMap,mvt=2,gvt=1;import{aborted as _vt}from"util";var Rwe=(t,e)=>t===void 0?[]:[yvt(t,e)],yvt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await _vt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw J3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var DC=(t,...e)=>{if(Sr(e[0]))return DC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=vwe(t,...e),i=Svt({...n,destination:r});return i.pipe=DC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Svt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=Evt(t,i);Twe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Awe(e,s,d);return await Promise.race([wwe(u),...Rwe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},Evt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as xvt}from"timers/promises";import{on as vvt}from"events";import{getDefaultHighWaterMark as bvt}from"stream";var MC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Tvt(e,o),Iwe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Tvt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Z3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;wvt(e,o,t);let a=t.readableObjectMode&&!s;return Iwe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},wvt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Iwe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=vvt(t,"data",{signal:e.signal,highWaterMark:xwe,highWatermark:xwe});return Avt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},X3=bvt(!0),xwe=X3,Avt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=Rvt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Hf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Zb(a)}},Rvt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[xC(t,r,!e),RC(t,i,!n,{})].filter(Boolean);var Owe=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=Ivt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([Ovt(t),d]);return}let f=O3(c,r),p=Z3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([Pvt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},Ivt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!PC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=Z3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await jTe(a,t,r,s)},Ovt=async t=>{await xvt(),t.readableFlowing===null&&t.resume()},Pvt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await _C(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await yC(r,{maxBuffer:s})):await Hg(r,{maxBuffer:s})}catch(a){return Pwe(jbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},Q3=async t=>{try{return await t}catch(e){return Pwe(e)}},Pwe=({bufferedData:t})=>rEe(t)?new Uint8Array(t):t;import{finished as Cvt}from"stream/promises";var tT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=Nvt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Cvt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Lvt(a,e,r,n)}finally{o.abort()}},Nvt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&kvt(t,r,n),n},kvt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{$vt(e,r),n.call(t,...i)}},$vt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Lvt=(t,e,r,n)=>{if(!Dvt(t,e,r,n))throw t},Dvt=(t,e,r,n=!0)=>r.propagating?Cwe(t)||UC(t):(r.propagating=!0,eW(r,e)===n?Cwe(t):UC(t)),eW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",UC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Cwe=t=>t?.code==="EPIPE";var Nwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>tW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),tW=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=tT(t,e,l);if(eW(l,e)){await u;return}let[d]=await Promise.all([Owe({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 kwe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Gf([t,e].filter(Boolean)):void 0,$we=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>tW({...Mvt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Uvt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Mvt=({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}},Uvt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Fvt}from"events";var Lwe=t=>Mg(t,"ipc"),Dwe=(t,e)=>{let r=VP(t);na({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Mwe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Lwe(s),a=Ac(e,"ipc"),c=Ac(r,"ipc");for await(let l of U3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(qbe(t,i,c),i.push(l)),o&&Dwe(l,s);return i},Uwe=async(t,e)=>(await Promise.allSettled([t]),e);var Fwe=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=HTe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Nwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),T=$we({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),I=[],x=Mwe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),R=jvt(m,t,S),O=qvt(h,S);try{return await Promise.race([Promise.all([{},WTe(v),Promise.all(g),T,x,Sbe(t,d),...R,...O]),_,Bvt(t,y),...hbe(t,s,f,y),...Lve({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...fbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(A){return f.terminationReason??="other",Promise.all([{error:A},v,Promise.all(g.map(b=>Q3(b))),Q3(T),Uwe(x,I),Promise.allSettled(R),Promise.allSettled(O)])}},jvt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:tT(n,i,r)),qvt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>so(s,{checkOpen:!1})&&!ro(s)).map(({type:i,value:s,stream:o=s})=>tT(o,n,e,{isSameDirection:Ts.has(i),stopOnExit:i==="native"}))),Bvt=async(t,{signal:e})=>{let[r]=await Fvt(t,"error",{signal:e});throw r};var jwe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),rT=(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}},Jg=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 zvt}from"stream";import{callbackify as Vvt}from"util";import{finished as qwe}from"stream/promises";var rW=async t=>{if(t!==void 0)try{await nW(t)}catch{}},Bwe=async t=>{if(t!==void 0)try{await iW(t)}catch{}},nW=async t=>{await qwe(t,{cleanup:!0,readable:!1,writable:!0})},iW=async t=>{await qwe(t,{cleanup:!0,readable:!0,writable:!1})},FC=async(t,e)=>{if(await t,e)throw e},jC=(t,e,r)=>{r&&!UC(r)?t.destroy(r):e&&t.destroy()};var zwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ji.has(r),{subprocessStdout:a,waitReadableDestroy:c}=sW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=oW(a,o),{read:f,onStdoutDataDone:p}=aW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new zvt({read:f,destroy:Vvt(lW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return cW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},sW=(t,e,r)=>{let n=Bg(t,e),i=rT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},oW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:X3},aW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ia(),o=MC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Hvt(this,o,s)},onStdoutDataDone:s}},Hvt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},cW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await iW(t),await n,await rW(i),await e,r.readable&&r.push(null)}catch(s){await rW(i),Vwe(r,s)}},lW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Jg(r,e)&&(Vwe(t,n),await FC(e,n))},Vwe=(t,e)=>{jC(t,t.readable,e)};import{Writable as Gvt}from"stream";import{callbackify as Hwe}from"util";var Gwe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=uW(t,r,e),o=new Gvt({...dW(n,t,i),destroy:Hwe(pW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return fW(n,o),o},uW=(t,e,r)=>{let n=tC(t,e),i=rT(r,n,"writableFinal"),s=rT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},dW=(t,e,r)=>({write:Wvt.bind(void 0,t),final:Hwe(Yvt.bind(void 0,t,e,r))}),Wvt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Yvt=async(t,e,r)=>{await Jg(r,e)&&(t.writable&&t.end(),await e)},fW=async(t,e,r)=>{try{await nW(t),e.writable&&e.end()}catch(n){await Bwe(r),Wwe(e,n)}},pW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Jg(r,e),await Jg(n,e)&&(Wwe(t,i),await FC(e,i))},Wwe=(t,e)=>{jC(t,t.writable,e)};import{Duplex as Kvt}from"stream";import{callbackify as Jvt}from"util";var Ywe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ji.has(r),{subprocessStdout:c,waitReadableDestroy:l}=sW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=uW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=oW(c,a),{read:_,onStdoutDataDone:y}=aW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new Kvt({read:_,...dW(u,t,d),destroy:Jvt(Zvt.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 cW({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),fW(u,v,c),v},Zvt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([lW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),pW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var hW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ji.has(e),o=Bg(t,r),a=MC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return Xvt(a,o,t)},Xvt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Kwe=(t,{encoding:e})=>{let r=jwe();t.readable=zwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Gwe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Ywe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=hW.bind(void 0,t,e),t[Symbol.asyncIterator]=hW.bind(void 0,t,e,{})};var Jwe=(t,e)=>{for(let[r,n]of ebt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Qvt=(async()=>{})().constructor.prototype,ebt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Qvt,t)]);var Zwe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=nbt(t,e,r),{subprocess:f,promise:p}=sbt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=DC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Jwe(f,p),sa.set(f,{options:u,fileDescriptors:d}),f},nbt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=GP(t,e,r),{file:a,commandArguments:c,options:l}=fC(t,e,r),u=ibt(l),d=cwe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},ibt=({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}},sbt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=rbt(...pC(t,e,r))}catch(h){return iwe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;tbt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];_we(c,a,l),Swe(c,r,l);let d={},f=ia();c.kill=kve.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=kwe(c,r),Kwe(c,r),twe(c,r);let p=obt({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}},obt=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 Fwe({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)=>xc(g,e,T)),v=xc(m,e,"all"),S=abt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Wg(S,n,e)},abt=({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?Jb({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}):vC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var qC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,cbt(n,t[n],i)]));return{...t,...r}},cbt=(t,e,r)=>lbt.has(t)&&Sr(e)&&Sr(r)?{...e,...r}:r,lbt=new Set(["env",...V6]);var xu=(t,e,r,n)=>{let i=(o,a,c)=>xu(o,a,r,c),s=(...o)=>ubt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},ubt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Sr(s))return i(t,qC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=dbt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?KTe(a,c,l):Zwe(a,c,l,i)},dbt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=cEe(e)?lEe(e,r):[e,...r],[o,a,c]=LP(...s),l=qC(qC(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 Xwe=({file:t,commandArguments:e})=>e0e(t,e),Qwe=({file:t,commandArguments:e})=>({...e0e(t,e),isSync:!0}),e0e=(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]=fbt(t);return{file:r,commandArguments:n}},fbt=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(pbt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},pbt=/ +/g;var t0e=(t,e,r)=>{t.sync=e(hbt,r),t.s=t.sync},r0e=({options:t})=>n0e(t),hbt=({options:t})=>({...n0e(t),isSync:!0}),n0e=t=>({options:{...mbt(t),...t}}),mbt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},i0e={preferLocal:!0};var s0e=xu(()=>({})),npr=xu(()=>({isSync:!0})),o0e=xu(Xwe),ipr=xu(Qwe),spr=xu(gbe),opr=xu(r0e,{},i0e,t0e),{sendMessage:apr,getOneMessage:cpr,getEachMessage:lpr,getCancelSignal:upr}=rwe();import{Transform as gbt}from"stream";var _bt=["NETLIFY_AI_GATEWAY_KEY"];function ybt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,..._bt])]}function Sbt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function Ebt(){let e=ybt().map(r=>process.env[r]).filter(r=>!(!r||Sbt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function ws(t){if(typeof t!="string")return t;let e=Ebt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(vbt(n),"g");r=r.replace(i,"******")}),r}function vbt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var nT=class extends gbt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=ws(i);n(null,s)}},BC=Symbol("maskedWrite");function a0e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[BC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?ws(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[BC]=!0,process.stdout.write=r}if(!process.stderr.write[BC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?ws(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[BC]=!0,process.stderr.write=r}}}var c0e=!1,l0e=()=>{c0e=!0},Si=()=>c0e;var iT=null,u0e=t=>(iT&&iT.destroy(),iT=new Ic({totalAllowedTime:t}),iT),d0e=()=>iT;var Ic=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&&Si())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 kP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ge.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 f0e={name:"@netlify/agent-runner-cli",type:"module",version:"1.159.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.4","@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 Abt=Tbt(import.meta.url),Rbt=Oc.dirname(Abt),xbt=wbt(import.meta.url),Zg=ye("shell"),mW=new Set,p0e={preferLocal:!0},hn=(t,e,r)=>{let[n,i]=Ibt(e,r),s={...p0e,...i},o=s0e(t,n,s);m0e(o,s),y0e(o);let a=r?.idleTimeout;return a&&a>0&&_0e(o,a),o},h0e=(t,e)=>{let r={...p0e,...e},n=o0e(t,r);return m0e(n,r),y0e(n),e?.idleTimeout&&e.idleTimeout>0&&_0e(n,e.idleTimeout),n},Ibt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},m0e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Pc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new nT).pipe(Pc.stdout),t.stderr?.pipe(new nT).pipe(Pc.stderr);return}t.stdout?.pipe(Pc.stdout),t.stderr?.pipe(Pc.stderr)},gW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Pc.kill(-t.pid,e),Zg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Zg.error("Error killing process:",r),!1}},g0e=t=>gW(t,"SIGKILL"),_0e=(t,e)=>{let r=null,n=()=>{Zg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),gW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zg.log(`Force killing idle process ${t.pid}`),g0e(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)},y0e=t=>{mW.add(t);let e=d0e();if(e){let r=e.onTimesUp(()=>{Zg.log(`Global timer expired, killing process ${t.pid}`),gW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zg.log(`Force killing process ${t.pid} after timeout`),g0e(t))},5e3)});t.on("exit",()=>{mW.delete(t),r()}),t.on("error",()=>{mW.delete(t),r()})}};function ca(t,e){if(!Pc.env.NETLIFY_LOCAL_MODE)try{let i=xbt.resolve(f0e.name),s=Oc.dirname(i);for(;s!==Oc.dirname(s);){let o=Oc.dirname(s);if(Oc.basename(o)==="node_modules"){let a=Oc.join(o,".bin",e);if(zC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Pc.env.NODE_PATH){let i=Oc.join(Pc.env.NODE_PATH,".bin",e);if(zC.existsSync(i))return i}let r=Oc.join(t,"node_modules",".bin",e);if(zC.existsSync(r))return r;let n=Oc.join(Rbt,"..","node_modules",".bin",e);if(zC.existsSync(n))return n}import fD from"process";import{fileURLToPath as nDt}from"url";import{createRequire as iDt}from"module";import pD from"path";var Obt="__netlify__getTracer",Pbt="__netlify__shutdownTracers",mt=(t,e)=>globalThis[Obt]?.(t,e),S0e=async()=>globalThis[Pbt]?.();function Yf(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 JLt}from"timers/promises";Ne();import Cwt from"process";Ne();var eTt=(t,e)=>{e.recordException(t),e.setStatus({code:Cn.ERROR})};var kc=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}=fAe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>pAe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=fAe(r,n,i),c=this._tracer.startSpan(e,s,o);return pAe(c,s,a)}};function fAe(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 pAe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:eTt,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 i_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var JW=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=TAe(e),n._asyncAttributesPending=e.filter(([i,s])=>i_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(i_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=TAe(this._rawAttributes),this._schemaUrl=tTt(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,i_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ce.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(i_(n)){ce.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=rTt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function ZW(t,e){return JW.FromAttributeList(Object.entries(t),e)}function TAe(t){return t.map(([e,r])=>i_(r)?[e,r.catch(n=>{ce.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function tTt(t){if(typeof t=="string"||t===void 0)return t;ce.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function rTt(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;ce.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var gT=class{emit(e){}enabled(){return!1}},wAe=new gT;var _T=Symbol.for("io.opentelemetry.js.api.logs"),s_=globalThis;function AAe(t,e,r){return n=>n===t?e:r}var XW=1;var QW=class{getLogger(e,r,n){return new gT}},fN=new QW;var pN=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):wAe}};var yT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new pN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:fN}_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 hN=class t{constructor(){this._proxyLoggerProvider=new yT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return s_[_T]?this.getLoggerProvider():(s_[_T]=AAe(XW,e,fN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=s_[_T])===null||e===void 0?void 0:e.call(s_,XW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete s_[_T],this._proxyLoggerProvider=new yT}};var RAe=hN.getInstance();function xAe(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 IAe(t){t.forEach(e=>e.disable())}function eY(t){let e=t.tracerProvider||At.getTracerProvider(),r=t.meterProvider||mT.getMeterProvider(),n=t.loggerProvider||RAe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return xAe(i,e,r,n),()=>{IAe(i)}}Ne();var nTt=zr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function OAe(t){return t.getValue(nTt)===!0}var o_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(o_||(o_={}));Ne();var tY="[_0-9a-z-*/]",iTt=`[a-z]${tY}{0,255}`,sTt=`[a-z0-9]${tY}{0,240}@[a-z]${tY}{0,13}`,oTt=new RegExp(`^(?:${iTt}|${sTt})$`),aTt=/^[ -~]{0,255}[!-~]$/,cTt=/,|=/;function rY(t){return oTt.test(t)}function nY(t){return aTt.test(t)&&!cTt.test(t)}var lTt=32,PAe=512,CAe=",",NAe="=",mN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!rY(e)||!nY(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>PAe)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=CAe+e),e=`${n[0]}${NAe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(CAe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(NAe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!rY(a)||!nY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>PAe)&&(r.set(a,c),n=l,r.size>=lTt))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 gN="traceparent",_N="tracestate",uTt="00",dTt="(?!ff)[\\da-f]{2}",fTt="(?![0]{32})[\\da-f]{32}",pTt="(?![0]{16})[\\da-f]{16}",hTt="[\\da-f]{2}",mTt=new RegExp(`^\\s?(${dTt})-(${fTt})-(${pTt})-(${hTt})(-.*)?\\s?$`);function kAe(t){let e=mTt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Pu=class{inject(e,r,n){let i=At.getSpanContext(e);if(!i||OAe(e)||!Ei(i))return;let s=`${uTt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||pr.NONE).toString(16)}`;n.set(r,gN,s),i.traceState&&n.set(r,_N,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,gN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=kAe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,_N);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new mN(typeof c=="string"?c:void 0)}return At.setSpanContext(e,o)}fields(){return[gN,_N]}};var yN=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 ST=class{_isCalled=!1;_deferred=new yN;_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 lk=jn(BY(),1);Ne();var mIe=t=>{throw TypeError(t)},GY=(t,e,r)=>e.has(t)||mIe("Cannot "+r),ck=(t,e,r)=>(GY(t,e,"read from private field"),r?r.call(t):e.get(t)),zY=(t,e,r)=>e.has(t)?mIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),fIe=(t,e,r,n)=>(GY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Pwt=(t,e,r)=>(GY(t,e,"access private method"),r),pIe="__netlify__getTracer",Nwt="__netlify__shutdownTracers",kwt="__nfOTLPTrace",$T,LT,HY,gIe,$wt=class{constructor(){zY(this,HY),zY(this,$T),zY(this,LT),fIe(this,$T,new ST(Pwt(this,HY,gIe),this)),fIe(this,LT,ce.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(ck(this,LT).debug(`export ${t.length.toString()} spans`),ck(this,$T).isCalled){e({code:o_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(kwt,JSON.stringify(Lwt(t))),e({code:o_.SUCCESS})}shutdown(){return ck(this,$T).call()}};$T=new WeakMap;LT=new WeakMap;HY=new WeakSet;gIe=function(){return ck(this,LT).debug("Shutting down"),Promise.resolve()};function Lwt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:ak(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||oo.SERVER,startTimeUnixNano:VY(e.startTime),endTimeUnixNano:VY(e.endTime),attributes:ak(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:VY(n.time),attributes:ak(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:ak(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function ak(t){return Object.keys(t).map(e=>_Ie(e,t[e]))}function _Ie(t,e){return{key:t,value:yIe(e)}}function yIe(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(yIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>_Ie(r,n))}}:{}}function VY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var hIe={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"}},SIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,pIe))return;let e=Cwt.version.slice(1),r=ZW({"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??[Dwt()],i=new lk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Pu});let s=t.instrumentations??[];eY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,pIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new kc(At.getTracer(a,c)):new kc(At.getTracer(hIe.name,hIe.version))}}),Object.defineProperty(globalThis,Nwt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Dwt=()=>new lk.SimpleSpanProcessor(new $wt);Ne();var DT=jn(BY(),1);Ne();import*as uk from"diagnostics_channel";var EIe=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?Cn.ERROR:Cn.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 kc?t:new kc(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){uk.subscribe(t,e);let r=()=>uk.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:oo.CLIENT},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:Cn.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 VDe=jn(BDe(),1);var uD=ye("tracing"),zDe=8e3,ZLt=5e3,e0=async(t=ZLt)=>{try{await Promise.race([S0e(),JLt(t)])}catch(e){uD.warn("Failed to flush tracers on shutdown",e)}},HDe=async(t,e,r)=>{if(!mt()){let n=[new DT.SimpleSpanProcessor(new WJ),new DT.SimpleSpanProcessor(new VDe.OTLPTraceExporter({url:r.exporterUrl}))];await SIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new EIe({skipHeaders:!0})]})}return r.traceparent?(Xn.setGlobalPropagator(new Pu),Xn.extract(jt.active(),{traceparent:r.traceparent,isRemote:!0})):jt.active()};function Gt(t,e,r){return uD.log(`\u23F3 TRACE: ${e} starting...`),Yf(t,e,r)}var WJ=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(", ")}]`:"";uD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&uD.log(` \u274C Error: ${e.status.message}`)}};function YJ(){return Be().captureLlmContentEnabled}function GDe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function dD(t,e,r){let n={role:t,parts:[{type:"text",content:ws(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var XLt=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 WDe(t,e,r,n){if(!t.length)return;let i=mt();if(!i)return;let s=YJ(),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&&XLt.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>zDe?`${a.message.slice(0,zDe)}\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":ws(_)}:{"gen_ai.output.messages":dD("assistant",_)}:{}}}).end(u)})}import{readdir as QLt,rm as eDt}from"fs/promises";import{join as tDt}from"path";async function YDe(t,e=[]){let n=(await QLt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>eDt(tDt(t,i),{recursive:!0,force:!0})))}var rDt=700,KDe=t=>{if(t.mode!=="create")return!1;if(t.accountType===Al)return!0;let{enforcedAICreditsRemaining:e}=t;return e!=null&&e<=rDt};var sDt=pD.dirname(nDt(import.meta.url)),JDe=iDt(import.meta.url),oDt=pD.resolve(sDt,"scripts/scaffold.js"),aDt="scripts/scaffold.js",cDt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,KJ=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},lDt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),uDt=t=>{let e=KJ(t);return e==="node"||e.endsWith("/node")},nl=t=>{if(typeof t!="string")return!1;let e=t.match(cDt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&lDt(KJ(e[r]));)r+=1;if(r>=e.length||!uDt(e[r]))return!1;let n=e[r+1];return n?KJ(n).includes(aDt):!1},_y=ye("create_stage"),ZDe="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.",dDt=`${ZDe}
|
|
590
|
+
if (condition) { yield value; }`)};import{Buffer as $St}from"buffer";import{StringDecoder as LSt}from"string_decoder";var xC=(t,e,r)=>{if(r)return;if(t)return{transform:DSt.bind(void 0,new TextEncoder)};let n=new LSt(e);return{transform:MSt.bind(void 0,n),final:USt.bind(void 0,n)}},DSt=function*(t,e){$St.isBuffer(e)?yield wc(e):typeof e=="string"?yield t.encode(e):yield e},MSt=function*(t,e){yield kr(e)?t.write(e):e},USt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as kTe}from"util";var N3=kTe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),IC=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=jSt}=e[r];for await(let i of n(t))yield*IC(i,e,r+1)},$Te=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*FSt(r,Number(e),t)},FSt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*IC(n,r,e+1)},LTe=kTe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),jSt=function*(t){yield t};var k3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},DTe=(t,e)=>[...e.flatMap(r=>[...Hf(r,t,0)]),...Zb(t)],Hf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=BSt}=e[r];for(let i of n(t))yield*Hf(i,e,r+1)},Zb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*qSt(r,Number(e),t)},qSt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Hf(n,r,e+1)},BSt=function*(t){yield t};var $3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=UTe(t,o,s),l=Vf(e),u=Vf(r),d=l?N3.bind(void 0,IC,a):k3.bind(void 0,Hf),f=l||u?N3.bind(void 0,$Te,a):k3.bind(void 0,Zb),p=l||u?LTe.bind(void 0,a):void 0;return{stream:new zSt({writableObjectMode:n,writableHighWaterMark:MTe(n),readableObjectMode:i,readableHighWaterMark:MTe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},OC=(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=UTe(o,r,a);t=DTe(c,t)}return t},UTe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:PTe(n,a)},xC(r,o,n),RC(r,s,n,c),{transform:t,final:e},{transform:CTe(i,a)},OTe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var FTe=(t,e)=>{for(let r of VSt(t))HSt(t,r,e)},VSt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),HSt=(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 ${Ru[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>GSt(a,n));r.input=qb(o)},GSt=(t,e)=>{let r=OC(t,e,"utf8",!0);return WSt(r),qb(r)},WSt=t=>{let e=t.find(r=>typeof r!="string"&&!kr(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 ZSt,appendFileSync as XSt}from"fs";var PC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Mg(r,n)&&!ji.has(e)&&YSt(n)&&(t.some(({type:i,value:s})=>i==="native"&&KSt.has(s))||t.every(({type:i})=>Ts.has(i))),YSt=t=>t===1||t===2,KSt=new Set(["pipe","overlapped"]),jTe=async(t,e,r,n)=>{for await(let i of t)JSt(e)||BTe(i,r,n)},qTe=(t,e,r)=>{for(let n of t)BTe(n,e,r)},JSt=t=>t._readableState.pipes.length>0,BTe=(t,e,r)=>{let n=VP(t);na({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var zTe=({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)=>QSt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},QSt=({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=Vbe(t,s,d),p=wc(f),{stdioItems:h,objectMode:m}=e[r],_=eEt([p],h,c,n),{serializedResult:y,finalResult:v=y}=tEt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});rEt({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&&nEt(y,h,i),S}catch(g){return n.error=g,S}},eEt=(t,e,r,n)=>{try{return OC(t,e,r,!1)}catch(i){return n.error=i,t}},tEt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qb(t)};let o=iEe(t,r);return n[s]?{serializedResult:o,finalResult:C3(o,!i[s],e)}:{serializedResult:o}},rEt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!PC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=C3(t,!1,o);try{qTe(a,e,n)}catch(c){r.error??=c}},nEt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>wC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?XSt(n,t):(r.add(s),ZSt(n,t))}};var VTe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,xc(e,r,"all")]:Array.isArray(e)?[xc(t,r,"all"),...e]:kr(t)&&kr(e)?j6([t,e]):`${t}${e}`};import{once as L3}from"events";var HTe=async(t,e)=>{let[r,n]=await iEt(t);return e.isForcefullyTerminated??=!1,[r,n]},iEt=async t=>{let[e,r]=await Promise.allSettled([L3(t,"spawn"),L3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?GTe(t):r.value},GTe=async t=>{try{return await L3(t,"exit")}catch{return GTe(t)}},WTe=async t=>{let[e,r]=await t;if(!sEt(e,r)&&D3(e,r))throw new no;return[e,r]},sEt=(t,e)=>t===void 0&&e===void 0,D3=(t,e)=>t!==0||e!==null;var YTe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=oEt(t,e,r),o=s?.code==="ETIMEDOUT",a=zbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},oEt=(t,e,r)=>t!==void 0?t:D3(e,r)?new no:void 0;var KTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=cEt(t,e,r),d=dEt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Wg(d,c,l)},cEt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=GP(t,e,r),a=lEt(r),{file:c,commandArguments:l,options:u}=fC(t,e,a);uEt(u);let d=ATe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},lEt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,uEt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&CC("ipcInput"),t&&CC("ipc: true"),r&&CC("detached: true"),n&&CC("cancelSignal")},CC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},dEt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=fEt({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}=YTe(c,r),{output:h,error:m=l}=zTe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>xc(v,r,S)),y=xc(VTe(h,r),r,"all");return hEt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},fEt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{FTe(s,r);let a=pEt(r);return aEt(...pC(t,e,a))}catch(a){return Gg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},pEt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:EC(e)}),hEt=({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?vC({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Jb({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 tbt}from"events";import{spawn as rbt}from"child_process";import ewe from"process";import{once as M3,on as mEt}from"events";var JTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(jg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:oC(t)}),gEt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),gEt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{rC(e,i);let s=Au(t,e,r),o=new AbortController;try{return await Promise.race([_Et(s,n,o),yEt(s,r,o),SEt(s,r,o)])}catch(a){throw qg(t),a}finally{o.abort(),nC(e,i)}},_Et=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await M3(t,"message",{signal:r});return n}for await(let[n]of mEt(t,"message",{signal:r}))if(e(n))return n},yEt=async(t,e,{signal:r})=>{await M3(t,"disconnect",{signal:r}),Dve(e)},SEt=async(t,e,{signal:r})=>{let[n]=await M3(t,"strict:error",{signal:r});throw QP(n,e)};import{once as XTe,on as EEt}from"events";var QTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>U3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),U3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{jg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:oC(t)}),rC(e,s);let o=Au(t,e,r),a=new AbortController,c={};return vEt(t,o,a),bEt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),TEt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},vEt=async(t,e,r)=>{try{await XTe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},bEt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await XTe(t,"strict:error",{signal:r.signal});n.error=QP(i,e),r.abort()}catch{}},TEt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of EEt(r,"message",{signal:s.signal}))ZTe(o),yield c}catch{ZTe(o)}finally{s.abort(),nC(e,a),n||qg(t),i&&await t}},ZTe=({error:t})=>{if(t)throw t};var twe=(t,{ipc:e})=>{Object.assign(t,nwe(t,!1,e))},rwe=()=>{let t=ewe,e=!0,r=ewe.channel!==void 0;return{...nwe(t,e,r),getCancelSignal:lbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},nwe=(t,e,r)=>({sendMessage:uC.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:JTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:QTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as wEt}from"child_process";import{PassThrough as AEt,Readable as REt,Writable as xEt,Duplex as IEt}from"stream";var iwe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{I3(n);let a=new wEt;OEt(a,n),Object.assign(a,{readable:PEt,writable:CEt,duplex:NEt});let c=Gg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=kEt(c,o,i);return{subprocess:a,promise:l}},OEt=(t,e)=>{let r=Xb(),n=Xb(),i=Xb(),s=Array.from({length:e.length-3},Xb),o=Xb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Xb=()=>{let t=new AEt;return t.end(),t},PEt=()=>new REt({read(){}}),CEt=()=>new xEt({write(){}}),NEt=()=>new IEt({read(){},write(){}}),kEt=async(t,e,r)=>Wg(t,e,r);import{createReadStream as swe,createWriteStream as owe}from"fs";import{Buffer as $Et}from"buffer";import{Readable as Qb,Writable as LEt,Duplex as DEt}from"stream";var cwe=(t,e)=>AC(MEt,t,e,!1),eT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ru[t]}.`)},awe={fileNumber:eT,generator:$3,asyncGenerator:$3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:DEt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},MEt={input:{...awe,fileUrl:({value:t})=>({stream:swe(t)}),filePath:({value:{file:t}})=>({stream:swe(t)}),webStream:({value:t})=>({stream:Qb.fromWeb(t)}),iterable:({value:t})=>({stream:Qb.from(t)}),asyncIterable:({value:t})=>({stream:Qb.from(t)}),string:({value:t})=>({stream:Qb.from(t)}),uint8Array:({value:t})=>({stream:Qb.from($Et.from(t))})},output:{...awe,fileUrl:({value:t})=>({stream:owe(t)}),filePath:({value:{file:t,append:e}})=>({stream:owe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:LEt.fromWeb(t)}),iterable:eT,asyncIterable:eT,string:eT,uint8Array:eT}};import{on as UEt,once as lwe}from"events";import{PassThrough as FEt,getDefaultHighWaterMark as jEt}from"stream";import{finished as fwe}from"stream/promises";function Gf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)j3(i);let e=t.some(({readableObjectMode:i})=>i),r=qEt(t,e),n=new F3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var qEt=(t,e)=>{if(t.length===0)return jEt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},F3=class extends FEt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(j3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=BEt(this,this.#e,this.#s);let r=HEt({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(j3(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)}},BEt=async(t,e,r)=>{NC(t,uwe);let n=new AbortController;try{await Promise.race([zEt(t,n),VEt(t,e,r,n)])}finally{n.abort(),NC(t,-uwe)}},zEt=async(t,{signal:e})=>{try{await fwe(t,{signal:e,cleanup:!0})}catch(r){throw pwe(t,r),r}},VEt=async(t,e,r,{signal:n})=>{for await(let[i]of UEt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},j3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},HEt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{NC(t,dwe);let a=new AbortController;try{await Promise.race([GEt(s,e,a),WEt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),YEt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),NC(t,-dwe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?q3(t):KEt(t))},GEt=async(t,e,{signal:r})=>{try{await t,r.aborted||q3(e)}catch(n){r.aborted||pwe(e,n)}},WEt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await fwe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;hwe(o)?i.add(e):mwe(t,o)}},YEt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await lwe(t,i,{signal:s}),!t.readable)return lwe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},KEt=t=>{t.writable&&t.end()},pwe=(t,e)=>{hwe(e)?q3(t):mwe(t,e)},hwe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",q3=t=>{(t.readable||t.writable)&&t.destroy()},mwe=(t,e)=>{t.destroyed||(t.once("error",JEt),t.destroy(e))},JEt=()=>{},NC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},uwe=2,dwe=1;import{finished as gwe}from"stream/promises";var Kg=(t,e)=>{t.pipe(e),ZEt(t,e),XEt(t,e)},ZEt=async(t,e)=>{if(!(ro(t)||ro(e))){try{await gwe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}B3(e)}},B3=t=>{t.writable&&t.end()},XEt=async(t,e)=>{if(!(ro(t)||ro(e))){try{await gwe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}z3(t)}},z3=t=>{t.readable&&t.destroy()};var _we=(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})=>Ts.has(c)))QEt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ts.has(c)))tvt({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]:Gf(s);Kg(o,i)}},QEt=(t,e,r,n)=>{r==="output"?Kg(t.stdio[n],e):Kg(e,t.stdio[n]);let i=evt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},evt=["stdin","stdout","stderr"],tvt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;rvt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},rvt=(t,{signal:e})=>{ro(t)&&Bf(t,nvt,e)},nvt=2;import{addAbortListener as ovt}from"events";var Wf=[];Wf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Wf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Wf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var kC=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",V3=Symbol.for("signal-exit emitter"),H3=globalThis,ivt=Object.defineProperty.bind(Object),G3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(H3[V3])return H3[V3];ivt(H3,V3,{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}},$C=class{},svt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),W3=class extends $C{onExit(){return()=>{}}load(){}unload(){}},Y3=class extends $C{#e=K3.platform==="win32"?"SIGINT":"SIGHUP";#r=new G3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Wf)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(!kC(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 Wf)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,Wf.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 kC(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"&&kC(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)}},K3=globalThis.process,{onExit:ywe,load:pur,unload:hur}=svt(kC(K3)?new Y3(K3):new W3);var Swe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=ywe(()=>{t.kill()});ovt(n,()=>{i()})};var vwe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=HP(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=avt(r,n,i),{sourceStream:d,sourceError:f}=lvt(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}},avt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=cvt(t,e,...r),a=tC(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},cvt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Ewe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||U6(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]=LP(r,...n);return{destination:e(Ewe)(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}`)},Ewe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),lvt=(t,e)=>{try{return{sourceStream:Bg(t,e)}}catch(r){return{sourceError:r}}};var Twe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=uvt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw J3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},uvt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return z3(t),n;if(e!==void 0)return B3(r),e},J3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Gg({error:t,command:bwe,escapedCommand:bwe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),bwe="source.pipe(destination)";var wwe=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 dvt}from"stream/promises";var Awe=(t,e,r)=>{let n=LC.has(e)?pvt(t,e):fvt(t,e);return Bf(t,mvt,r.signal),Bf(e,gvt,r.signal),hvt(e),n},fvt=(t,e)=>{let r=Gf([t]);return Kg(r,e),LC.set(e,r),r},pvt=(t,e)=>{let r=LC.get(e);return r.add(t),r},hvt=async t=>{try{await dvt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}LC.delete(t)},LC=new WeakMap,mvt=2,gvt=1;import{aborted as _vt}from"util";var Rwe=(t,e)=>t===void 0?[]:[yvt(t,e)],yvt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await _vt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw J3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var DC=(t,...e)=>{if(Sr(e[0]))return DC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=vwe(t,...e),i=Svt({...n,destination:r});return i.pipe=DC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Svt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=Evt(t,i);Twe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Awe(e,s,d);return await Promise.race([wwe(u),...Rwe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},Evt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as xvt}from"timers/promises";import{on as vvt}from"events";import{getDefaultHighWaterMark as bvt}from"stream";var MC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Tvt(e,o),Iwe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Tvt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Z3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;wvt(e,o,t);let a=t.readableObjectMode&&!s;return Iwe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},wvt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Iwe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=vvt(t,"data",{signal:e.signal,highWaterMark:xwe,highWatermark:xwe});return Avt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},X3=bvt(!0),xwe=X3,Avt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=Rvt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Hf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Zb(a)}},Rvt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[xC(t,r,!e),RC(t,i,!n,{})].filter(Boolean);var Owe=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=Ivt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([Ovt(t),d]);return}let f=O3(c,r),p=Z3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([Pvt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},Ivt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!PC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=Z3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await jTe(a,t,r,s)},Ovt=async t=>{await xvt(),t.readableFlowing===null&&t.resume()},Pvt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await _C(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await yC(r,{maxBuffer:s})):await Hg(r,{maxBuffer:s})}catch(a){return Pwe(jbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},Q3=async t=>{try{return await t}catch(e){return Pwe(e)}},Pwe=({bufferedData:t})=>rEe(t)?new Uint8Array(t):t;import{finished as Cvt}from"stream/promises";var tT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=Nvt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Cvt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||Lvt(a,e,r,n)}finally{o.abort()}},Nvt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&kvt(t,r,n),n},kvt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{$vt(e,r),n.call(t,...i)}},$vt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Lvt=(t,e,r,n)=>{if(!Dvt(t,e,r,n))throw t},Dvt=(t,e,r,n=!0)=>r.propagating?Cwe(t)||UC(t):(r.propagating=!0,eW(r,e)===n?Cwe(t):UC(t)),eW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",UC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Cwe=t=>t?.code==="EPIPE";var Nwe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>tW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),tW=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=tT(t,e,l);if(eW(l,e)){await u;return}let[d]=await Promise.all([Owe({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 kwe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Gf([t,e].filter(Boolean)):void 0,$we=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>tW({...Mvt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Uvt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),Mvt=({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}},Uvt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Fvt}from"events";var Lwe=t=>Mg(t,"ipc"),Dwe=(t,e)=>{let r=VP(t);na({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Mwe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Lwe(s),a=Ac(e,"ipc"),c=Ac(r,"ipc");for await(let l of U3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(qbe(t,i,c),i.push(l)),o&&Dwe(l,s);return i},Uwe=async(t,e)=>(await Promise.allSettled([t]),e);var Fwe=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=HTe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Nwe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),T=$we({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),I=[],x=Mwe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),R=jvt(m,t,S),O=qvt(h,S);try{return await Promise.race([Promise.all([{},WTe(v),Promise.all(g),T,x,Sbe(t,d),...R,...O]),_,Bvt(t,y),...hbe(t,s,f,y),...Lve({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...fbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(A){return f.terminationReason??="other",Promise.all([{error:A},v,Promise.all(g.map(b=>Q3(b))),Q3(T),Uwe(x,I),Promise.allSettled(R),Promise.allSettled(O)])}},jvt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:tT(n,i,r)),qvt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>so(s,{checkOpen:!1})&&!ro(s)).map(({type:i,value:s,stream:o=s})=>tT(o,n,e,{isSameDirection:Ts.has(i),stopOnExit:i==="native"}))),Bvt=async(t,{signal:e})=>{let[r]=await Fvt(t,"error",{signal:e});throw r};var jwe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),rT=(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}},Jg=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 zvt}from"stream";import{callbackify as Vvt}from"util";import{finished as qwe}from"stream/promises";var rW=async t=>{if(t!==void 0)try{await nW(t)}catch{}},Bwe=async t=>{if(t!==void 0)try{await iW(t)}catch{}},nW=async t=>{await qwe(t,{cleanup:!0,readable:!1,writable:!0})},iW=async t=>{await qwe(t,{cleanup:!0,readable:!0,writable:!1})},FC=async(t,e)=>{if(await t,e)throw e},jC=(t,e,r)=>{r&&!UC(r)?t.destroy(r):e&&t.destroy()};var zwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ji.has(r),{subprocessStdout:a,waitReadableDestroy:c}=sW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=oW(a,o),{read:f,onStdoutDataDone:p}=aW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new zvt({read:f,destroy:Vvt(lW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return cW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},sW=(t,e,r)=>{let n=Bg(t,e),i=rT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},oW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:X3},aW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ia(),o=MC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Hvt(this,o,s)},onStdoutDataDone:s}},Hvt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},cW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await iW(t),await n,await rW(i),await e,r.readable&&r.push(null)}catch(s){await rW(i),Vwe(r,s)}},lW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Jg(r,e)&&(Vwe(t,n),await FC(e,n))},Vwe=(t,e)=>{jC(t,t.readable,e)};import{Writable as Gvt}from"stream";import{callbackify as Hwe}from"util";var Gwe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=uW(t,r,e),o=new Gvt({...dW(n,t,i),destroy:Hwe(pW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return fW(n,o),o},uW=(t,e,r)=>{let n=tC(t,e),i=rT(r,n,"writableFinal"),s=rT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},dW=(t,e,r)=>({write:Wvt.bind(void 0,t),final:Hwe(Yvt.bind(void 0,t,e,r))}),Wvt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Yvt=async(t,e,r)=>{await Jg(r,e)&&(t.writable&&t.end(),await e)},fW=async(t,e,r)=>{try{await nW(t),e.writable&&e.end()}catch(n){await Bwe(r),Wwe(e,n)}},pW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Jg(r,e),await Jg(n,e)&&(Wwe(t,i),await FC(e,i))},Wwe=(t,e)=>{jC(t,t.writable,e)};import{Duplex as Kvt}from"stream";import{callbackify as Jvt}from"util";var Ywe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ji.has(r),{subprocessStdout:c,waitReadableDestroy:l}=sW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=uW(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=oW(c,a),{read:_,onStdoutDataDone:y}=aW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new Kvt({read:_,...dW(u,t,d),destroy:Jvt(Zvt.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 cW({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),fW(u,v,c),v},Zvt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([lW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),pW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var hW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ji.has(e),o=Bg(t,r),a=MC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return Xvt(a,o,t)},Xvt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Kwe=(t,{encoding:e})=>{let r=jwe();t.readable=zwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Gwe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Ywe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=hW.bind(void 0,t,e),t[Symbol.asyncIterator]=hW.bind(void 0,t,e,{})};var Jwe=(t,e)=>{for(let[r,n]of ebt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Qvt=(async()=>{})().constructor.prototype,ebt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Qvt,t)]);var Zwe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=nbt(t,e,r),{subprocess:f,promise:p}=sbt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=DC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Jwe(f,p),sa.set(f,{options:u,fileDescriptors:d}),f},nbt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=GP(t,e,r),{file:a,commandArguments:c,options:l}=fC(t,e,r),u=ibt(l),d=cwe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},ibt=({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}},sbt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=rbt(...pC(t,e,r))}catch(h){return iwe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;tbt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];_we(c,a,l),Swe(c,r,l);let d={},f=ia();c.kill=kve.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=kwe(c,r),Kwe(c,r),twe(c,r);let p=obt({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}},obt=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 Fwe({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)=>xc(g,e,T)),v=xc(m,e,"all"),S=abt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Wg(S,n,e)},abt=({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?Jb({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}):vC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var qC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,cbt(n,t[n],i)]));return{...t,...r}},cbt=(t,e,r)=>lbt.has(t)&&Sr(e)&&Sr(r)?{...e,...r}:r,lbt=new Set(["env",...V6]);var xu=(t,e,r,n)=>{let i=(o,a,c)=>xu(o,a,r,c),s=(...o)=>ubt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},ubt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Sr(s))return i(t,qC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=dbt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?KTe(a,c,l):Zwe(a,c,l,i)},dbt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=cEe(e)?lEe(e,r):[e,...r],[o,a,c]=LP(...s),l=qC(qC(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 Xwe=({file:t,commandArguments:e})=>e0e(t,e),Qwe=({file:t,commandArguments:e})=>({...e0e(t,e),isSync:!0}),e0e=(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]=fbt(t);return{file:r,commandArguments:n}},fbt=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(pbt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},pbt=/ +/g;var t0e=(t,e,r)=>{t.sync=e(hbt,r),t.s=t.sync},r0e=({options:t})=>n0e(t),hbt=({options:t})=>({...n0e(t),isSync:!0}),n0e=t=>({options:{...mbt(t),...t}}),mbt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},i0e={preferLocal:!0};var s0e=xu(()=>({})),npr=xu(()=>({isSync:!0})),o0e=xu(Xwe),ipr=xu(Qwe),spr=xu(gbe),opr=xu(r0e,{},i0e,t0e),{sendMessage:apr,getOneMessage:cpr,getEachMessage:lpr,getCancelSignal:upr}=rwe();import{Transform as gbt}from"stream";var _bt=["NETLIFY_AI_GATEWAY_KEY"];function ybt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,..._bt])]}function Sbt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function Ebt(){let e=ybt().map(r=>process.env[r]).filter(r=>!(!r||Sbt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function ws(t){if(typeof t!="string")return t;let e=Ebt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(vbt(n),"g");r=r.replace(i,"******")}),r}function vbt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var nT=class extends gbt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=ws(i);n(null,s)}},BC=Symbol("maskedWrite");function a0e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[BC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?ws(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[BC]=!0,process.stdout.write=r}if(!process.stderr.write[BC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?ws(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[BC]=!0,process.stderr.write=r}}}var c0e=!1,l0e=()=>{c0e=!0},Si=()=>c0e;var iT=null,u0e=t=>(iT&&iT.destroy(),iT=new Ic({totalAllowedTime:t}),iT),d0e=()=>iT;var Ic=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&&Si())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 kP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ge.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 f0e={name:"@netlify/agent-runner-cli",type:"module",version:"1.159.4",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.4","@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 Abt=Tbt(import.meta.url),Rbt=Oc.dirname(Abt),xbt=wbt(import.meta.url),Zg=ye("shell"),mW=new Set,p0e={preferLocal:!0},hn=(t,e,r)=>{let[n,i]=Ibt(e,r),s={...p0e,...i},o=s0e(t,n,s);m0e(o,s),y0e(o);let a=r?.idleTimeout;return a&&a>0&&_0e(o,a),o},h0e=(t,e)=>{let r={...p0e,...e},n=o0e(t,r);return m0e(n,r),y0e(n),e?.idleTimeout&&e.idleTimeout>0&&_0e(n,e.idleTimeout),n},Ibt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},m0e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Pc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new nT).pipe(Pc.stdout),t.stderr?.pipe(new nT).pipe(Pc.stderr);return}t.stdout?.pipe(Pc.stdout),t.stderr?.pipe(Pc.stderr)},gW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Pc.kill(-t.pid,e),Zg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Zg.error("Error killing process:",r),!1}},g0e=t=>gW(t,"SIGKILL"),_0e=(t,e)=>{let r=null,n=()=>{Zg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),gW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zg.log(`Force killing idle process ${t.pid}`),g0e(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)},y0e=t=>{mW.add(t);let e=d0e();if(e){let r=e.onTimesUp(()=>{Zg.log(`Global timer expired, killing process ${t.pid}`),gW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zg.log(`Force killing process ${t.pid} after timeout`),g0e(t))},5e3)});t.on("exit",()=>{mW.delete(t),r()}),t.on("error",()=>{mW.delete(t),r()})}};function ca(t,e){if(!Pc.env.NETLIFY_LOCAL_MODE)try{let i=xbt.resolve(f0e.name),s=Oc.dirname(i);for(;s!==Oc.dirname(s);){let o=Oc.dirname(s);if(Oc.basename(o)==="node_modules"){let a=Oc.join(o,".bin",e);if(zC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Pc.env.NODE_PATH){let i=Oc.join(Pc.env.NODE_PATH,".bin",e);if(zC.existsSync(i))return i}let r=Oc.join(t,"node_modules",".bin",e);if(zC.existsSync(r))return r;let n=Oc.join(Rbt,"..","node_modules",".bin",e);if(zC.existsSync(n))return n}import fD from"process";import{fileURLToPath as nDt}from"url";import{createRequire as iDt}from"module";import pD from"path";var Obt="__netlify__getTracer",Pbt="__netlify__shutdownTracers",mt=(t,e)=>globalThis[Obt]?.(t,e),S0e=async()=>globalThis[Pbt]?.();function Yf(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 JLt}from"timers/promises";Ne();import Cwt from"process";Ne();var eTt=(t,e)=>{e.recordException(t),e.setStatus({code:Cn.ERROR})};var kc=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}=fAe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>pAe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=fAe(r,n,i),c=this._tracer.startSpan(e,s,o);return pAe(c,s,a)}};function fAe(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 pAe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:eTt,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 i_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var JW=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=TAe(e),n._asyncAttributesPending=e.filter(([i,s])=>i_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(i_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=TAe(this._rawAttributes),this._schemaUrl=tTt(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,i_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ce.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(i_(n)){ce.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=rTt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function ZW(t,e){return JW.FromAttributeList(Object.entries(t),e)}function TAe(t){return t.map(([e,r])=>i_(r)?[e,r.catch(n=>{ce.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function tTt(t){if(typeof t=="string"||t===void 0)return t;ce.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function rTt(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;ce.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var gT=class{emit(e){}enabled(){return!1}},wAe=new gT;var _T=Symbol.for("io.opentelemetry.js.api.logs"),s_=globalThis;function AAe(t,e,r){return n=>n===t?e:r}var XW=1;var QW=class{getLogger(e,r,n){return new gT}},fN=new QW;var pN=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):wAe}};var yT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new pN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:fN}_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 hN=class t{constructor(){this._proxyLoggerProvider=new yT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return s_[_T]?this.getLoggerProvider():(s_[_T]=AAe(XW,e,fN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=s_[_T])===null||e===void 0?void 0:e.call(s_,XW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete s_[_T],this._proxyLoggerProvider=new yT}};var RAe=hN.getInstance();function xAe(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 IAe(t){t.forEach(e=>e.disable())}function eY(t){let e=t.tracerProvider||At.getTracerProvider(),r=t.meterProvider||mT.getMeterProvider(),n=t.loggerProvider||RAe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return xAe(i,e,r,n),()=>{IAe(i)}}Ne();var nTt=zr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function OAe(t){return t.getValue(nTt)===!0}var o_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(o_||(o_={}));Ne();var tY="[_0-9a-z-*/]",iTt=`[a-z]${tY}{0,255}`,sTt=`[a-z0-9]${tY}{0,240}@[a-z]${tY}{0,13}`,oTt=new RegExp(`^(?:${iTt}|${sTt})$`),aTt=/^[ -~]{0,255}[!-~]$/,cTt=/,|=/;function rY(t){return oTt.test(t)}function nY(t){return aTt.test(t)&&!cTt.test(t)}var lTt=32,PAe=512,CAe=",",NAe="=",mN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!rY(e)||!nY(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>PAe)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=CAe+e),e=`${n[0]}${NAe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(CAe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(NAe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!rY(a)||!nY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>PAe)&&(r.set(a,c),n=l,r.size>=lTt))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 gN="traceparent",_N="tracestate",uTt="00",dTt="(?!ff)[\\da-f]{2}",fTt="(?![0]{32})[\\da-f]{32}",pTt="(?![0]{16})[\\da-f]{16}",hTt="[\\da-f]{2}",mTt=new RegExp(`^\\s?(${dTt})-(${fTt})-(${pTt})-(${hTt})(-.*)?\\s?$`);function kAe(t){let e=mTt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Pu=class{inject(e,r,n){let i=At.getSpanContext(e);if(!i||OAe(e)||!Ei(i))return;let s=`${uTt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||pr.NONE).toString(16)}`;n.set(r,gN,s),i.traceState&&n.set(r,_N,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,gN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=kAe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,_N);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new mN(typeof c=="string"?c:void 0)}return At.setSpanContext(e,o)}fields(){return[gN,_N]}};var yN=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 ST=class{_isCalled=!1;_deferred=new yN;_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 lk=jn(BY(),1);Ne();var mIe=t=>{throw TypeError(t)},GY=(t,e,r)=>e.has(t)||mIe("Cannot "+r),ck=(t,e,r)=>(GY(t,e,"read from private field"),r?r.call(t):e.get(t)),zY=(t,e,r)=>e.has(t)?mIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),fIe=(t,e,r,n)=>(GY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Pwt=(t,e,r)=>(GY(t,e,"access private method"),r),pIe="__netlify__getTracer",Nwt="__netlify__shutdownTracers",kwt="__nfOTLPTrace",$T,LT,HY,gIe,$wt=class{constructor(){zY(this,HY),zY(this,$T),zY(this,LT),fIe(this,$T,new ST(Pwt(this,HY,gIe),this)),fIe(this,LT,ce.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(ck(this,LT).debug(`export ${t.length.toString()} spans`),ck(this,$T).isCalled){e({code:o_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(kwt,JSON.stringify(Lwt(t))),e({code:o_.SUCCESS})}shutdown(){return ck(this,$T).call()}};$T=new WeakMap;LT=new WeakMap;HY=new WeakSet;gIe=function(){return ck(this,LT).debug("Shutting down"),Promise.resolve()};function Lwt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:ak(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||oo.SERVER,startTimeUnixNano:VY(e.startTime),endTimeUnixNano:VY(e.endTime),attributes:ak(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:VY(n.time),attributes:ak(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:ak(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function ak(t){return Object.keys(t).map(e=>_Ie(e,t[e]))}function _Ie(t,e){return{key:t,value:yIe(e)}}function yIe(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(yIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>_Ie(r,n))}}:{}}function VY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var hIe={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"}},SIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,pIe))return;let e=Cwt.version.slice(1),r=ZW({"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??[Dwt()],i=new lk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Pu});let s=t.instrumentations??[];eY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,pIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new kc(At.getTracer(a,c)):new kc(At.getTracer(hIe.name,hIe.version))}}),Object.defineProperty(globalThis,Nwt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Dwt=()=>new lk.SimpleSpanProcessor(new $wt);Ne();var DT=jn(BY(),1);Ne();import*as uk from"diagnostics_channel";var EIe=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?Cn.ERROR:Cn.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 kc?t:new kc(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){uk.subscribe(t,e);let r=()=>uk.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:oo.CLIENT},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:Cn.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 VDe=jn(BDe(),1);var uD=ye("tracing"),zDe=8e3,ZLt=5e3,e0=async(t=ZLt)=>{try{await Promise.race([S0e(),JLt(t)])}catch(e){uD.warn("Failed to flush tracers on shutdown",e)}},HDe=async(t,e,r)=>{if(!mt()){let n=[new DT.SimpleSpanProcessor(new WJ),new DT.SimpleSpanProcessor(new VDe.OTLPTraceExporter({url:r.exporterUrl}))];await SIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new EIe({skipHeaders:!0})]})}return r.traceparent?(Xn.setGlobalPropagator(new Pu),Xn.extract(jt.active(),{traceparent:r.traceparent,isRemote:!0})):jt.active()};function Gt(t,e,r){return uD.log(`\u23F3 TRACE: ${e} starting...`),Yf(t,e,r)}var WJ=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(", ")}]`:"";uD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&uD.log(` \u274C Error: ${e.status.message}`)}};function YJ(){return Be().captureLlmContentEnabled}function GDe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function dD(t,e,r){let n={role:t,parts:[{type:"text",content:ws(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var XLt=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 WDe(t,e,r,n){if(!t.length)return;let i=mt();if(!i)return;let s=YJ(),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&&XLt.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>zDe?`${a.message.slice(0,zDe)}\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":ws(_)}:{"gen_ai.output.messages":dD("assistant",_)}:{}}}).end(u)})}import{readdir as QLt,rm as eDt}from"fs/promises";import{join as tDt}from"path";async function YDe(t,e=[]){let n=(await QLt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>eDt(tDt(t,i),{recursive:!0,force:!0})))}var rDt=700,KDe=t=>{if(t.mode!=="create")return!1;if(t.accountType===Al)return!0;let{enforcedAICreditsRemaining:e}=t;return e!=null&&e<=rDt};var sDt=pD.dirname(nDt(import.meta.url)),JDe=iDt(import.meta.url),oDt=pD.resolve(sDt,"scripts/scaffold.js"),aDt="scripts/scaffold.js",cDt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,KJ=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},lDt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),uDt=t=>{let e=KJ(t);return e==="node"||e.endsWith("/node")},nl=t=>{if(typeof t!="string")return!1;let e=t.match(cDt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&lDt(KJ(e[r]));)r+=1;if(r>=e.length||!uDt(e[r]))return!1;let n=e[r+1];return n?KJ(n).includes(aDt):!1},_y=ye("create_stage"),ZDe="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.",dDt=`${ZDe}
|
|
591
591
|
|
|
592
592
|
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.`,fDt=`${ZDe}
|
|
593
593
|
|
package/dist/index.js
CHANGED
|
@@ -98,7 +98,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
98
98
|
`,LF:`
|
|
99
99
|
`,concatBytes:HL},S$e=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},E$e={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:S$e};import{Buffer as v$e}from"buffer";var pre=(t,e)=>t?void 0:T$e.bind(void 0,e),T$e=function*(t,e){if(typeof e!="string"&&!jt(e)&&!v$e.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},hre=(t,e)=>t?b$e.bind(void 0,e):A$e.bind(void 0,e),b$e=function*(t,e){mre(t,e),yield e},A$e=function*(t,e){if(mre(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},mre=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
100
100
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
101
|
-
if (condition) { yield value; }`)};import{Buffer as x$e}from"buffer";import{StringDecoder as w$e}from"string_decoder";var vx=(t,e,r)=>{if(r)return;if(t)return{transform:R$e.bind(void 0,new TextEncoder)};let n=new w$e(e);return{transform:I$e.bind(void 0,n),final:C$e.bind(void 0,n)}},R$e=function*(t,e){x$e.isBuffer(e)?yield us(e):typeof e=="string"?yield t.encode(e):yield e},I$e=function*(t,e){yield jt(e)?t.write(e):e},C$e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as gre}from"util";var YL=gre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Tx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=O$e}=e[r];for await(let i of n(t))yield*Tx(i,e,r+1)},_re=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*P$e(r,Number(e),t)},P$e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Tx(n,r,e+1)},yre=gre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),O$e=function*(t){yield t};var KL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Sre=(t,e)=>[...e.flatMap(r=>[...kl(r,t,0)]),...O_(t)],kl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=k$e}=e[r];for(let i of n(t))yield*kl(i,e,r+1)},O_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*N$e(r,Number(e),t)},N$e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*kl(n,r,e+1)},k$e=function*(t){yield t};var ZL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=vre(t,s,o),l=Nl(e),u=Nl(r),d=l?YL.bind(void 0,Tx,a):KL.bind(void 0,kl),f=l||u?YL.bind(void 0,_re,a):KL.bind(void 0,O_),p=l||u?yre.bind(void 0,a):void 0;return{stream:new M$e({writableObjectMode:n,writableHighWaterMark:Ere(n),readableObjectMode:i,readableHighWaterMark:Ere(i),transform(m,y,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},bx=(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=vre(s,r,a);t=Sre(c,t)}return t},vre=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:pre(n,a)},vx(r,s,n),Ex(r,o,n,c),{transform:t,final:e},{transform:hre(i,a)},fre({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Tre=(t,e)=>{for(let r of D$e(t))L$e(t,r,e)},D$e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),L$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 ${Na[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>$$e(a,n));r.input=v_(s)},$$e=(t,e)=>{let r=bx(t,e,"utf8",!0);return U$e(r),v_(r)},U$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 z$e,appendFileSync as G$e}from"fs";var Ax=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&ff(r,n)&&!yn.has(e)&&F$e(n)&&(t.some(({type:i,value:o})=>i==="native"&&B$e.has(o))||t.every(({type:i})=>Wn.has(i))),F$e=t=>t===1||t===2,B$e=new Set(["pipe","overlapped"]),bre=async(t,e,r,n)=>{for await(let i of t)j$e(e)||xre(i,r,n)},Are=(t,e,r)=>{for(let n of t)xre(n,e,r)},j$e=t=>t._readableState.pipes.length>0,xre=(t,e,r)=>{let n=UA(t);lo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var wre=({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)=>q$e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},q$e=({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=Rte(t,o,d),p=us(f),{stdioItems:h,objectMode:m}=e[r],y=V$e([p],h,c,n),{serializedResult:E,finalResult:b=E}=H$e({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});W$e({serializedResult:E,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&&Y$e(E,h,i),x}catch(S){return n.error=S,x}},V$e=(t,e,r,n)=>{try{return bx(t,e,r,!1)}catch(i){return n.error=i,t}},H$e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:v_(t)};let s=jQ(t,r);return n[o]?{serializedResult:s,finalResult:WL(s,!i[o],e)}:{serializedResult:s}},W$e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Ax({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=WL(t,!1,s);try{Are(a,e,n)}catch(c){r.error??=c}},Y$e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>yx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?G$e(n,t):(r.add(o),z$e(n,t))}};var Rre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ps(e,r,"all")]:Array.isArray(e)?[ps(t,r,"all"),...e]:jt(t)&&jt(e)?rL([t,e]):`${t}${e}`};import{once as JL}from"events";var Ire=async(t,e)=>{let[r,n]=await K$e(t);return e.isForcefullyTerminated??=!1,[r,n]},K$e=async t=>{let[e,r]=await Promise.allSettled([JL(t,"spawn"),JL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Cre(t):r.value},Cre=async t=>{try{return await JL(t,"exit")}catch{return Cre(t)}},Pre=async t=>{let[e,r]=await t;if(!Z$e(e,r)&&XL(e,r))throw new xi;return[e,r]},Z$e=(t,e)=>t===void 0&&e===void 0,XL=(t,e)=>t!==0||e!==null;var Ore=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=J$e(t,e,r),s=o?.code==="ETIMEDOUT",a=wte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},J$e=(t,e,r)=>t!==void 0?t:XL(e,r)?new xi:void 0;var Nre=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Q$e(t,e,r),d=r1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Tf(d,c,l)},Q$e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BA(t,e,r),a=e1e(r),{file:c,commandArguments:l,options:u}=sx(t,e,a);t1e(u);let d=cre(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},e1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,t1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&xx("ipcInput"),t&&xx("ipc: true"),r&&xx("detached: true"),n&&xx("cancelSignal")},xx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},r1e=({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}=Ore(c,r),{output:h,error:m=l}=wre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((b,x)=>ps(b,r,x)),E=ps(Rre(h,r),r,"all");return o1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,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{Tre(o,r);let a=i1e(r);return X$e(...ax(t,e,a))}catch(a){return vf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},i1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:hx(e)}),o1e=({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?mx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):P_({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 HUe}from"events";import{spawn as WUe}from"child_process";import $re from"process";import{once as QL,on as s1e}from"events";var kre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(mf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),a1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),a1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ZA(e,i);let o=Oa(t,e,r),s=new AbortController;try{return await Promise.race([c1e(o,n,s),l1e(o,r,s),u1e(o,r,s)])}catch(a){throw gf(t),a}finally{s.abort(),JA(e,i)}},c1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await QL(t,"message",{signal:r});return n}for await(let[n]of s1e(t,"message",{signal:r}))if(e(n))return n},l1e=async(t,e,{signal:r})=>{await QL(t,"disconnect",{signal:r}),See(e)},u1e=async(t,e,{signal:r})=>{let[n]=await QL(t,"strict:error",{signal:r});throw WA(n,e)};import{once as Dre,on as d1e}from"events";var Lre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>e$({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),e$=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{mf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),ZA(e,o);let s=Oa(t,e,r),a=new AbortController,c={};return f1e(t,s,a),p1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),h1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},f1e=async(t,e,r)=>{try{await Dre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},p1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Dre(t,"strict:error",{signal:r.signal});n.error=WA(i,e),r.abort()}catch{}},h1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of d1e(r,"message",{signal:o.signal}))Mre(s),yield c}catch{Mre(s)}finally{o.abort(),JA(e,a),n||gf(t),i&&await t}},Mre=({error:t})=>{if(t)throw t};var Ure=(t,{ipc:e})=>{Object.assign(t,Bre(t,!1,e))},Fre=()=>{let t=$re,e=!0,r=$re.channel!==void 0;return{...Bre(t,e,r),getCancelSignal:Hee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Bre=(t,e,r)=>({sendMessage:ix.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:kre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Lre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as m1e}from"child_process";import{PassThrough as g1e,Readable as _1e,Writable as y1e,Duplex as S1e}from"stream";var jre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{qL(n);let a=new m1e;E1e(a,n),Object.assign(a,{readable:v1e,writable:T1e,duplex:b1e});let c=vf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=A1e(c,s,i);return{subprocess:a,promise:l}},E1e=(t,e)=>{let r=N_(),n=N_(),i=N_(),o=Array.from({length:e.length-3},N_),s=N_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},N_=()=>{let t=new g1e;return t.end(),t},v1e=()=>new _1e({read(){}}),T1e=()=>new y1e({write(){}}),b1e=()=>new S1e({read(){},write(){}}),A1e=async(t,e,r)=>Tf(t,e,r);import{createReadStream as zre,createWriteStream as Gre}from"fs";import{Buffer as x1e}from"buffer";import{Readable as k_,Writable as w1e,Duplex as R1e}from"stream";var Vre=(t,e)=>Sx(I1e,t,e,!1),M_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Na[t]}.`)},qre={fileNumber:M_,generator:ZL,asyncGenerator:ZL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:R1e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},I1e={input:{...qre,fileUrl:({value:t})=>({stream:zre(t)}),filePath:({value:{file:t}})=>({stream:zre(t)}),webStream:({value:t})=>({stream:k_.fromWeb(t)}),iterable:({value:t})=>({stream:k_.from(t)}),asyncIterable:({value:t})=>({stream:k_.from(t)}),string:({value:t})=>({stream:k_.from(t)}),uint8Array:({value:t})=>({stream:k_.from(x1e.from(t))})},output:{...qre,fileUrl:({value:t})=>({stream:Gre(t)}),filePath:({value:{file:t,append:e}})=>({stream:Gre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:w1e.fromWeb(t)}),iterable:M_,asyncIterable:M_,string:M_,uint8Array:M_}};import{on as C1e,once as Hre}from"events";import{PassThrough as P1e,getDefaultHighWaterMark as O1e}from"stream";import{finished as Kre}from"stream/promises";function Ml(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)r$(i);let e=t.some(({readableObjectMode:i})=>i),r=N1e(t,e),n=new t$({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var N1e=(t,e)=>{if(t.length===0)return O1e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},t$=class extends P1e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(r$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=k1e(this,this.#e,this.#o);let r=L1e({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(r$(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)}},k1e=async(t,e,r)=>{wx(t,Wre);let n=new AbortController;try{await Promise.race([M1e(t,n),D1e(t,e,r,n)])}finally{n.abort(),wx(t,-Wre)}},M1e=async(t,{signal:e})=>{try{await Kre(t,{signal:e,cleanup:!0})}catch(r){throw Zre(t,r),r}},D1e=async(t,e,r,{signal:n})=>{for await(let[i]of C1e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},r$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},L1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{wx(t,Yre);let a=new AbortController;try{await Promise.race([$1e(o,e,a),U1e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),F1e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),wx(t,-Yre)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?n$(t):B1e(t))},$1e=async(t,e,{signal:r})=>{try{await t,r.aborted||n$(e)}catch(n){r.aborted||Zre(e,n)}},U1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Kre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Jre(s)?i.add(e):Xre(t,s)}},F1e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Hre(t,i,{signal:o}),!t.readable)return Hre(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},B1e=t=>{t.writable&&t.end()},Zre=(t,e)=>{Jre(e)?n$(t):Xre(t,e)},Jre=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",n$=t=>{(t.readable||t.writable)&&t.destroy()},Xre=(t,e)=>{t.destroyed||(t.once("error",j1e),t.destroy(e))},j1e=()=>{},wx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Wre=2,Yre=1;import{finished as Qre}from"stream/promises";var Af=(t,e)=>{t.pipe(e),z1e(t,e),G1e(t,e)},z1e=async(t,e)=>{if(!(Ai(t)||Ai(e))){try{await Qre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}i$(e)}},i$=t=>{t.writable&&t.end()},G1e=async(t,e)=>{if(!(Ai(t)||Ai(e))){try{await Qre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}o$(t)}},o$=t=>{t.readable&&t.destroy()};var ene=(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})=>Wn.has(c)))q1e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Wn.has(c)))H1e({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]:Ml(o);Af(s,i)}},q1e=(t,e,r,n)=>{r==="output"?Af(t.stdio[n],e):Af(e,t.stdio[n]);let i=V1e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},V1e=["stdin","stdout","stderr"],H1e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;W1e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},W1e=(t,{signal:e})=>{Ai(t)&&Pl(t,Y1e,e)},Y1e=2;import{addAbortListener as J1e}from"events";var Dl=[];Dl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Dl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Dl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Rx=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",s$=Symbol.for("signal-exit emitter"),a$=globalThis,K1e=Object.defineProperty.bind(Object),c$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(a$[s$])return a$[s$];K1e(a$,s$,{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}},Ix=class{},Z1e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),l$=class extends Ix{onExit(){return()=>{}}load(){}unload(){}},u$=class extends Ix{#e=d$.platform==="win32"?"SIGINT":"SIGHUP";#r=new c$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Dl)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(!Rx(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 Dl)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,Dl.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 Rx(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"&&Rx(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)}},d$=globalThis.process,{onExit:tne,load:rvt,unload:nvt}=Z1e(Rx(d$)?new u$(d$):new l$);var rne=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=tne(()=>{t.kill()});J1e(n,()=>{i()})};var ine=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=FA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=X1e(r,n,i),{sourceStream:d,sourceError:f}=eUe(t,l),{options:p,fileDescriptors:h}=fo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},X1e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Q1e(t,e,...r),a=KA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Q1e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(nne,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||eL(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]=CA(r,...n);return{destination:e(nne)(i,o,s),pipeOptions:s}}if(fo.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}`)},nne=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),eUe=(t,e)=>{try{return{sourceStream:_f(t,e)}}catch(r){return{sourceError:r}}};var sne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=tUe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw f$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},tUe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return o$(t),n;if(e!==void 0)return i$(r),e},f$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>vf({error:t,command:one,escapedCommand:one,fileDescriptors:e,options:r,startTime:n,isSync:!1}),one="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 rUe}from"stream/promises";var cne=(t,e,r)=>{let n=Cx.has(e)?iUe(t,e):nUe(t,e);return Pl(t,sUe,r.signal),Pl(e,aUe,r.signal),oUe(e),n},nUe=(t,e)=>{let r=Ml([t]);return Af(r,e),Cx.set(e,r),r},iUe=(t,e)=>{let r=Cx.get(e);return r.add(t),r},oUe=async t=>{try{await rUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Cx.delete(t)},Cx=new WeakMap,sUe=2,aUe=1;import{aborted as cUe}from"util";var lne=(t,e)=>t===void 0?[]:[lUe(t,e)],lUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await cUe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw f$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Px=(t,...e)=>{if(Ot(e[0]))return Px.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ine(t,...e),i=uUe({...n,destination:r});return i.pipe=Px.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},uUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=dUe(t,i);sne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=cne(e,o,d);return await Promise.race([ane(u),...lne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},dUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as yUe}from"timers/promises";import{on as fUe}from"events";import{getDefaultHighWaterMark as pUe}from"stream";var Ox=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return hUe(e,s),dne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},hUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},p$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;mUe(e,s,t);let a=t.readableObjectMode&&!o;return dne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},mUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},dne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=fUe(t,"data",{signal:e.signal,highWaterMark:une,highWatermark:une});return gUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},h$=pUe(!0),une=h$,gUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=_Ue({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*kl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*O_(a)}},_Ue=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[vx(t,r,!e),Ex(t,i,!n,{})].filter(Boolean);var fne=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=SUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([EUe(t),d]);return}let f=VL(c,r),p=p$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([vUe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},SUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Ax({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=p$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await bre(a,t,r,o)},EUe=async t=>{await yUe(),t.readableFlowing===null&&t.resume()},vUe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await dx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await fx(r,{maxBuffer:o})):await Ef(r,{maxBuffer:o})}catch(a){return pne(bte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},m$=async t=>{try{return await t}catch(e){return pne(e)}},pne=({bufferedData:t})=>FQ(t)?new Uint8Array(t):t;import{finished as TUe}from"stream/promises";var D_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=bUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],TUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||wUe(a,e,r,n)}finally{s.abort()}},bUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&AUe(t,r,n),n},AUe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{xUe(e,r),n.call(t,...i)}},xUe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},wUe=(t,e,r,n)=>{if(!RUe(t,e,r,n))throw t},RUe=(t,e,r,n=!0)=>r.propagating?hne(t)||Nx(t):(r.propagating=!0,g$(r,e)===n?hne(t):Nx(t)),g$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Nx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",hne=t=>t?.code==="EPIPE";var mne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>_$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),_$=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=D_(t,e,l);if(g$(l,e)){await u;return}let[d]=await Promise.all([fne({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 gne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ml([t,e].filter(Boolean)):void 0,_ne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>_$({...IUe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:CUe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),IUe=({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}},CUe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as PUe}from"events";var yne=t=>ff(t,"ipc"),Sne=(t,e)=>{let r=UA(t);lo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Ene=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=yne(o),a=ds(e,"ipc"),c=ds(r,"ipc");for await(let l of e$({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ate(t,i,c),i.push(l)),s&&Sne(l,o);return i},vne=async(t,e)=>(await Promise.allSettled([t]),e);var Tne=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:E})=>{let b=Ire(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=mne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),N=_ne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),w=[],M=Ene({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),O=OUe(m,t,x),P=NUe(h,x);try{return await Promise.race([Promise.all([{},Pre(b),Promise.all(S),N,M,rte(t,d),...O,...P]),y,kUe(t,E),...Jee(t,o,f,E),...yee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...Kee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},b,Promise.all(S.map(_=>m$(_))),m$(N),vne(M,w),Promise.allSettled(O),Promise.allSettled(P)])}},OUe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:D_(n,i,r)),NUe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ri(o,{checkOpen:!1})&&!Ai(o)).map(({type:i,value:o,stream:s=o})=>D_(s,n,e,{isSameDirection:Wn.has(i),stopOnExit:i==="native"}))),kUe=async(t,{signal:e})=>{let[r]=await PUe(t,"error",{signal:e});throw r};var bne=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),L_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=uo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},xf=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 MUe}from"stream";import{callbackify as DUe}from"util";import{finished as Ane}from"stream/promises";var y$=async t=>{if(t!==void 0)try{await S$(t)}catch{}},xne=async t=>{if(t!==void 0)try{await E$(t)}catch{}},S$=async t=>{await Ane(t,{cleanup:!0,readable:!1,writable:!0})},E$=async t=>{await Ane(t,{cleanup:!0,readable:!0,writable:!1})},kx=async(t,e)=>{if(await t,e)throw e},Mx=(t,e,r)=>{r&&!Nx(r)?t.destroy(r):e&&t.destroy()};var wne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||yn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=v$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=T$(a,s),{read:f,onStdoutDataDone:p}=b$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new MUe({read:f,destroy:DUe(x$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return A$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},v$=(t,e,r)=>{let n=_f(t,e),i=L_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},T$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:h$},b$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=uo(),s=Ox({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){LUe(this,s,o)},onStdoutDataDone:o}},LUe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},A$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await E$(t),await n,await y$(i),await e,r.readable&&r.push(null)}catch(o){await y$(i),Rne(r,o)}},x$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await xf(r,e)&&(Rne(t,n),await kx(e,n))},Rne=(t,e)=>{Mx(t,t.readable,e)};import{Writable as $Ue}from"stream";import{callbackify as Ine}from"util";var Cne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=w$(t,r,e),s=new $Ue({...R$(n,t,i),destroy:Ine(C$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return I$(n,s),s},w$=(t,e,r)=>{let n=KA(t,e),i=L_(r,n,"writableFinal"),o=L_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},R$=(t,e,r)=>({write:UUe.bind(void 0,t),final:Ine(FUe.bind(void 0,t,e,r))}),UUe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},FUe=async(t,e,r)=>{await xf(r,e)&&(t.writable&&t.end(),await e)},I$=async(t,e,r)=>{try{await S$(t),e.writable&&e.end()}catch(n){await xne(r),Pne(e,n)}},C$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await xf(r,e),await xf(n,e)&&(Pne(t,i),await kx(e,i))},Pne=(t,e)=>{Mx(t,t.writable,e)};import{Duplex as BUe}from"stream";import{callbackify as jUe}from"util";var One=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||yn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=v$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=w$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=T$(c,a),{read:y,onStdoutDataDone:E}=b$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new BUe({read:y,...R$(u,t,d),destroy:jUe(zUe.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 A$({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),I$(u,b,c),b},zUe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([x$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),C$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var P$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||yn.has(e),s=_f(t,r),a=Ox({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return GUe(a,s,t)},GUe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Nne=(t,{encoding:e})=>{let r=bne();t.readable=wne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Cne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=One.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=P$.bind(void 0,t,e),t[Symbol.asyncIterator]=P$.bind(void 0,t,e,{})};var kne=(t,e)=>{for(let[r,n]of VUe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},qUe=(async()=>{})().constructor.prototype,VUe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(qUe,t)]);var Mne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=YUe(t,e,r),{subprocess:f,promise:p}=ZUe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Px.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),kne(f,p),fo.set(f,{options:u,fileDescriptors:d}),f},YUe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BA(t,e,r),{file:a,commandArguments:c,options:l}=sx(t,e,r),u=KUe(l),d=Vre(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},KUe=({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}},ZUe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=WUe(...ax(t,e,r))}catch(h){return jre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;HUe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ene(c,a,l),rne(c,r,l);let d={},f=uo();c.kill=gee.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=gne(c,r),Nne(c,r),Ure(c,r);let p=JUe({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}},JUe=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 Tne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((S,N)=>ps(S,e,N)),b=ps(m,e,"all"),x=XUe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Tf(x,n,e)},XUe=({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?P_({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 po,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):mx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Dx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,QUe(n,t[n],i)]));return{...t,...r}},QUe=(t,e,r)=>eFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,eFe=new Set(["env",...sL]);var ka=(t,e,r,n)=>{let i=(s,a,c)=>ka(s,a,r,c),o=(...s)=>tFe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},tFe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Dx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=rFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Nre(a,c,l):Mne(a,c,l,i)},rFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=VQ(e)?HQ(e,r):[e,...r],[s,a,c]=CA(...o),l=Dx(Dx(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 Dne=({file:t,commandArguments:e})=>$ne(t,e),Lne=({file:t,commandArguments:e})=>({...$ne(t,e),isSync:!0}),$ne=(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(iFe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},iFe=/ +/g;var Une=(t,e,r)=>{t.sync=e(oFe,r),t.s=t.sync},Fne=({options:t})=>Bne(t),oFe=({options:t})=>({...Bne(t),isSync:!0}),Bne=t=>({options:{...sFe(t),...t}}),sFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},jne={preferLocal:!0};var zne=ka(()=>({})),Hbt=ka(()=>({isSync:!0})),Gne=ka(Dne),Wbt=ka(Lne),Ybt=ka(Qee),Kbt=ka(Fne,{},jne,Une),{sendMessage:Zbt,getOneMessage:Jbt,getEachMessage:Xbt,getCancelSignal:Qbt}=Fre();var qne=!1,Vne=()=>{qne=!0},mo=()=>qne;var $_=null,Hne=t=>($_&&$_.destroy(),$_=new hs({totalAllowedTime:t}),$_),Wne=()=>$_;var hs=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&&mo())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 vA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{le.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 Yne={name:"@netlify/agent-runner-cli",type:"module",version:"1.159.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.4","@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 uFe=cFe(import.meta.url),dFe=ms.dirname(uFe),fFe=lFe(import.meta.url),wf=fe("shell"),O$=new Set,Kne={preferLocal:!0},dr=(t,e,r)=>{let[n,i]=pFe(e,r),o={...Kne,...i},s=zne(t,n,o);Jne(s,o),eie(s);let a=r?.idleTimeout;return a&&a>0&&Qne(s,a),s},Zne=(t,e)=>{let r={...Kne,...e},n=Gne(t,r);return Jne(n,r),eie(n),e?.idleTimeout&&e.idleTimeout>0&&Qne(n,e.idleTimeout),n},pFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Jne=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(gs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new d_).pipe(gs.stdout),t.stderr?.pipe(new d_).pipe(gs.stderr);return}t.stdout?.pipe(gs.stdout),t.stderr?.pipe(gs.stderr)},N$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(gs.kill(-t.pid,e),wf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return wf.error("Error killing process:",r),!1}},Xne=t=>N$(t,"SIGKILL"),Qne=(t,e)=>{let r=null,n=()=>{wf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),N$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(wf.log(`Force killing idle process ${t.pid}`),Xne(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)},eie=t=>{O$.add(t);let e=Wne();if(e){let r=e.onTimesUp(()=>{wf.log(`Global timer expired, killing process ${t.pid}`),N$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(wf.log(`Force killing process ${t.pid} after timeout`),Xne(t))},5e3)});t.on("exit",()=>{O$.delete(t),r()}),t.on("error",()=>{O$.delete(t),r()})}};function go(t,e){if(!gs.env.NETLIFY_LOCAL_MODE)try{let i=fFe.resolve(Yne.name),o=ms.dirname(i);for(;o!==ms.dirname(o);){let s=ms.dirname(o);if(ms.basename(s)==="node_modules"){let a=ms.join(s,".bin",e);if(Lx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(gs.env.NODE_PATH){let i=ms.join(gs.env.NODE_PATH,".bin",e);if(Lx.existsSync(i))return i}let r=ms.join(t,"node_modules",".bin",e);if(Lx.existsSync(r))return r;let n=ms.join(dFe,"..","node_modules",".bin",e);if(Lx.existsSync(n))return n}var hFe=fe("utils"),mFe=t=>new Promise(e=>{setTimeout(e,t)});var k$=t=>{try{return new URL(t).hostname||null}catch{return null}},$x=(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 mFe(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},Ma=(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},tie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):hFe.error("Could not parse JSON",n))}},gFe=t=>t.charAt(0).toUpperCase()+t.slice(1),_o=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():gFe(e)).join(" ");function _s(t,e){e&&t.log(`Skill invoked: ${e}`)}var Ux=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),rie=(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 M$=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}},_Fe=1e4,D$=(t,e=_Fe)=>{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 yFe}from"crypto";import{createReadStream as SFe}from"fs";import Fx from"fs/promises";import aie from"os";import Bx from"path";var nie=fe("repo"),cie="runner-diffs-",lie=t=>`${cie}${t}-`,uie=async t=>{let e=aie.tmpdir(),r;try{r=await Fx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(cie)&&!n.startsWith(lie(t))).map(n=>Fx.rm(Bx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xr=(t,e={})=>dr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),jx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{nie.info("Getting runner diffs");let n=await vFe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=bFe(o);await AFe(h,r)}nie.info("Changes after processing"),await $$(r);let s=await F$(o,r);if(await L$(s,r),i=await TFe(r),!i)return{hasChanges:!1,ignored:s};await Xr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Fx.mkdtemp(Bx.join(aie.tmpdir(),lie(t.sessionId))),c=async({from:h,to:m,fileName:y,binary:E})=>{let b=Bx.join(a,y);await Xr([...E?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await Fx.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 sie(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 oie(d,h)||(f=h)}await sie(r),le.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await oie(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},iie=async t=>{let e=yFe("sha256");for await(let r of SFe(t))e.update(r);return e.digest("hex")},oie=async(t,e)=>t.size===e.size&&await iie(t.path)===await iie(e.path),sie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xr(["reset","--soft","HEAD~1"],{cwd:t})},L$=async(t=[],e=process.cwd())=>{await Xr(["add",".",...t],{cwd:e})},$$=async(t=process.cwd())=>{let e=await Xr(["status","-s"],{cwd:t});return String(e.stdout??"")},die=/.. (.+)?\.log$/,EFe=[die],vFe=async(t=process.cwd())=>{let e=await $$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
101
|
+
if (condition) { yield value; }`)};import{Buffer as x$e}from"buffer";import{StringDecoder as w$e}from"string_decoder";var vx=(t,e,r)=>{if(r)return;if(t)return{transform:R$e.bind(void 0,new TextEncoder)};let n=new w$e(e);return{transform:I$e.bind(void 0,n),final:C$e.bind(void 0,n)}},R$e=function*(t,e){x$e.isBuffer(e)?yield us(e):typeof e=="string"?yield t.encode(e):yield e},I$e=function*(t,e){yield jt(e)?t.write(e):e},C$e=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as gre}from"util";var YL=gre(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Tx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=O$e}=e[r];for await(let i of n(t))yield*Tx(i,e,r+1)},_re=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*P$e(r,Number(e),t)},P$e=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Tx(n,r,e+1)},yre=gre(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),O$e=function*(t){yield t};var KL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Sre=(t,e)=>[...e.flatMap(r=>[...kl(r,t,0)]),...O_(t)],kl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=k$e}=e[r];for(let i of n(t))yield*kl(i,e,r+1)},O_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*N$e(r,Number(e),t)},N$e=function*(t,e,r){if(t!==void 0)for(let n of t())yield*kl(n,r,e+1)},k$e=function*(t){yield t};var ZL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=vre(t,s,o),l=Nl(e),u=Nl(r),d=l?YL.bind(void 0,Tx,a):KL.bind(void 0,kl),f=l||u?YL.bind(void 0,_re,a):KL.bind(void 0,O_),p=l||u?yre.bind(void 0,a):void 0;return{stream:new M$e({writableObjectMode:n,writableHighWaterMark:Ere(n),readableObjectMode:i,readableHighWaterMark:Ere(i),transform(m,y,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},bx=(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=vre(s,r,a);t=Sre(c,t)}return t},vre=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:pre(n,a)},vx(r,s,n),Ex(r,o,n,c),{transform:t,final:e},{transform:hre(i,a)},fre({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Tre=(t,e)=>{for(let r of D$e(t))L$e(t,r,e)},D$e=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),L$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 ${Na[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>$$e(a,n));r.input=v_(s)},$$e=(t,e)=>{let r=bx(t,e,"utf8",!0);return U$e(r),v_(r)},U$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 z$e,appendFileSync as G$e}from"fs";var Ax=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&ff(r,n)&&!yn.has(e)&&F$e(n)&&(t.some(({type:i,value:o})=>i==="native"&&B$e.has(o))||t.every(({type:i})=>Wn.has(i))),F$e=t=>t===1||t===2,B$e=new Set(["pipe","overlapped"]),bre=async(t,e,r,n)=>{for await(let i of t)j$e(e)||xre(i,r,n)},Are=(t,e,r)=>{for(let n of t)xre(n,e,r)},j$e=t=>t._readableState.pipes.length>0,xre=(t,e,r)=>{let n=UA(t);lo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var wre=({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)=>q$e({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},q$e=({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=Rte(t,o,d),p=us(f),{stdioItems:h,objectMode:m}=e[r],y=V$e([p],h,c,n),{serializedResult:E,finalResult:b=E}=H$e({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});W$e({serializedResult:E,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&&Y$e(E,h,i),x}catch(S){return n.error=S,x}},V$e=(t,e,r,n)=>{try{return bx(t,e,r,!1)}catch(i){return n.error=i,t}},H$e=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:v_(t)};let s=jQ(t,r);return n[o]?{serializedResult:s,finalResult:WL(s,!i[o],e)}:{serializedResult:s}},W$e=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Ax({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=WL(t,!1,s);try{Are(a,e,n)}catch(c){r.error??=c}},Y$e=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>yx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?G$e(n,t):(r.add(o),z$e(n,t))}};var Rre=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ps(e,r,"all")]:Array.isArray(e)?[ps(t,r,"all"),...e]:jt(t)&&jt(e)?rL([t,e]):`${t}${e}`};import{once as JL}from"events";var Ire=async(t,e)=>{let[r,n]=await K$e(t);return e.isForcefullyTerminated??=!1,[r,n]},K$e=async t=>{let[e,r]=await Promise.allSettled([JL(t,"spawn"),JL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Cre(t):r.value},Cre=async t=>{try{return await JL(t,"exit")}catch{return Cre(t)}},Pre=async t=>{let[e,r]=await t;if(!Z$e(e,r)&&XL(e,r))throw new xi;return[e,r]},Z$e=(t,e)=>t===void 0&&e===void 0,XL=(t,e)=>t!==0||e!==null;var Ore=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=J$e(t,e,r),s=o?.code==="ETIMEDOUT",a=wte(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},J$e=(t,e,r)=>t!==void 0?t:XL(e,r)?new xi:void 0;var Nre=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Q$e(t,e,r),d=r1e({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Tf(d,c,l)},Q$e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BA(t,e,r),a=e1e(r),{file:c,commandArguments:l,options:u}=sx(t,e,a);t1e(u);let d=cre(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},e1e=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,t1e=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&xx("ipcInput"),t&&xx("ipc: true"),r&&xx("detached: true"),n&&xx("cancelSignal")},xx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},r1e=({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}=Ore(c,r),{output:h,error:m=l}=wre({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((b,x)=>ps(b,r,x)),E=ps(Rre(h,r),r,"all");return o1e({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,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{Tre(o,r);let a=i1e(r);return X$e(...ax(t,e,a))}catch(a){return vf({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},i1e=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:hx(e)}),o1e=({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?mx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):P_({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 HUe}from"events";import{spawn as WUe}from"child_process";import $re from"process";import{once as QL,on as s1e}from"events";var kre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(mf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),a1e({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),a1e=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ZA(e,i);let o=Oa(t,e,r),s=new AbortController;try{return await Promise.race([c1e(o,n,s),l1e(o,r,s),u1e(o,r,s)])}catch(a){throw gf(t),a}finally{s.abort(),JA(e,i)}},c1e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await QL(t,"message",{signal:r});return n}for await(let[n]of s1e(t,"message",{signal:r}))if(e(n))return n},l1e=async(t,e,{signal:r})=>{await QL(t,"disconnect",{signal:r}),See(e)},u1e=async(t,e,{signal:r})=>{let[n]=await QL(t,"strict:error",{signal:r});throw WA(n,e)};import{once as Dre,on as d1e}from"events";var Lre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>e$({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),e$=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{mf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),ZA(e,o);let s=Oa(t,e,r),a=new AbortController,c={};return f1e(t,s,a),p1e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),h1e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},f1e=async(t,e,r)=>{try{await Dre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},p1e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Dre(t,"strict:error",{signal:r.signal});n.error=WA(i,e),r.abort()}catch{}},h1e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of d1e(r,"message",{signal:o.signal}))Mre(s),yield c}catch{Mre(s)}finally{o.abort(),JA(e,a),n||gf(t),i&&await t}},Mre=({error:t})=>{if(t)throw t};var Ure=(t,{ipc:e})=>{Object.assign(t,Bre(t,!1,e))},Fre=()=>{let t=$re,e=!0,r=$re.channel!==void 0;return{...Bre(t,e,r),getCancelSignal:Hee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Bre=(t,e,r)=>({sendMessage:ix.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:kre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Lre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as m1e}from"child_process";import{PassThrough as g1e,Readable as _1e,Writable as y1e,Duplex as S1e}from"stream";var jre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{qL(n);let a=new m1e;E1e(a,n),Object.assign(a,{readable:v1e,writable:T1e,duplex:b1e});let c=vf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=A1e(c,s,i);return{subprocess:a,promise:l}},E1e=(t,e)=>{let r=N_(),n=N_(),i=N_(),o=Array.from({length:e.length-3},N_),s=N_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},N_=()=>{let t=new g1e;return t.end(),t},v1e=()=>new _1e({read(){}}),T1e=()=>new y1e({write(){}}),b1e=()=>new S1e({read(){},write(){}}),A1e=async(t,e,r)=>Tf(t,e,r);import{createReadStream as zre,createWriteStream as Gre}from"fs";import{Buffer as x1e}from"buffer";import{Readable as k_,Writable as w1e,Duplex as R1e}from"stream";var Vre=(t,e)=>Sx(I1e,t,e,!1),M_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Na[t]}.`)},qre={fileNumber:M_,generator:ZL,asyncGenerator:ZL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:R1e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},I1e={input:{...qre,fileUrl:({value:t})=>({stream:zre(t)}),filePath:({value:{file:t}})=>({stream:zre(t)}),webStream:({value:t})=>({stream:k_.fromWeb(t)}),iterable:({value:t})=>({stream:k_.from(t)}),asyncIterable:({value:t})=>({stream:k_.from(t)}),string:({value:t})=>({stream:k_.from(t)}),uint8Array:({value:t})=>({stream:k_.from(x1e.from(t))})},output:{...qre,fileUrl:({value:t})=>({stream:Gre(t)}),filePath:({value:{file:t,append:e}})=>({stream:Gre(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:w1e.fromWeb(t)}),iterable:M_,asyncIterable:M_,string:M_,uint8Array:M_}};import{on as C1e,once as Hre}from"events";import{PassThrough as P1e,getDefaultHighWaterMark as O1e}from"stream";import{finished as Kre}from"stream/promises";function Ml(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)r$(i);let e=t.some(({readableObjectMode:i})=>i),r=N1e(t,e),n=new t$({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var N1e=(t,e)=>{if(t.length===0)return O1e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},t$=class extends P1e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(r$(e),this.#e.has(e))return;this.#e.add(e),this.#n??=k1e(this,this.#e,this.#o);let r=L1e({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(r$(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)}},k1e=async(t,e,r)=>{wx(t,Wre);let n=new AbortController;try{await Promise.race([M1e(t,n),D1e(t,e,r,n)])}finally{n.abort(),wx(t,-Wre)}},M1e=async(t,{signal:e})=>{try{await Kre(t,{signal:e,cleanup:!0})}catch(r){throw Zre(t,r),r}},D1e=async(t,e,r,{signal:n})=>{for await(let[i]of C1e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},r$=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},L1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{wx(t,Yre);let a=new AbortController;try{await Promise.race([$1e(o,e,a),U1e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),F1e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),wx(t,-Yre)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?n$(t):B1e(t))},$1e=async(t,e,{signal:r})=>{try{await t,r.aborted||n$(e)}catch(n){r.aborted||Zre(e,n)}},U1e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Kre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Jre(s)?i.add(e):Xre(t,s)}},F1e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Hre(t,i,{signal:o}),!t.readable)return Hre(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},B1e=t=>{t.writable&&t.end()},Zre=(t,e)=>{Jre(e)?n$(t):Xre(t,e)},Jre=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",n$=t=>{(t.readable||t.writable)&&t.destroy()},Xre=(t,e)=>{t.destroyed||(t.once("error",j1e),t.destroy(e))},j1e=()=>{},wx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Wre=2,Yre=1;import{finished as Qre}from"stream/promises";var Af=(t,e)=>{t.pipe(e),z1e(t,e),G1e(t,e)},z1e=async(t,e)=>{if(!(Ai(t)||Ai(e))){try{await Qre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}i$(e)}},i$=t=>{t.writable&&t.end()},G1e=async(t,e)=>{if(!(Ai(t)||Ai(e))){try{await Qre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}o$(t)}},o$=t=>{t.readable&&t.destroy()};var ene=(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})=>Wn.has(c)))q1e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Wn.has(c)))H1e({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]:Ml(o);Af(s,i)}},q1e=(t,e,r,n)=>{r==="output"?Af(t.stdio[n],e):Af(e,t.stdio[n]);let i=V1e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},V1e=["stdin","stdout","stderr"],H1e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;W1e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},W1e=(t,{signal:e})=>{Ai(t)&&Pl(t,Y1e,e)},Y1e=2;import{addAbortListener as J1e}from"events";var Dl=[];Dl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Dl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Dl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Rx=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",s$=Symbol.for("signal-exit emitter"),a$=globalThis,K1e=Object.defineProperty.bind(Object),c$=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(a$[s$])return a$[s$];K1e(a$,s$,{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}},Ix=class{},Z1e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),l$=class extends Ix{onExit(){return()=>{}}load(){}unload(){}},u$=class extends Ix{#e=d$.platform==="win32"?"SIGINT":"SIGHUP";#r=new c$;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Dl)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(!Rx(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 Dl)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,Dl.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 Rx(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"&&Rx(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)}},d$=globalThis.process,{onExit:tne,load:rvt,unload:nvt}=Z1e(Rx(d$)?new u$(d$):new l$);var rne=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=tne(()=>{t.kill()});J1e(n,()=>{i()})};var ine=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=FA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=X1e(r,n,i),{sourceStream:d,sourceError:f}=eUe(t,l),{options:p,fileDescriptors:h}=fo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},X1e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Q1e(t,e,...r),a=KA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Q1e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(nne,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||eL(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]=CA(r,...n);return{destination:e(nne)(i,o,s),pipeOptions:s}}if(fo.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}`)},nne=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),eUe=(t,e)=>{try{return{sourceStream:_f(t,e)}}catch(r){return{sourceError:r}}};var sne=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=tUe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw f$({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},tUe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return o$(t),n;if(e!==void 0)return i$(r),e},f$=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>vf({error:t,command:one,escapedCommand:one,fileDescriptors:e,options:r,startTime:n,isSync:!1}),one="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 rUe}from"stream/promises";var cne=(t,e,r)=>{let n=Cx.has(e)?iUe(t,e):nUe(t,e);return Pl(t,sUe,r.signal),Pl(e,aUe,r.signal),oUe(e),n},nUe=(t,e)=>{let r=Ml([t]);return Af(r,e),Cx.set(e,r),r},iUe=(t,e)=>{let r=Cx.get(e);return r.add(t),r},oUe=async t=>{try{await rUe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Cx.delete(t)},Cx=new WeakMap,sUe=2,aUe=1;import{aborted as cUe}from"util";var lne=(t,e)=>t===void 0?[]:[lUe(t,e)],lUe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await cUe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw f$({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Px=(t,...e)=>{if(Ot(e[0]))return Px.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=ine(t,...e),i=uUe({...n,destination:r});return i.pipe=Px.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},uUe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=dUe(t,i);sne({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=cne(e,o,d);return await Promise.race([ane(u),...lne(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},dUe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as yUe}from"timers/promises";import{on as fUe}from"events";import{getDefaultHighWaterMark as pUe}from"stream";var Ox=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return hUe(e,s),dne({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},hUe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},p$=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;mUe(e,s,t);let a=t.readableObjectMode&&!o;return dne({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},mUe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},dne=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=fUe(t,"data",{signal:e.signal,highWaterMark:une,highWatermark:une});return gUe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},h$=pUe(!0),une=h$,gUe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=_Ue({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*kl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*O_(a)}},_Ue=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[vx(t,r,!e),Ex(t,i,!n,{})].filter(Boolean);var fne=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=SUe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([EUe(t),d]);return}let f=VL(c,r),p=p$({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([vUe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},SUe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Ax({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=p$({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await bre(a,t,r,o)},EUe=async t=>{await yUe(),t.readableFlowing===null&&t.resume()},vUe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await dx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await fx(r,{maxBuffer:o})):await Ef(r,{maxBuffer:o})}catch(a){return pne(bte({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},m$=async t=>{try{return await t}catch(e){return pne(e)}},pne=({bufferedData:t})=>FQ(t)?new Uint8Array(t):t;import{finished as TUe}from"stream/promises";var D_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=bUe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],TUe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||wUe(a,e,r,n)}finally{s.abort()}},bUe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&AUe(t,r,n),n},AUe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{xUe(e,r),n.call(t,...i)}},xUe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},wUe=(t,e,r,n)=>{if(!RUe(t,e,r,n))throw t},RUe=(t,e,r,n=!0)=>r.propagating?hne(t)||Nx(t):(r.propagating=!0,g$(r,e)===n?hne(t):Nx(t)),g$=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Nx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",hne=t=>t?.code==="EPIPE";var mne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>_$({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),_$=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=D_(t,e,l);if(g$(l,e)){await u;return}let[d]=await Promise.all([fne({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 gne=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ml([t,e].filter(Boolean)):void 0,_ne=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>_$({...IUe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:CUe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),IUe=({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}},CUe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as PUe}from"events";var yne=t=>ff(t,"ipc"),Sne=(t,e)=>{let r=UA(t);lo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Ene=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=yne(o),a=ds(e,"ipc"),c=ds(r,"ipc");for await(let l of e$({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ate(t,i,c),i.push(l)),s&&Sne(l,o);return i},vne=async(t,e)=>(await Promise.allSettled([t]),e);var Tne=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:E})=>{let b=Ire(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},S=mne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),N=_ne({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),w=[],M=Ene({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),O=OUe(m,t,x),P=NUe(h,x);try{return await Promise.race([Promise.all([{},Pre(b),Promise.all(S),N,M,rte(t,d),...O,...P]),y,kUe(t,E),...Jee(t,o,f,E),...yee({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...Kee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},b,Promise.all(S.map(_=>m$(_))),m$(N),vne(M,w),Promise.allSettled(O),Promise.allSettled(P)])}},OUe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:D_(n,i,r)),NUe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ri(o,{checkOpen:!1})&&!Ai(o)).map(({type:i,value:o,stream:s=o})=>D_(s,n,e,{isSameDirection:Wn.has(i),stopOnExit:i==="native"}))),kUe=async(t,{signal:e})=>{let[r]=await PUe(t,"error",{signal:e});throw r};var bne=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),L_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=uo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},xf=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 MUe}from"stream";import{callbackify as DUe}from"util";import{finished as Ane}from"stream/promises";var y$=async t=>{if(t!==void 0)try{await S$(t)}catch{}},xne=async t=>{if(t!==void 0)try{await E$(t)}catch{}},S$=async t=>{await Ane(t,{cleanup:!0,readable:!1,writable:!0})},E$=async t=>{await Ane(t,{cleanup:!0,readable:!0,writable:!1})},kx=async(t,e)=>{if(await t,e)throw e},Mx=(t,e,r)=>{r&&!Nx(r)?t.destroy(r):e&&t.destroy()};var wne=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||yn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=v$(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=T$(a,s),{read:f,onStdoutDataDone:p}=b$({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new MUe({read:f,destroy:DUe(x$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return A$({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},v$=(t,e,r)=>{let n=_f(t,e),i=L_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},T$=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:h$},b$=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=uo(),s=Ox({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){LUe(this,s,o)},onStdoutDataDone:o}},LUe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},A$=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await E$(t),await n,await y$(i),await e,r.readable&&r.push(null)}catch(o){await y$(i),Rne(r,o)}},x$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await xf(r,e)&&(Rne(t,n),await kx(e,n))},Rne=(t,e)=>{Mx(t,t.readable,e)};import{Writable as $Ue}from"stream";import{callbackify as Ine}from"util";var Cne=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=w$(t,r,e),s=new $Ue({...R$(n,t,i),destroy:Ine(C$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return I$(n,s),s},w$=(t,e,r)=>{let n=KA(t,e),i=L_(r,n,"writableFinal"),o=L_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},R$=(t,e,r)=>({write:UUe.bind(void 0,t),final:Ine(FUe.bind(void 0,t,e,r))}),UUe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},FUe=async(t,e,r)=>{await xf(r,e)&&(t.writable&&t.end(),await e)},I$=async(t,e,r)=>{try{await S$(t),e.writable&&e.end()}catch(n){await xne(r),Pne(e,n)}},C$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await xf(r,e),await xf(n,e)&&(Pne(t,i),await kx(e,i))},Pne=(t,e)=>{Mx(t,t.writable,e)};import{Duplex as BUe}from"stream";import{callbackify as jUe}from"util";var One=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||yn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=v$(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=w$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=T$(c,a),{read:y,onStdoutDataDone:E}=b$({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new BUe({read:y,...R$(u,t,d),destroy:jUe(zUe.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 A$({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),I$(u,b,c),b},zUe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([x$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),C$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var P$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||yn.has(e),s=_f(t,r),a=Ox({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return GUe(a,s,t)},GUe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Nne=(t,{encoding:e})=>{let r=bne();t.readable=wne.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Cne.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=One.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=P$.bind(void 0,t,e),t[Symbol.asyncIterator]=P$.bind(void 0,t,e,{})};var kne=(t,e)=>{for(let[r,n]of VUe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},qUe=(async()=>{})().constructor.prototype,VUe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(qUe,t)]);var Mne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=YUe(t,e,r),{subprocess:f,promise:p}=ZUe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Px.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),kne(f,p),fo.set(f,{options:u,fileDescriptors:d}),f},YUe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BA(t,e,r),{file:a,commandArguments:c,options:l}=sx(t,e,r),u=KUe(l),d=Vre(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},KUe=({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}},ZUe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=WUe(...ax(t,e,r))}catch(h){return jre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;HUe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ene(c,a,l),rne(c,r,l);let d={},f=uo();c.kill=gee.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=gne(c,r),Nne(c,r),Ure(c,r);let p=JUe({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}},JUe=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 Tne({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((S,N)=>ps(S,e,N)),b=ps(m,e,"all"),x=XUe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Tf(x,n,e)},XUe=({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?P_({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 po,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):mx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Dx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,QUe(n,t[n],i)]));return{...t,...r}},QUe=(t,e,r)=>eFe.has(t)&&Ot(e)&&Ot(r)?{...e,...r}:r,eFe=new Set(["env",...sL]);var ka=(t,e,r,n)=>{let i=(s,a,c)=>ka(s,a,r,c),o=(...s)=>tFe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},tFe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ot(o))return i(t,Dx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=rFe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Nre(a,c,l):Mne(a,c,l,i)},rFe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=VQ(e)?HQ(e,r):[e,...r],[s,a,c]=CA(...o),l=Dx(Dx(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 Dne=({file:t,commandArguments:e})=>$ne(t,e),Lne=({file:t,commandArguments:e})=>({...$ne(t,e),isSync:!0}),$ne=(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(iFe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},iFe=/ +/g;var Une=(t,e,r)=>{t.sync=e(oFe,r),t.s=t.sync},Fne=({options:t})=>Bne(t),oFe=({options:t})=>({...Bne(t),isSync:!0}),Bne=t=>({options:{...sFe(t),...t}}),sFe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},jne={preferLocal:!0};var zne=ka(()=>({})),Hbt=ka(()=>({isSync:!0})),Gne=ka(Dne),Wbt=ka(Lne),Ybt=ka(Qee),Kbt=ka(Fne,{},jne,Une),{sendMessage:Zbt,getOneMessage:Jbt,getEachMessage:Xbt,getCancelSignal:Qbt}=Fre();var qne=!1,Vne=()=>{qne=!0},mo=()=>qne;var $_=null,Hne=t=>($_&&$_.destroy(),$_=new hs({totalAllowedTime:t}),$_),Wne=()=>$_;var hs=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&&mo())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 vA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{le.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 Yne={name:"@netlify/agent-runner-cli",type:"module",version:"1.159.4",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.4","@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 uFe=cFe(import.meta.url),dFe=ms.dirname(uFe),fFe=lFe(import.meta.url),wf=fe("shell"),O$=new Set,Kne={preferLocal:!0},dr=(t,e,r)=>{let[n,i]=pFe(e,r),o={...Kne,...i},s=zne(t,n,o);Jne(s,o),eie(s);let a=r?.idleTimeout;return a&&a>0&&Qne(s,a),s},Zne=(t,e)=>{let r={...Kne,...e},n=Gne(t,r);return Jne(n,r),eie(n),e?.idleTimeout&&e.idleTimeout>0&&Qne(n,e.idleTimeout),n},pFe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Jne=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(gs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new d_).pipe(gs.stdout),t.stderr?.pipe(new d_).pipe(gs.stderr);return}t.stdout?.pipe(gs.stdout),t.stderr?.pipe(gs.stderr)},N$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(gs.kill(-t.pid,e),wf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return wf.error("Error killing process:",r),!1}},Xne=t=>N$(t,"SIGKILL"),Qne=(t,e)=>{let r=null,n=()=>{wf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),N$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(wf.log(`Force killing idle process ${t.pid}`),Xne(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)},eie=t=>{O$.add(t);let e=Wne();if(e){let r=e.onTimesUp(()=>{wf.log(`Global timer expired, killing process ${t.pid}`),N$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(wf.log(`Force killing process ${t.pid} after timeout`),Xne(t))},5e3)});t.on("exit",()=>{O$.delete(t),r()}),t.on("error",()=>{O$.delete(t),r()})}};function go(t,e){if(!gs.env.NETLIFY_LOCAL_MODE)try{let i=fFe.resolve(Yne.name),o=ms.dirname(i);for(;o!==ms.dirname(o);){let s=ms.dirname(o);if(ms.basename(s)==="node_modules"){let a=ms.join(s,".bin",e);if(Lx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(gs.env.NODE_PATH){let i=ms.join(gs.env.NODE_PATH,".bin",e);if(Lx.existsSync(i))return i}let r=ms.join(t,"node_modules",".bin",e);if(Lx.existsSync(r))return r;let n=ms.join(dFe,"..","node_modules",".bin",e);if(Lx.existsSync(n))return n}var hFe=fe("utils"),mFe=t=>new Promise(e=>{setTimeout(e,t)});var k$=t=>{try{return new URL(t).hostname||null}catch{return null}},$x=(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 mFe(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},Ma=(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},tie=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):hFe.error("Could not parse JSON",n))}},gFe=t=>t.charAt(0).toUpperCase()+t.slice(1),_o=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():gFe(e)).join(" ");function _s(t,e){e&&t.log(`Skill invoked: ${e}`)}var Ux=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),rie=(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 M$=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}},_Fe=1e4,D$=(t,e=_Fe)=>{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 yFe}from"crypto";import{createReadStream as SFe}from"fs";import Fx from"fs/promises";import aie from"os";import Bx from"path";var nie=fe("repo"),cie="runner-diffs-",lie=t=>`${cie}${t}-`,uie=async t=>{let e=aie.tmpdir(),r;try{r=await Fx.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(cie)&&!n.startsWith(lie(t))).map(n=>Fx.rm(Bx.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xr=(t,e={})=>dr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),jx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{nie.info("Getting runner diffs");let n=await vFe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let h=bFe(o);await AFe(h,r)}nie.info("Changes after processing"),await $$(r);let s=await F$(o,r);if(await L$(s,r),i=await TFe(r),!i)return{hasChanges:!1,ignored:s};await Xr(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await Fx.mkdtemp(Bx.join(aie.tmpdir(),lie(t.sessionId))),c=async({from:h,to:m,fileName:y,binary:E})=>{let b=Bx.join(a,y);await Xr([...E?["diff",h,m,"--binary"]:["diff",h,m],`--output=${b}`],{stdio:["ignore","ignore","pipe"],cwd:r});let{size:S}=await Fx.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 sie(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 oie(d,h)||(f=h)}await sie(r),le.distribution("diff.size",u.size);let p={hasChanges:!0,diff:l,resultDiff:d,ignored:s};return await oie(l,u)||(p.diffBinary=u),f&&(p.resultDiffBinary=f),p},iie=async t=>{let e=yFe("sha256");for await(let r of SFe(t))e.update(r);return e.digest("hex")},oie=async(t,e)=>t.size===e.size&&await iie(t.path)===await iie(e.path),sie=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xr(["reset","--soft","HEAD~1"],{cwd:t})},L$=async(t=[],e=process.cwd())=>{await Xr(["add",".",...t],{cwd:e})},$$=async(t=process.cwd())=>{let e=await Xr(["status","-s"],{cwd:t});return String(e.stdout??"")},die=/.. (.+)?\.log$/,EFe=[die],vFe=async(t=process.cwd())=>{let e=await $$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
102
|
`).filter(i=>EFe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},TFe=async(t=process.cwd())=>{try{return await Xr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},U$=async(t=process.cwd())=>{let{stdout:e}=await Xr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},fie=async(t=process.cwd())=>{let{stdout:e}=await Xr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},F$=async(t,e=process.cwd())=>{t||=await $$(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(`
|
|
103
103
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${Bx.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(die)?.[1];o&&n.push(`:!${o}.log`)}),n},pie=async(t=process.cwd())=>{await Xr(["reset","--hard","HEAD"],{cwd:t})},hie=async(t=process.cwd())=>{let e=await Xr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
104
104
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},bFe=t=>{let e=t.split(`
|
|
@@ -215,7 +215,7 @@ A: ${i}`).join(`
|
|
|
215
215
|
`),[yze,e,Sze].filter(Boolean).join(" ")].filter(Boolean).join(`
|
|
216
216
|
|
|
217
217
|
`);import x2 from"path";import bze from"fs/promises";var w2=fe("agent-output-utils");async function tc({initialResult:t,agentName:e,hasError:r}){let n="",i=x2.join(process.cwd(),ur,as);try{let o=await bze.readFile(i,"utf-8");o&&(n=o,w2.log(`Pulled result from ${x2.relative(process.cwd(),i)}`))}catch{w2.log(`No results file found at ${x2.relative(process.cwd(),i)}`)}return n||(!t&&!r?`${e} has finished working on task.`:t||void 0)}var Aze=[/^API Error:\s*\d{3}/i,/^\d{3}\s*status code/i,/^API request failed:\s*\d{3}/i,/^API Error: The socket connection was closed/i,/^overloaded_error/i];function iI(t){let e=t.trim();return Aze.some(r=>r.test(e))?"Encountered a temporary issue \u2014 the agent will attempt to continue.":t}var pce=256*1024,hce=t=>`
|
|
218
|
-
\u2026 [truncated ${t} characters]`;function mce(t){if(t.length<=pce)return t;let e=hce(t.length).length,r=t.slice(0,pce-e);return`${r}${hce(t.length-r.length)}`}function gce(t){return t.includes("usage exceeded")?!1:t.includes("insufficient credits")||t.includes("openrouter.ai/settings/credits")}function rc({error:t,agentName:e}){let r=t&&typeof t=="object"?JSON.stringify(t):t,n=r?.replace(/\s+/g," ").trim().toLowerCase()||"",i="";return n?.includes("ai gateway is not available for your account")||n?.includes("ai gateway is not enabled for your account")?i="AI Gateway is currently not available on your account. Please confirm your account meets the criteria for using Agent Runners and AI Gateway and that your account has remaining AI Gateway inference credits available. Reach out to Netlify support if this is unexpected.":n?.includes("error when talking to gemini api")?i="Gemini's API is currently having issues. Please try again or use a different available agent while Google resolves the issue.":(n?.includes("connection closed prematurely")||n?.includes("499")&&e.toLowerCase().includes("gemini"))&&(i=`The ${e} models were currently overloaded. Please try again or use a different available agent.`),n?.includes("request timed out")&&(i=`The ${e} API request's have timed out. Please try again or use a different available agent.`),(n?.includes("network error")||n?.includes("socket connection was closed"))&&(i=`The ${e} agent is having network issues. Please try again or use a different available agent.`),n?.includes("503")&&!n?.includes("usage exceeded")&&(i=`The ${e} API is currently experiencing high load. Retrying automatically...`),(n?.includes("529")||n?.includes("overloaded_error"))&&(i=`The ${e} API is currently overloaded. Retrying automatically...`),n?.includes("at capacity")&&(i=`The ${e} model is currently at capacity. Retrying automatically...`),(n?.includes("there's an issue with the selected model")||n?.includes("is not available for")&&n?.includes("provider"))&&(i=`The ${e} model is temporarily unavailable. Please try again later or use a different available agent.`),gce(n)&&(i=`${e} is temporarily unavailable. Please use a different available agent.`),i&&w2.log(`Providing updated error messsage: ${i}, replacing original error: ${r}`),i||r||void 0}function nc(t){if(!t)return!1;let r=(t&&typeof t=="object"?JSON.stringify(t):t)?.replace(/\s+/g," ").trim().toLowerCase()||"";return r?.includes("error when talking to gemini api")||r?.includes("499")||r?.includes("connection closed prematurely")||r?.includes("socket connection was closed")||r?.includes("request timed out")||r?.includes("network error")?!0:r?.includes("usage exceeded")?!1:!!(r?.includes("503")||r?.includes("529")||r?.includes("overloaded_error")||r?.includes("at capacity"))}function ic(t){if(!t)return!1;let e=t.replace(/\s+/g," ").trim().toLowerCase();return!!(e.includes("there's an issue with the selected model")||e.includes("is not available for")&&e.includes("provider")||gce(e))}import oI from"process";import{fileURLToPath as Cze}from"url";import{createRequire as Pze}from"module";import sI from"path";import{readdir as xze,rm as wze}from"fs/promises";import{join as Rze}from"path";async function _ce(t,e=[]){let n=(await xze(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>wze(Rze(t,i),{recursive:!0,force:!0})))}var Ize=700,yce=t=>{if(t.mode!=="create")return!1;if(t.accountType===f_)return!0;let{enforcedAICreditsRemaining:e}=t;return e!=null&&e<=Ize};var Oze=sI.dirname(Cze(import.meta.url)),Sce=Pze(import.meta.url),Nze=sI.resolve(Oze,"scripts/scaffold.js"),kze="scripts/scaffold.js",Mze=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,R2=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},Dze=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),Lze=t=>{let e=R2(t);return e==="node"||e.endsWith("/node")},Ps=t=>{if(typeof t!="string")return!1;let e=t.match(Mze)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&Dze(R2(e[r]));)r+=1;if(r>=e.length||!Lze(e[r]))return!1;let n=e[r+1];return n?R2(n).includes(kze):!1},$p=fe("create_stage"),Ece="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.",$ze=`${Ece}
|
|
218
|
+
\u2026 [truncated ${t} characters]`;function mce(t){if(t.length<=pce)return t;let e=hce(t.length).length,r=t.slice(0,pce-e);return`${r}${hce(t.length-r.length)}`}function gce(t){return t.includes("usage exceeded")?!1:t.includes("insufficient credits")||t.includes("openrouter.ai/settings/credits")}function rc({error:t,agentName:e}){let r=t&&typeof t=="object"?JSON.stringify(t):t,n=r?.replace(/\s+/g," ").trim().toLowerCase()||"",i="";return n?.includes("ai gateway is not available for your account")||n?.includes("ai gateway is not enabled for your account")?i="AI Gateway is currently not available on your account. Please confirm your account meets the criteria for using Agent Runners and AI Gateway and that your account has remaining AI Gateway inference credits available. Reach out to Netlify support if this is unexpected.":n?.includes("error when talking to gemini api")?i="Gemini's API is currently having issues. Please try again or use a different available agent while Google resolves the issue.":(n?.includes("connection closed prematurely")||n?.includes("499")&&e.toLowerCase().includes("gemini"))&&(i=`The ${e} models were currently overloaded. Please try again or use a different available agent.`),n?.includes("request timed out")&&(i=`The ${e} API request's have timed out. Please try again or use a different available agent.`),(n?.includes("network error")||n?.includes("socket connection was closed"))&&(i=`The ${e} agent is having network issues. Please try again or use a different available agent.`),(n?.includes("econnreset")||n?.includes("fetch failed"))&&(i=`The ${e} agent hit a temporary connection issue. Retrying automatically...`),n?.includes("503")&&!n?.includes("usage exceeded")&&(i=`The ${e} API is currently experiencing high load. Retrying automatically...`),(n?.includes("529")||n?.includes("overloaded_error"))&&(i=`The ${e} API is currently overloaded. Retrying automatically...`),n?.includes("at capacity")&&(i=`The ${e} model is currently at capacity. Retrying automatically...`),(n?.includes("there's an issue with the selected model")||n?.includes("is not available for")&&n?.includes("provider"))&&(i=`The ${e} model is temporarily unavailable. Please try again later or use a different available agent.`),gce(n)&&(i=`${e} is temporarily unavailable. Please use a different available agent.`),i&&w2.log(`Providing updated error messsage: ${i}, replacing original error: ${r}`),i||r||void 0}function nc(t){if(!t)return!1;let r=(t&&typeof t=="object"?JSON.stringify(t):t)?.replace(/\s+/g," ").trim().toLowerCase()||"";return r?.includes("error when talking to gemini api")||r?.includes("499")||r?.includes("connection closed prematurely")||r?.includes("socket connection was closed")||r?.includes("request timed out")||r?.includes("network error")||r?.includes("econnreset")||r?.includes("fetch failed")?!0:r?.includes("usage exceeded")?!1:!!(r?.includes("503")||r?.includes("529")||r?.includes("overloaded_error")||r?.includes("at capacity"))}function ic(t){if(!t)return!1;let e=t.replace(/\s+/g," ").trim().toLowerCase();return!!(e.includes("there's an issue with the selected model")||e.includes("is not available for")&&e.includes("provider")||gce(e))}import oI from"process";import{fileURLToPath as Cze}from"url";import{createRequire as Pze}from"module";import sI from"path";import{readdir as xze,rm as wze}from"fs/promises";import{join as Rze}from"path";async function _ce(t,e=[]){let n=(await xze(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>wze(Rze(t,i),{recursive:!0,force:!0})))}var Ize=700,yce=t=>{if(t.mode!=="create")return!1;if(t.accountType===f_)return!0;let{enforcedAICreditsRemaining:e}=t;return e!=null&&e<=Ize};var Oze=sI.dirname(Cze(import.meta.url)),Sce=Pze(import.meta.url),Nze=sI.resolve(Oze,"scripts/scaffold.js"),kze="scripts/scaffold.js",Mze=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,R2=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},Dze=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),Lze=t=>{let e=R2(t);return e==="node"||e.endsWith("/node")},Ps=t=>{if(typeof t!="string")return!1;let e=t.match(Mze)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&Dze(R2(e[r]));)r+=1;if(r>=e.length||!Lze(e[r]))return!1;let n=e[r+1];return n?R2(n).includes(kze):!1},$p=fe("create_stage"),Ece="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.",$ze=`${Ece}
|
|
219
219
|
|
|
220
220
|
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.`,Uze=`${Ece}
|
|
221
221
|
|