@netlify/agent-runner-cli 1.169.3 → 1.170.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.js +18 -18
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -621,7 +621,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
621
621
|
`,LF:`
|
|
622
622
|
`,concatBytes:oY},jTt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},zTt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:jTt};import{Buffer as qTt}from"buffer";var WRe=(t,e)=>t?void 0:BTt.bind(void 0,e),BTt=function*(t,e){if(typeof e!="string"&&!Zr(e)&&!qTt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},YRe=(t,e)=>t?HTt.bind(void 0,e):VTt.bind(void 0,e),HTt=function*(t,e){KRe(t,e),yield e},VTt=function*(t,e){if(KRe(t,e),typeof e!="string"&&!Zr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},KRe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
623
623
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
624
|
-
if (condition) { yield value; }`)};import{Buffer as GTt}from"buffer";import{StringDecoder as WTt}from"string_decoder";var XN=(t,e,r)=>{if(r)return;if(t)return{transform:YTt.bind(void 0,new TextEncoder)};let n=new WTt(e);return{transform:KTt.bind(void 0,n),final:JTt.bind(void 0,n)}},YTt=function*(t,e){GTt.isBuffer(e)?yield Xc(e):typeof e=="string"?yield t.encode(e):yield e},KTt=function*(t,e){yield Zr(e)?t.write(e):e},JTt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as JRe}from"util";var cY=JRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),QN=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=XTt}=e[r];for await(let i of n(t))yield*QN(i,e,r+1)},ZRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ZTt(r,Number(e),t)},ZTt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*QN(n,r,e+1)},XRe=JRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),XTt=function*(t){yield t};var lY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},QRe=(t,e)=>[...e.flatMap(r=>[...vp(r,t,0)]),...qT(t)],vp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=ewt}=e[r];for(let i of n(t))yield*vp(i,e,r+1)},qT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*QTt(r,Number(e),t)},QTt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*vp(n,r,e+1)},ewt=function*(t){yield t};var uY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=t0e(t,o,s),l=Ep(e),u=Ep(r),d=l?cY.bind(void 0,QN,a):lY.bind(void 0,vp),f=l||u?cY.bind(void 0,ZRe,a):lY.bind(void 0,qT),p=l||u?XRe.bind(void 0,a):void 0;return{stream:new twt({writableObjectMode:n,writableHighWaterMark:e0e(n),readableObjectMode:i,readableHighWaterMark:e0e(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},ek=(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=t0e(o,r,a);t=QRe(c,t)}return t},t0e=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:WRe(n,a)},XN(r,o,n),ZN(r,s,n,c),{transform:t,final:e},{transform:YRe(i,a)},GRe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var r0e=(t,e)=>{for(let r of rwt(t))nwt(t,r,e)},rwt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),nwt=(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 ${nd[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>iwt(a,n));r.input=NT(o)},iwt=(t,e)=>{let r=ek(t,e,"utf8",!0);return swt(r),NT(r)},swt=t=>{let e=t.find(r=>typeof r!="string"&&!Zr(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 lwt,appendFileSync as uwt}from"fs";var tk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&v_(r,n)&&!ls.has(e)&&owt(n)&&(t.some(({type:i,value:s})=>i==="native"&&awt.has(s))||t.every(({type:i})=>Gs.has(i))),owt=t=>t===1||t===2,awt=new Set(["pipe","overlapped"]),n0e=async(t,e,r,n)=>{for await(let i of t)cwt(e)||s0e(i,r,n)},i0e=(t,e,r)=>{for(let n of t)s0e(n,e,r)},cwt=t=>t._readableState.pipes.length>0,s0e=(t,e,r)=>{let n=mN(t);Ia({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var o0e=({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)=>dwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},dwt=({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=aRe(t,s,d),p=Xc(f),{stdioItems:h,objectMode:m}=e[r],_=fwt([p],h,c,n),{serializedResult:y,finalResult:v=y}=pwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});hwt({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&&mwt(y,h,i),S}catch(g){return n.error=g,S}},fwt=(t,e,r,n)=>{try{return ek(t,e,r,!1)}catch(i){return n.error=i,t}},pwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:NT(t)};let o=vbe(t,r);return n[s]?{serializedResult:o,finalResult:aY(o,!i[s],e)}:{serializedResult:o}},hwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!tk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=aY(t,!1,o);try{i0e(a,e,n)}catch(c){r.error??=c}},mwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>KN.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?uwt(n,t):(r.add(s),lwt(n,t))}};var a0e=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,tl(e,r,"all")]:Array.isArray(e)?[tl(t,r,"all"),...e]:Zr(t)&&Zr(e)?gW([t,e]):`${t}${e}`};import{once as dY}from"events";var c0e=async(t,e)=>{let[r,n]=await gwt(t);return e.isForcefullyTerminated??=!1,[r,n]},gwt=async t=>{let[e,r]=await Promise.allSettled([dY(t,"spawn"),dY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?l0e(t):r.value},l0e=async t=>{try{return await dY(t,"exit")}catch{return l0e(t)}},u0e=async t=>{let[e,r]=await t;if(!_wt(e,r)&&fY(e,r))throw new Ao;return[e,r]},_wt=(t,e)=>t===void 0&&e===void 0,fY=(t,e)=>t!==0||e!==null;var d0e=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ywt(t,e,r),o=s?.code==="ETIMEDOUT",a=oRe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ywt=(t,e,r)=>t!==void 0?t:fY(e,r)?new Ao:void 0;var f0e=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Ewt(t,e,r),d=Twt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return O_(d,c,l)},Ewt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),a=vwt(r),{file:c,commandArguments:l,options:u}=MN(t,e,a);bwt(u);let d=qRe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},vwt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,bwt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&rk("ipcInput"),t&&rk("ipc: true"),r&&rk("detached: true"),n&&rk("cancelSignal")},rk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Twt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=wwt({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}=d0e(c,r),{output:h,error:m=l}=o0e({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>tl(v,r,S)),y=tl(a0e(h,r),r,"all");return Awt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},wwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{r0e(s,r);let a=Rwt(r);return Swt(...UN(t,e,a))}catch(a){return I_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Rwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:VN(e)}),Awt=({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?GN({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):zT({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 p0t}from"events";import{spawn as h0t}from"child_process";import _0e from"process";import{once as pY,on as xwt}from"events";var p0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(w_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),Pwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Pwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{xN(e,i);let s=rd(t,e,r),o=new AbortController;try{return await Promise.race([Cwt(s,n,o),Iwt(s,r,o),Owt(s,r,o)])}catch(a){throw R_(t),a}finally{o.abort(),PN(e,i)}},Cwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await pY(t,"message",{signal:r});return n}for await(let[n]of xwt(t,"message",{signal:r}))if(e(n))return n},Iwt=async(t,e,{signal:r})=>{await pY(t,"disconnect",{signal:r}),QTe(e)},Owt=async(t,e,{signal:r})=>{let[n]=await pY(t,"strict:error",{signal:r});throw wN(n,e)};import{once as m0e,on as Nwt}from"events";var g0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>hY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),hY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{w_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),xN(e,s);let o=rd(t,e,r),a=new AbortController,c={};return kwt(t,o,a),$wt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Lwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},kwt=async(t,e,r)=>{try{await m0e(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},$wt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await m0e(t,"strict:error",{signal:r.signal});n.error=wN(i,e),r.abort()}catch{}},Lwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Nwt(r,"message",{signal:s.signal}))h0e(o),yield c}catch{h0e(o)}finally{s.abort(),PN(e,a),n||R_(t),i&&await t}},h0e=({error:t})=>{if(t)throw t};var y0e=(t,{ipc:e})=>{Object.assign(t,E0e(t,!1,e))},S0e=()=>{let t=_0e,e=!0,r=_0e.channel!==void 0;return{...E0e(t,e,r),getCancelSignal:Awe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},E0e=(t,e,r)=>({sendMessage:LN.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:p0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:g0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Dwt}from"child_process";import{PassThrough as Mwt,Readable as Uwt,Writable as Fwt,Duplex as jwt}from"stream";var v0e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{iY(n);let a=new Dwt;zwt(a,n),Object.assign(a,{readable:qwt,writable:Bwt,duplex:Hwt});let c=I_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Vwt(c,o,i);return{subprocess:a,promise:l}},zwt=(t,e)=>{let r=BT(),n=BT(),i=BT(),s=Array.from({length:e.length-3},BT),o=BT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},BT=()=>{let t=new Mwt;return t.end(),t},qwt=()=>new Uwt({read(){}}),Bwt=()=>new Fwt({write(){}}),Hwt=()=>new jwt({read(){},write(){}}),Vwt=async(t,e,r)=>O_(t,e,r);import{createReadStream as b0e,createWriteStream as T0e}from"fs";import{Buffer as Gwt}from"buffer";import{Readable as HT,Writable as Wwt,Duplex as Ywt}from"stream";var R0e=(t,e)=>JN(Kwt,t,e,!1),VT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${nd[t]}.`)},w0e={fileNumber:VT,generator:uY,asyncGenerator:uY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Ywt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Kwt={input:{...w0e,fileUrl:({value:t})=>({stream:b0e(t)}),filePath:({value:{file:t}})=>({stream:b0e(t)}),webStream:({value:t})=>({stream:HT.fromWeb(t)}),iterable:({value:t})=>({stream:HT.from(t)}),asyncIterable:({value:t})=>({stream:HT.from(t)}),string:({value:t})=>({stream:HT.from(t)}),uint8Array:({value:t})=>({stream:HT.from(Gwt.from(t))})},output:{...w0e,fileUrl:({value:t})=>({stream:T0e(t)}),filePath:({value:{file:t,append:e}})=>({stream:T0e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Wwt.fromWeb(t)}),iterable:VT,asyncIterable:VT,string:VT,uint8Array:VT}};import{on as Jwt,once as A0e}from"events";import{PassThrough as Zwt,getDefaultHighWaterMark as Xwt}from"stream";import{finished as C0e}from"stream/promises";function bp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)gY(i);let e=t.some(({readableObjectMode:i})=>i),r=Qwt(t,e),n=new mY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Qwt=(t,e)=>{if(t.length===0)return Xwt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},mY=class extends Zwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(gY(e),this.#e.has(e))return;this.#e.add(e),this.#n??=eRt(this,this.#e,this.#s);let r=nRt({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(gY(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)}},eRt=async(t,e,r)=>{nk(t,x0e);let n=new AbortController;try{await Promise.race([tRt(t,n),rRt(t,e,r,n)])}finally{n.abort(),nk(t,-x0e)}},tRt=async(t,{signal:e})=>{try{await C0e(t,{signal:e,cleanup:!0})}catch(r){throw I0e(t,r),r}},rRt=async(t,e,r,{signal:n})=>{for await(let[i]of Jwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},gY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},nRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{nk(t,P0e);let a=new AbortController;try{await Promise.race([iRt(s,e,a),sRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),oRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),nk(t,-P0e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?_Y(t):aRt(t))},iRt=async(t,e,{signal:r})=>{try{await t,r.aborted||_Y(e)}catch(n){r.aborted||I0e(e,n)}},sRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await C0e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;O0e(o)?i.add(e):N0e(t,o)}},oRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await A0e(t,i,{signal:s}),!t.readable)return A0e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},aRt=t=>{t.writable&&t.end()},I0e=(t,e)=>{O0e(e)?_Y(t):N0e(t,e)},O0e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_Y=t=>{(t.readable||t.writable)&&t.destroy()},N0e=(t,e)=>{t.destroyed||(t.once("error",cRt),t.destroy(e))},cRt=()=>{},nk=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},x0e=2,P0e=1;import{finished as k0e}from"stream/promises";var k_=(t,e)=>{t.pipe(e),lRt(t,e),uRt(t,e)},lRt=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await k0e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}yY(e)}},yY=t=>{t.writable&&t.end()},uRt=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await k0e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}SY(t)}},SY=t=>{t.readable&&t.destroy()};var $0e=(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})=>Gs.has(c)))dRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Gs.has(c)))pRt({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]:bp(s);k_(o,i)}},dRt=(t,e,r,n)=>{r==="output"?k_(t.stdio[n],e):k_(e,t.stdio[n]);let i=fRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},fRt=["stdin","stdout","stderr"],pRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;hRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},hRt=(t,{signal:e})=>{Ro(t)&&yp(t,mRt,e)},mRt=2;import{addAbortListener as yRt}from"events";var Tp=[];Tp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Tp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Tp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ik=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",EY=Symbol.for("signal-exit emitter"),vY=globalThis,gRt=Object.defineProperty.bind(Object),bY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vY[EY])return vY[EY];gRt(vY,EY,{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}},sk=class{},_Rt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),TY=class extends sk{onExit(){return()=>{}}load(){}unload(){}},wY=class extends sk{#e=RY.platform==="win32"?"SIGINT":"SIGHUP";#r=new bY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Tp)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(!ik(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 Tp)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,Tp.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 ik(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"&&ik(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)}},RY=globalThis.process,{onExit:L0e,load:Xgr,unload:Qgr}=_Rt(ik(RY)?new wY(RY):new TY);var D0e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=L0e(()=>{t.kill()});yRt(n,()=>{i()})};var U0e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=gN(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=SRt(r,n,i),{sourceStream:d,sourceError:f}=vRt(t,l),{options:p,fileDescriptors:h}=Na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},SRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=ERt(t,e,...r),a=AN(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},ERt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(M0e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||hW(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]=oN(r,...n);return{destination:e(M0e)(i,s,o),pipeOptions:o}}if(Na.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}`)},M0e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),vRt=(t,e)=>{try{return{sourceStream:A_(t,e)}}catch(r){return{sourceError:r}}};var j0e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=bRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw AY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},bRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return SY(t),n;if(e!==void 0)return yY(r),e},AY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>I_({error:t,command:F0e,escapedCommand:F0e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),F0e="source.pipe(destination)";var z0e=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 TRt}from"stream/promises";var q0e=(t,e,r)=>{let n=ok.has(e)?RRt(t,e):wRt(t,e);return yp(t,xRt,r.signal),yp(e,PRt,r.signal),ARt(e),n},wRt=(t,e)=>{let r=bp([t]);return k_(r,e),ok.set(e,r),r},RRt=(t,e)=>{let r=ok.get(e);return r.add(t),r},ARt=async t=>{try{await TRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ok.delete(t)},ok=new WeakMap,xRt=2,PRt=1;import{aborted as CRt}from"util";var B0e=(t,e)=>t===void 0?[]:[IRt(t,e)],IRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await CRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw AY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ak=(t,...e)=>{if(Lr(e[0]))return ak.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=U0e(t,...e),i=ORt({...n,destination:r});return i.pipe=ak.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},ORt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=NRt(t,i);j0e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=q0e(e,s,d);return await Promise.race([z0e(u),...B0e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},NRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as FRt}from"timers/promises";import{on as kRt}from"events";import{getDefaultHighWaterMark as $Rt}from"stream";var ck=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return LRt(e,o),V0e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},LRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},xY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;DRt(e,o,t);let a=t.readableObjectMode&&!s;return V0e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},DRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},V0e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=kRt(t,"data",{signal:e.signal,highWaterMark:H0e,highWatermark:H0e});return MRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},PY=$Rt(!0),H0e=PY,MRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=URt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*vp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*qT(a)}},URt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[XN(t,r,!e),ZN(t,i,!n,{})].filter(Boolean);var G0e=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=jRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([zRt(t),d]);return}let f=sY(c,r),p=xY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([qRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},jRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!tk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=xY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await n0e(a,t,r,s)},zRt=async t=>{await FRt(),t.readableFlowing===null&&t.resume()},qRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qN(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await BN(r,{maxBuffer:s})):await C_(r,{maxBuffer:s})}catch(a){return W0e(nRe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},CY=async t=>{try{return await t}catch(e){return W0e(e)}},W0e=({bufferedData:t})=>Sbe(t)?new Uint8Array(t):t;import{finished as BRt}from"stream/promises";var GT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=HRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],BRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||WRt(a,e,r,n)}finally{o.abort()}},HRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&VRt(t,r,n),n},VRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{GRt(e,r),n.call(t,...i)}},GRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},WRt=(t,e,r,n)=>{if(!YRt(t,e,r,n))throw t},YRt=(t,e,r,n=!0)=>r.propagating?Y0e(t)||lk(t):(r.propagating=!0,IY(r,e)===n?Y0e(t):lk(t)),IY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",lk=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y0e=t=>t?.code==="EPIPE";var K0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>OY({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),OY=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=GT(t,e,l);if(IY(l,e)){await u;return}let[d]=await Promise.all([G0e({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 J0e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?bp([t,e].filter(Boolean)):void 0,Z0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>OY({...KRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:JRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),KRt=({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}},JRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as ZRt}from"events";var X0e=t=>v_(t,"ipc"),Q0e=(t,e)=>{let r=mN(t);Ia({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var eAe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=X0e(s),a=Qc(e,"ipc"),c=Qc(r,"ipc");for await(let l of hY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(iRe(t,i,c),i.push(l)),o&&Q0e(l,s);return i},tAe=async(t,e)=>(await Promise.allSettled([t]),e);var rAe=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=c0e(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=K0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),R=Z0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),x=[],w=eAe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),b=XRt(m,t,S),C=QRt(h,S);try{return await Promise.race([Promise.all([{},u0e(v),Promise.all(g),R,w,Dwe(t,d),...b,...C]),_,e0t(t,y),...Owe(t,s,f,y),...XTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Cwe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(N){return f.terminationReason??="other",Promise.all([{error:N},v,Promise.all(g.map(A=>CY(A))),CY(R),tAe(w,x),Promise.allSettled(b),Promise.allSettled(C)])}},XRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:GT(n,i,r)),QRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Po(s,{checkOpen:!1})&&!Ro(s)).map(({type:i,value:s,stream:o=s})=>GT(o,n,e,{isSameDirection:Gs.has(i),stopOnExit:i==="native"}))),e0t=async(t,{signal:e})=>{let[r]=await ZRt(t,"error",{signal:e});throw r};var nAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),WT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Oa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},$_=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 t0t}from"stream";import{callbackify as r0t}from"util";import{finished as iAe}from"stream/promises";var NY=async t=>{if(t!==void 0)try{await kY(t)}catch{}},sAe=async t=>{if(t!==void 0)try{await $Y(t)}catch{}},kY=async t=>{await iAe(t,{cleanup:!0,readable:!1,writable:!0})},$Y=async t=>{await iAe(t,{cleanup:!0,readable:!0,writable:!1})},uk=async(t,e)=>{if(await t,e)throw e},dk=(t,e,r)=>{r&&!lk(r)?t.destroy(r):e&&t.destroy()};var oAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ls.has(r),{subprocessStdout:a,waitReadableDestroy:c}=LY(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=DY(a,o),{read:f,onStdoutDataDone:p}=MY({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new t0t({read:f,destroy:r0t(FY.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return UY({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},LY=(t,e,r)=>{let n=A_(t,e),i=WT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},DY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:PY},MY=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Oa(),o=ck({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){n0t(this,o,s)},onStdoutDataDone:s}},n0t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},UY=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await $Y(t),await n,await NY(i),await e,r.readable&&r.push(null)}catch(s){await NY(i),aAe(r,s)}},FY=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await $_(r,e)&&(aAe(t,n),await uk(e,n))},aAe=(t,e)=>{dk(t,t.readable,e)};import{Writable as i0t}from"stream";import{callbackify as cAe}from"util";var lAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=jY(t,r,e),o=new i0t({...zY(n,t,i),destroy:cAe(BY.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return qY(n,o),o},jY=(t,e,r)=>{let n=AN(t,e),i=WT(r,n,"writableFinal"),s=WT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},zY=(t,e,r)=>({write:s0t.bind(void 0,t),final:cAe(o0t.bind(void 0,t,e,r))}),s0t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},o0t=async(t,e,r)=>{await $_(r,e)&&(t.writable&&t.end(),await e)},qY=async(t,e,r)=>{try{await kY(t),e.writable&&e.end()}catch(n){await sAe(r),uAe(e,n)}},BY=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await $_(r,e),await $_(n,e)&&(uAe(t,i),await uk(e,i))},uAe=(t,e)=>{dk(t,t.writable,e)};import{Duplex as a0t}from"stream";import{callbackify as c0t}from"util";var dAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ls.has(r),{subprocessStdout:c,waitReadableDestroy:l}=LY(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=jY(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=DY(c,a),{read:_,onStdoutDataDone:y}=MY({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new a0t({read:_,...zY(u,t,d),destroy:c0t(l0t.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 UY({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),qY(u,v,c),v},l0t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([FY({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),BY({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var HY=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ls.has(e),o=A_(t,r),a=ck({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return u0t(a,o,t)},u0t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var fAe=(t,{encoding:e})=>{let r=nAe();t.readable=oAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=lAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=dAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=HY.bind(void 0,t,e),t[Symbol.asyncIterator]=HY.bind(void 0,t,e,{})};var pAe=(t,e)=>{for(let[r,n]of f0t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},d0t=(async()=>{})().constructor.prototype,f0t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(d0t,t)]);var hAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=m0t(t,e,r),{subprocess:f,promise:p}=_0t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ak.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),pAe(f,p),Na.set(f,{options:u,fileDescriptors:d}),f},m0t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),{file:a,commandArguments:c,options:l}=MN(t,e,r),u=g0t(l),d=R0e(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},g0t=({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}},_0t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=h0t(...UN(t,e,r))}catch(h){return v0e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;p0t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];$0e(c,a,l),D0e(c,r,l);let d={},f=Oa();c.kill=JTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=J0e(c,r),fAe(c,r),y0e(c,r);let p=y0t({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}},y0t=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 rAe({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,R)=>tl(g,e,R)),v=tl(m,e,"all"),S=S0t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return O_(S,n,e)},S0t=({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?zT({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 ka,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):GN({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var fk=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,E0t(n,t[n],i)]));return{...t,...r}},E0t=(t,e,r)=>v0t.has(t)&&Lr(e)&&Lr(r)?{...e,...r}:r,v0t=new Set(["env",...EW]);var id=(t,e,r,n)=>{let i=(o,a,c)=>id(o,a,r,c),s=(...o)=>b0t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},b0t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Lr(s))return i(t,fk(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=T0t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?f0e(a,c,l):hAe(a,c,l,i)},T0t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Rbe(e)?Abe(e,r):[e,...r],[o,a,c]=oN(...s),l=fk(fk(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 mAe=({file:t,commandArguments:e})=>_Ae(t,e),gAe=({file:t,commandArguments:e})=>({..._Ae(t,e),isSync:!0}),_Ae=(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]=w0t(t);return{file:r,commandArguments:n}},w0t=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(R0t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},R0t=/ +/g;var yAe=(t,e,r)=>{t.sync=e(A0t,r),t.s=t.sync},SAe=({options:t})=>EAe(t),A0t=({options:t})=>({...EAe(t),isSync:!0}),EAe=t=>({options:{...x0t(t),...t}}),x0t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},vAe={preferLocal:!0};var bAe=id(()=>({})),qSr=id(()=>({isSync:!0})),TAe=id(mAe),BSr=id(gAe),HSr=id(kwe),VSr=id(SAe,{},vAe,yAe),{sendMessage:GSr,getOneMessage:WSr,getEachMessage:YSr,getCancelSignal:KSr}=S0e();import{Transform as P0t}from"stream";var C0t=["NETLIFY_AI_GATEWAY_KEY"];function I0t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...C0t])]}function O0t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function N0t(){let e=I0t().map(r=>process.env[r]).filter(r=>!(!r||O0t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Bi(t){if(typeof t!="string")return t;let e=N0t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(k0t(n),"g");r=r.replace(i,"******")}),r}function k0t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var YT=class extends P0t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Bi(i);n(null,s)}},pk=Symbol("maskedWrite");function wAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[pk]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Bi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stdout.write=r}if(!process.stderr.write[pk]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Bi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stderr.write=r}}}var RAe=!1,AAe=()=>{RAe=!0},Hi=()=>RAe;var KT=null,xAe=t=>(KT&&KT.destroy(),KT=new Co({totalAllowedTime:t}),KT),PAe=()=>KT;var Co=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&&Hi())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 tN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{de.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 CAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.169.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:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var M0t=L0t(import.meta.url),U0t=rl.dirname(M0t),F0t=D0t(import.meta.url),L_=pe("shell"),VY=new Set,IAe={preferLocal:!0},pr=(t,e,r)=>{let[n,i]=j0t(e,r),s={...IAe,...i},o=bAe(t,n,s);NAe(o,s),LAe(o);let a=r?.idleTimeout;return a&&a>0&&$Ae(o,a),o},OAe=(t,e)=>{let r={...IAe,...e},n=TAe(t,r);return NAe(n,r),LAe(n),e?.idleTimeout&&e.idleTimeout>0&&$Ae(n,e.idleTimeout),n},j0t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},NAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||La.env.NETLIFY_LOCAL_QUIET==="true")return;if(La.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new YT).pipe(La.stdout),t.stderr?.pipe(new YT).pipe(La.stderr);return}t.stdout?.pipe(La.stdout),t.stderr?.pipe(La.stderr)},GY=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(La.kill(-t.pid,e),L_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return L_.error("Error killing process:",r),!1}},kAe=t=>GY(t,"SIGKILL"),$Ae=(t,e)=>{let r=null,n=()=>{L_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),GY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(L_.log(`Force killing idle process ${t.pid}`),kAe(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)},LAe=t=>{VY.add(t);let e=PAe();if(e){let r=e.onTimesUp(()=>{L_.log(`Global timer expired, killing process ${t.pid}`),GY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(L_.log(`Force killing process ${t.pid} after timeout`),kAe(t))},5e3)});t.on("exit",()=>{VY.delete(t),r()}),t.on("error",()=>{VY.delete(t),r()})}};function Da(t,e){if(!La.env.NETLIFY_LOCAL_MODE)try{let i=F0t.resolve(CAe.name),s=rl.dirname(i);for(;s!==rl.dirname(s);){let o=rl.dirname(s);if(rl.basename(o)==="node_modules"){let a=rl.join(o,".bin",e);if(hk.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(La.env.NODE_PATH){let i=rl.join(La.env.NODE_PATH,".bin",e);if(hk.existsSync(i))return i}let r=rl.join(t,"node_modules",".bin",e);if(hk.existsSync(r))return r;let n=rl.join(U0t,"..","node_modules",".bin",e);if(hk.existsSync(n))return n}import MM from"process";import{fileURLToPath as hFt}from"url";import{createRequire as mFt}from"module";import WR from"path";import{readFileSync as gFt}from"fs";var z0t="__netlify__getTracer",q0t="__netlify__shutdownTracers",xt=(t,e)=>globalThis[z0t]?.(t,e),DAe=async()=>globalThis[q0t]?.();function JT(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 cFt}from"timers/promises";Le();import Bxt from"process";Le();var fAt=(t,e)=>{e.recordException(t),e.setStatus({code:ri.ERROR})};var sl=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}=Cxe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>Ixe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Cxe(r,n,i),c=this._tracer.startSpan(e,s,o);return Ixe(c,s,a)}};function Cxe(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??tr.active(),{opts:n,ctx:i,fn:s}}function Ixe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:fAt,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)}}Le();var q_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var AK=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=jxe(e),n._asyncAttributesPending=e.filter(([i,s])=>q_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(q_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=jxe(this._rawAttributes),this._schemaUrl=pAt(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,q_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ae.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(q_(n)){ae.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=hAt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function xK(t,e){return AK.FromAttributeList(Object.entries(t),e)}function jxe(t){return t.map(([e,r])=>q_(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function pAt(t){if(typeof t=="string"||t===void 0)return t;ae.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function hAt(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;ae.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Le();var cw=class{emit(e){}enabled(){return!1}},zxe=new cw;var lw=Symbol.for("io.opentelemetry.js.api.logs"),B_=globalThis;function qxe(t,e,r){return n=>n===t?e:r}var PK=1;var CK=class{getLogger(e,r,n){return new cw}},Mk=new CK;var Uk=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):zxe}};var uw=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new Uk(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Mk}_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 Fk=class t{constructor(){this._proxyLoggerProvider=new uw}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return B_[lw]?this.getLoggerProvider():(B_[lw]=qxe(PK,e,Mk),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=B_[lw])===null||e===void 0?void 0:e.call(B_,PK))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete B_[lw],this._proxyLoggerProvider=new uw}};var Bxe=Fk.getInstance();function Hxe(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 Vxe(t){t.forEach(e=>e.disable())}function IK(t){let e=t.tracerProvider||Mt.getTracerProvider(),r=t.meterProvider||aw.getMeterProvider(),n=t.loggerProvider||Bxe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Hxe(i,e,r,n),()=>{Vxe(i)}}Le();var mAt=ln("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Gxe(t){return t.getValue(mAt)===!0}var H_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(H_||(H_={}));Le();var OK="[_0-9a-z-*/]",gAt=`[a-z]${OK}{0,255}`,_At=`[a-z0-9]${OK}{0,240}@[a-z]${OK}{0,13}`,yAt=new RegExp(`^(?:${gAt}|${_At})$`),SAt=/^[ -~]{0,255}[!-~]$/,EAt=/,|=/;function NK(t){return yAt.test(t)}function kK(t){return SAt.test(t)&&!EAt.test(t)}var vAt=32,Wxe=512,Yxe=",",Kxe="=",jk=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!NK(e)||!kK(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>Wxe)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=Yxe+e),e=`${n[0]}${Kxe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(Yxe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Kxe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!NK(a)||!kK(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>Wxe)&&(r.set(a,c),n=l,r.size>=vAt))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 zk="traceparent",qk="tracestate",bAt="00",TAt="(?!ff)[\\da-f]{2}",wAt="(?![0]{32})[\\da-f]{32}",RAt="(?![0]{16})[\\da-f]{16}",AAt="[\\da-f]{2}",xAt=new RegExp(`^\\s?(${TAt})-(${wAt})-(${RAt})-(${AAt})(-.*)?\\s?$`);function Jxe(t){let e=xAt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ad=class{inject(e,r,n){let i=Mt.getSpanContext(e);if(!i||Gxe(e)||!Vi(i))return;let s=`${bAt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Pr.NONE).toString(16)}`;n.set(r,zk,s),i.traceState&&n.set(r,qk,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,zk);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=Jxe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,qk);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new jk(typeof c=="string"?c:void 0)}return Mt.setSpanContext(e,o)}fields(){return[zk,qk]}};var Bk=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 dw=class{_isCalled=!1;_deferred=new Bk;_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 $$=Wn(y5(),1);Le();var NIe=t=>{throw TypeError(t)},b5=(t,e,r)=>e.has(t)||NIe("Cannot "+r),k$=(t,e,r)=>(b5(t,e,"read from private field"),r?r.call(t):e.get(t)),S5=(t,e,r)=>e.has(t)?NIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),CIe=(t,e,r,n)=>(b5(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),qxt=(t,e,r)=>(b5(t,e,"access private method"),r),IIe="__netlify__getTracer",Hxt="__netlify__shutdownTracers",Vxt="__nfOTLPTrace",Aw,xw,v5,kIe,Gxt=class{constructor(){S5(this,v5),S5(this,Aw),S5(this,xw),CIe(this,Aw,new dw(qxt(this,v5,kIe),this)),CIe(this,xw,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(k$(this,xw).debug(`export ${t.length.toString()} spans`),k$(this,Aw).isCalled){e({code:H_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Vxt,JSON.stringify(Wxt(t))),e({code:H_.SUCCESS})}shutdown(){return k$(this,Aw).call()}};Aw=new WeakMap;xw=new WeakMap;v5=new WeakSet;kIe=function(){return k$(this,xw).debug("Shutting down"),Promise.resolve()};function Wxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:N$(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||Io.SERVER,startTimeUnixNano:E5(e.startTime),endTimeUnixNano:E5(e.endTime),attributes:N$(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:E5(n.time),attributes:N$(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:N$(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function N$(t){return Object.keys(t).map(e=>$Ie(e,t[e]))}function $Ie(t,e){return{key:t,value:LIe(e)}}function LIe(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(LIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>$Ie(r,n))}}:{}}function E5(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var OIe={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"}},DIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,IIe))return;let e=Bxt.version.slice(1),r=xK({"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??[Yxt()],i=new $$.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ad});let s=t.instrumentations??[];IK({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,IIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new sl(Mt.getTracer(a,c)):new sl(Mt.getTracer(OIe.name,OIe.version))}}),Object.defineProperty(globalThis,Hxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Yxt=()=>new $$.SimpleSpanProcessor(new Gxt);Le();var Pw=Wn(y5(),1);Le();import*as L$ from"diagnostics_channel";var MIe=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?ri.ERROR:ri.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 sl?t:new sl(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){L$.subscribe(t,e);let r=()=>L$.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:Io.CLIENT},tr.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:ri.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 aUe=Wn(sUe(),1);var LM=pe("tracing"),oUe=8e3,lFt=5e3,GR=async(t=lFt)=>{try{await Promise.race([DAe(),cFt(t)])}catch(e){LM.warn("Failed to flush tracers on shutdown",e)}},cUe=async(t,e,r)=>{if(!xt()){let n=[new Pw.SimpleSpanProcessor(new TX),new Pw.SimpleSpanProcessor(new aUe.OTLPTraceExporter({url:r.exporterUrl}))];await DIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new MIe({skipHeaders:!0})]})}return r.traceparent?(vi.setGlobalPropagator(new ad),vi.extract(tr.active(),{traceparent:r.traceparent,isRemote:!0})):tr.active()};function ir(t,e,r){return LM.log(`\u23F3 TRACE: ${e} starting...`),JT(t,e,r)}var TX=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(", ")}]`:"";LM.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&LM.log(` \u274C Error: ${e.status.message}`)}};function wX(){return tt().captureLlmContentEnabled}function lUe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function DM(t,e,r){let n={role:t,parts:[{type:"text",content:Bi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var uFt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]);function uUe(t,e,r,n){if(!t.length)return;let i=xt();if(!i)return;let s=wX(),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&&uFt.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>oUe?`${a.message.slice(0,oUe)}\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":Bi(_)}:{"gen_ai.output.messages":DM("assistant",_)}:{}}}).end(u)})}import{readdir as dFt,rm as fFt}from"fs/promises";import{join as pFt}from"path";async function dUe(t,e=[]){let n=(await dFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>fFt(pFt(t,i),{recursive:!0,force:!0})))}var lh=({mode:t,sessionCreditLimit:e})=>t==="create"&&e!=null&&e<=300;var RX=t=>{if(!lh(t))return"default";let e=tt();return e.createAskFirstEnabled&&e.questionsEnabled?"ask_first":e.creditWrapUpEnabled?"budget_constrained":"default"},fUe=t=>{let e=RX(t);return{budget_eligible:lh(t),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var _Ft=WR.dirname(hFt(import.meta.url)),pUe=mFt(import.meta.url),yFt=WR.resolve(_Ft,"scripts/scaffold.js"),SFt="scripts/scaffold.js",EFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,AX=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},vFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),bFt=t=>{let e=AX(t);return e==="node"||e.endsWith("/node")},Cl=t=>{if(typeof t!="string")return!1;let e=t.match(EFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&vFt(AX(e[r]));)r+=1;if(r>=e.length||!bFt(e[r]))return!1;let n=e[r+1];return n?AX(n).includes(SFt):!1},uh=pe("create_stage"),xX="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.",TFt=`${xX}
|
|
624
|
+
if (condition) { yield value; }`)};import{Buffer as GTt}from"buffer";import{StringDecoder as WTt}from"string_decoder";var XN=(t,e,r)=>{if(r)return;if(t)return{transform:YTt.bind(void 0,new TextEncoder)};let n=new WTt(e);return{transform:KTt.bind(void 0,n),final:JTt.bind(void 0,n)}},YTt=function*(t,e){GTt.isBuffer(e)?yield Xc(e):typeof e=="string"?yield t.encode(e):yield e},KTt=function*(t,e){yield Zr(e)?t.write(e):e},JTt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as JRe}from"util";var cY=JRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),QN=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=XTt}=e[r];for await(let i of n(t))yield*QN(i,e,r+1)},ZRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ZTt(r,Number(e),t)},ZTt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*QN(n,r,e+1)},XRe=JRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),XTt=function*(t){yield t};var lY=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},QRe=(t,e)=>[...e.flatMap(r=>[...vp(r,t,0)]),...qT(t)],vp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=ewt}=e[r];for(let i of n(t))yield*vp(i,e,r+1)},qT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*QTt(r,Number(e),t)},QTt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*vp(n,r,e+1)},ewt=function*(t){yield t};var uY=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=t0e(t,o,s),l=Ep(e),u=Ep(r),d=l?cY.bind(void 0,QN,a):lY.bind(void 0,vp),f=l||u?cY.bind(void 0,ZRe,a):lY.bind(void 0,qT),p=l||u?XRe.bind(void 0,a):void 0;return{stream:new twt({writableObjectMode:n,writableHighWaterMark:e0e(n),readableObjectMode:i,readableHighWaterMark:e0e(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},ek=(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=t0e(o,r,a);t=QRe(c,t)}return t},t0e=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:WRe(n,a)},XN(r,o,n),ZN(r,s,n,c),{transform:t,final:e},{transform:YRe(i,a)},GRe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var r0e=(t,e)=>{for(let r of rwt(t))nwt(t,r,e)},rwt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),nwt=(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 ${nd[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>iwt(a,n));r.input=NT(o)},iwt=(t,e)=>{let r=ek(t,e,"utf8",!0);return swt(r),NT(r)},swt=t=>{let e=t.find(r=>typeof r!="string"&&!Zr(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 lwt,appendFileSync as uwt}from"fs";var tk=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&v_(r,n)&&!ls.has(e)&&owt(n)&&(t.some(({type:i,value:s})=>i==="native"&&awt.has(s))||t.every(({type:i})=>Gs.has(i))),owt=t=>t===1||t===2,awt=new Set(["pipe","overlapped"]),n0e=async(t,e,r,n)=>{for await(let i of t)cwt(e)||s0e(i,r,n)},i0e=(t,e,r)=>{for(let n of t)s0e(n,e,r)},cwt=t=>t._readableState.pipes.length>0,s0e=(t,e,r)=>{let n=mN(t);Ia({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var o0e=({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)=>dwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},dwt=({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=aRe(t,s,d),p=Xc(f),{stdioItems:h,objectMode:m}=e[r],_=fwt([p],h,c,n),{serializedResult:y,finalResult:v=y}=pwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});hwt({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&&mwt(y,h,i),S}catch(g){return n.error=g,S}},fwt=(t,e,r,n)=>{try{return ek(t,e,r,!1)}catch(i){return n.error=i,t}},pwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:NT(t)};let o=vbe(t,r);return n[s]?{serializedResult:o,finalResult:aY(o,!i[s],e)}:{serializedResult:o}},hwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!tk({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=aY(t,!1,o);try{i0e(a,e,n)}catch(c){r.error??=c}},mwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>KN.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?uwt(n,t):(r.add(s),lwt(n,t))}};var a0e=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,tl(e,r,"all")]:Array.isArray(e)?[tl(t,r,"all"),...e]:Zr(t)&&Zr(e)?gW([t,e]):`${t}${e}`};import{once as dY}from"events";var c0e=async(t,e)=>{let[r,n]=await gwt(t);return e.isForcefullyTerminated??=!1,[r,n]},gwt=async t=>{let[e,r]=await Promise.allSettled([dY(t,"spawn"),dY(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?l0e(t):r.value},l0e=async t=>{try{return await dY(t,"exit")}catch{return l0e(t)}},u0e=async t=>{let[e,r]=await t;if(!_wt(e,r)&&fY(e,r))throw new Ao;return[e,r]},_wt=(t,e)=>t===void 0&&e===void 0,fY=(t,e)=>t!==0||e!==null;var d0e=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ywt(t,e,r),o=s?.code==="ETIMEDOUT",a=oRe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ywt=(t,e,r)=>t!==void 0?t:fY(e,r)?new Ao:void 0;var f0e=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Ewt(t,e,r),d=Twt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return O_(d,c,l)},Ewt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),a=vwt(r),{file:c,commandArguments:l,options:u}=MN(t,e,a);bwt(u);let d=qRe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},vwt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,bwt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&rk("ipcInput"),t&&rk("ipc: true"),r&&rk("detached: true"),n&&rk("cancelSignal")},rk=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Twt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=wwt({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}=d0e(c,r),{output:h,error:m=l}=o0e({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>tl(v,r,S)),y=tl(a0e(h,r),r,"all");return Awt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},wwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{r0e(s,r);let a=Rwt(r);return Swt(...UN(t,e,a))}catch(a){return I_({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Rwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:VN(e)}),Awt=({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?GN({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):zT({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 p0t}from"events";import{spawn as h0t}from"child_process";import _0e from"process";import{once as pY,on as xwt}from"events";var p0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(w_({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),Pwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Pwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{xN(e,i);let s=rd(t,e,r),o=new AbortController;try{return await Promise.race([Cwt(s,n,o),Iwt(s,r,o),Owt(s,r,o)])}catch(a){throw R_(t),a}finally{o.abort(),PN(e,i)}},Cwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await pY(t,"message",{signal:r});return n}for await(let[n]of xwt(t,"message",{signal:r}))if(e(n))return n},Iwt=async(t,e,{signal:r})=>{await pY(t,"disconnect",{signal:r}),QTe(e)},Owt=async(t,e,{signal:r})=>{let[n]=await pY(t,"strict:error",{signal:r});throw wN(n,e)};import{once as m0e,on as Nwt}from"events";var g0e=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>hY({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),hY=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{w_({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ON(t)}),xN(e,s);let o=rd(t,e,r),a=new AbortController,c={};return kwt(t,o,a),$wt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Lwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},kwt=async(t,e,r)=>{try{await m0e(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},$wt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await m0e(t,"strict:error",{signal:r.signal});n.error=wN(i,e),r.abort()}catch{}},Lwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Nwt(r,"message",{signal:s.signal}))h0e(o),yield c}catch{h0e(o)}finally{s.abort(),PN(e,a),n||R_(t),i&&await t}},h0e=({error:t})=>{if(t)throw t};var y0e=(t,{ipc:e})=>{Object.assign(t,E0e(t,!1,e))},S0e=()=>{let t=_0e,e=!0,r=_0e.channel!==void 0;return{...E0e(t,e,r),getCancelSignal:Awe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},E0e=(t,e,r)=>({sendMessage:LN.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:p0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:g0e.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Dwt}from"child_process";import{PassThrough as Mwt,Readable as Uwt,Writable as Fwt,Duplex as jwt}from"stream";var v0e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{iY(n);let a=new Dwt;zwt(a,n),Object.assign(a,{readable:qwt,writable:Bwt,duplex:Hwt});let c=I_({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Vwt(c,o,i);return{subprocess:a,promise:l}},zwt=(t,e)=>{let r=BT(),n=BT(),i=BT(),s=Array.from({length:e.length-3},BT),o=BT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},BT=()=>{let t=new Mwt;return t.end(),t},qwt=()=>new Uwt({read(){}}),Bwt=()=>new Fwt({write(){}}),Hwt=()=>new jwt({read(){},write(){}}),Vwt=async(t,e,r)=>O_(t,e,r);import{createReadStream as b0e,createWriteStream as T0e}from"fs";import{Buffer as Gwt}from"buffer";import{Readable as HT,Writable as Wwt,Duplex as Ywt}from"stream";var R0e=(t,e)=>JN(Kwt,t,e,!1),VT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${nd[t]}.`)},w0e={fileNumber:VT,generator:uY,asyncGenerator:uY,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Ywt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Kwt={input:{...w0e,fileUrl:({value:t})=>({stream:b0e(t)}),filePath:({value:{file:t}})=>({stream:b0e(t)}),webStream:({value:t})=>({stream:HT.fromWeb(t)}),iterable:({value:t})=>({stream:HT.from(t)}),asyncIterable:({value:t})=>({stream:HT.from(t)}),string:({value:t})=>({stream:HT.from(t)}),uint8Array:({value:t})=>({stream:HT.from(Gwt.from(t))})},output:{...w0e,fileUrl:({value:t})=>({stream:T0e(t)}),filePath:({value:{file:t,append:e}})=>({stream:T0e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Wwt.fromWeb(t)}),iterable:VT,asyncIterable:VT,string:VT,uint8Array:VT}};import{on as Jwt,once as A0e}from"events";import{PassThrough as Zwt,getDefaultHighWaterMark as Xwt}from"stream";import{finished as C0e}from"stream/promises";function bp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)gY(i);let e=t.some(({readableObjectMode:i})=>i),r=Qwt(t,e),n=new mY({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Qwt=(t,e)=>{if(t.length===0)return Xwt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},mY=class extends Zwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(gY(e),this.#e.has(e))return;this.#e.add(e),this.#n??=eRt(this,this.#e,this.#s);let r=nRt({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(gY(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)}},eRt=async(t,e,r)=>{nk(t,x0e);let n=new AbortController;try{await Promise.race([tRt(t,n),rRt(t,e,r,n)])}finally{n.abort(),nk(t,-x0e)}},tRt=async(t,{signal:e})=>{try{await C0e(t,{signal:e,cleanup:!0})}catch(r){throw I0e(t,r),r}},rRt=async(t,e,r,{signal:n})=>{for await(let[i]of Jwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},gY=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},nRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{nk(t,P0e);let a=new AbortController;try{await Promise.race([iRt(s,e,a),sRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),oRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),nk(t,-P0e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?_Y(t):aRt(t))},iRt=async(t,e,{signal:r})=>{try{await t,r.aborted||_Y(e)}catch(n){r.aborted||I0e(e,n)}},sRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await C0e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;O0e(o)?i.add(e):N0e(t,o)}},oRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await A0e(t,i,{signal:s}),!t.readable)return A0e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},aRt=t=>{t.writable&&t.end()},I0e=(t,e)=>{O0e(e)?_Y(t):N0e(t,e)},O0e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_Y=t=>{(t.readable||t.writable)&&t.destroy()},N0e=(t,e)=>{t.destroyed||(t.once("error",cRt),t.destroy(e))},cRt=()=>{},nk=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},x0e=2,P0e=1;import{finished as k0e}from"stream/promises";var k_=(t,e)=>{t.pipe(e),lRt(t,e),uRt(t,e)},lRt=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await k0e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}yY(e)}},yY=t=>{t.writable&&t.end()},uRt=async(t,e)=>{if(!(Ro(t)||Ro(e))){try{await k0e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}SY(t)}},SY=t=>{t.readable&&t.destroy()};var $0e=(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})=>Gs.has(c)))dRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Gs.has(c)))pRt({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]:bp(s);k_(o,i)}},dRt=(t,e,r,n)=>{r==="output"?k_(t.stdio[n],e):k_(e,t.stdio[n]);let i=fRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},fRt=["stdin","stdout","stderr"],pRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;hRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},hRt=(t,{signal:e})=>{Ro(t)&&yp(t,mRt,e)},mRt=2;import{addAbortListener as yRt}from"events";var Tp=[];Tp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Tp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Tp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ik=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",EY=Symbol.for("signal-exit emitter"),vY=globalThis,gRt=Object.defineProperty.bind(Object),bY=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vY[EY])return vY[EY];gRt(vY,EY,{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}},sk=class{},_Rt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),TY=class extends sk{onExit(){return()=>{}}load(){}unload(){}},wY=class extends sk{#e=RY.platform==="win32"?"SIGINT":"SIGHUP";#r=new bY;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Tp)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(!ik(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 Tp)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,Tp.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 ik(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"&&ik(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)}},RY=globalThis.process,{onExit:L0e,load:Xgr,unload:Qgr}=_Rt(ik(RY)?new wY(RY):new TY);var D0e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=L0e(()=>{t.kill()});yRt(n,()=>{i()})};var U0e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=gN(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=SRt(r,n,i),{sourceStream:d,sourceError:f}=vRt(t,l),{options:p,fileDescriptors:h}=Na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},SRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=ERt(t,e,...r),a=AN(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},ERt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(M0e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||hW(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]=oN(r,...n);return{destination:e(M0e)(i,s,o),pipeOptions:o}}if(Na.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}`)},M0e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),vRt=(t,e)=>{try{return{sourceStream:A_(t,e)}}catch(r){return{sourceError:r}}};var j0e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=bRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw AY({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},bRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return SY(t),n;if(e!==void 0)return yY(r),e},AY=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>I_({error:t,command:F0e,escapedCommand:F0e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),F0e="source.pipe(destination)";var z0e=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 TRt}from"stream/promises";var q0e=(t,e,r)=>{let n=ok.has(e)?RRt(t,e):wRt(t,e);return yp(t,xRt,r.signal),yp(e,PRt,r.signal),ARt(e),n},wRt=(t,e)=>{let r=bp([t]);return k_(r,e),ok.set(e,r),r},RRt=(t,e)=>{let r=ok.get(e);return r.add(t),r},ARt=async t=>{try{await TRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}ok.delete(t)},ok=new WeakMap,xRt=2,PRt=1;import{aborted as CRt}from"util";var B0e=(t,e)=>t===void 0?[]:[IRt(t,e)],IRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await CRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw AY({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ak=(t,...e)=>{if(Lr(e[0]))return ak.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=U0e(t,...e),i=ORt({...n,destination:r});return i.pipe=ak.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},ORt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=NRt(t,i);j0e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=q0e(e,s,d);return await Promise.race([z0e(u),...B0e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},NRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as FRt}from"timers/promises";import{on as kRt}from"events";import{getDefaultHighWaterMark as $Rt}from"stream";var ck=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return LRt(e,o),V0e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},LRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},xY=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;DRt(e,o,t);let a=t.readableObjectMode&&!s;return V0e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},DRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},V0e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=kRt(t,"data",{signal:e.signal,highWaterMark:H0e,highWatermark:H0e});return MRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},PY=$Rt(!0),H0e=PY,MRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=URt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*vp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*qT(a)}},URt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[XN(t,r,!e),ZN(t,i,!n,{})].filter(Boolean);var G0e=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=jRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([zRt(t),d]);return}let f=sY(c,r),p=xY({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([qRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},jRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!tk({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=xY({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await n0e(a,t,r,s)},zRt=async t=>{await FRt(),t.readableFlowing===null&&t.resume()},qRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qN(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await BN(r,{maxBuffer:s})):await C_(r,{maxBuffer:s})}catch(a){return W0e(nRe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},CY=async t=>{try{return await t}catch(e){return W0e(e)}},W0e=({bufferedData:t})=>Sbe(t)?new Uint8Array(t):t;import{finished as BRt}from"stream/promises";var GT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=HRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],BRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||WRt(a,e,r,n)}finally{o.abort()}},HRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&VRt(t,r,n),n},VRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{GRt(e,r),n.call(t,...i)}},GRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},WRt=(t,e,r,n)=>{if(!YRt(t,e,r,n))throw t},YRt=(t,e,r,n=!0)=>r.propagating?Y0e(t)||lk(t):(r.propagating=!0,IY(r,e)===n?Y0e(t):lk(t)),IY=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",lk=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y0e=t=>t?.code==="EPIPE";var K0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>OY({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),OY=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=GT(t,e,l);if(IY(l,e)){await u;return}let[d]=await Promise.all([G0e({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 J0e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?bp([t,e].filter(Boolean)):void 0,Z0e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>OY({...KRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:JRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),KRt=({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}},JRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as ZRt}from"events";var X0e=t=>v_(t,"ipc"),Q0e=(t,e)=>{let r=mN(t);Ia({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var eAe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=X0e(s),a=Qc(e,"ipc"),c=Qc(r,"ipc");for await(let l of hY({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(iRe(t,i,c),i.push(l)),o&&Q0e(l,s);return i},tAe=async(t,e)=>(await Promise.allSettled([t]),e);var rAe=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=c0e(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=K0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),R=Z0e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),x=[],w=eAe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),b=XRt(m,t,S),C=QRt(h,S);try{return await Promise.race([Promise.all([{},u0e(v),Promise.all(g),R,w,Dwe(t,d),...b,...C]),_,e0t(t,y),...Owe(t,s,f,y),...XTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Cwe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(N){return f.terminationReason??="other",Promise.all([{error:N},v,Promise.all(g.map(A=>CY(A))),CY(R),tAe(w,x),Promise.allSettled(b),Promise.allSettled(C)])}},XRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:GT(n,i,r)),QRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Po(s,{checkOpen:!1})&&!Ro(s)).map(({type:i,value:s,stream:o=s})=>GT(o,n,e,{isSameDirection:Gs.has(i),stopOnExit:i==="native"}))),e0t=async(t,{signal:e})=>{let[r]=await ZRt(t,"error",{signal:e});throw r};var nAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),WT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Oa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},$_=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 t0t}from"stream";import{callbackify as r0t}from"util";import{finished as iAe}from"stream/promises";var NY=async t=>{if(t!==void 0)try{await kY(t)}catch{}},sAe=async t=>{if(t!==void 0)try{await $Y(t)}catch{}},kY=async t=>{await iAe(t,{cleanup:!0,readable:!1,writable:!0})},$Y=async t=>{await iAe(t,{cleanup:!0,readable:!0,writable:!1})},uk=async(t,e)=>{if(await t,e)throw e},dk=(t,e,r)=>{r&&!lk(r)?t.destroy(r):e&&t.destroy()};var oAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ls.has(r),{subprocessStdout:a,waitReadableDestroy:c}=LY(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=DY(a,o),{read:f,onStdoutDataDone:p}=MY({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new t0t({read:f,destroy:r0t(FY.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return UY({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},LY=(t,e,r)=>{let n=A_(t,e),i=WT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},DY=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:PY},MY=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Oa(),o=ck({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){n0t(this,o,s)},onStdoutDataDone:s}},n0t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},UY=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await $Y(t),await n,await NY(i),await e,r.readable&&r.push(null)}catch(s){await NY(i),aAe(r,s)}},FY=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await $_(r,e)&&(aAe(t,n),await uk(e,n))},aAe=(t,e)=>{dk(t,t.readable,e)};import{Writable as i0t}from"stream";import{callbackify as cAe}from"util";var lAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=jY(t,r,e),o=new i0t({...zY(n,t,i),destroy:cAe(BY.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return qY(n,o),o},jY=(t,e,r)=>{let n=AN(t,e),i=WT(r,n,"writableFinal"),s=WT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},zY=(t,e,r)=>({write:s0t.bind(void 0,t),final:cAe(o0t.bind(void 0,t,e,r))}),s0t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},o0t=async(t,e,r)=>{await $_(r,e)&&(t.writable&&t.end(),await e)},qY=async(t,e,r)=>{try{await kY(t),e.writable&&e.end()}catch(n){await sAe(r),uAe(e,n)}},BY=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await $_(r,e),await $_(n,e)&&(uAe(t,i),await uk(e,i))},uAe=(t,e)=>{dk(t,t.writable,e)};import{Duplex as a0t}from"stream";import{callbackify as c0t}from"util";var dAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ls.has(r),{subprocessStdout:c,waitReadableDestroy:l}=LY(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=jY(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=DY(c,a),{read:_,onStdoutDataDone:y}=MY({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new a0t({read:_,...zY(u,t,d),destroy:c0t(l0t.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 UY({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),qY(u,v,c),v},l0t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([FY({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),BY({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var HY=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ls.has(e),o=A_(t,r),a=ck({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return u0t(a,o,t)},u0t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var fAe=(t,{encoding:e})=>{let r=nAe();t.readable=oAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=lAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=dAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=HY.bind(void 0,t,e),t[Symbol.asyncIterator]=HY.bind(void 0,t,e,{})};var pAe=(t,e)=>{for(let[r,n]of f0t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},d0t=(async()=>{})().constructor.prototype,f0t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(d0t,t)]);var hAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=m0t(t,e,r),{subprocess:f,promise:p}=_0t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ak.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),pAe(f,p),Na.set(f,{options:u,fileDescriptors:d}),f},m0t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=_N(t,e,r),{file:a,commandArguments:c,options:l}=MN(t,e,r),u=g0t(l),d=R0e(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},g0t=({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}},_0t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=h0t(...UN(t,e,r))}catch(h){return v0e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;p0t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];$0e(c,a,l),D0e(c,r,l);let d={},f=Oa();c.kill=JTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=J0e(c,r),fAe(c,r),y0e(c,r);let p=y0t({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}},y0t=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 rAe({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,R)=>tl(g,e,R)),v=tl(m,e,"all"),S=S0t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return O_(S,n,e)},S0t=({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?zT({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 ka,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):GN({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var fk=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,E0t(n,t[n],i)]));return{...t,...r}},E0t=(t,e,r)=>v0t.has(t)&&Lr(e)&&Lr(r)?{...e,...r}:r,v0t=new Set(["env",...EW]);var id=(t,e,r,n)=>{let i=(o,a,c)=>id(o,a,r,c),s=(...o)=>b0t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},b0t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Lr(s))return i(t,fk(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=T0t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?f0e(a,c,l):hAe(a,c,l,i)},T0t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Rbe(e)?Abe(e,r):[e,...r],[o,a,c]=oN(...s),l=fk(fk(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 mAe=({file:t,commandArguments:e})=>_Ae(t,e),gAe=({file:t,commandArguments:e})=>({..._Ae(t,e),isSync:!0}),_Ae=(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]=w0t(t);return{file:r,commandArguments:n}},w0t=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(R0t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},R0t=/ +/g;var yAe=(t,e,r)=>{t.sync=e(A0t,r),t.s=t.sync},SAe=({options:t})=>EAe(t),A0t=({options:t})=>({...EAe(t),isSync:!0}),EAe=t=>({options:{...x0t(t),...t}}),x0t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},vAe={preferLocal:!0};var bAe=id(()=>({})),qSr=id(()=>({isSync:!0})),TAe=id(mAe),BSr=id(gAe),HSr=id(kwe),VSr=id(SAe,{},vAe,yAe),{sendMessage:GSr,getOneMessage:WSr,getEachMessage:YSr,getCancelSignal:KSr}=S0e();import{Transform as P0t}from"stream";var C0t=["NETLIFY_AI_GATEWAY_KEY"];function I0t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...C0t])]}function O0t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function N0t(){let e=I0t().map(r=>process.env[r]).filter(r=>!(!r||O0t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Bi(t){if(typeof t!="string")return t;let e=N0t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(k0t(n),"g");r=r.replace(i,"******")}),r}function k0t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var YT=class extends P0t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Bi(i);n(null,s)}},pk=Symbol("maskedWrite");function wAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[pk]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Bi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stdout.write=r}if(!process.stderr.write[pk]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Bi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[pk]=!0,process.stderr.write=r}}}var RAe=!1,AAe=()=>{RAe=!0},Hi=()=>RAe;var KT=null,xAe=t=>(KT&&KT.destroy(),KT=new Co({totalAllowedTime:t}),KT),PAe=()=>KT;var Co=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&&Hi())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 tN({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{de.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 CAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.170.0-alpha.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.1",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var M0t=L0t(import.meta.url),U0t=rl.dirname(M0t),F0t=D0t(import.meta.url),L_=pe("shell"),VY=new Set,IAe={preferLocal:!0},pr=(t,e,r)=>{let[n,i]=j0t(e,r),s={...IAe,...i},o=bAe(t,n,s);NAe(o,s),LAe(o);let a=r?.idleTimeout;return a&&a>0&&$Ae(o,a),o},OAe=(t,e)=>{let r={...IAe,...e},n=TAe(t,r);return NAe(n,r),LAe(n),e?.idleTimeout&&e.idleTimeout>0&&$Ae(n,e.idleTimeout),n},j0t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},NAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||La.env.NETLIFY_LOCAL_QUIET==="true")return;if(La.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new YT).pipe(La.stdout),t.stderr?.pipe(new YT).pipe(La.stderr);return}t.stdout?.pipe(La.stdout),t.stderr?.pipe(La.stderr)},GY=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(La.kill(-t.pid,e),L_.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return L_.error("Error killing process:",r),!1}},kAe=t=>GY(t,"SIGKILL"),$Ae=(t,e)=>{let r=null,n=()=>{L_.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),GY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(L_.log(`Force killing idle process ${t.pid}`),kAe(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)},LAe=t=>{VY.add(t);let e=PAe();if(e){let r=e.onTimesUp(()=>{L_.log(`Global timer expired, killing process ${t.pid}`),GY(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(L_.log(`Force killing process ${t.pid} after timeout`),kAe(t))},5e3)});t.on("exit",()=>{VY.delete(t),r()}),t.on("error",()=>{VY.delete(t),r()})}};function Da(t,e){if(!La.env.NETLIFY_LOCAL_MODE)try{let i=F0t.resolve(CAe.name),s=rl.dirname(i);for(;s!==rl.dirname(s);){let o=rl.dirname(s);if(rl.basename(o)==="node_modules"){let a=rl.join(o,".bin",e);if(hk.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(La.env.NODE_PATH){let i=rl.join(La.env.NODE_PATH,".bin",e);if(hk.existsSync(i))return i}let r=rl.join(t,"node_modules",".bin",e);if(hk.existsSync(r))return r;let n=rl.join(U0t,"..","node_modules",".bin",e);if(hk.existsSync(n))return n}import MM from"process";import{fileURLToPath as hFt}from"url";import{createRequire as mFt}from"module";import WR from"path";import{readFileSync as gFt}from"fs";var z0t="__netlify__getTracer",q0t="__netlify__shutdownTracers",xt=(t,e)=>globalThis[z0t]?.(t,e),DAe=async()=>globalThis[q0t]?.();function JT(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 cFt}from"timers/promises";Le();import Bxt from"process";Le();var fAt=(t,e)=>{e.recordException(t),e.setStatus({code:ri.ERROR})};var sl=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}=Cxe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>Ixe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Cxe(r,n,i),c=this._tracer.startSpan(e,s,o);return Ixe(c,s,a)}};function Cxe(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??tr.active(),{opts:n,ctx:i,fn:s}}function Ixe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:fAt,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)}}Le();var q_=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var AK=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=jxe(e),n._asyncAttributesPending=e.filter(([i,s])=>q_(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(q_(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=jxe(this._rawAttributes),this._schemaUrl=pAt(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,q_(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ae.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(q_(n)){ae.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=hAt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function xK(t,e){return AK.FromAttributeList(Object.entries(t),e)}function jxe(t){return t.map(([e,r])=>q_(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function pAt(t){if(typeof t=="string"||t===void 0)return t;ae.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function hAt(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;ae.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Le();var cw=class{emit(e){}enabled(){return!1}},zxe=new cw;var lw=Symbol.for("io.opentelemetry.js.api.logs"),B_=globalThis;function qxe(t,e,r){return n=>n===t?e:r}var PK=1;var CK=class{getLogger(e,r,n){return new cw}},Mk=new CK;var Uk=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):zxe}};var uw=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new Uk(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Mk}_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 Fk=class t{constructor(){this._proxyLoggerProvider=new uw}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return B_[lw]?this.getLoggerProvider():(B_[lw]=qxe(PK,e,Mk),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=B_[lw])===null||e===void 0?void 0:e.call(B_,PK))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete B_[lw],this._proxyLoggerProvider=new uw}};var Bxe=Fk.getInstance();function Hxe(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 Vxe(t){t.forEach(e=>e.disable())}function IK(t){let e=t.tracerProvider||Mt.getTracerProvider(),r=t.meterProvider||aw.getMeterProvider(),n=t.loggerProvider||Bxe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Hxe(i,e,r,n),()=>{Vxe(i)}}Le();var mAt=ln("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Gxe(t){return t.getValue(mAt)===!0}var H_;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(H_||(H_={}));Le();var OK="[_0-9a-z-*/]",gAt=`[a-z]${OK}{0,255}`,_At=`[a-z0-9]${OK}{0,240}@[a-z]${OK}{0,13}`,yAt=new RegExp(`^(?:${gAt}|${_At})$`),SAt=/^[ -~]{0,255}[!-~]$/,EAt=/,|=/;function NK(t){return yAt.test(t)}function kK(t){return SAt.test(t)&&!EAt.test(t)}var vAt=32,Wxe=512,Yxe=",",Kxe="=",jk=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!NK(e)||!kK(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>Wxe)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=Yxe+e),e=`${n[0]}${Kxe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(Yxe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Kxe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!NK(a)||!kK(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>Wxe)&&(r.set(a,c),n=l,r.size>=vAt))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 zk="traceparent",qk="tracestate",bAt="00",TAt="(?!ff)[\\da-f]{2}",wAt="(?![0]{32})[\\da-f]{32}",RAt="(?![0]{16})[\\da-f]{16}",AAt="[\\da-f]{2}",xAt=new RegExp(`^\\s?(${TAt})-(${wAt})-(${RAt})-(${AAt})(-.*)?\\s?$`);function Jxe(t){let e=xAt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ad=class{inject(e,r,n){let i=Mt.getSpanContext(e);if(!i||Gxe(e)||!Vi(i))return;let s=`${bAt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Pr.NONE).toString(16)}`;n.set(r,zk,s),i.traceState&&n.set(r,qk,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,zk);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=Jxe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,qk);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new jk(typeof c=="string"?c:void 0)}return Mt.setSpanContext(e,o)}fields(){return[zk,qk]}};var Bk=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 dw=class{_isCalled=!1;_deferred=new Bk;_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 $$=Wn(y5(),1);Le();var NIe=t=>{throw TypeError(t)},b5=(t,e,r)=>e.has(t)||NIe("Cannot "+r),k$=(t,e,r)=>(b5(t,e,"read from private field"),r?r.call(t):e.get(t)),S5=(t,e,r)=>e.has(t)?NIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),CIe=(t,e,r,n)=>(b5(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),qxt=(t,e,r)=>(b5(t,e,"access private method"),r),IIe="__netlify__getTracer",Hxt="__netlify__shutdownTracers",Vxt="__nfOTLPTrace",Aw,xw,v5,kIe,Gxt=class{constructor(){S5(this,v5),S5(this,Aw),S5(this,xw),CIe(this,Aw,new dw(qxt(this,v5,kIe),this)),CIe(this,xw,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(k$(this,xw).debug(`export ${t.length.toString()} spans`),k$(this,Aw).isCalled){e({code:H_.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Vxt,JSON.stringify(Wxt(t))),e({code:H_.SUCCESS})}shutdown(){return k$(this,Aw).call()}};Aw=new WeakMap;xw=new WeakMap;v5=new WeakSet;kIe=function(){return k$(this,xw).debug("Shutting down"),Promise.resolve()};function Wxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:N$(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||Io.SERVER,startTimeUnixNano:E5(e.startTime),endTimeUnixNano:E5(e.endTime),attributes:N$(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:E5(n.time),attributes:N$(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:N$(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function N$(t){return Object.keys(t).map(e=>$Ie(e,t[e]))}function $Ie(t,e){return{key:t,value:LIe(e)}}function LIe(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(LIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>$Ie(r,n))}}:{}}function E5(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var OIe={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"}},DIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,IIe))return;let e=Bxt.version.slice(1),r=xK({"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??[Yxt()],i=new $$.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ad});let s=t.instrumentations??[];IK({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,IIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new sl(Mt.getTracer(a,c)):new sl(Mt.getTracer(OIe.name,OIe.version))}}),Object.defineProperty(globalThis,Hxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Yxt=()=>new $$.SimpleSpanProcessor(new Gxt);Le();var Pw=Wn(y5(),1);Le();import*as L$ from"diagnostics_channel";var MIe=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?ri.ERROR:ri.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 sl?t:new sl(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){L$.subscribe(t,e);let r=()=>L$.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:Io.CLIENT},tr.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:ri.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 aUe=Wn(sUe(),1);var LM=pe("tracing"),oUe=8e3,lFt=5e3,GR=async(t=lFt)=>{try{await Promise.race([DAe(),cFt(t)])}catch(e){LM.warn("Failed to flush tracers on shutdown",e)}},cUe=async(t,e,r)=>{if(!xt()){let n=[new Pw.SimpleSpanProcessor(new TX),new Pw.SimpleSpanProcessor(new aUe.OTLPTraceExporter({url:r.exporterUrl}))];await DIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new MIe({skipHeaders:!0})]})}return r.traceparent?(vi.setGlobalPropagator(new ad),vi.extract(tr.active(),{traceparent:r.traceparent,isRemote:!0})):tr.active()};function ir(t,e,r){return LM.log(`\u23F3 TRACE: ${e} starting...`),JT(t,e,r)}var TX=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(", ")}]`:"";LM.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&LM.log(` \u274C Error: ${e.status.message}`)}};function wX(){return tt().captureLlmContentEnabled}function lUe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function DM(t,e,r){let n={role:t,parts:[{type:"text",content:Bi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var uFt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]);function uUe(t,e,r,n){if(!t.length)return;let i=xt();if(!i)return;let s=wX(),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&&uFt.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>oUe?`${a.message.slice(0,oUe)}\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":Bi(_)}:{"gen_ai.output.messages":DM("assistant",_)}:{}}}).end(u)})}import{readdir as dFt,rm as fFt}from"fs/promises";import{join as pFt}from"path";async function dUe(t,e=[]){let n=(await dFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>fFt(pFt(t,i),{recursive:!0,force:!0})))}var lh=({mode:t,sessionCreditLimit:e})=>t==="create"&&e!=null&&e<=300;var RX=t=>{if(!lh(t))return"default";let e=tt();return e.createAskFirstEnabled&&e.questionsEnabled?"ask_first":e.creditWrapUpEnabled?"budget_constrained":"default"},fUe=t=>{let e=RX(t);return{budget_eligible:lh(t),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var _Ft=WR.dirname(hFt(import.meta.url)),pUe=mFt(import.meta.url),yFt=WR.resolve(_Ft,"scripts/scaffold.js"),SFt="scripts/scaffold.js",EFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,AX=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},vFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),bFt=t=>{let e=AX(t);return e==="node"||e.endsWith("/node")},Cl=t=>{if(typeof t!="string")return!1;let e=t.match(EFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&vFt(AX(e[r]));)r+=1;if(r>=e.length||!bFt(e[r]))return!1;let n=e[r+1];return n?AX(n).includes(SFt):!1},uh=pe("create_stage"),xX="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.",TFt=`${xX}
|
|
625
625
|
|
|
626
626
|
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.`,wFt=`${xX}
|
|
627
627
|
|