@netlify/agent-runner-cli 1.142.1-test.3 → 1.142.1-test.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -578,7 +578,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
578
578
  `,LF:`
579
579
  `,concatBytes:u6},nmt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},imt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:nmt};import{Buffer as smt}from"buffer";var $ve=(t,e)=>t?void 0:omt.bind(void 0,e),omt=function*(t,e){if(typeof e!="string"&&!Pr(e)&&!smt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Lve=(t,e)=>t?amt.bind(void 0,e):cmt.bind(void 0,e),amt=function*(t,e){Dve(t,e),yield e},cmt=function*(t,e){if(Dve(t,e),typeof e!="string"&&!Pr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Dve=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
580
580
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
581
- if (condition) { yield value; }`)};import{Buffer as lmt}from"buffer";import{StringDecoder as umt}from"string_decoder";var VO=(t,e,r)=>{if(r)return;if(t)return{transform:dmt.bind(void 0,new TextEncoder)};let n=new umt(e);return{transform:fmt.bind(void 0,n),final:pmt.bind(void 0,n)}},dmt=function*(t,e){lmt.isBuffer(e)?yield hc(e):typeof e=="string"?yield t.encode(e):yield e},fmt=function*(t,e){yield Pr(e)?t.write(e):e},pmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Mve}from"util";var f6=Mve(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),HO=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=mmt}=e[r];for await(let i of n(t))yield*HO(i,e,r+1)},Uve=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*hmt(r,Number(e),t)},hmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*HO(n,r,e+1)},Fve=Mve(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),mmt=function*(t){yield t};var p6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},jve=(t,e)=>[...e.flatMap(r=>[...Pf(r,t,0)]),...Rb(t)],Pf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_mt}=e[r];for(let i of n(t))yield*Pf(i,e,r+1)},Rb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*gmt(r,Number(e),t)},gmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Pf(n,r,e+1)},_mt=function*(t){yield t};var h6=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Bve(t,o,s),l=If(e),u=If(r),d=l?f6.bind(void 0,HO,a):p6.bind(void 0,Pf),f=l||u?f6.bind(void 0,Uve,a):p6.bind(void 0,Rb),p=l||u?Fve.bind(void 0,a):void 0;return{stream:new ymt({writableObjectMode:n,writableHighWaterMark:qve(n),readableObjectMode:i,readableHighWaterMark:qve(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},GO=(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=Bve(o,r,a);t=jve(c,t)}return t},Bve=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:$ve(n,a)},VO(r,o,n),zO(r,s,n,c),{transform:t,final:e},{transform:Lve(i,a)},kve({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var zve=(t,e)=>{for(let r of Smt(t))Emt(t,r,e)},Smt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Emt=(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 ${lu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>vmt(a,n));r.input=mb(o)},vmt=(t,e)=>{let r=GO(t,e,"utf8",!0);return bmt(r),mb(r)},bmt=t=>{let e=t.find(r=>typeof r!="string"&&!Pr(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 Amt,appendFileSync as xmt}from"fs";var WO=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Tg(r,n)&&!$i.has(e)&&Tmt(n)&&(t.some(({type:i,value:s})=>i==="native"&&wmt.has(s))||t.every(({type:i})=>vs.has(i))),Tmt=t=>t===1||t===2,wmt=new Set(["pipe","overlapped"]),Vve=async(t,e,r,n)=>{for await(let i of t)Rmt(e)||Gve(i,r,n)},Hve=(t,e,r)=>{for(let n of t)Gve(n,e,r)},Rmt=t=>t._readableState.pipes.length>0,Gve=(t,e,r)=>{let n=aO(t);Xo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Wve=({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)=>Imt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Imt=({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=YEe(t,s,d),p=hc(f),{stdioItems:h,objectMode:m}=e[r],_=Pmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Omt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Cmt({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&&Nmt(y,h,i),S}catch(g){return n.error=g,S}},Pmt=(t,e,r,n)=>{try{return GO(t,e,r,!1)}catch(i){return n.error=i,t}},Omt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:mb(t)};let o=cye(t,r);return n[s]?{serializedResult:o,finalResult:d6(o,!i[s],e)}:{serializedResult:o}},Cmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!WO({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=d6(t,!1,o);try{Hve(a,e,n)}catch(c){r.error??=c}},Nmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>qO.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?xmt(n,t):(r.add(s),Amt(n,t))}};var Yve=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,_c(e,r,"all")]:Array.isArray(e)?[_c(t,r,"all"),...e]:Pr(t)&&Pr(e)?EG([t,e]):`${t}${e}`};import{once as m6}from"events";var Kve=async(t,e)=>{let[r,n]=await kmt(t);return e.isForcefullyTerminated??=!1,[r,n]},kmt=async t=>{let[e,r]=await Promise.allSettled([m6(t,"spawn"),m6(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Jve(t):r.value},Jve=async t=>{try{return await m6(t,"exit")}catch{return Jve(t)}},Zve=async t=>{let[e,r]=await t;if(!$mt(e,r)&&g6(e,r))throw new Zs;return[e,r]},$mt=(t,e)=>t===void 0&&e===void 0,g6=(t,e)=>t!==0||e!==null;var Xve=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Lmt(t,e,r),o=s?.code==="ETIMEDOUT",a=WEe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Lmt=(t,e,r)=>t!==void 0?t:g6(e,r)?new Zs:void 0;var Qve=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Mmt(t,e,r),d=jmt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return kg(d,c,l)},Mmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=lO(t,e,r),a=Umt(r),{file:c,commandArguments:l,options:u}=PO(t,e,a);Fmt(u);let d=Pve(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Umt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Fmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&YO("ipcInput"),t&&YO("ipc: true"),r&&YO("detached: true"),n&&YO("cancelSignal")},YO=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},jmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=qmt({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}=Xve(c,r),{output:h,error:m=l}=Wve({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>_c(v,r,S)),y=_c(Yve(h,r),r,"all");return zmt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},qmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{zve(s,r);let a=Bmt(r);return Dmt(...OO(t,e,a))}catch(a){return Ng({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Bmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:MO(e)}),zmt=({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?UO({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):wb({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 O_t}from"events";import{spawn as C_t}from"child_process";import ibe from"process";import{once as _6,on as Vmt}from"events";var ebe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Ag({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:TO(t)}),Hmt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Hmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{SO(e,i);let s=cu(t,e,r),o=new AbortController;try{return await Promise.race([Gmt(s,n,o),Wmt(s,r,o),Ymt(s,r,o)])}catch(a){throw xg(t),a}finally{o.abort(),EO(e,i)}},Gmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await _6(t,"message",{signal:r});return n}for await(let[n]of Vmt(t,"message",{signal:r}))if(e(n))return n},Wmt=async(t,e,{signal:r})=>{await _6(t,"disconnect",{signal:r}),jSe(e)},Ymt=async(t,e,{signal:r})=>{let[n]=await _6(t,"strict:error",{signal:r});throw gO(n,e)};import{once as rbe,on as Kmt}from"events";var nbe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>y6({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),y6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Ag({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:TO(t)}),SO(e,s);let o=cu(t,e,r),a=new AbortController,c={};return Jmt(t,o,a),Zmt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Xmt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Jmt=async(t,e,r)=>{try{await rbe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Zmt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await rbe(t,"strict:error",{signal:r.signal});n.error=gO(i,e),r.abort()}catch{}},Xmt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Kmt(r,"message",{signal:s.signal}))tbe(o),yield c}catch{tbe(o)}finally{s.abort(),EO(e,a),n||xg(t),i&&await t}},tbe=({error:t})=>{if(t)throw t};var sbe=(t,{ipc:e})=>{Object.assign(t,abe(t,!1,e))},obe=()=>{let t=ibe,e=!0,r=ibe.channel!==void 0;return{...abe(t,e,r),getCancelSignal:pEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},abe=(t,e,r)=>({sendMessage:xO.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ebe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:nbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Qmt}from"child_process";import{PassThrough as egt,Readable as tgt,Writable as rgt,Duplex as ngt}from"stream";var cbe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{c6(n);let a=new Qmt;igt(a,n),Object.assign(a,{readable:sgt,writable:ogt,duplex:agt});let c=Ng({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=cgt(c,o,i);return{subprocess:a,promise:l}},igt=(t,e)=>{let r=Ab(),n=Ab(),i=Ab(),s=Array.from({length:e.length-3},Ab),o=Ab(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Ab=()=>{let t=new egt;return t.end(),t},sgt=()=>new tgt({read(){}}),ogt=()=>new rgt({write(){}}),agt=()=>new ngt({read(){},write(){}}),cgt=async(t,e,r)=>kg(t,e,r);import{createReadStream as lbe,createWriteStream as ube}from"fs";import{Buffer as lgt}from"buffer";import{Readable as xb,Writable as ugt,Duplex as dgt}from"stream";var fbe=(t,e)=>BO(fgt,t,e,!1),Ib=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${lu[t]}.`)},dbe={fileNumber:Ib,generator:h6,asyncGenerator:h6,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:dgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},fgt={input:{...dbe,fileUrl:({value:t})=>({stream:lbe(t)}),filePath:({value:{file:t}})=>({stream:lbe(t)}),webStream:({value:t})=>({stream:xb.fromWeb(t)}),iterable:({value:t})=>({stream:xb.from(t)}),asyncIterable:({value:t})=>({stream:xb.from(t)}),string:({value:t})=>({stream:xb.from(t)}),uint8Array:({value:t})=>({stream:xb.from(lgt.from(t))})},output:{...dbe,fileUrl:({value:t})=>({stream:ube(t)}),filePath:({value:{file:t,append:e}})=>({stream:ube(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:ugt.fromWeb(t)}),iterable:Ib,asyncIterable:Ib,string:Ib,uint8Array:Ib}};import{on as pgt,once as pbe}from"events";import{PassThrough as hgt,getDefaultHighWaterMark as mgt}from"stream";import{finished as gbe}from"stream/promises";function Of(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)E6(i);let e=t.some(({readableObjectMode:i})=>i),r=ggt(t,e),n=new S6({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var ggt=(t,e)=>{if(t.length===0)return mgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},S6=class extends hgt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(E6(e),this.#e.has(e))return;this.#e.add(e),this.#n??=_gt(this,this.#e,this.#s);let r=Egt({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(E6(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)}},_gt=async(t,e,r)=>{KO(t,hbe);let n=new AbortController;try{await Promise.race([ygt(t,n),Sgt(t,e,r,n)])}finally{n.abort(),KO(t,-hbe)}},ygt=async(t,{signal:e})=>{try{await gbe(t,{signal:e,cleanup:!0})}catch(r){throw _be(t,r),r}},Sgt=async(t,e,r,{signal:n})=>{for await(let[i]of pgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},E6=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Egt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{KO(t,mbe);let a=new AbortController;try{await Promise.race([vgt(s,e,a),bgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Tgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),KO(t,-mbe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?v6(t):wgt(t))},vgt=async(t,e,{signal:r})=>{try{await t,r.aborted||v6(e)}catch(n){r.aborted||_be(e,n)}},bgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await gbe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;ybe(o)?i.add(e):Sbe(t,o)}},Tgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await pbe(t,i,{signal:s}),!t.readable)return pbe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},wgt=t=>{t.writable&&t.end()},_be=(t,e)=>{ybe(e)?v6(t):Sbe(t,e)},ybe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",v6=t=>{(t.readable||t.writable)&&t.destroy()},Sbe=(t,e)=>{t.destroyed||(t.once("error",Rgt),t.destroy(e))},Rgt=()=>{},KO=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},hbe=2,mbe=1;import{finished as Ebe}from"stream/promises";var Lg=(t,e)=>{t.pipe(e),Agt(t,e),xgt(t,e)},Agt=async(t,e)=>{if(!(Js(t)||Js(e))){try{await Ebe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}b6(e)}},b6=t=>{t.writable&&t.end()},xgt=async(t,e)=>{if(!(Js(t)||Js(e))){try{await Ebe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}T6(t)}},T6=t=>{t.readable&&t.destroy()};var vbe=(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})=>vs.has(c)))Igt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!vs.has(c)))Ogt({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]:Of(s);Lg(o,i)}},Igt=(t,e,r,n)=>{r==="output"?Lg(t.stdio[n],e):Lg(e,t.stdio[n]);let i=Pgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Pgt=["stdin","stdout","stderr"],Ogt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;Cgt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},Cgt=(t,{signal:e})=>{Js(t)&&Af(t,Ngt,e)},Ngt=2;import{addAbortListener as Lgt}from"events";var Cf=[];Cf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Cf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Cf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var JO=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",w6=Symbol.for("signal-exit emitter"),R6=globalThis,kgt=Object.defineProperty.bind(Object),A6=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(R6[w6])return R6[w6];kgt(R6,w6,{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}},ZO=class{},$gt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),x6=class extends ZO{onExit(){return()=>{}}load(){}unload(){}},I6=class extends ZO{#e=P6.platform==="win32"?"SIGINT":"SIGHUP";#r=new A6;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Cf)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(!JO(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 Cf)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,Cf.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 JO(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"&&JO(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)}},P6=globalThis.process,{onExit:bbe,load:qnr,unload:Bnr}=$gt(JO(P6)?new I6(P6):new x6);var Tbe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=bbe(()=>{t.kill()});Lgt(n,()=>{i()})};var Rbe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=cO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Dgt(r,n,i),{sourceStream:d,sourceError:f}=Ugt(t,l),{options:p,fileDescriptors:h}=ea.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},Dgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Mgt(t,e,...r),a=yO(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Mgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(wbe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||yG(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]=XP(r,...n);return{destination:e(wbe)(i,s,o),pipeOptions:o}}if(ea.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}`)},wbe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Ugt=(t,e)=>{try{return{sourceStream:Ig(t,e)}}catch(r){return{sourceError:r}}};var xbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Fgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw O6({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Fgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return T6(t),n;if(e!==void 0)return b6(r),e},O6=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Ng({error:t,command:Abe,escapedCommand:Abe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Abe="source.pipe(destination)";var Ibe=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 jgt}from"stream/promises";var Pbe=(t,e,r)=>{let n=XO.has(e)?Bgt(t,e):qgt(t,e);return Af(t,Vgt,r.signal),Af(e,Hgt,r.signal),zgt(e),n},qgt=(t,e)=>{let r=Of([t]);return Lg(r,e),XO.set(e,r),r},Bgt=(t,e)=>{let r=XO.get(e);return r.add(t),r},zgt=async t=>{try{await jgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}XO.delete(t)},XO=new WeakMap,Vgt=2,Hgt=1;import{aborted as Ggt}from"util";var Obe=(t,e)=>t===void 0?[]:[Wgt(t,e)],Wgt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Ggt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw O6({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var QO=(t,...e)=>{if(yr(e[0]))return QO.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Rbe(t,...e),i=Ygt({...n,destination:r});return i.pipe=QO.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Ygt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=Kgt(t,i);xbe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Pbe(e,s,d);return await Promise.race([Ibe(u),...Obe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},Kgt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as r_t}from"timers/promises";import{on as Jgt}from"events";import{getDefaultHighWaterMark as Zgt}from"stream";var eC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Xgt(e,o),Nbe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Xgt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},C6=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;Qgt(e,o,t);let a=t.readableObjectMode&&!s;return Nbe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Qgt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Nbe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=Jgt(t,"data",{signal:e.signal,highWaterMark:Cbe,highWatermark:Cbe});return e_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},N6=Zgt(!0),Cbe=N6,e_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=t_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Pf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Rb(a)}},t_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[VO(t,r,!e),zO(t,i,!n,{})].filter(Boolean);var kbe=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=n_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([i_t(t),d]);return}let f=l6(c,r),p=C6({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([s_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},n_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!WO({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=C6({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Vve(a,t,r,s)},i_t=async t=>{await r_t(),t.readableFlowing===null&&t.resume()},s_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await $O(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await LO(r,{maxBuffer:s})):await Cg(r,{maxBuffer:s})}catch(a){return $be(VEe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},k6=async t=>{try{return await t}catch(e){return $be(e)}},$be=({bufferedData:t})=>oye(t)?new Uint8Array(t):t;import{finished as o_t}from"stream/promises";var Pb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=a_t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],o_t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||u_t(a,e,r,n)}finally{o.abort()}},a_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&c_t(t,r,n),n},c_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{l_t(e,r),n.call(t,...i)}},l_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},u_t=(t,e,r,n)=>{if(!d_t(t,e,r,n))throw t},d_t=(t,e,r,n=!0)=>r.propagating?Lbe(t)||tC(t):(r.propagating=!0,$6(r,e)===n?Lbe(t):tC(t)),$6=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",tC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Lbe=t=>t?.code==="EPIPE";var Dbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>L6({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),L6=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=Pb(t,e,l);if($6(l,e)){await u;return}let[d]=await Promise.all([kbe({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 Mbe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Of([t,e].filter(Boolean)):void 0,Ube=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>L6({...f_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:p_t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),f_t=({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}},p_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as h_t}from"events";var Fbe=t=>Tg(t,"ipc"),jbe=(t,e)=>{let r=aO(t);Xo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var qbe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Fbe(s),a=mc(e,"ipc"),c=mc(r,"ipc");for await(let l of y6({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(HEe(t,i,c),i.push(l)),o&&jbe(l,s);return i},Bbe=async(t,e)=>(await Promise.allSettled([t]),e);var zbe=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=Kve(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Dbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=Ube({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),I=[],x=qbe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),R=m_t(m,t,S),P=g_t(h,S);try{return await Promise.race([Promise.all([{},Zve(v),Promise.all(g),w,x,TEe(t,d),...R,...P]),_,__t(t,y),...yEe(t,s,f,y),...FSe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...gEe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(A){return f.terminationReason??="other",Promise.all([{error:A},v,Promise.all(g.map(b=>k6(b))),k6(w),Bbe(x,I),Promise.allSettled(R),Promise.allSettled(P)])}},m_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Pb(n,i,r)),g_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Qs(s,{checkOpen:!1})&&!Js(s)).map(({type:i,value:s,stream:o=s})=>Pb(o,n,e,{isSameDirection:vs.has(i),stopOnExit:i==="native"}))),__t=async(t,{signal:e})=>{let[r]=await h_t(t,"error",{signal:e});throw r};var Vbe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Ob=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Qo();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Dg=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 y_t}from"stream";import{callbackify as S_t}from"util";import{finished as Hbe}from"stream/promises";var D6=async t=>{if(t!==void 0)try{await M6(t)}catch{}},Gbe=async t=>{if(t!==void 0)try{await U6(t)}catch{}},M6=async t=>{await Hbe(t,{cleanup:!0,readable:!1,writable:!0})},U6=async t=>{await Hbe(t,{cleanup:!0,readable:!0,writable:!1})},rC=async(t,e)=>{if(await t,e)throw e},nC=(t,e,r)=>{r&&!tC(r)?t.destroy(r):e&&t.destroy()};var Wbe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||$i.has(r),{subprocessStdout:a,waitReadableDestroy:c}=F6(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=j6(a,o),{read:f,onStdoutDataDone:p}=q6({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new y_t({read:f,destroy:S_t(z6.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return B6({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},F6=(t,e,r)=>{let n=Ig(t,e),i=Ob(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},j6=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:N6},q6=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Qo(),o=eC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){E_t(this,o,s)},onStdoutDataDone:s}},E_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},B6=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await U6(t),await n,await D6(i),await e,r.readable&&r.push(null)}catch(s){await D6(i),Ybe(r,s)}},z6=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Dg(r,e)&&(Ybe(t,n),await rC(e,n))},Ybe=(t,e)=>{nC(t,t.readable,e)};import{Writable as v_t}from"stream";import{callbackify as Kbe}from"util";var Jbe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=V6(t,r,e),o=new v_t({...H6(n,t,i),destroy:Kbe(W6.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return G6(n,o),o},V6=(t,e,r)=>{let n=yO(t,e),i=Ob(r,n,"writableFinal"),s=Ob(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},H6=(t,e,r)=>({write:b_t.bind(void 0,t),final:Kbe(T_t.bind(void 0,t,e,r))}),b_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},T_t=async(t,e,r)=>{await Dg(r,e)&&(t.writable&&t.end(),await e)},G6=async(t,e,r)=>{try{await M6(t),e.writable&&e.end()}catch(n){await Gbe(r),Zbe(e,n)}},W6=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Dg(r,e),await Dg(n,e)&&(Zbe(t,i),await rC(e,i))},Zbe=(t,e)=>{nC(t,t.writable,e)};import{Duplex as w_t}from"stream";import{callbackify as R_t}from"util";var Xbe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||$i.has(r),{subprocessStdout:c,waitReadableDestroy:l}=F6(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=V6(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=j6(c,a),{read:_,onStdoutDataDone:y}=q6({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new w_t({read:_,...H6(u,t,d),destroy:R_t(A_t.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 B6({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),G6(u,v,c),v},A_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([z6({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),W6({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var Y6=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||$i.has(e),o=Ig(t,r),a=eC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return x_t(a,o,t)},x_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Qbe=(t,{encoding:e})=>{let r=Vbe();t.readable=Wbe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Jbe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Xbe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Y6.bind(void 0,t,e),t[Symbol.asyncIterator]=Y6.bind(void 0,t,e,{})};var eTe=(t,e)=>{for(let[r,n]of P_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},I_t=(async()=>{})().constructor.prototype,P_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(I_t,t)]);var tTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=N_t(t,e,r),{subprocess:f,promise:p}=$_t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=QO.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),eTe(f,p),ea.set(f,{options:u,fileDescriptors:d}),f},N_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=lO(t,e,r),{file:a,commandArguments:c,options:l}=PO(t,e,r),u=k_t(l),d=fbe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},k_t=({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}},$_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=C_t(...OO(t,e,r))}catch(h){return cbe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;O_t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];vbe(c,a,l),Tbe(c,r,l);let d={},f=Qo();c.kill=MSe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Mbe(c,r),Qbe(c,r),sbe(c,r);let p=L_t({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}},L_t=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 zbe({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,w)=>_c(g,e,w)),v=_c(m,e,"all"),S=D_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return kg(S,n,e)},D_t=({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?wb({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 ta,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):UO({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var iC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,M_t(n,t[n],i)]));return{...t,...r}},M_t=(t,e,r)=>U_t.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,U_t=new Set(["env",...wG]);var uu=(t,e,r,n)=>{let i=(o,a,c)=>uu(o,a,r,c),s=(...o)=>F_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},F_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,iC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=j_t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?Qve(a,c,l):tTe(a,c,l,i)},j_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=fye(e)?pye(e,r):[e,...r],[o,a,c]=XP(...s),l=iC(iC(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 rTe=({file:t,commandArguments:e})=>iTe(t,e),nTe=({file:t,commandArguments:e})=>({...iTe(t,e),isSync:!0}),iTe=(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]=q_t(t);return{file:r,commandArguments:n}},q_t=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(B_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},B_t=/ +/g;var sTe=(t,e,r)=>{t.sync=e(z_t,r),t.s=t.sync},oTe=({options:t})=>aTe(t),z_t=({options:t})=>({...aTe(t),isSync:!0}),aTe=t=>({options:{...V_t(t),...t}}),V_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},cTe={preferLocal:!0};var lTe=uu(()=>({})),Nor=uu(()=>({isSync:!0})),uTe=uu(rTe),kor=uu(nTe),$or=uu(EEe),Lor=uu(oTe,{},cTe,sTe),{sendMessage:Dor,getOneMessage:Mor,getEachMessage:Uor,getCancelSignal:For}=obe();import{Transform as H_t}from"stream";var G_t=["NETLIFY_AI_GATEWAY_KEY"];function W_t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...G_t])]}function Y_t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function K_t(){let e=W_t().map(r=>process.env[r]).filter(r=>!(!r||Y_t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function bs(t){if(typeof t!="string")return t;let e=K_t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(J_t(n),"g");r=r.replace(i,"******")}),r}function J_t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Cb=class extends H_t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=bs(i);n(null,s)}},sC=Symbol("maskedWrite");function dTe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[sC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?bs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[sC]=!0,process.stdout.write=r}if(!process.stderr.write[sC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?bs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[sC]=!0,process.stderr.write=r}}}var fTe=!1,pTe=()=>{fTe=!0},hi=()=>fTe;var Nb=null,hTe=t=>(Nb&&Nb.destroy(),Nb=new yc({totalAllowedTime:t}),Nb),mTe=()=>Nb;var yc=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 JP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Oe.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 gTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.142.1-test.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:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@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.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var eyt=X_t(import.meta.url),tyt=Sc.dirname(eyt),ryt=Q_t(import.meta.url),Mg=Re("shell"),K6=new Set,_Te={preferLocal:!0},Li=(t,e,r)=>{let[n,i]=nyt(e,r),s={..._Te,...i},o=lTe(t,n,s);STe(o,s),bTe(o);let a=r?.idleTimeout;return a&&a>0&&vTe(o,a),o},yTe=(t,e)=>{let r={..._Te,...e},n=uTe(t,r);return STe(n,r),bTe(n),e?.idleTimeout&&e.idleTimeout>0&&vTe(n,e.idleTimeout),n},nyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},STe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ec.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Cb).pipe(Ec.stdout),t.stderr?.pipe(new Cb).pipe(Ec.stderr);return}t.stdout?.pipe(Ec.stdout),t.stderr?.pipe(Ec.stderr)},J6=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ec.kill(-t.pid,e),Mg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Mg.error("Error killing process:",r),!1}},ETe=t=>J6(t,"SIGKILL"),vTe=(t,e)=>{let r=null,n=()=>{Mg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),J6(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Mg.log(`Force killing idle process ${t.pid}`),ETe(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)},bTe=t=>{K6.add(t);let e=mTe();if(e){let r=e.onTimesUp(()=>{Mg.log(`Global timer expired, killing process ${t.pid}`),J6(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Mg.log(`Force killing process ${t.pid} after timeout`),ETe(t))},5e3)});t.on("exit",()=>{K6.delete(t),r()}),t.on("error",()=>{K6.delete(t),r()})}};function du(t,e){if(!Ec.env.NETLIFY_LOCAL_MODE)try{let i=ryt.resolve(gTe.name),s=Sc.dirname(i);for(;s!==Sc.dirname(s);){let o=Sc.dirname(s);if(Sc.basename(o)==="node_modules"){let a=Sc.join(o,".bin",e);if(oC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ec.env.NODE_PATH){let i=Sc.join(Ec.env.NODE_PATH,".bin",e);if(oC.existsSync(i))return i}let r=Sc.join(t,"node_modules",".bin",e);if(oC.existsSync(r))return r;let n=Sc.join(tyt,"..","node_modules",".bin",e);if(oC.existsSync(n))return n}import uL from"process";import{fileURLToPath as GOt}from"url";import{createRequire as WOt}from"module";import dL from"path";var iyt="__netlify__getTracer",syt="__netlify__shutdownTracers",dt=(t,e)=>globalThis[iyt]?.(t,e),TTe=async()=>globalThis[syt]?.();function Nf(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 jOt}from"timers/promises";import tEt from"process";var wTe=typeof globalThis=="object"?globalThis:global;var vc="1.9.0";var RTe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function oyt(t){var e=new Set([t]),r=new Set,n=t.match(RTe);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(c){return c===t};function s(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(RTe);if(!l)return s(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||i.major!==u.major?s(c):i.major===0?i.minor===u.minor&&i.patch<=u.patch?o(c):s(c):i.minor<=u.minor?o(c):s(c)}}var ATe=oyt(vc);var ayt=vc.split(".")[0],kb=Symbol.for("opentelemetry.js.api."+ayt),$b=wTe;function fu(t,e,r,n){var i;n===void 0&&(n=!1);var s=$b[kb]=(i=$b[kb])!==null&&i!==void 0?i:{version:vc};if(!n&&s[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(s.version!==vc){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+vc);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+vc+"."),!0}function eo(t){var e,r,n=(e=$b[kb])===null||e===void 0?void 0:e.version;if(!(!n||!ATe(n)))return(r=$b[kb])===null||r===void 0?void 0:r[t]}function pu(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+vc+".");var r=$b[kb];r&&delete r[t]}var cyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},lyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},xTe=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Lb("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Lb("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Lb("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Lb("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Lb("verbose",this._namespace,e)},t})();function Lb(t,e,r){var n=eo("diag");if(n)return r.unshift(e),n[t].apply(n,lyt([],cyt(r),!1))}var Gn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(Gn||(Gn={}));function ITe(t,e){t<Gn.NONE?t=Gn.NONE:t>Gn.ALL&&(t=Gn.ALL),e=e||{};function r(n,i){var s=e[n];return typeof s=="function"&&t>=i?s.bind(e):function(){}}return{error:r("error",Gn.ERROR),warn:r("warn",Gn.WARN),info:r("info",Gn.INFO),debug:r("debug",Gn.DEBUG),verbose:r("verbose",Gn.VERBOSE)}}var uyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},dyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},fyt="diag",Di=(function(){function t(){function e(i){return function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];var a=eo("diag");if(a)return a[i].apply(a,dyt([],uyt(s),!1))}}var r=this,n=function(i,s){var o,a,c;if(s===void 0&&(s={logLevel:Gn.INFO}),i===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof s=="number"&&(s={logLevel:s});var u=eo("diag"),d=ITe((a=s.logLevel)!==null&&a!==void 0?a:Gn.INFO,i);if(u&&!s.suppressOverrideMessage){var f=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return fu("diag",d,r,!0)};r.setLogger=n,r.disable=function(){pu(fyt,r)},r.createComponentLogger=function(i){return new xTe(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var pyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},hyt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},PTe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=pyt(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=new t(this._entries);try{for(var o=hyt(n),a=o.next();!a.done;a=o.next()){var c=a.value;s._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return s},t.prototype.clear=function(){return new t},t})();var Par=Di.instance();function OTe(t){return t===void 0&&(t={}),new PTe(new Map(Object.entries(t)))}function aC(t){return Symbol.for(t)}var myt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var s=new t(r._currentContext);return s._currentContext.set(n,i),s},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t})(),CTe=new myt;var NTe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},kTe={set:function(t,e,r){t!=null&&(t[e]=r)}};var gyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},_yt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},$Te=(function(){function t(){}return t.prototype.active=function(){return CTe},t.prototype.with=function(e,r,n){for(var i=[],s=3;s<arguments.length;s++)i[s-3]=arguments[s];return r.call.apply(r,_yt([n],gyt(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var yyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Syt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Z6="context",Eyt=new $Te,hu=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return fu(Z6,e,Di.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Syt([e,r,n],yyt(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return eo(Z6)||Eyt},t.prototype.disable=function(){this._getContextManager().disable(),pu(Z6,Di.instance())},t})();var cC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(cC||(cC={}));var X6="0000000000000000",Q6="00000000000000000000000000000000",LTe={traceId:Q6,spanId:X6,traceFlags:cC.NONE};var mu=(function(){function t(e){e===void 0&&(e=LTe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var e3=aC("OpenTelemetry Context Key SPAN");function lC(t){return t.getValue(e3)||void 0}function DTe(){return lC(hu.getInstance().active())}function Db(t,e){return t.setValue(e3,e)}function MTe(t){return t.deleteValue(e3)}function UTe(t,e){return Db(t,new mu(e))}function uC(t){var e;return(e=lC(t))===null||e===void 0?void 0:e.spanContext()}var vyt=/^([0-9a-f]{32})$/i,byt=/^[0-9a-f]{16}$/i;function Tyt(t){return vyt.test(t)&&t!==Q6}function wyt(t){return byt.test(t)&&t!==X6}function dC(t){return Tyt(t.traceId)&&wyt(t.spanId)}function FTe(t){return new mu(t)}var t3=hu.getInstance(),fC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=t3.active());var i=!!r?.root;if(i)return new mu;var s=n&&uC(n);return Ryt(s)&&dC(s)?new mu(s):new mu},t.prototype.startActiveSpan=function(e,r,n,i){var s,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(s=r,a=n):(s=r,o=n,a=i);var c=o??t3.active(),l=this.startSpan(e,s,c),u=Db(c,l);return t3.with(u,a,void 0,l)}},t})();function Ryt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var Ayt=new fC,jTe=(function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,i){var s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Ayt},t})();var qTe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new fC},t})();var xyt=new qTe,r3=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new jTe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:xyt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)},t})();var gu;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(gu||(gu={}));var na;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(na||(na={}));var bc=hu.getInstance();var n3=Di.instance();var BTe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var i3=aC("OpenTelemetry Baggage Key");function s3(t){return t.getValue(i3)||void 0}function zTe(){return s3(hu.getInstance().active())}function VTe(t,e){return t.setValue(i3,e)}function HTe(t){return t.deleteValue(i3)}var o3="propagation",Iyt=new BTe,GTe=(function(){function t(){this.createBaggage=OTe,this.getBaggage=s3,this.getActiveBaggage=zTe,this.setBaggage=VTe,this.deleteBaggage=HTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return fu(o3,e,Di.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=kTe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=NTe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){pu(o3,Di.instance())},t.prototype._getGlobalPropagator=function(){return eo(o3)||Iyt},t})();var Mb=GTe.getInstance();var a3="trace",WTe=(function(){function t(){this._proxyTracerProvider=new r3,this.wrapSpanContext=FTe,this.isSpanContextValid=dC,this.deleteSpan=MTe,this.getSpan=lC,this.getActiveSpan=DTe,this.getSpanContext=uC,this.setSpan=Db,this.setSpanContext=UTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=fu(a3,this._proxyTracerProvider,Di.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return eo(a3)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){pu(a3,Di.instance()),this._proxyTracerProvider=new r3},t})();var Ub=WTe.getInstance();var Oyt=function(t,e){e.recordException(t),e.setStatus({code:na.ERROR})};var kf=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,i){var s=YTe(r,n,i),o=s.opts,a=s.ctx,c=s.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return KTe(l,o,c)})},t.prototype.withSpan=function(e,r,n,i){var s=YTe(r,n,i),o=s.opts,a=s.ctx,c=s.fn,l=this._tracer.startSpan(e,o,a);return KTe(l,o,c)},t})();function YTe(t,e,r){var n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??bc.active(),{opts:n,ctx:i,fn:s}}function KTe(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:Oyt,s=function(a){throw i(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},s):(t.end(),o)}catch(a){throw s(a)}}iW();Qe();var lT=class{emit(e){}enabled(){return!1}},cRe=new lT;var uT=Symbol.for("io.opentelemetry.js.api.logs"),Wg=globalThis;function lRe(t,e,r){return n=>n===t?e:r}var sW=1;var oW=class{getLogger(e,r,n){return new lT}},nN=new oW;var iN=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):cRe}};var dT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new iN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:nN}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var sN=class t{constructor(){this._proxyLoggerProvider=new dT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Wg[uT]?this.getLoggerProvider():(Wg[uT]=lRe(sW,e,nN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Wg[uT])===null||e===void 0?void 0:e.call(Wg,sW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Wg[uT],this._proxyLoggerProvider=new dT}};var uRe=sN.getInstance();function dRe(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 fRe(t){t.forEach(e=>e.disable())}function aW(t){let e=t.tracerProvider||Or.getTracerProvider(),r=t.meterProvider||Kb.getMeterProvider(),n=t.loggerProvider||uRe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return dRe(i,e,r,n),()=>{fRe(i)}}dr();var xN=Ln(TW(),1);dr();var HRe=t=>{throw TypeError(t)},xW=(t,e,r)=>e.has(t)||HRe("Cannot "+r),AN=(t,e,r)=>(xW(t,e,"read from private field"),r?r.call(t):e.get(t)),wW=(t,e,r)=>e.has(t)?HRe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),BRe=(t,e,r,n)=>(xW(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),eEt=(t,e,r)=>(xW(t,e,"access private method"),r),zRe="__netlify__getTracer",rEt="__netlify__shutdownTracers",nEt="__nfOTLPTrace",pT,hT,AW,GRe,iEt=class{constructor(){wW(this,AW),wW(this,pT),wW(this,hT),BRe(this,pT,new ua(eEt(this,AW,GRe),this)),BRe(this,hT,n3.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(AN(this,hT).debug(`export ${t.length.toString()} spans`),AN(this,pT).isCalled){e({code:Xt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(nEt,JSON.stringify(sEt(t))),e({code:Xt.SUCCESS})}shutdown(){return AN(this,pT).call()}};pT=new WeakMap;hT=new WeakMap;AW=new WeakSet;GRe=function(){return AN(this,hT).debug("Shutting down"),Promise.resolve()};function sEt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:RN(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||gu.SERVER,startTimeUnixNano:RW(e.startTime),endTimeUnixNano:RW(e.endTime),attributes:RN(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:RW(n.time),attributes:RN(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:RN(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function RN(t){return Object.keys(t).map(e=>WRe(e,t[e]))}function WRe(t,e){return{key:t,value:YRe(e)}}function YRe(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(YRe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>WRe(r,n))}}:{}}function RW(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var VRe={name:"@netlify/otel",version:"6.0.3",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":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},KRe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,zRe))return;let e=tEt.version.slice(1),r=rN({"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??[oEt()],i=new xN.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new xc});let s=t.instrumentations??[];aW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,zRe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new kf(Ub.getTracer(a,c)):new kf(Ub.getTracer(VRe.name,VRe.version))}}),Object.defineProperty(globalThis,rEt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},oEt=()=>new xN.SimpleSpanProcessor(new iEt);dr();var mT=Ln(TW(),1);import*as IN from"diagnostics_channel";var JRe=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?na.ERROR:na.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 kf?t:new kf(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){IN.subscribe(t,e);let r=()=>IN.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:gu.CLIENT},bc.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:na.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 cke=Ln(oke(),1);var cL=Re("tracing"),ake=8e3,qOt=5e3,Iw=async(t=qOt)=>{try{await Promise.race([TTe(),jOt(t)])}catch(e){cL.warn("Failed to flush tracers on shutdown",e)}},lke=async(t,e,r)=>{if(!dt()){let n=[new mT.SimpleSpanProcessor(new d9),new mT.SimpleSpanProcessor(new cke.OTLPTraceExporter({url:r.exporterUrl}))];await KRe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new JRe({skipHeaders:!0})]})}return r.traceparent?(Mb.setGlobalPropagator(new xc),Mb.extract(bc.active(),{traceparent:r.traceparent,isRemote:!0})):bc.active()};function zt(t,e,r){return cL.log(`\u23F3 TRACE: ${e} starting...`),Nf(t,e,r)}var d9=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(", ")}]`:"";cL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&cL.log(` \u274C Error: ${e.status.message}`)}};function f9(){return gt().captureLlmContentEnabled}function uke(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t}function lL(t,e,r){let n={role:t,parts:[{type:"text",content:bs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function dke(t,e,r,n){if(!t.length)return;let i=dt();if(!i)return;let s=f9(),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.title||a.type||`step-${a.id??c}`,f=a.type==="tool_use"||a.type==="tool_result",p=a.message?a.message.length>ake?`${a.message.slice(0,ake)}\u2026`:a.message:void 0;i.startSpan(d,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":d,"gen_ai.operation.name":f?"execute_tool":"chat",...f?{"gen_ai.tool.name":d}:{},"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&&p?f?{"gen_ai.tool.call.result":bs(p)}:{"gen_ai.output.messages":lL("assistant",p)}:{}}}).end(u)})}import{readdir as BOt,rm as zOt}from"fs/promises";import{join as VOt}from"path";async function fke(t,e=[]){let n=(await BOt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>zOt(VOt(t,i),{recursive:!0,force:!0})))}var HOt=700,pke=t=>t.mode==="create"&&(t.accountType===gl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=HOt);var YOt=dL.dirname(GOt(import.meta.url)),hke=WOt(import.meta.url),KOt=dL.resolve(YOt,"scripts/scaffold.js"),JOt="scripts/scaffold.js",ZOt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,p9=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},XOt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),QOt=t=>{let e=p9(t);return e==="node"||e.endsWith("/node")},gp=t=>{if(typeof t!="string")return!1;let e=t.match(ZOt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&XOt(p9(e[r]));)r+=1;if(r>=e.length||!QOt(e[r]))return!1;let n=e[r+1];return n?p9(n).includes(JOt):!1},V_=Re("create_stage"),mke="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.",eCt=`${mke}
581
+ if (condition) { yield value; }`)};import{Buffer as lmt}from"buffer";import{StringDecoder as umt}from"string_decoder";var VO=(t,e,r)=>{if(r)return;if(t)return{transform:dmt.bind(void 0,new TextEncoder)};let n=new umt(e);return{transform:fmt.bind(void 0,n),final:pmt.bind(void 0,n)}},dmt=function*(t,e){lmt.isBuffer(e)?yield hc(e):typeof e=="string"?yield t.encode(e):yield e},fmt=function*(t,e){yield Pr(e)?t.write(e):e},pmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Mve}from"util";var f6=Mve(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),HO=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=mmt}=e[r];for await(let i of n(t))yield*HO(i,e,r+1)},Uve=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*hmt(r,Number(e),t)},hmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*HO(n,r,e+1)},Fve=Mve(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),mmt=function*(t){yield t};var p6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},jve=(t,e)=>[...e.flatMap(r=>[...Pf(r,t,0)]),...Rb(t)],Pf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=_mt}=e[r];for(let i of n(t))yield*Pf(i,e,r+1)},Rb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*gmt(r,Number(e),t)},gmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Pf(n,r,e+1)},_mt=function*(t){yield t};var h6=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Bve(t,o,s),l=If(e),u=If(r),d=l?f6.bind(void 0,HO,a):p6.bind(void 0,Pf),f=l||u?f6.bind(void 0,Uve,a):p6.bind(void 0,Rb),p=l||u?Fve.bind(void 0,a):void 0;return{stream:new ymt({writableObjectMode:n,writableHighWaterMark:qve(n),readableObjectMode:i,readableHighWaterMark:qve(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},GO=(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=Bve(o,r,a);t=jve(c,t)}return t},Bve=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:$ve(n,a)},VO(r,o,n),zO(r,s,n,c),{transform:t,final:e},{transform:Lve(i,a)},kve({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var zve=(t,e)=>{for(let r of Smt(t))Emt(t,r,e)},Smt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Emt=(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 ${lu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>vmt(a,n));r.input=mb(o)},vmt=(t,e)=>{let r=GO(t,e,"utf8",!0);return bmt(r),mb(r)},bmt=t=>{let e=t.find(r=>typeof r!="string"&&!Pr(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 Amt,appendFileSync as xmt}from"fs";var WO=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Tg(r,n)&&!$i.has(e)&&Tmt(n)&&(t.some(({type:i,value:s})=>i==="native"&&wmt.has(s))||t.every(({type:i})=>vs.has(i))),Tmt=t=>t===1||t===2,wmt=new Set(["pipe","overlapped"]),Vve=async(t,e,r,n)=>{for await(let i of t)Rmt(e)||Gve(i,r,n)},Hve=(t,e,r)=>{for(let n of t)Gve(n,e,r)},Rmt=t=>t._readableState.pipes.length>0,Gve=(t,e,r)=>{let n=aO(t);Xo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Wve=({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)=>Imt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Imt=({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=YEe(t,s,d),p=hc(f),{stdioItems:h,objectMode:m}=e[r],_=Pmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Omt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Cmt({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&&Nmt(y,h,i),S}catch(g){return n.error=g,S}},Pmt=(t,e,r,n)=>{try{return GO(t,e,r,!1)}catch(i){return n.error=i,t}},Omt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:mb(t)};let o=cye(t,r);return n[s]?{serializedResult:o,finalResult:d6(o,!i[s],e)}:{serializedResult:o}},Cmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!WO({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=d6(t,!1,o);try{Hve(a,e,n)}catch(c){r.error??=c}},Nmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>qO.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?xmt(n,t):(r.add(s),Amt(n,t))}};var Yve=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,_c(e,r,"all")]:Array.isArray(e)?[_c(t,r,"all"),...e]:Pr(t)&&Pr(e)?EG([t,e]):`${t}${e}`};import{once as m6}from"events";var Kve=async(t,e)=>{let[r,n]=await kmt(t);return e.isForcefullyTerminated??=!1,[r,n]},kmt=async t=>{let[e,r]=await Promise.allSettled([m6(t,"spawn"),m6(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Jve(t):r.value},Jve=async t=>{try{return await m6(t,"exit")}catch{return Jve(t)}},Zve=async t=>{let[e,r]=await t;if(!$mt(e,r)&&g6(e,r))throw new Zs;return[e,r]},$mt=(t,e)=>t===void 0&&e===void 0,g6=(t,e)=>t!==0||e!==null;var Xve=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Lmt(t,e,r),o=s?.code==="ETIMEDOUT",a=WEe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Lmt=(t,e,r)=>t!==void 0?t:g6(e,r)?new Zs:void 0;var Qve=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Mmt(t,e,r),d=jmt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return kg(d,c,l)},Mmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=lO(t,e,r),a=Umt(r),{file:c,commandArguments:l,options:u}=PO(t,e,a);Fmt(u);let d=Pve(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Umt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Fmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&YO("ipcInput"),t&&YO("ipc: true"),r&&YO("detached: true"),n&&YO("cancelSignal")},YO=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},jmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=qmt({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}=Xve(c,r),{output:h,error:m=l}=Wve({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>_c(v,r,S)),y=_c(Yve(h,r),r,"all");return zmt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},qmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{zve(s,r);let a=Bmt(r);return Dmt(...OO(t,e,a))}catch(a){return Ng({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Bmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:MO(e)}),zmt=({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?UO({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):wb({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 O_t}from"events";import{spawn as C_t}from"child_process";import ibe from"process";import{once as _6,on as Vmt}from"events";var ebe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Ag({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:TO(t)}),Hmt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Hmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{SO(e,i);let s=cu(t,e,r),o=new AbortController;try{return await Promise.race([Gmt(s,n,o),Wmt(s,r,o),Ymt(s,r,o)])}catch(a){throw xg(t),a}finally{o.abort(),EO(e,i)}},Gmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await _6(t,"message",{signal:r});return n}for await(let[n]of Vmt(t,"message",{signal:r}))if(e(n))return n},Wmt=async(t,e,{signal:r})=>{await _6(t,"disconnect",{signal:r}),jSe(e)},Ymt=async(t,e,{signal:r})=>{let[n]=await _6(t,"strict:error",{signal:r});throw gO(n,e)};import{once as rbe,on as Kmt}from"events";var nbe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>y6({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),y6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Ag({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:TO(t)}),SO(e,s);let o=cu(t,e,r),a=new AbortController,c={};return Jmt(t,o,a),Zmt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Xmt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Jmt=async(t,e,r)=>{try{await rbe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Zmt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await rbe(t,"strict:error",{signal:r.signal});n.error=gO(i,e),r.abort()}catch{}},Xmt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Kmt(r,"message",{signal:s.signal}))tbe(o),yield c}catch{tbe(o)}finally{s.abort(),EO(e,a),n||xg(t),i&&await t}},tbe=({error:t})=>{if(t)throw t};var sbe=(t,{ipc:e})=>{Object.assign(t,abe(t,!1,e))},obe=()=>{let t=ibe,e=!0,r=ibe.channel!==void 0;return{...abe(t,e,r),getCancelSignal:pEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},abe=(t,e,r)=>({sendMessage:xO.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ebe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:nbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Qmt}from"child_process";import{PassThrough as egt,Readable as tgt,Writable as rgt,Duplex as ngt}from"stream";var cbe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{c6(n);let a=new Qmt;igt(a,n),Object.assign(a,{readable:sgt,writable:ogt,duplex:agt});let c=Ng({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=cgt(c,o,i);return{subprocess:a,promise:l}},igt=(t,e)=>{let r=Ab(),n=Ab(),i=Ab(),s=Array.from({length:e.length-3},Ab),o=Ab(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Ab=()=>{let t=new egt;return t.end(),t},sgt=()=>new tgt({read(){}}),ogt=()=>new rgt({write(){}}),agt=()=>new ngt({read(){},write(){}}),cgt=async(t,e,r)=>kg(t,e,r);import{createReadStream as lbe,createWriteStream as ube}from"fs";import{Buffer as lgt}from"buffer";import{Readable as xb,Writable as ugt,Duplex as dgt}from"stream";var fbe=(t,e)=>BO(fgt,t,e,!1),Ib=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${lu[t]}.`)},dbe={fileNumber:Ib,generator:h6,asyncGenerator:h6,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:dgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},fgt={input:{...dbe,fileUrl:({value:t})=>({stream:lbe(t)}),filePath:({value:{file:t}})=>({stream:lbe(t)}),webStream:({value:t})=>({stream:xb.fromWeb(t)}),iterable:({value:t})=>({stream:xb.from(t)}),asyncIterable:({value:t})=>({stream:xb.from(t)}),string:({value:t})=>({stream:xb.from(t)}),uint8Array:({value:t})=>({stream:xb.from(lgt.from(t))})},output:{...dbe,fileUrl:({value:t})=>({stream:ube(t)}),filePath:({value:{file:t,append:e}})=>({stream:ube(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:ugt.fromWeb(t)}),iterable:Ib,asyncIterable:Ib,string:Ib,uint8Array:Ib}};import{on as pgt,once as pbe}from"events";import{PassThrough as hgt,getDefaultHighWaterMark as mgt}from"stream";import{finished as gbe}from"stream/promises";function Of(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)E6(i);let e=t.some(({readableObjectMode:i})=>i),r=ggt(t,e),n=new S6({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var ggt=(t,e)=>{if(t.length===0)return mgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},S6=class extends hgt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(E6(e),this.#e.has(e))return;this.#e.add(e),this.#n??=_gt(this,this.#e,this.#s);let r=Egt({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(E6(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)}},_gt=async(t,e,r)=>{KO(t,hbe);let n=new AbortController;try{await Promise.race([ygt(t,n),Sgt(t,e,r,n)])}finally{n.abort(),KO(t,-hbe)}},ygt=async(t,{signal:e})=>{try{await gbe(t,{signal:e,cleanup:!0})}catch(r){throw _be(t,r),r}},Sgt=async(t,e,r,{signal:n})=>{for await(let[i]of pgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},E6=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Egt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{KO(t,mbe);let a=new AbortController;try{await Promise.race([vgt(s,e,a),bgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Tgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),KO(t,-mbe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?v6(t):wgt(t))},vgt=async(t,e,{signal:r})=>{try{await t,r.aborted||v6(e)}catch(n){r.aborted||_be(e,n)}},bgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await gbe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;ybe(o)?i.add(e):Sbe(t,o)}},Tgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await pbe(t,i,{signal:s}),!t.readable)return pbe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},wgt=t=>{t.writable&&t.end()},_be=(t,e)=>{ybe(e)?v6(t):Sbe(t,e)},ybe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",v6=t=>{(t.readable||t.writable)&&t.destroy()},Sbe=(t,e)=>{t.destroyed||(t.once("error",Rgt),t.destroy(e))},Rgt=()=>{},KO=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},hbe=2,mbe=1;import{finished as Ebe}from"stream/promises";var Lg=(t,e)=>{t.pipe(e),Agt(t,e),xgt(t,e)},Agt=async(t,e)=>{if(!(Js(t)||Js(e))){try{await Ebe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}b6(e)}},b6=t=>{t.writable&&t.end()},xgt=async(t,e)=>{if(!(Js(t)||Js(e))){try{await Ebe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}T6(t)}},T6=t=>{t.readable&&t.destroy()};var vbe=(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})=>vs.has(c)))Igt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!vs.has(c)))Ogt({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]:Of(s);Lg(o,i)}},Igt=(t,e,r,n)=>{r==="output"?Lg(t.stdio[n],e):Lg(e,t.stdio[n]);let i=Pgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Pgt=["stdin","stdout","stderr"],Ogt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;Cgt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},Cgt=(t,{signal:e})=>{Js(t)&&Af(t,Ngt,e)},Ngt=2;import{addAbortListener as Lgt}from"events";var Cf=[];Cf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Cf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Cf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var JO=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",w6=Symbol.for("signal-exit emitter"),R6=globalThis,kgt=Object.defineProperty.bind(Object),A6=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(R6[w6])return R6[w6];kgt(R6,w6,{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}},ZO=class{},$gt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),x6=class extends ZO{onExit(){return()=>{}}load(){}unload(){}},I6=class extends ZO{#e=P6.platform==="win32"?"SIGINT":"SIGHUP";#r=new A6;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Cf)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(!JO(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 Cf)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,Cf.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 JO(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"&&JO(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)}},P6=globalThis.process,{onExit:bbe,load:qnr,unload:Bnr}=$gt(JO(P6)?new I6(P6):new x6);var Tbe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=bbe(()=>{t.kill()});Lgt(n,()=>{i()})};var Rbe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=cO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Dgt(r,n,i),{sourceStream:d,sourceError:f}=Ugt(t,l),{options:p,fileDescriptors:h}=ea.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},Dgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Mgt(t,e,...r),a=yO(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Mgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(wbe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||yG(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]=XP(r,...n);return{destination:e(wbe)(i,s,o),pipeOptions:o}}if(ea.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}`)},wbe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Ugt=(t,e)=>{try{return{sourceStream:Ig(t,e)}}catch(r){return{sourceError:r}}};var xbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Fgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw O6({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Fgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return T6(t),n;if(e!==void 0)return b6(r),e},O6=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Ng({error:t,command:Abe,escapedCommand:Abe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Abe="source.pipe(destination)";var Ibe=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 jgt}from"stream/promises";var Pbe=(t,e,r)=>{let n=XO.has(e)?Bgt(t,e):qgt(t,e);return Af(t,Vgt,r.signal),Af(e,Hgt,r.signal),zgt(e),n},qgt=(t,e)=>{let r=Of([t]);return Lg(r,e),XO.set(e,r),r},Bgt=(t,e)=>{let r=XO.get(e);return r.add(t),r},zgt=async t=>{try{await jgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}XO.delete(t)},XO=new WeakMap,Vgt=2,Hgt=1;import{aborted as Ggt}from"util";var Obe=(t,e)=>t===void 0?[]:[Wgt(t,e)],Wgt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Ggt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw O6({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var QO=(t,...e)=>{if(yr(e[0]))return QO.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Rbe(t,...e),i=Ygt({...n,destination:r});return i.pipe=QO.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Ygt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=Kgt(t,i);xbe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Pbe(e,s,d);return await Promise.race([Ibe(u),...Obe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},Kgt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as r_t}from"timers/promises";import{on as Jgt}from"events";import{getDefaultHighWaterMark as Zgt}from"stream";var eC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Xgt(e,o),Nbe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Xgt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},C6=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;Qgt(e,o,t);let a=t.readableObjectMode&&!s;return Nbe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Qgt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Nbe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=Jgt(t,"data",{signal:e.signal,highWaterMark:Cbe,highWatermark:Cbe});return e_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},N6=Zgt(!0),Cbe=N6,e_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=t_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Pf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Rb(a)}},t_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[VO(t,r,!e),zO(t,i,!n,{})].filter(Boolean);var kbe=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=n_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([i_t(t),d]);return}let f=l6(c,r),p=C6({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([s_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},n_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!WO({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=C6({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Vve(a,t,r,s)},i_t=async t=>{await r_t(),t.readableFlowing===null&&t.resume()},s_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await $O(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await LO(r,{maxBuffer:s})):await Cg(r,{maxBuffer:s})}catch(a){return $be(VEe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},k6=async t=>{try{return await t}catch(e){return $be(e)}},$be=({bufferedData:t})=>oye(t)?new Uint8Array(t):t;import{finished as o_t}from"stream/promises";var Pb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=a_t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],o_t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||u_t(a,e,r,n)}finally{o.abort()}},a_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&c_t(t,r,n),n},c_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{l_t(e,r),n.call(t,...i)}},l_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},u_t=(t,e,r,n)=>{if(!d_t(t,e,r,n))throw t},d_t=(t,e,r,n=!0)=>r.propagating?Lbe(t)||tC(t):(r.propagating=!0,$6(r,e)===n?Lbe(t):tC(t)),$6=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",tC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Lbe=t=>t?.code==="EPIPE";var Dbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>L6({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),L6=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=Pb(t,e,l);if($6(l,e)){await u;return}let[d]=await Promise.all([kbe({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 Mbe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Of([t,e].filter(Boolean)):void 0,Ube=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>L6({...f_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:p_t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),f_t=({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}},p_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as h_t}from"events";var Fbe=t=>Tg(t,"ipc"),jbe=(t,e)=>{let r=aO(t);Xo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var qbe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Fbe(s),a=mc(e,"ipc"),c=mc(r,"ipc");for await(let l of y6({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(HEe(t,i,c),i.push(l)),o&&jbe(l,s);return i},Bbe=async(t,e)=>(await Promise.allSettled([t]),e);var zbe=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=Kve(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Dbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=Ube({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),I=[],x=qbe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),R=m_t(m,t,S),P=g_t(h,S);try{return await Promise.race([Promise.all([{},Zve(v),Promise.all(g),w,x,TEe(t,d),...R,...P]),_,__t(t,y),...yEe(t,s,f,y),...FSe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...gEe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(A){return f.terminationReason??="other",Promise.all([{error:A},v,Promise.all(g.map(b=>k6(b))),k6(w),Bbe(x,I),Promise.allSettled(R),Promise.allSettled(P)])}},m_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Pb(n,i,r)),g_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Qs(s,{checkOpen:!1})&&!Js(s)).map(({type:i,value:s,stream:o=s})=>Pb(o,n,e,{isSameDirection:vs.has(i),stopOnExit:i==="native"}))),__t=async(t,{signal:e})=>{let[r]=await h_t(t,"error",{signal:e});throw r};var Vbe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Ob=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=Qo();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Dg=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 y_t}from"stream";import{callbackify as S_t}from"util";import{finished as Hbe}from"stream/promises";var D6=async t=>{if(t!==void 0)try{await M6(t)}catch{}},Gbe=async t=>{if(t!==void 0)try{await U6(t)}catch{}},M6=async t=>{await Hbe(t,{cleanup:!0,readable:!1,writable:!0})},U6=async t=>{await Hbe(t,{cleanup:!0,readable:!0,writable:!1})},rC=async(t,e)=>{if(await t,e)throw e},nC=(t,e,r)=>{r&&!tC(r)?t.destroy(r):e&&t.destroy()};var Wbe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||$i.has(r),{subprocessStdout:a,waitReadableDestroy:c}=F6(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=j6(a,o),{read:f,onStdoutDataDone:p}=q6({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new y_t({read:f,destroy:S_t(z6.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return B6({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},F6=(t,e,r)=>{let n=Ig(t,e),i=Ob(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},j6=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:N6},q6=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=Qo(),o=eC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){E_t(this,o,s)},onStdoutDataDone:s}},E_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},B6=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await U6(t),await n,await D6(i),await e,r.readable&&r.push(null)}catch(s){await D6(i),Ybe(r,s)}},z6=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Dg(r,e)&&(Ybe(t,n),await rC(e,n))},Ybe=(t,e)=>{nC(t,t.readable,e)};import{Writable as v_t}from"stream";import{callbackify as Kbe}from"util";var Jbe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=V6(t,r,e),o=new v_t({...H6(n,t,i),destroy:Kbe(W6.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return G6(n,o),o},V6=(t,e,r)=>{let n=yO(t,e),i=Ob(r,n,"writableFinal"),s=Ob(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},H6=(t,e,r)=>({write:b_t.bind(void 0,t),final:Kbe(T_t.bind(void 0,t,e,r))}),b_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},T_t=async(t,e,r)=>{await Dg(r,e)&&(t.writable&&t.end(),await e)},G6=async(t,e,r)=>{try{await M6(t),e.writable&&e.end()}catch(n){await Gbe(r),Zbe(e,n)}},W6=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Dg(r,e),await Dg(n,e)&&(Zbe(t,i),await rC(e,i))},Zbe=(t,e)=>{nC(t,t.writable,e)};import{Duplex as w_t}from"stream";import{callbackify as R_t}from"util";var Xbe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||$i.has(r),{subprocessStdout:c,waitReadableDestroy:l}=F6(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=V6(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=j6(c,a),{read:_,onStdoutDataDone:y}=q6({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new w_t({read:_,...H6(u,t,d),destroy:R_t(A_t.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 B6({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),G6(u,v,c),v},A_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([z6({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),W6({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var Y6=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||$i.has(e),o=Ig(t,r),a=eC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return x_t(a,o,t)},x_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Qbe=(t,{encoding:e})=>{let r=Vbe();t.readable=Wbe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Jbe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Xbe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Y6.bind(void 0,t,e),t[Symbol.asyncIterator]=Y6.bind(void 0,t,e,{})};var eTe=(t,e)=>{for(let[r,n]of P_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},I_t=(async()=>{})().constructor.prototype,P_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(I_t,t)]);var tTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=N_t(t,e,r),{subprocess:f,promise:p}=$_t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=QO.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),eTe(f,p),ea.set(f,{options:u,fileDescriptors:d}),f},N_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=lO(t,e,r),{file:a,commandArguments:c,options:l}=PO(t,e,r),u=k_t(l),d=fbe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},k_t=({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}},$_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=C_t(...OO(t,e,r))}catch(h){return cbe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;O_t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];vbe(c,a,l),Tbe(c,r,l);let d={},f=Qo();c.kill=MSe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Mbe(c,r),Qbe(c,r),sbe(c,r);let p=L_t({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}},L_t=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 zbe({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,w)=>_c(g,e,w)),v=_c(m,e,"all"),S=D_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return kg(S,n,e)},D_t=({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?wb({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 ta,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):UO({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var iC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,M_t(n,t[n],i)]));return{...t,...r}},M_t=(t,e,r)=>U_t.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,U_t=new Set(["env",...wG]);var uu=(t,e,r,n)=>{let i=(o,a,c)=>uu(o,a,r,c),s=(...o)=>F_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},F_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,iC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=j_t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?Qve(a,c,l):tTe(a,c,l,i)},j_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=fye(e)?pye(e,r):[e,...r],[o,a,c]=XP(...s),l=iC(iC(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 rTe=({file:t,commandArguments:e})=>iTe(t,e),nTe=({file:t,commandArguments:e})=>({...iTe(t,e),isSync:!0}),iTe=(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]=q_t(t);return{file:r,commandArguments:n}},q_t=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(B_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},B_t=/ +/g;var sTe=(t,e,r)=>{t.sync=e(z_t,r),t.s=t.sync},oTe=({options:t})=>aTe(t),z_t=({options:t})=>({...aTe(t),isSync:!0}),aTe=t=>({options:{...V_t(t),...t}}),V_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},cTe={preferLocal:!0};var lTe=uu(()=>({})),Nor=uu(()=>({isSync:!0})),uTe=uu(rTe),kor=uu(nTe),$or=uu(EEe),Lor=uu(oTe,{},cTe,sTe),{sendMessage:Dor,getOneMessage:Mor,getEachMessage:Uor,getCancelSignal:For}=obe();import{Transform as H_t}from"stream";var G_t=["NETLIFY_AI_GATEWAY_KEY"];function W_t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...G_t])]}function Y_t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function K_t(){let e=W_t().map(r=>process.env[r]).filter(r=>!(!r||Y_t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function bs(t){if(typeof t!="string")return t;let e=K_t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(J_t(n),"g");r=r.replace(i,"******")}),r}function J_t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Cb=class extends H_t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=bs(i);n(null,s)}},sC=Symbol("maskedWrite");function dTe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[sC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?bs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[sC]=!0,process.stdout.write=r}if(!process.stderr.write[sC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?bs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[sC]=!0,process.stderr.write=r}}}var fTe=!1,pTe=()=>{fTe=!0},hi=()=>fTe;var Nb=null,hTe=t=>(Nb&&Nb.destroy(),Nb=new yc({totalAllowedTime:t}),Nb),mTe=()=>Nb;var yc=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 JP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Oe.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 gTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.142.1-test.4",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@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.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var eyt=X_t(import.meta.url),tyt=Sc.dirname(eyt),ryt=Q_t(import.meta.url),Mg=Re("shell"),K6=new Set,_Te={preferLocal:!0},Li=(t,e,r)=>{let[n,i]=nyt(e,r),s={..._Te,...i},o=lTe(t,n,s);STe(o,s),bTe(o);let a=r?.idleTimeout;return a&&a>0&&vTe(o,a),o},yTe=(t,e)=>{let r={..._Te,...e},n=uTe(t,r);return STe(n,r),bTe(n),e?.idleTimeout&&e.idleTimeout>0&&vTe(n,e.idleTimeout),n},nyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},STe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ec.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Cb).pipe(Ec.stdout),t.stderr?.pipe(new Cb).pipe(Ec.stderr);return}t.stdout?.pipe(Ec.stdout),t.stderr?.pipe(Ec.stderr)},J6=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ec.kill(-t.pid,e),Mg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Mg.error("Error killing process:",r),!1}},ETe=t=>J6(t,"SIGKILL"),vTe=(t,e)=>{let r=null,n=()=>{Mg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),J6(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Mg.log(`Force killing idle process ${t.pid}`),ETe(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)},bTe=t=>{K6.add(t);let e=mTe();if(e){let r=e.onTimesUp(()=>{Mg.log(`Global timer expired, killing process ${t.pid}`),J6(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Mg.log(`Force killing process ${t.pid} after timeout`),ETe(t))},5e3)});t.on("exit",()=>{K6.delete(t),r()}),t.on("error",()=>{K6.delete(t),r()})}};function du(t,e){if(!Ec.env.NETLIFY_LOCAL_MODE)try{let i=ryt.resolve(gTe.name),s=Sc.dirname(i);for(;s!==Sc.dirname(s);){let o=Sc.dirname(s);if(Sc.basename(o)==="node_modules"){let a=Sc.join(o,".bin",e);if(oC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ec.env.NODE_PATH){let i=Sc.join(Ec.env.NODE_PATH,".bin",e);if(oC.existsSync(i))return i}let r=Sc.join(t,"node_modules",".bin",e);if(oC.existsSync(r))return r;let n=Sc.join(tyt,"..","node_modules",".bin",e);if(oC.existsSync(n))return n}import uL from"process";import{fileURLToPath as GOt}from"url";import{createRequire as WOt}from"module";import dL from"path";var iyt="__netlify__getTracer",syt="__netlify__shutdownTracers",dt=(t,e)=>globalThis[iyt]?.(t,e),TTe=async()=>globalThis[syt]?.();function Nf(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 jOt}from"timers/promises";import tEt from"process";var wTe=typeof globalThis=="object"?globalThis:global;var vc="1.9.0";var RTe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function oyt(t){var e=new Set([t]),r=new Set,n=t.match(RTe);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(c){return c===t};function s(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(RTe);if(!l)return s(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||i.major!==u.major?s(c):i.major===0?i.minor===u.minor&&i.patch<=u.patch?o(c):s(c):i.minor<=u.minor?o(c):s(c)}}var ATe=oyt(vc);var ayt=vc.split(".")[0],kb=Symbol.for("opentelemetry.js.api."+ayt),$b=wTe;function fu(t,e,r,n){var i;n===void 0&&(n=!1);var s=$b[kb]=(i=$b[kb])!==null&&i!==void 0?i:{version:vc};if(!n&&s[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(s.version!==vc){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+vc);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+vc+"."),!0}function eo(t){var e,r,n=(e=$b[kb])===null||e===void 0?void 0:e.version;if(!(!n||!ATe(n)))return(r=$b[kb])===null||r===void 0?void 0:r[t]}function pu(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+vc+".");var r=$b[kb];r&&delete r[t]}var cyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},lyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},xTe=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Lb("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Lb("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Lb("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Lb("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Lb("verbose",this._namespace,e)},t})();function Lb(t,e,r){var n=eo("diag");if(n)return r.unshift(e),n[t].apply(n,lyt([],cyt(r),!1))}var Gn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(Gn||(Gn={}));function ITe(t,e){t<Gn.NONE?t=Gn.NONE:t>Gn.ALL&&(t=Gn.ALL),e=e||{};function r(n,i){var s=e[n];return typeof s=="function"&&t>=i?s.bind(e):function(){}}return{error:r("error",Gn.ERROR),warn:r("warn",Gn.WARN),info:r("info",Gn.INFO),debug:r("debug",Gn.DEBUG),verbose:r("verbose",Gn.VERBOSE)}}var uyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},dyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},fyt="diag",Di=(function(){function t(){function e(i){return function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];var a=eo("diag");if(a)return a[i].apply(a,dyt([],uyt(s),!1))}}var r=this,n=function(i,s){var o,a,c;if(s===void 0&&(s={logLevel:Gn.INFO}),i===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof s=="number"&&(s={logLevel:s});var u=eo("diag"),d=ITe((a=s.logLevel)!==null&&a!==void 0?a:Gn.INFO,i);if(u&&!s.suppressOverrideMessage){var f=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return fu("diag",d,r,!0)};r.setLogger=n,r.disable=function(){pu(fyt,r)},r.createComponentLogger=function(i){return new xTe(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var pyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},hyt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},PTe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=pyt(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=new t(this._entries);try{for(var o=hyt(n),a=o.next();!a.done;a=o.next()){var c=a.value;s._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return s},t.prototype.clear=function(){return new t},t})();var Par=Di.instance();function OTe(t){return t===void 0&&(t={}),new PTe(new Map(Object.entries(t)))}function aC(t){return Symbol.for(t)}var myt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var s=new t(r._currentContext);return s._currentContext.set(n,i),s},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t})(),CTe=new myt;var NTe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},kTe={set:function(t,e,r){t!=null&&(t[e]=r)}};var gyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},_yt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},$Te=(function(){function t(){}return t.prototype.active=function(){return CTe},t.prototype.with=function(e,r,n){for(var i=[],s=3;s<arguments.length;s++)i[s-3]=arguments[s];return r.call.apply(r,_yt([n],gyt(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var yyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Syt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Z6="context",Eyt=new $Te,hu=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return fu(Z6,e,Di.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Syt([e,r,n],yyt(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return eo(Z6)||Eyt},t.prototype.disable=function(){this._getContextManager().disable(),pu(Z6,Di.instance())},t})();var cC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(cC||(cC={}));var X6="0000000000000000",Q6="00000000000000000000000000000000",LTe={traceId:Q6,spanId:X6,traceFlags:cC.NONE};var mu=(function(){function t(e){e===void 0&&(e=LTe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var e3=aC("OpenTelemetry Context Key SPAN");function lC(t){return t.getValue(e3)||void 0}function DTe(){return lC(hu.getInstance().active())}function Db(t,e){return t.setValue(e3,e)}function MTe(t){return t.deleteValue(e3)}function UTe(t,e){return Db(t,new mu(e))}function uC(t){var e;return(e=lC(t))===null||e===void 0?void 0:e.spanContext()}var vyt=/^([0-9a-f]{32})$/i,byt=/^[0-9a-f]{16}$/i;function Tyt(t){return vyt.test(t)&&t!==Q6}function wyt(t){return byt.test(t)&&t!==X6}function dC(t){return Tyt(t.traceId)&&wyt(t.spanId)}function FTe(t){return new mu(t)}var t3=hu.getInstance(),fC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=t3.active());var i=!!r?.root;if(i)return new mu;var s=n&&uC(n);return Ryt(s)&&dC(s)?new mu(s):new mu},t.prototype.startActiveSpan=function(e,r,n,i){var s,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(s=r,a=n):(s=r,o=n,a=i);var c=o??t3.active(),l=this.startSpan(e,s,c),u=Db(c,l);return t3.with(u,a,void 0,l)}},t})();function Ryt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var Ayt=new fC,jTe=(function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,i){var s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Ayt},t})();var qTe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new fC},t})();var xyt=new qTe,r3=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new jTe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:xyt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)},t})();var gu;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(gu||(gu={}));var na;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(na||(na={}));var bc=hu.getInstance();var n3=Di.instance();var BTe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var i3=aC("OpenTelemetry Baggage Key");function s3(t){return t.getValue(i3)||void 0}function zTe(){return s3(hu.getInstance().active())}function VTe(t,e){return t.setValue(i3,e)}function HTe(t){return t.deleteValue(i3)}var o3="propagation",Iyt=new BTe,GTe=(function(){function t(){this.createBaggage=OTe,this.getBaggage=s3,this.getActiveBaggage=zTe,this.setBaggage=VTe,this.deleteBaggage=HTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return fu(o3,e,Di.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=kTe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=NTe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){pu(o3,Di.instance())},t.prototype._getGlobalPropagator=function(){return eo(o3)||Iyt},t})();var Mb=GTe.getInstance();var a3="trace",WTe=(function(){function t(){this._proxyTracerProvider=new r3,this.wrapSpanContext=FTe,this.isSpanContextValid=dC,this.deleteSpan=MTe,this.getSpan=lC,this.getActiveSpan=DTe,this.getSpanContext=uC,this.setSpan=Db,this.setSpanContext=UTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=fu(a3,this._proxyTracerProvider,Di.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return eo(a3)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){pu(a3,Di.instance()),this._proxyTracerProvider=new r3},t})();var Ub=WTe.getInstance();var Oyt=function(t,e){e.recordException(t),e.setStatus({code:na.ERROR})};var kf=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,i){var s=YTe(r,n,i),o=s.opts,a=s.ctx,c=s.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return KTe(l,o,c)})},t.prototype.withSpan=function(e,r,n,i){var s=YTe(r,n,i),o=s.opts,a=s.ctx,c=s.fn,l=this._tracer.startSpan(e,o,a);return KTe(l,o,c)},t})();function YTe(t,e,r){var n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??bc.active(),{opts:n,ctx:i,fn:s}}function KTe(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:Oyt,s=function(a){throw i(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},s):(t.end(),o)}catch(a){throw s(a)}}iW();Qe();var lT=class{emit(e){}enabled(){return!1}},cRe=new lT;var uT=Symbol.for("io.opentelemetry.js.api.logs"),Wg=globalThis;function lRe(t,e,r){return n=>n===t?e:r}var sW=1;var oW=class{getLogger(e,r,n){return new lT}},nN=new oW;var iN=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):cRe}};var dT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new iN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:nN}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var sN=class t{constructor(){this._proxyLoggerProvider=new dT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Wg[uT]?this.getLoggerProvider():(Wg[uT]=lRe(sW,e,nN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Wg[uT])===null||e===void 0?void 0:e.call(Wg,sW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Wg[uT],this._proxyLoggerProvider=new dT}};var uRe=sN.getInstance();function dRe(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 fRe(t){t.forEach(e=>e.disable())}function aW(t){let e=t.tracerProvider||Or.getTracerProvider(),r=t.meterProvider||Kb.getMeterProvider(),n=t.loggerProvider||uRe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return dRe(i,e,r,n),()=>{fRe(i)}}dr();var xN=Ln(TW(),1);dr();var HRe=t=>{throw TypeError(t)},xW=(t,e,r)=>e.has(t)||HRe("Cannot "+r),AN=(t,e,r)=>(xW(t,e,"read from private field"),r?r.call(t):e.get(t)),wW=(t,e,r)=>e.has(t)?HRe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),BRe=(t,e,r,n)=>(xW(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),eEt=(t,e,r)=>(xW(t,e,"access private method"),r),zRe="__netlify__getTracer",rEt="__netlify__shutdownTracers",nEt="__nfOTLPTrace",pT,hT,AW,GRe,iEt=class{constructor(){wW(this,AW),wW(this,pT),wW(this,hT),BRe(this,pT,new ua(eEt(this,AW,GRe),this)),BRe(this,hT,n3.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(AN(this,hT).debug(`export ${t.length.toString()} spans`),AN(this,pT).isCalled){e({code:Xt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(nEt,JSON.stringify(sEt(t))),e({code:Xt.SUCCESS})}shutdown(){return AN(this,pT).call()}};pT=new WeakMap;hT=new WeakMap;AW=new WeakSet;GRe=function(){return AN(this,hT).debug("Shutting down"),Promise.resolve()};function sEt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:RN(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||gu.SERVER,startTimeUnixNano:RW(e.startTime),endTimeUnixNano:RW(e.endTime),attributes:RN(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:RW(n.time),attributes:RN(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:RN(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function RN(t){return Object.keys(t).map(e=>WRe(e,t[e]))}function WRe(t,e){return{key:t,value:YRe(e)}}function YRe(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(YRe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>WRe(r,n))}}:{}}function RW(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var VRe={name:"@netlify/otel",version:"6.0.3",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":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},KRe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,zRe))return;let e=tEt.version.slice(1),r=rN({"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??[oEt()],i=new xN.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new xc});let s=t.instrumentations??[];aW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,zRe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new kf(Ub.getTracer(a,c)):new kf(Ub.getTracer(VRe.name,VRe.version))}}),Object.defineProperty(globalThis,rEt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},oEt=()=>new xN.SimpleSpanProcessor(new iEt);dr();var mT=Ln(TW(),1);import*as IN from"diagnostics_channel";var JRe=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?na.ERROR:na.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 kf?t:new kf(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){IN.subscribe(t,e);let r=()=>IN.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:gu.CLIENT},bc.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:na.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 cke=Ln(oke(),1);var cL=Re("tracing"),ake=8e3,qOt=5e3,Iw=async(t=qOt)=>{try{await Promise.race([TTe(),jOt(t)])}catch(e){cL.warn("Failed to flush tracers on shutdown",e)}},lke=async(t,e,r)=>{if(!dt()){let n=[new mT.SimpleSpanProcessor(new d9),new mT.SimpleSpanProcessor(new cke.OTLPTraceExporter({url:r.exporterUrl}))];await KRe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new JRe({skipHeaders:!0})]})}return r.traceparent?(Mb.setGlobalPropagator(new xc),Mb.extract(bc.active(),{traceparent:r.traceparent,isRemote:!0})):bc.active()};function zt(t,e,r){return cL.log(`\u23F3 TRACE: ${e} starting...`),Nf(t,e,r)}var d9=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(", ")}]`:"";cL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&cL.log(` \u274C Error: ${e.status.message}`)}};function f9(){return gt().captureLlmContentEnabled}function uke(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t}function lL(t,e,r){let n={role:t,parts:[{type:"text",content:bs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function dke(t,e,r,n){if(!t.length)return;let i=dt();if(!i)return;let s=f9(),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.title||a.type||`step-${a.id??c}`,f=a.type==="tool_use"||a.type==="tool_result",p=a.message?a.message.length>ake?`${a.message.slice(0,ake)}\u2026`:a.message:void 0;i.startSpan(d,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":d,"gen_ai.operation.name":f?"execute_tool":"chat",...f?{"gen_ai.tool.name":d}:{},"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&&p?f?{"gen_ai.tool.call.result":bs(p)}:{"gen_ai.output.messages":lL("assistant",p)}:{}}}).end(u)})}import{readdir as BOt,rm as zOt}from"fs/promises";import{join as VOt}from"path";async function fke(t,e=[]){let n=(await BOt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>zOt(VOt(t,i),{recursive:!0,force:!0})))}var HOt=700,pke=t=>t.mode==="create"&&(t.accountType===gl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=HOt);var YOt=dL.dirname(GOt(import.meta.url)),hke=WOt(import.meta.url),KOt=dL.resolve(YOt,"scripts/scaffold.js"),JOt="scripts/scaffold.js",ZOt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,p9=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},XOt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),QOt=t=>{let e=p9(t);return e==="node"||e.endsWith("/node")},gp=t=>{if(typeof t!="string")return!1;let e=t.match(ZOt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&XOt(p9(e[r]));)r+=1;if(r>=e.length||!QOt(e[r]))return!1;let n=e[r+1];return n?p9(n).includes(JOt):!1},V_=Re("create_stage"),mke="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.",eCt=`${mke}
582
582
 
583
583
  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.`,tCt=`${mke}
584
584
 
@@ -871,7 +871,7 @@ Use the following file for the complete context of the ask, the environment, and
871
871
  `,l=await OFt({hash:o,manifestPath:i,manifestString:c});return{manifestInfo:{manifestPath:i,manifestString:c},identical:l}},OFt=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!uFe(e)?!1:await lFe(e,"utf8")===r},fFe=async function({manifestPath:t,manifestString:e}){await AFt(PFt(t),{recursive:!0}),await IFt(t,e)},pFe=async function(t){let e=HD(t);await xFt(e,{force:!0,recursive:!0,maxRetries:3})},HD=function(t){return`${t}${mFe}`},hFe=function(t){return t.endsWith(mFe)},mFe=".netlify.cache.json",J7=async function(t){let e=HD(t);if(!uFe(e))return!1;let{expires:r}=await CFt(t);return iFe(r)},CFt=async function(t){let e=HD(t),r=await lFe(e,"utf-8");return JSON.parse(r)};import{homedir as DFt}from"os";import{resolve as gFe,isAbsolute as MFt,join as UFt,sep as X7}from"path";import{normalize as NFt}from"path";import{existsSync as kFt}from"fs";import $Ft from"process";var Z7=function(t){try{let e=LFt(t);return kFt(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},LFt=function(t=$Ft.cwd()){return NFt(t)};var w0=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await FFt(t,r),i=await zFt({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:i}},FFt=async function(t,e){let r=await Z7(e),n=jFt(t,r);return qFt(n,r),n},jFt=function(t,e){if(MFt(t))return gFe(t);if(e!=="")return gFe(e,t);throw new Error(`Current directory does not exist: ${e}`)},qFt=function(t,e){if(e!==""&&BFt(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},BFt=function(t,e){return`${e}${X7}`.startsWith(`${t}${X7}`)},zFt=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Vp({cacheDir:e,cwd:r}),{name:i,relPath:s}=await VFt(t,r);return UFt(n,i,s)},VFt=async function(t,e){let r=await Q7(e),n=HFt(t);return r.map(({name:i,base:s})=>WFt(i,s,n)).find(Boolean)},HFt=function(t){return t.replace(GFt,"\\")},GFt=/^[a-zA-Z]:\\/,WFt=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},Q7=async function(t){return[...await YFt(t),{name:"home",base:DFt()},{name:"root",base:X7}]},YFt=async function(t){let e=await Z7(t);return e===""?[]:[{name:"cwd",base:e}]};var JFt=1,eX=async function({cacheDir:t,cwd:e,depth:r=JFt}={}){let n=await Q7(e),i=Vp({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>ZFt({name:a,base:c,cacheDir:i,depth:r})))).flat()},ZFt=async function({name:t,base:e,cacheDir:r,depth:n}){return(await rFe(`${r}/${t}`,{fileFilter:XFt,depth:n,type:"files_directories"})).map(({path:o})=>KFt(e,o))},XFt=function({basename:t}){return!hFe(t)};var QFt=async function(t,{move:e=_Fe,ttl:r=njt,digests:n=[],cacheDir:i,cwd:s}={}){let{srcPath:o,cachePath:a}=await w0({path:t,cacheDir:i,cwdOpt:s});if(!await b0(o))return!1;let{manifestInfo:c,identical:l}=await dFe({cachePath:a,move:e,ttl:r,digests:n});return l||(await tX(a,{force:!0,recursive:!0,maxRetries:3}),await H7(o,a,e),await fFe(c)),!0},ejt=async function(t,{move:e=_Fe,cacheDir:r,cwd:n}={}){let{srcPath:i,cachePath:s}=await w0({path:t,cacheDir:r,cwdOpt:n});return!await b0(s)||await J7(s)?!1:(await tX(i,{force:!0,recursive:!0,maxRetries:3}),await H7(s,i,e),!0)},tjt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await w0({path:t,cacheDir:e,cwdOpt:r});return await b0(n)?(await tX(n,{force:!0,recursive:!0,maxRetries:3}),await pFe(n),!0):!1},rjt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await w0({path:t,cacheDir:e,cwdOpt:r});return await b0(n)&&!await J7(n)},_Fe=!1,njt=void 0,GD=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(i=>t(i,...r)))).some(Boolean):t(e,...r)},ijt=GD.bind(null,QFt),sjt=GD.bind(null,ejt),ojt=GD.bind(null,tjt),ajt=GD.bind(null,rjt),yFe=function(t){return{save:(e,r)=>ijt(e,{...t,...r}),restore:(e,r)=>sjt(e,{...t,...r}),remove:(e,r)=>ojt(e,{...t,...r}),has:(e,r)=>ajt(e,{...t,...r}),list:e=>eX({...t,...e}),getCacheDir:e=>Vp({...t,...e})}};var mn=Re("native_session"),rX=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await ll.stat(ul.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),Zp=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return mn.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:n,include:i}=r,s=!1;try{s=(await ll.stat(n)).isDirectory()}catch{}if(!s)return mn.log(`Native session base dir ${n} not found, skipping`),null;let o=await rX(n,i);if(o.length===0)return mn.log(`No native session history found under ${n}, skipping`),null;let a=ul.join(SFe.tmpdir(),`native-session-${e}.zip`);try{await Li("zip",["-r","-q","-X",a,...o],{cwd:n});let c=await ll.readFile(a);mn.log(`Zipped native session (${c.length} bytes) from ${o.join(", ")}`);let{upload_url:l,s3_key:u}=await Y$e(t,e);return await i0(l,c,{contentType:"application/zip"}),mn.log("Successfully uploaded native session to S3"),u}catch(c){return mn.error("Failed to archive/upload native session, continuing without it:",c),null}finally{await ll.rm(a,{force:!0}).catch(()=>{})}},EFe=async t=>{if(!t)return!1;let{baseDir:e,include:r}=t,n=await rX(e,r);for(let i of n)if((await ll.readdir(ul.join(e,i)).catch(()=>[])).length>0)return!0;return!1},cjt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),vFe=async(t,e)=>{let r=await ll.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await vFe(ul.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},bFe=async(t,e)=>{if(!t||!e)return!1;let r=new RegExp(`(^|[^a-zA-Z0-9])${cjt(e)}([^a-zA-Z0-9]|$)`),{baseDir:n,include:i}=t,s=await rX(n,i);for(let o of s)if(await vFe(ul.join(n,o),r))return!0;return!1},TFe=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return mn.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,i=ul.join(SFe.tmpdir(),`native-session-restore-${e}.zip`);try{let s=await K$e(t,e);if(!s?.download_url)return mn.log("No native session available to restore, skipping"),!1;let o=await rLe(s.download_url);return await ll.writeFile(i,o),mn.log(`Downloaded native session (${o.length} bytes) to ${i}`),await ll.mkdir(n,{recursive:!0}),await Li("unzip",["-o","-q",i,"-d",n]),mn.log(`Restored native session into ${n}`),!0}catch(s){return mn.error("Failed to fetch/restore native session, continuing without it:",s),!1}finally{await ll.rm(i,{force:!0}).catch(()=>{})}},ljt="native-sessions",wFe=(t,e)=>yFe({cacheDir:ul.join(e.dir,ljt),cwd:t}),RFe=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await wFe(r,e).restore(n.map(s=>ul.join(r,s)),{})?(mn.log(`Restored native session from buildbot cache into ${r}`),!0):(mn.log("No native session in buildbot cache, skipping restore"),!1)}catch(i){return mn.error("Failed to restore native session from buildbot cache, continuing without it:",i),!1}},uS=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await wFe(r,e).save(n.map(s=>ul.join(r,s)),{})?(mn.log(`Saved native session to buildbot cache under ${e.dir}`),!0):(mn.log("No native session history to save to buildbot cache, skipping"),!1)}catch(i){return mn.error("Failed to save native session to buildbot cache, continuing:",i),!1}};var R0=Re("inference_stage"),AFe=5,ja=async t=>{let{additionalContext:e,cliPath:r,config:n,context:i,buildErrors:s,runner:o,persistSteps:a,aiGateway:c,attempt:l,contextPrefix:u,priorAgentSessionId:d,cwd:f,abortSignal:p,onSessionId:h,resumeSession:m,effortOverride:_}=t;if(hi())throw new Error("Shutdown in progress, aborting inference stage");R0.log(`Running inference stage, attempt ${l} of ${AFe}`);let y=!1,v=await zt(dt(),"inference-stage",async S=>{S?.setAttributes({"inference.attempt":l||1}),dTe();let g=!!(l&&l>1),w=await ujt(n,g),I=!!m&&!!d;I&&n.runner==="gemini"&&!await t0(d)&&(I=!1);let x=w.viable||I;y=x,w.outcome!=="not_eligible"&&Oe.inc("inference.native_resume",1,{outcome:w.outcome,...w.source?{source:w.source}:{}});let{prompt:R}=await zt(dt(),"compose-prompt",async()=>await SLe({cliPath:r,config:n,buildErrorContext:djt(s),netlify:i,additionalContext:e,resumePrompt:x})),P=`
872
872
  ${u||""}
873
873
  ${R}
874
- `.trim(),A={...n,prompt:P},b=d??(x?w.sessionId:void 0),$=await zt(dt(),`run-${n.runner}`,async C=>{let T=f9();C?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":uke(n.runner),"gen_ai.system":n.runner,...T?{"gen_ai.input.messages":lL("user",P)}:{}});let O=Date.now(),N=await o({aiGateway:c,config:A,netlify:i,persistSteps:a,continueSession:g||x,priorAgentSessionId:b,cwd:f,abortSignal:p,onSessionId:h,..._?{effortOverride:_}:{}}),q=Date.now(),Z=N.resolvedModel||n.model||"unknown",se=N.error?"error":"stop";return C?.setAttributes({...T?{"gen_ai.output.messages":lL("assistant",N.result??N.error??"",se)}:{},"gen_ai.response.finish_reasons":[se],"gen_ai.request.model":Z,"gen_ai.response.model":Z,...N.effort?{"gen_ai.request.effort":N.effort}:{},...N.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":N.usage.input_tokens}:{},...N.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":N.usage.output_tokens}:{},...N.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":N.usage.cache_creation_input_tokens}:{},...N.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":N.usage.cache_read_input_tokens}:{}}),dke(N.steps??[],n.mode,O,q),N});return $.result&&($.result=bs($.result)),$.error&&($.error=bs($.error)),await a.flush(),$});if(v.aborted)return R0.log("Inference turn was interrupted (credit wrap-up); skipping retry/error handling",{agentSessionId:v.agentSessionId}),{runnerResult:v,nativeResume:y};if(v.error){if(hi()){let S=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(S,{agentSessionId:v.agentSessionId}),S}if(R0.error("Runner failed",{stepsCount:v.steps.length,duration:v.duration,error:v.error,isRetryableError:v.isRetryableError,attempt:l||1,agentSessionId:v.agentSessionId}),Oe.inc("inference.failed",1,{attempt:l||1,is_retryable:!!v.isRetryableError,is_provider_unavailable:!!v.isProviderUnavailableError}),v.isRetryableError&&(!l||l<AFe))return R0.log("Retrying inference stage"),await new Promise(g=>setTimeout(g,5e3)),{runnerResult:(await ja({...t,attempt:(l||1)+1,priorAgentSessionId:v.agentSessionId,contextPrefix:v.agentSessionId?"":"<important> The agent has already started on this work but ran into networking errors trying to complete it. Please continue from where it left off (you can use git commands to see what's currently changed thus far) and do not start over. Here is the full prompt for context: </important>"})).runnerResult,nativeResume:y};{if(R0.log("Do not retry inference stage"),v.error.toLowerCase().includes("usage exceeded"))throw new Us(v.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);let S=v.isRetryableError||v.isProviderUnavailableError?new Rd(v.error):new Error(v.error);throw Object.assign(S,{agentSessionId:v.agentSessionId}),S}}return{runnerResult:v,nativeResume:y}},ujt=async(t,e)=>{if(e)return{viable:!1,outcome:"not_eligible"};let r=t.previousSession,{viable:n,outcome:i}=ELe(t);if(!n)return{viable:n,outcome:i};let s=r?.nativeSessionId,o=il(t.runner),a=async()=>s?t.runner==="gemini"?!!await sJ(s):bFe(o,s):!1,c;if(xFe(t)&&await EFe(o))c="local";else if(t.fastInit&&gt().warmNativeResumeEnabled&&await RFe({archive:o,cache:t.cache})&&await a())c="cache_restore";else{if(c="fetch",!gt().coldResumeFromS3Enabled)return{viable:!1,outcome:"cold_resume_disabled",source:c};if(!await TFe({runnerId:t.id,sessionId:t.sessionId,archive:o}))return{viable:!1,outcome:"fetch_failed",source:c}}return t.runner==="gemini"&&s&&!await t0(s)?{viable:!1,outcome:"sanitize_failed",source:c}:{viable:!0,sessionId:s,outcome:"resumed",source:c}},djt=t=>!t||t.length===0?"":`
874
+ `.trim(),A={...n,prompt:P},b=d??(x?w.sessionId:void 0),$=await zt(dt(),`run-${n.runner}`,async C=>{let T=f9();C?.setAttributes({"gen_ai.operation.name":"chat","gen_ai.capability.name":n.mode,"gen_ai.provider.name":uke(n.runner),"gen_ai.system":n.runner,...T?{"gen_ai.input.messages":lL("user",P)}:{}});let O=Date.now(),N=await o({aiGateway:c,config:A,netlify:i,persistSteps:a,continueSession:g||x,priorAgentSessionId:b,cwd:f,abortSignal:p,onSessionId:h,..._?{effortOverride:_}:{}}),q=Date.now(),Z=N.resolvedModel||n.model||"unknown",se=N.error?"error":"stop";return C?.setAttributes({...T?{"gen_ai.output.messages":lL("assistant",N.result??N.error??"",se)}:{},"gen_ai.response.finish_reasons":[se],"gen_ai.request.model":Z,"gen_ai.response.model":Z,...N.effort?{"gen_ai.request.effort":N.effort}:{},...N.usage?.input_tokens!=null?{"gen_ai.usage.input_tokens":N.usage.input_tokens}:{},...N.usage?.output_tokens!=null?{"gen_ai.usage.output_tokens":N.usage.output_tokens}:{},...N.usage?.cache_creation_input_tokens!=null?{"gen_ai.usage.cache_creation.input_tokens":N.usage.cache_creation_input_tokens}:{},...N.usage?.cache_read_input_tokens!=null?{"gen_ai.usage.cache_read.input_tokens":N.usage.cache_read_input_tokens}:{}}),dke(N.steps??[],n.mode,O,q),N});return $.result&&($.result=bs($.result)),$.error&&($.error=bs($.error)),await a.flush(),$});if(v.aborted)return R0.log("Inference turn was interrupted (credit wrap-up); skipping retry/error handling",{agentSessionId:v.agentSessionId}),{runnerResult:v,nativeResume:y};if(v.error){if(hi()){let S=new Error("Shutdown in progress, aborting inference stage");throw Object.assign(S,{agentSessionId:v.agentSessionId}),S}if(R0.error("Runner failed",{stepsCount:v.steps.length,duration:v.duration,error:v.error,isRetryableError:v.isRetryableError,attempt:l||1,agentSessionId:v.agentSessionId}),Oe.inc("inference.failed",1,{attempt:l||1,is_retryable:!!v.isRetryableError,is_provider_unavailable:!!v.isProviderUnavailableError}),v.isRetryableError&&(!l||l<AFe))return R0.log("Retrying inference stage"),await new Promise(g=>setTimeout(g,5e3)),{runnerResult:(await ja({...t,attempt:(l||1)+1,priorAgentSessionId:v.agentSessionId,contextPrefix:v.agentSessionId?"":"<important> The agent has already started on this work but ran into networking errors trying to complete it. Please continue from where it left off (you can use git commands to see what's currently changed thus far) and do not start over. Here is the full prompt for context: </important>"})).runnerResult,nativeResume:y};{if(R0.log("Do not retry inference stage"),v.error.toLowerCase().includes("usage exceeded")){let g=new Us(v.error,503,"Credit limit reached. Please add more credits to continue using Agent Runners.",!0);throw Object.assign(g,{agentSessionId:v.agentSessionId}),g}let S=v.isRetryableError||v.isProviderUnavailableError?new Rd(v.error):new Error(v.error);throw Object.assign(S,{agentSessionId:v.agentSessionId}),S}}return{runnerResult:v,nativeResume:y}},ujt=async(t,e)=>{if(e)return{viable:!1,outcome:"not_eligible"};let r=t.previousSession,{viable:n,outcome:i}=ELe(t);if(!n)return{viable:n,outcome:i};let s=r?.nativeSessionId,o=il(t.runner),a=async()=>s?t.runner==="gemini"?!!await sJ(s):bFe(o,s):!1,c;if(xFe(t)&&await EFe(o))c="local";else if(t.fastInit&&gt().warmNativeResumeEnabled&&await RFe({archive:o,cache:t.cache})&&await a())c="cache_restore";else{if(c="fetch",!gt().coldResumeFromS3Enabled)return{viable:!1,outcome:"cold_resume_disabled",source:c};if(!await TFe({runnerId:t.id,sessionId:t.sessionId,archive:o}))return{viable:!1,outcome:"fetch_failed",source:c}}return t.runner==="gemini"&&s&&!await t0(s)?{viable:!1,outcome:"sanitize_failed",source:c}:{viable:!0,sessionId:s,outcome:"resumed",source:c}},djt=t=>!t||t.length===0?"":`
875
875
  Deploy failed failed. Here are the errors to review on the latest build:
876
876
 
877
877
  Below are all of the logs with potential issues that we extracted. Some of them may be false positives, discern them carefully and ensure fixes are relevant.