@netlify/agent-runner-cli 1.145.0-ex-2517.6 → 1.145.0-ex-2517.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +4 -4
- package/dist/bin.js +4 -4
- package/dist/index.js +41 -41
- package/package.json +1 -1
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:T6},Nmt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},kmt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Nmt};import{Buffer as $mt}from"buffer";var Kve=(t,e)=>t?void 0:Lmt.bind(void 0,e),Lmt=function*(t,e){if(typeof e!="string"&&!Pr(e)&&!$mt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Jve=(t,e)=>t?Dmt.bind(void 0,e):Mmt.bind(void 0,e),Dmt=function*(t,e){Zve(t,e),yield e},Mmt=function*(t,e){if(Zve(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},Zve=(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 Umt}from"buffer";import{StringDecoder as Fmt}from"string_decoder";var ZO=(t,e,r)=>{if(r)return;if(t)return{transform:jmt.bind(void 0,new TextEncoder)};let n=new Fmt(e);return{transform:qmt.bind(void 0,n),final:Bmt.bind(void 0,n)}},jmt=function*(t,e){Umt.isBuffer(e)?yield Ec(e):typeof e=="string"?yield t.encode(e):yield e},qmt=function*(t,e){yield Pr(e)?t.write(e):e},Bmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Xve}from"util";var R6=Xve(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),XO=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Vmt}=e[r];for await(let i of n(t))yield*XO(i,e,r+1)},Qve=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zmt(r,Number(e),t)},zmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*XO(n,r,e+1)},ebe=Xve(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Vmt=function*(t){yield t};var A6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},tbe=(t,e)=>[...e.flatMap(r=>[...Uf(r,t,0)]),...Ob(t)],Uf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Gmt}=e[r];for(let i of n(t))yield*Uf(i,e,r+1)},Ob=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Hmt(r,Number(e),t)},Hmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Uf(n,r,e+1)},Gmt=function*(t){yield t};var x6=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=nbe(t,o,s),l=Mf(e),u=Mf(r),d=l?R6.bind(void 0,XO,a):A6.bind(void 0,Uf),f=l||u?R6.bind(void 0,Qve,a):A6.bind(void 0,Ob),p=l||u?ebe.bind(void 0,a):void 0;return{stream:new Wmt({writableObjectMode:n,writableHighWaterMark:rbe(n),readableObjectMode:i,readableHighWaterMark:rbe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},QO=(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=nbe(o,r,a);t=tbe(c,t)}return t},nbe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Kve(n,a)},ZO(r,o,n),JO(r,s,n,c),{transform:t,final:e},{transform:Jve(i,a)},Yve({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var ibe=(t,e)=>{for(let r of Ymt(t))Kmt(t,r,e)},Ymt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Kmt=(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 ${vu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Jmt(a,n));r.input=Eb(o)},Jmt=(t,e)=>{let r=QO(t,e,"utf8",!0);return Zmt(r),Eb(r)},Zmt=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 tgt,appendFileSync as rgt}from"fs";var eC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ig(r,n)&&!Di.has(e)&&Xmt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Qmt.has(s))||t.every(({type:i})=>vs.has(i))),Xmt=t=>t===1||t===2,Qmt=new Set(["pipe","overlapped"]),sbe=async(t,e,r,n)=>{for await(let i of t)egt(e)||abe(i,r,n)},obe=(t,e,r)=>{for(let n of t)abe(n,e,r)},egt=t=>t._readableState.pipes.length>0,abe=(t,e,r)=>{let n=hO(t);ta({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var cbe=({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)=>ngt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},ngt=({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=lve(t,s,d),p=Ec(f),{stdioItems:h,objectMode:m}=e[r],_=igt([p],h,c,n),{serializedResult:y,finalResult:v=y}=sgt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});ogt({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&&agt(y,h,i),S}catch(g){return n.error=g,S}},igt=(t,e,r,n)=>{try{return QO(t,e,r,!1)}catch(i){return n.error=i,t}},sgt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Eb(t)};let o=Tye(t,r);return n[s]?{serializedResult:o,finalResult:w6(o,!i[s],e)}:{serializedResult:o}},ogt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!eC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=w6(t,!1,o);try{obe(a,e,n)}catch(c){r.error??=c}},agt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>YO.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?rgt(n,t):(r.add(s),tgt(n,t))}};var lbe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Tc(e,r,"all")]:Array.isArray(e)?[Tc(t,r,"all"),...e]:Pr(t)&&Pr(e)?kG([t,e]):`${t}${e}`};import{once as I6}from"events";var ube=async(t,e)=>{let[r,n]=await cgt(t);return e.isForcefullyTerminated??=!1,[r,n]},cgt=async t=>{let[e,r]=await Promise.allSettled([I6(t,"spawn"),I6(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?dbe(t):r.value},dbe=async t=>{try{return await I6(t,"exit")}catch{return dbe(t)}},fbe=async t=>{let[e,r]=await t;if(!lgt(e,r)&&P6(e,r))throw new Xs;return[e,r]},lgt=(t,e)=>t===void 0&&e===void 0,P6=(t,e)=>t!==0||e!==null;var pbe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ugt(t,e,r),o=s?.code==="ETIMEDOUT",a=cve(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ugt=(t,e,r)=>t!==void 0?t:P6(e,r)?new Xs:void 0;var hbe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=fgt(t,e,r),d=mgt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},fgt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gO(t,e,r),a=pgt(r),{file:c,commandArguments:l,options:u}=DO(t,e,a);hgt(u);let d=Vve(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},pgt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,hgt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&tC("ipcInput"),t&&tC("ipc: true"),r&&tC("detached: true"),n&&tC("cancelSignal")},tC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},mgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=ggt({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}=pbe(c,r),{output:h,error:m=l}=cbe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>Tc(v,r,S)),y=Tc(lbe(h,r),r,"all");return ygt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},ggt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{ibe(s,r);let a=_gt(r);return dgt(...MO(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},_gt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:VO(e)}),ygt=({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?HO({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Pb({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 syt}from"events";import{spawn as oyt}from"child_process";import Sbe from"process";import{once as O6,on as Sgt}from"events";var mbe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Cg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:OO(t)}),Egt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Egt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{AO(e,i);let s=Eu(t,e,r),o=new AbortController;try{return await Promise.race([vgt(s,n,o),bgt(s,r,o),Tgt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),xO(e,i)}},vgt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await O6(t,"message",{signal:r});return n}for await(let[n]of Sgt(t,"message",{signal:r}))if(e(n))return n},bgt=async(t,e,{signal:r})=>{await O6(t,"disconnect",{signal:r}),tEe(e)},Tgt=async(t,e,{signal:r})=>{let[n]=await O6(t,"strict:error",{signal:r});throw TO(n,e)};import{once as _be,on as wgt}from"events";var ybe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>C6({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),C6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Cg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:OO(t)}),AO(e,s);let o=Eu(t,e,r),a=new AbortController,c={};return Rgt(t,o,a),Agt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),xgt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Rgt=async(t,e,r)=>{try{await _be(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Agt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await _be(t,"strict:error",{signal:r.signal});n.error=TO(i,e),r.abort()}catch{}},xgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of wgt(r,"message",{signal:s.signal}))gbe(o),yield c}catch{gbe(o)}finally{s.abort(),xO(e,a),n||Ng(t),i&&await t}},gbe=({error:t})=>{if(t)throw t};var Ebe=(t,{ipc:e})=>{Object.assign(t,bbe(t,!1,e))},vbe=()=>{let t=Sbe,e=!0,r=Sbe.channel!==void 0;return{...bbe(t,e,r),getCancelSignal:IEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},bbe=(t,e,r)=>({sendMessage:$O.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:mbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ybe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Igt}from"child_process";import{PassThrough as Pgt,Readable as Ogt,Writable as Cgt,Duplex as Ngt}from"stream";var Tbe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{v6(n);let a=new Igt;kgt(a,n),Object.assign(a,{readable:$gt,writable:Lgt,duplex:Dgt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Mgt(c,o,i);return{subprocess:a,promise:l}},kgt=(t,e)=>{let r=Cb(),n=Cb(),i=Cb(),s=Array.from({length:e.length-3},Cb),o=Cb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Cb=()=>{let t=new Pgt;return t.end(),t},$gt=()=>new Ogt({read(){}}),Lgt=()=>new Cgt({write(){}}),Dgt=()=>new Ngt({read(){},write(){}}),Mgt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as wbe,createWriteStream as Rbe}from"fs";import{Buffer as Ugt}from"buffer";import{Readable as Nb,Writable as Fgt,Duplex as jgt}from"stream";var xbe=(t,e)=>KO(qgt,t,e,!1),kb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${vu[t]}.`)},Abe={fileNumber:kb,generator:x6,asyncGenerator:x6,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:jgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},qgt={input:{...Abe,fileUrl:({value:t})=>({stream:wbe(t)}),filePath:({value:{file:t}})=>({stream:wbe(t)}),webStream:({value:t})=>({stream:Nb.fromWeb(t)}),iterable:({value:t})=>({stream:Nb.from(t)}),asyncIterable:({value:t})=>({stream:Nb.from(t)}),string:({value:t})=>({stream:Nb.from(t)}),uint8Array:({value:t})=>({stream:Nb.from(Ugt.from(t))})},output:{...Abe,fileUrl:({value:t})=>({stream:Rbe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Rbe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Fgt.fromWeb(t)}),iterable:kb,asyncIterable:kb,string:kb,uint8Array:kb}};import{on as Bgt,once as Ibe}from"events";import{PassThrough as zgt,getDefaultHighWaterMark as Vgt}from"stream";import{finished as Cbe}from"stream/promises";function Ff(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)k6(i);let e=t.some(({readableObjectMode:i})=>i),r=Hgt(t,e),n=new N6({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Hgt=(t,e)=>{if(t.length===0)return Vgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},N6=class extends zgt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(k6(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Ggt(this,this.#e,this.#s);let r=Kgt({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(k6(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)}},Ggt=async(t,e,r)=>{rC(t,Pbe);let n=new AbortController;try{await Promise.race([Wgt(t,n),Ygt(t,e,r,n)])}finally{n.abort(),rC(t,-Pbe)}},Wgt=async(t,{signal:e})=>{try{await Cbe(t,{signal:e,cleanup:!0})}catch(r){throw Nbe(t,r),r}},Ygt=async(t,e,r,{signal:n})=>{for await(let[i]of Bgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},k6=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Kgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{rC(t,Obe);let a=new AbortController;try{await Promise.race([Jgt(s,e,a),Zgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Xgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),rC(t,-Obe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?$6(t):Qgt(t))},Jgt=async(t,e,{signal:r})=>{try{await t,r.aborted||$6(e)}catch(n){r.aborted||Nbe(e,n)}},Zgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Cbe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;kbe(o)?i.add(e):$be(t,o)}},Xgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Ibe(t,i,{signal:s}),!t.readable)return Ibe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Qgt=t=>{t.writable&&t.end()},Nbe=(t,e)=>{kbe(e)?$6(t):$be(t,e)},kbe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",$6=t=>{(t.readable||t.writable)&&t.destroy()},$be=(t,e)=>{t.destroyed||(t.once("error",e_t),t.destroy(e))},e_t=()=>{},rC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Pbe=2,Obe=1;import{finished as Lbe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),t_t(t,e),r_t(t,e)},t_t=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await Lbe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}L6(e)}},L6=t=>{t.writable&&t.end()},r_t=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await Lbe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}D6(t)}},D6=t=>{t.readable&&t.destroy()};var Dbe=(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)))n_t(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!vs.has(c)))s_t({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]:Ff(s);jg(o,i)}},n_t=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=i_t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},i_t=["stdin","stdout","stderr"],s_t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;o_t(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},o_t=(t,{signal:e})=>{Zs(t)&&Lf(t,a_t,e)},a_t=2;import{addAbortListener as u_t}from"events";var jf=[];jf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&jf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&jf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var nC=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",M6=Symbol.for("signal-exit emitter"),U6=globalThis,c_t=Object.defineProperty.bind(Object),F6=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(U6[M6])return U6[M6];c_t(U6,M6,{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}},iC=class{},l_t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),j6=class extends iC{onExit(){return()=>{}}load(){}unload(){}},q6=class extends iC{#e=B6.platform==="win32"?"SIGINT":"SIGHUP";#r=new F6;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of jf)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(!nC(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 jf)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,jf.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 nC(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"&&nC(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)}},B6=globalThis.process,{onExit:Mbe,load:Oir,unload:Cir}=l_t(nC(B6)?new q6(B6):new j6);var Ube=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Mbe(()=>{t.kill()});u_t(n,()=>{i()})};var jbe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=mO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=d_t(r,n,i),{sourceStream:d,sourceError:f}=p_t(t,l),{options:p,fileDescriptors:h}=na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},d_t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=f_t(t,e,...r),a=RO(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},f_t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Fbe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||CG(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]=sO(r,...n);return{destination:e(Fbe)(i,s,o),pipeOptions:o}}if(na.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Fbe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),p_t=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var Bbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=h_t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw z6({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},h_t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return D6(t),n;if(e!==void 0)return L6(r),e},z6=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:qbe,escapedCommand:qbe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),qbe="source.pipe(destination)";var zbe=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 m_t}from"stream/promises";var Vbe=(t,e,r)=>{let n=sC.has(e)?__t(t,e):g_t(t,e);return Lf(t,S_t,r.signal),Lf(e,E_t,r.signal),y_t(e),n},g_t=(t,e)=>{let r=Ff([t]);return jg(r,e),sC.set(e,r),r},__t=(t,e)=>{let r=sC.get(e);return r.add(t),r},y_t=async t=>{try{await m_t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}sC.delete(t)},sC=new WeakMap,S_t=2,E_t=1;import{aborted as v_t}from"util";var Hbe=(t,e)=>t===void 0?[]:[b_t(t,e)],b_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await v_t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw z6({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var oC=(t,...e)=>{if(yr(e[0]))return oC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=jbe(t,...e),i=T_t({...n,destination:r});return i.pipe=oC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},T_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=w_t(t,i);Bbe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Vbe(e,s,d);return await Promise.race([zbe(u),...Hbe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},w_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as C_t}from"timers/promises";import{on as R_t}from"events";import{getDefaultHighWaterMark as A_t}from"stream";var aC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return x_t(e,o),Wbe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},x_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},V6=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;I_t(e,o,t);let a=t.readableObjectMode&&!s;return Wbe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},I_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Wbe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=R_t(t,"data",{signal:e.signal,highWaterMark:Gbe,highWatermark:Gbe});return P_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},H6=A_t(!0),Gbe=H6,P_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=O_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Uf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Ob(a)}},O_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[ZO(t,r,!e),JO(t,i,!n,{})].filter(Boolean);var Ybe=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([k_t(t),d]);return}let f=b6(c,r),p=V6({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([$_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(!eC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=V6({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await sbe(a,t,r,s)},k_t=async t=>{await C_t(),t.readableFlowing===null&&t.resume()},$_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qO(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await BO(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return Kbe(sve({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},G6=async t=>{try{return await t}catch(e){return Kbe(e)}},Kbe=({bufferedData:t})=>vye(t)?new Uint8Array(t):t;import{finished as L_t}from"stream/promises";var $b=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=D_t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],L_t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||F_t(a,e,r,n)}finally{o.abort()}},D_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&M_t(t,r,n),n},M_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{U_t(e,r),n.call(t,...i)}},U_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},F_t=(t,e,r,n)=>{if(!j_t(t,e,r,n))throw t},j_t=(t,e,r,n=!0)=>r.propagating?Jbe(t)||cC(t):(r.propagating=!0,W6(r,e)===n?Jbe(t):cC(t)),W6=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",cC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Jbe=t=>t?.code==="EPIPE";var Zbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>Y6({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),Y6=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=$b(t,e,l);if(W6(l,e)){await u;return}let[d]=await Promise.all([Ybe({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 Xbe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ff([t,e].filter(Boolean)):void 0,Qbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>Y6({...q_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:B_t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),q_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}},B_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as z_t}from"events";var eTe=t=>Ig(t,"ipc"),tTe=(t,e)=>{let r=hO(t);ta({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var rTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=eTe(s),a=vc(e,"ipc"),c=vc(r,"ipc");for await(let l of C6({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ove(t,i,c),i.push(l)),o&&tTe(l,s);return i},nTe=async(t,e)=>(await Promise.allSettled([t]),e);var iTe=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=ube(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Zbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=Qbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),P=[],x=rTe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),R=V_t(m,t,S),O=H_t(h,S);try{return await Promise.race([Promise.all([{},fbe(v),Promise.all(g),w,x,UEe(t,d),...R,...O]),_,G_t(t,y),...kEe(t,s,f,y),...eEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...CEe({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=>G6(b))),G6(w),nTe(x,P),Promise.allSettled(R),Promise.allSettled(O)])}},V_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:$b(n,i,r)),H_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>eo(s,{checkOpen:!1})&&!Zs(s)).map(({type:i,value:s,stream:o=s})=>$b(o,n,e,{isSameDirection:vs.has(i),stopOnExit:i==="native"}))),G_t=async(t,{signal:e})=>{let[r]=await z_t(t,"error",{signal:e});throw r};var sTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Lb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ra();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},qg=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as W_t}from"stream";import{callbackify as Y_t}from"util";import{finished as oTe}from"stream/promises";var K6=async t=>{if(t!==void 0)try{await J6(t)}catch{}},aTe=async t=>{if(t!==void 0)try{await Z6(t)}catch{}},J6=async t=>{await oTe(t,{cleanup:!0,readable:!1,writable:!0})},Z6=async t=>{await oTe(t,{cleanup:!0,readable:!0,writable:!1})},lC=async(t,e)=>{if(await t,e)throw e},uC=(t,e,r)=>{r&&!cC(r)?t.destroy(r):e&&t.destroy()};var cTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Di.has(r),{subprocessStdout:a,waitReadableDestroy:c}=X6(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Q6(a,o),{read:f,onStdoutDataDone:p}=e3({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new W_t({read:f,destroy:Y_t(r3.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return t3({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},X6=(t,e,r)=>{let n=kg(t,e),i=Lb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Q6=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:H6},e3=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ra(),o=aC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){K_t(this,o,s)},onStdoutDataDone:s}},K_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},t3=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Z6(t),await n,await K6(i),await e,r.readable&&r.push(null)}catch(s){await K6(i),lTe(r,s)}},r3=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await qg(r,e)&&(lTe(t,n),await lC(e,n))},lTe=(t,e)=>{uC(t,t.readable,e)};import{Writable as J_t}from"stream";import{callbackify as uTe}from"util";var dTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=n3(t,r,e),o=new J_t({...i3(n,t,i),destroy:uTe(o3.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return s3(n,o),o},n3=(t,e,r)=>{let n=RO(t,e),i=Lb(r,n,"writableFinal"),s=Lb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},i3=(t,e,r)=>({write:Z_t.bind(void 0,t),final:uTe(X_t.bind(void 0,t,e,r))}),Z_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},X_t=async(t,e,r)=>{await qg(r,e)&&(t.writable&&t.end(),await e)},s3=async(t,e,r)=>{try{await J6(t),e.writable&&e.end()}catch(n){await aTe(r),fTe(e,n)}},o3=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await qg(r,e),await qg(n,e)&&(fTe(t,i),await lC(e,i))},fTe=(t,e)=>{uC(t,t.writable,e)};import{Duplex as Q_t}from"stream";import{callbackify as eyt}from"util";var pTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Di.has(r),{subprocessStdout:c,waitReadableDestroy:l}=X6(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=n3(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Q6(c,a),{read:_,onStdoutDataDone:y}=e3({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new Q_t({read:_,...i3(u,t,d),destroy:eyt(tyt.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 t3({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),s3(u,v,c),v},tyt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([r3({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),o3({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var a3=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Di.has(e),o=kg(t,r),a=aC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return ryt(a,o,t)},ryt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var hTe=(t,{encoding:e})=>{let r=sTe();t.readable=cTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=dTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=pTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=a3.bind(void 0,t,e),t[Symbol.asyncIterator]=a3.bind(void 0,t,e,{})};var mTe=(t,e)=>{for(let[r,n]of iyt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},nyt=(async()=>{})().constructor.prototype,iyt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(nyt,t)]);var gTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=ayt(t,e,r),{subprocess:f,promise:p}=lyt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=oC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),mTe(f,p),na.set(f,{options:u,fileDescriptors:d}),f},ayt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gO(t,e,r),{file:a,commandArguments:c,options:l}=DO(t,e,r),u=cyt(l),d=xbe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},cyt=({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}},lyt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=oyt(...MO(t,e,r))}catch(h){return Tbe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;syt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Dbe(c,a,l),Ube(c,r,l);let d={},f=ra();c.kill=XSe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Xbe(c,r),hTe(c,r),Ebe(c,r);let p=uyt({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}},uyt=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 iTe({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)=>Tc(g,e,w)),v=Tc(m,e,"all"),S=dyt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(S,n,e)},dyt=({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?Pb({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 ia,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):HO({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var dC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,fyt(n,t[n],i)]));return{...t,...r}},fyt=(t,e,r)=>pyt.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,pyt=new Set(["env",...MG]);var bu=(t,e,r,n)=>{let i=(o,a,c)=>bu(o,a,r,c),s=(...o)=>hyt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},hyt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,dC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=myt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?hbe(a,c,l):gTe(a,c,l,i)},myt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=xye(e)?Iye(e,r):[e,...r],[o,a,c]=sO(...s),l=dC(dC(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 _Te=({file:t,commandArguments:e})=>STe(t,e),yTe=({file:t,commandArguments:e})=>({...STe(t,e),isSync:!0}),STe=(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]=gyt(t);return{file:r,commandArguments:n}},gyt=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(_yt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},_yt=/ +/g;var ETe=(t,e,r)=>{t.sync=e(yyt,r),t.s=t.sync},vTe=({options:t})=>bTe(t),yyt=({options:t})=>({...bTe(t),isSync:!0}),bTe=t=>({options:{...Syt(t),...t}}),Syt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},TTe={preferLocal:!0};var wTe=bu(()=>({})),bar=bu(()=>({isSync:!0})),RTe=bu(_Te),Tar=bu(yTe),war=bu(LEe),Rar=bu(vTe,{},TTe,ETe),{sendMessage:Aar,getOneMessage:xar,getEachMessage:Iar,getCancelSignal:Par}=vbe();import{Transform as Eyt}from"stream";var vyt=["NETLIFY_AI_GATEWAY_KEY"];function byt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...vyt])]}function Tyt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function wyt(){let e=byt().map(r=>process.env[r]).filter(r=>!(!r||Tyt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function bs(t){if(typeof t!="string")return t;let e=wyt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(Ryt(n),"g");r=r.replace(i,"******")}),r}function Ryt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Db=class extends Eyt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=bs(i);n(null,s)}},fC=Symbol("maskedWrite");function ATe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[fC]){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[fC]=!0,process.stdout.write=r}if(!process.stderr.write[fC]){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[fC]=!0,process.stderr.write=r}}}var xTe=!1,ITe=()=>{xTe=!0},gi=()=>xTe;var Mb=null,PTe=t=>(Mb&&Mb.destroy(),Mb=new wc({totalAllowedTime:t}),Mb),OTe=()=>Mb;var wc=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&&gi())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 nO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Se.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 CTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.6",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.2","@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 Pyt=xyt(import.meta.url),Oyt=Rc.dirname(Pyt),Cyt=Iyt(import.meta.url),Bg=ve("shell"),c3=new Set,NTe={preferLocal:!0},Gn=(t,e,r)=>{let[n,i]=Nyt(e,r),s={...NTe,...i},o=wTe(t,n,s);$Te(o,s),MTe(o);let a=r?.idleTimeout;return a&&a>0&&DTe(o,a),o},kTe=(t,e)=>{let r={...NTe,...e},n=RTe(t,r);return $Te(n,r),MTe(n),e?.idleTimeout&&e.idleTimeout>0&&DTe(n,e.idleTimeout),n},Nyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},$Te=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ac.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Db).pipe(Ac.stdout),t.stderr?.pipe(new Db).pipe(Ac.stderr);return}t.stdout?.pipe(Ac.stdout),t.stderr?.pipe(Ac.stderr)},l3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ac.kill(-t.pid,e),Bg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bg.error("Error killing process:",r),!1}},LTe=t=>l3(t,"SIGKILL"),DTe=(t,e)=>{let r=null,n=()=>{Bg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),l3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing idle process ${t.pid}`),LTe(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)},MTe=t=>{c3.add(t);let e=OTe();if(e){let r=e.onTimesUp(()=>{Bg.log(`Global timer expired, killing process ${t.pid}`),l3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing process ${t.pid} after timeout`),LTe(t))},5e3)});t.on("exit",()=>{c3.delete(t),r()}),t.on("error",()=>{c3.delete(t),r()})}};function oa(t,e){if(!Ac.env.NETLIFY_LOCAL_MODE)try{let i=Cyt.resolve(CTe.name),s=Rc.dirname(i);for(;s!==Rc.dirname(s);){let o=Rc.dirname(s);if(Rc.basename(o)==="node_modules"){let a=Rc.join(o,".bin",e);if(pC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ac.env.NODE_PATH){let i=Rc.join(Ac.env.NODE_PATH,".bin",e);if(pC.existsSync(i))return i}let r=Rc.join(t,"node_modules",".bin",e);if(pC.existsSync(r))return r;let n=Rc.join(Oyt,"..","node_modules",".bin",e);if(pC.existsSync(n))return n}import _L from"process";import{fileURLToPath as vCt}from"url";import{createRequire as bCt}from"module";import yL from"path";var kyt="__netlify__getTracer",$yt="__netlify__shutdownTracers",ht=(t,e)=>globalThis[kyt]?.(t,e),UTe=async()=>globalThis[$yt]?.();function qf(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 mCt}from"timers/promises";import OEt from"process";var FTe=typeof globalThis=="object"?globalThis:global;var xc="1.9.0";var jTe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Lyt(t){var e=new Set([t]),r=new Set,n=t.match(jTe);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(jTe);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 qTe=Lyt(xc);var Dyt=xc.split(".")[0],Ub=Symbol.for("opentelemetry.js.api."+Dyt),Fb=FTe;function Tu(t,e,r,n){var i;n===void 0&&(n=!1);var s=Fb[Ub]=(i=Fb[Ub])!==null&&i!==void 0?i:{version:xc};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!==xc){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+xc);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+xc+"."),!0}function to(t){var e,r,n=(e=Fb[Ub])===null||e===void 0?void 0:e.version;if(!(!n||!qTe(n)))return(r=Fb[Ub])===null||r===void 0?void 0:r[t]}function wu(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+xc+".");var r=Fb[Ub];r&&delete r[t]}var Myt=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},Uyt=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))},BTe=(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 jb("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("verbose",this._namespace,e)},t})();function jb(t,e,r){var n=to("diag");if(n)return r.unshift(e),n[t].apply(n,Uyt([],Myt(r),!1))}var Wn;(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"})(Wn||(Wn={}));function zTe(t,e){t<Wn.NONE?t=Wn.NONE:t>Wn.ALL&&(t=Wn.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",Wn.ERROR),warn:r("warn",Wn.WARN),info:r("info",Wn.INFO),debug:r("debug",Wn.DEBUG),verbose:r("verbose",Wn.VERBOSE)}}var Fyt=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},jyt=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))},qyt="diag",Mi=(function(){function t(){function e(i){return function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];var a=to("diag");if(a)return a[i].apply(a,jyt([],Fyt(s),!1))}}var r=this,n=function(i,s){var o,a,c;if(s===void 0&&(s={logLevel:Wn.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=to("diag"),d=zTe((a=s.logLevel)!==null&&a!==void 0?a:Wn.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 Tu("diag",d,r,!0)};r.setLogger=n,r.disable=function(){wu(qyt,r)},r.createComponentLogger=function(i){return new BTe(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 Byt=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},zyt=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.")},VTe=(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=Byt(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=zyt(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 ycr=Mi.instance();function HTe(t){return t===void 0&&(t={}),new VTe(new Map(Object.entries(t)))}function hC(t){return Symbol.for(t)}var Vyt=(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})(),GTe=new Vyt;var WTe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},YTe={set:function(t,e,r){t!=null&&(t[e]=r)}};var Hyt=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},Gyt=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))},KTe=(function(){function t(){}return t.prototype.active=function(){return GTe},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,Gyt([n],Hyt(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var Wyt=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},Yyt=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))},u3="context",Kyt=new KTe,Ru=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Tu(u3,e,Mi.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,Yyt([e,r,n],Wyt(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return to(u3)||Kyt},t.prototype.disable=function(){this._getContextManager().disable(),wu(u3,Mi.instance())},t})();var mC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(mC||(mC={}));var d3="0000000000000000",f3="00000000000000000000000000000000",JTe={traceId:f3,spanId:d3,traceFlags:mC.NONE};var Au=(function(){function t(e){e===void 0&&(e=JTe),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 p3=hC("OpenTelemetry Context Key SPAN");function gC(t){return t.getValue(p3)||void 0}function ZTe(){return gC(Ru.getInstance().active())}function qb(t,e){return t.setValue(p3,e)}function XTe(t){return t.deleteValue(p3)}function QTe(t,e){return qb(t,new Au(e))}function _C(t){var e;return(e=gC(t))===null||e===void 0?void 0:e.spanContext()}var Jyt=/^([0-9a-f]{32})$/i,Zyt=/^[0-9a-f]{16}$/i;function Xyt(t){return Jyt.test(t)&&t!==f3}function Qyt(t){return Zyt.test(t)&&t!==d3}function yC(t){return Xyt(t.traceId)&&Qyt(t.spanId)}function ewe(t){return new Au(t)}var h3=Ru.getInstance(),SC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=h3.active());var i=!!r?.root;if(i)return new Au;var s=n&&_C(n);return eSt(s)&&yC(s)?new Au(s):new Au},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??h3.active(),l=this.startSpan(e,s,c),u=qb(c,l);return h3.with(u,a,void 0,l)}},t})();function eSt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var tSt=new SC,twe=(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):tSt},t})();var rwe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new SC},t})();var rSt=new rwe,m3=(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 twe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:rSt},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 xu;(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"})(xu||(xu={}));var aa;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(aa||(aa={}));var Ic=Ru.getInstance();var g3=Mi.instance();var nwe=(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 _3=hC("OpenTelemetry Baggage Key");function y3(t){return t.getValue(_3)||void 0}function iwe(){return y3(Ru.getInstance().active())}function swe(t,e){return t.setValue(_3,e)}function owe(t){return t.deleteValue(_3)}var S3="propagation",nSt=new nwe,awe=(function(){function t(){this.createBaggage=HTe,this.getBaggage=y3,this.getActiveBaggage=iwe,this.setBaggage=swe,this.deleteBaggage=owe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Tu(S3,e,Mi.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=YTe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=WTe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){wu(S3,Mi.instance())},t.prototype._getGlobalPropagator=function(){return to(S3)||nSt},t})();var Bb=awe.getInstance();var E3="trace",cwe=(function(){function t(){this._proxyTracerProvider=new m3,this.wrapSpanContext=ewe,this.isSpanContextValid=yC,this.deleteSpan=XTe,this.getSpan=gC,this.getActiveSpan=ZTe,this.getSpanContext=_C,this.setSpan=qb,this.setSpanContext=QTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Tu(E3,this._proxyTracerProvider,Mi.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return to(E3)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){wu(E3,Mi.instance()),this._proxyTracerProvider=new m3},t})();var zb=cwe.getInstance();var sSt=function(t,e){e.recordException(t),e.setStatus({code:aa.ERROR})};var Bf=(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=lwe(r,n,i),o=s.opts,a=s.ctx,c=s.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return uwe(l,o,c)})},t.prototype.withSpan=function(e,r,n,i){var s=lwe(r,n,i),o=s.opts,a=s.ctx,c=s.fn,l=this._tracer.startSpan(e,o,a);return uwe(l,o,c)},t})();function lwe(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??Ic.active(),{opts:n,ctx:i,fn:s}}function uwe(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:sSt,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)}}_W();et();var hT=class{emit(e){}enabled(){return!1}},TRe=new hT;var mT=Symbol.for("io.opentelemetry.js.api.logs"),Xg=globalThis;function wRe(t,e,r){return n=>n===t?e:r}var yW=1;var SW=class{getLogger(e,r,n){return new hT}},uN=new SW;var dN=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):TRe}};var gT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new dN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:uN}_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 fN=class t{constructor(){this._proxyLoggerProvider=new gT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Xg[mT]?this.getLoggerProvider():(Xg[mT]=wRe(yW,e,uN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Xg[mT])===null||e===void 0?void 0:e.call(Xg,yW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Xg[mT],this._proxyLoggerProvider=new gT}};var RRe=fN.getInstance();function ARe(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 xRe(t){t.forEach(e=>e.disable())}function EW(t){let e=t.tracerProvider||Or.getTracerProvider(),r=t.meterProvider||eT.getMeterProvider(),n=t.loggerProvider||RRe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return ARe(i,e,r,n),()=>{xRe(i)}}dr();var $N=Ln(DW(),1);dr();var oAe=t=>{throw TypeError(t)},jW=(t,e,r)=>e.has(t)||oAe("Cannot "+r),kN=(t,e,r)=>(jW(t,e,"read from private field"),r?r.call(t):e.get(t)),MW=(t,e,r)=>e.has(t)?oAe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),nAe=(t,e,r,n)=>(jW(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),PEt=(t,e,r)=>(jW(t,e,"access private method"),r),iAe="__netlify__getTracer",CEt="__netlify__shutdownTracers",NEt="__nfOTLPTrace",yT,ST,FW,aAe,kEt=class{constructor(){MW(this,FW),MW(this,yT),MW(this,ST),nAe(this,yT,new ha(PEt(this,FW,aAe),this)),nAe(this,ST,g3.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(kN(this,ST).debug(`export ${t.length.toString()} spans`),kN(this,yT).isCalled){e({code:Qt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(NEt,JSON.stringify($Et(t))),e({code:Qt.SUCCESS})}shutdown(){return kN(this,yT).call()}};yT=new WeakMap;ST=new WeakMap;FW=new WeakSet;aAe=function(){return kN(this,ST).debug("Shutting down"),Promise.resolve()};function $Et(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:NN(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||xu.SERVER,startTimeUnixNano:UW(e.startTime),endTimeUnixNano:UW(e.endTime),attributes:NN(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:UW(n.time),attributes:NN(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:NN(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function NN(t){return Object.keys(t).map(e=>cAe(e,t[e]))}function cAe(t,e){return{key:t,value:lAe(e)}}function lAe(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(lAe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>cAe(r,n))}}:{}}function UW(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var sAe={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"}},uAe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,iAe))return;let e=OEt.version.slice(1),r=lN({"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??[LEt()],i=new $N.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new kc});let s=t.instrumentations??[];EW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,iAe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Bf(zb.getTracer(a,c)):new Bf(zb.getTracer(sAe.name,sAe.version))}}),Object.defineProperty(globalThis,CEt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},LEt=()=>new $N.SimpleSpanProcessor(new kEt);dr();var ET=Ln(DW(),1);import*as LN from"diagnostics_channel";var dAe=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?aa.ERROR:aa.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 Bf?t:new Bf(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){LN.subscribe(t,e);let r=()=>LN.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:xu.CLIENT},Ic.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:aa.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 Tke=Ln(vke(),1);var mL=ve("tracing"),bke=8e3,gCt=5e3,kw=async(t=gCt)=>{try{await Promise.race([UTe(),mCt(t)])}catch(e){mL.warn("Failed to flush tracers on shutdown",e)}},wke=async(t,e,r)=>{if(!ht()){let n=[new ET.SimpleSpanProcessor(new w9),new ET.SimpleSpanProcessor(new Tke.OTLPTraceExporter({url:r.exporterUrl}))];await uAe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new dAe({skipHeaders:!0})]})}return r.traceparent?(Bb.setGlobalPropagator(new kc),Bb.extract(Ic.active(),{traceparent:r.traceparent,isRemote:!0})):Ic.active()};function Vt(t,e,r){return mL.log(`\u23F3 TRACE: ${e} starting...`),qf(t,e,r)}var w9=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(", ")}]`:"";mL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&mL.log(` \u274C Error: ${e.status.message}`)}};function R9(){return rt().captureLlmContentEnabled}function Rke(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function gL(t,e,r){let n={role:t,parts:[{type:"text",content:bs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function Ake(t,e,r,n){if(!t.length)return;let i=ht();if(!i)return;let s=R9(),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>bke?`${a.message.slice(0,bke)}\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":gL("assistant",p)}:{}}}).end(u)})}import{readdir as _Ct,rm as yCt}from"fs/promises";import{join as SCt}from"path";async function xke(t,e=[]){let n=(await _Ct(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>yCt(SCt(t,i),{recursive:!0,force:!0})))}var ECt=700,Ike=t=>t.mode==="create"&&(t.accountType===wl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=ECt);var TCt=yL.dirname(vCt(import.meta.url)),Pke=bCt(import.meta.url),wCt=yL.resolve(TCt,"scripts/scaffold.js"),RCt="scripts/scaffold.js",ACt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,A9=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},xCt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),ICt=t=>{let e=A9(t);return e==="node"||e.endsWith("/node")},el=t=>{if(typeof t!="string")return!1;let e=t.match(ACt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&xCt(A9(e[r]));)r+=1;if(r>=e.length||!ICt(e[r]))return!1;let n=e[r+1];return n?A9(n).includes(RCt):!1},K_=ve("create_stage"),Oke="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.",PCt=`${Oke}
|
|
581
|
+
if (condition) { yield value; }`)};import{Buffer as Umt}from"buffer";import{StringDecoder as Fmt}from"string_decoder";var ZO=(t,e,r)=>{if(r)return;if(t)return{transform:jmt.bind(void 0,new TextEncoder)};let n=new Fmt(e);return{transform:qmt.bind(void 0,n),final:Bmt.bind(void 0,n)}},jmt=function*(t,e){Umt.isBuffer(e)?yield Ec(e):typeof e=="string"?yield t.encode(e):yield e},qmt=function*(t,e){yield Pr(e)?t.write(e):e},Bmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Xve}from"util";var R6=Xve(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),XO=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Vmt}=e[r];for await(let i of n(t))yield*XO(i,e,r+1)},Qve=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zmt(r,Number(e),t)},zmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*XO(n,r,e+1)},ebe=Xve(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Vmt=function*(t){yield t};var A6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},tbe=(t,e)=>[...e.flatMap(r=>[...Uf(r,t,0)]),...Ob(t)],Uf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Gmt}=e[r];for(let i of n(t))yield*Uf(i,e,r+1)},Ob=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Hmt(r,Number(e),t)},Hmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Uf(n,r,e+1)},Gmt=function*(t){yield t};var x6=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=nbe(t,o,s),l=Mf(e),u=Mf(r),d=l?R6.bind(void 0,XO,a):A6.bind(void 0,Uf),f=l||u?R6.bind(void 0,Qve,a):A6.bind(void 0,Ob),p=l||u?ebe.bind(void 0,a):void 0;return{stream:new Wmt({writableObjectMode:n,writableHighWaterMark:rbe(n),readableObjectMode:i,readableHighWaterMark:rbe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},QO=(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=nbe(o,r,a);t=tbe(c,t)}return t},nbe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Kve(n,a)},ZO(r,o,n),JO(r,s,n,c),{transform:t,final:e},{transform:Jve(i,a)},Yve({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var ibe=(t,e)=>{for(let r of Ymt(t))Kmt(t,r,e)},Ymt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Kmt=(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 ${vu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Jmt(a,n));r.input=Eb(o)},Jmt=(t,e)=>{let r=QO(t,e,"utf8",!0);return Zmt(r),Eb(r)},Zmt=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 tgt,appendFileSync as rgt}from"fs";var eC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ig(r,n)&&!Di.has(e)&&Xmt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Qmt.has(s))||t.every(({type:i})=>vs.has(i))),Xmt=t=>t===1||t===2,Qmt=new Set(["pipe","overlapped"]),sbe=async(t,e,r,n)=>{for await(let i of t)egt(e)||abe(i,r,n)},obe=(t,e,r)=>{for(let n of t)abe(n,e,r)},egt=t=>t._readableState.pipes.length>0,abe=(t,e,r)=>{let n=hO(t);ta({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var cbe=({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)=>ngt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},ngt=({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=lve(t,s,d),p=Ec(f),{stdioItems:h,objectMode:m}=e[r],_=igt([p],h,c,n),{serializedResult:y,finalResult:v=y}=sgt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});ogt({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&&agt(y,h,i),S}catch(g){return n.error=g,S}},igt=(t,e,r,n)=>{try{return QO(t,e,r,!1)}catch(i){return n.error=i,t}},sgt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Eb(t)};let o=Tye(t,r);return n[s]?{serializedResult:o,finalResult:w6(o,!i[s],e)}:{serializedResult:o}},ogt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!eC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=w6(t,!1,o);try{obe(a,e,n)}catch(c){r.error??=c}},agt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>YO.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?rgt(n,t):(r.add(s),tgt(n,t))}};var lbe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Tc(e,r,"all")]:Array.isArray(e)?[Tc(t,r,"all"),...e]:Pr(t)&&Pr(e)?kG([t,e]):`${t}${e}`};import{once as I6}from"events";var ube=async(t,e)=>{let[r,n]=await cgt(t);return e.isForcefullyTerminated??=!1,[r,n]},cgt=async t=>{let[e,r]=await Promise.allSettled([I6(t,"spawn"),I6(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?dbe(t):r.value},dbe=async t=>{try{return await I6(t,"exit")}catch{return dbe(t)}},fbe=async t=>{let[e,r]=await t;if(!lgt(e,r)&&P6(e,r))throw new Xs;return[e,r]},lgt=(t,e)=>t===void 0&&e===void 0,P6=(t,e)=>t!==0||e!==null;var pbe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ugt(t,e,r),o=s?.code==="ETIMEDOUT",a=cve(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ugt=(t,e,r)=>t!==void 0?t:P6(e,r)?new Xs:void 0;var hbe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=fgt(t,e,r),d=mgt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},fgt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gO(t,e,r),a=pgt(r),{file:c,commandArguments:l,options:u}=DO(t,e,a);hgt(u);let d=Vve(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},pgt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,hgt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&tC("ipcInput"),t&&tC("ipc: true"),r&&tC("detached: true"),n&&tC("cancelSignal")},tC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},mgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=ggt({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}=pbe(c,r),{output:h,error:m=l}=cbe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>Tc(v,r,S)),y=Tc(lbe(h,r),r,"all");return ygt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},ggt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{ibe(s,r);let a=_gt(r);return dgt(...MO(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},_gt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:VO(e)}),ygt=({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?HO({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Pb({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 syt}from"events";import{spawn as oyt}from"child_process";import Sbe from"process";import{once as O6,on as Sgt}from"events";var mbe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Cg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:OO(t)}),Egt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Egt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{AO(e,i);let s=Eu(t,e,r),o=new AbortController;try{return await Promise.race([vgt(s,n,o),bgt(s,r,o),Tgt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),xO(e,i)}},vgt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await O6(t,"message",{signal:r});return n}for await(let[n]of Sgt(t,"message",{signal:r}))if(e(n))return n},bgt=async(t,e,{signal:r})=>{await O6(t,"disconnect",{signal:r}),tEe(e)},Tgt=async(t,e,{signal:r})=>{let[n]=await O6(t,"strict:error",{signal:r});throw TO(n,e)};import{once as _be,on as wgt}from"events";var ybe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>C6({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),C6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Cg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:OO(t)}),AO(e,s);let o=Eu(t,e,r),a=new AbortController,c={};return Rgt(t,o,a),Agt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),xgt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Rgt=async(t,e,r)=>{try{await _be(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Agt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await _be(t,"strict:error",{signal:r.signal});n.error=TO(i,e),r.abort()}catch{}},xgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of wgt(r,"message",{signal:s.signal}))gbe(o),yield c}catch{gbe(o)}finally{s.abort(),xO(e,a),n||Ng(t),i&&await t}},gbe=({error:t})=>{if(t)throw t};var Ebe=(t,{ipc:e})=>{Object.assign(t,bbe(t,!1,e))},vbe=()=>{let t=Sbe,e=!0,r=Sbe.channel!==void 0;return{...bbe(t,e,r),getCancelSignal:IEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},bbe=(t,e,r)=>({sendMessage:$O.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:mbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ybe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Igt}from"child_process";import{PassThrough as Pgt,Readable as Ogt,Writable as Cgt,Duplex as Ngt}from"stream";var Tbe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{v6(n);let a=new Igt;kgt(a,n),Object.assign(a,{readable:$gt,writable:Lgt,duplex:Dgt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Mgt(c,o,i);return{subprocess:a,promise:l}},kgt=(t,e)=>{let r=Cb(),n=Cb(),i=Cb(),s=Array.from({length:e.length-3},Cb),o=Cb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Cb=()=>{let t=new Pgt;return t.end(),t},$gt=()=>new Ogt({read(){}}),Lgt=()=>new Cgt({write(){}}),Dgt=()=>new Ngt({read(){},write(){}}),Mgt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as wbe,createWriteStream as Rbe}from"fs";import{Buffer as Ugt}from"buffer";import{Readable as Nb,Writable as Fgt,Duplex as jgt}from"stream";var xbe=(t,e)=>KO(qgt,t,e,!1),kb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${vu[t]}.`)},Abe={fileNumber:kb,generator:x6,asyncGenerator:x6,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:jgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},qgt={input:{...Abe,fileUrl:({value:t})=>({stream:wbe(t)}),filePath:({value:{file:t}})=>({stream:wbe(t)}),webStream:({value:t})=>({stream:Nb.fromWeb(t)}),iterable:({value:t})=>({stream:Nb.from(t)}),asyncIterable:({value:t})=>({stream:Nb.from(t)}),string:({value:t})=>({stream:Nb.from(t)}),uint8Array:({value:t})=>({stream:Nb.from(Ugt.from(t))})},output:{...Abe,fileUrl:({value:t})=>({stream:Rbe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Rbe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Fgt.fromWeb(t)}),iterable:kb,asyncIterable:kb,string:kb,uint8Array:kb}};import{on as Bgt,once as Ibe}from"events";import{PassThrough as zgt,getDefaultHighWaterMark as Vgt}from"stream";import{finished as Cbe}from"stream/promises";function Ff(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)k6(i);let e=t.some(({readableObjectMode:i})=>i),r=Hgt(t,e),n=new N6({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Hgt=(t,e)=>{if(t.length===0)return Vgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},N6=class extends zgt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(k6(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Ggt(this,this.#e,this.#s);let r=Kgt({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(k6(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)}},Ggt=async(t,e,r)=>{rC(t,Pbe);let n=new AbortController;try{await Promise.race([Wgt(t,n),Ygt(t,e,r,n)])}finally{n.abort(),rC(t,-Pbe)}},Wgt=async(t,{signal:e})=>{try{await Cbe(t,{signal:e,cleanup:!0})}catch(r){throw Nbe(t,r),r}},Ygt=async(t,e,r,{signal:n})=>{for await(let[i]of Bgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},k6=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Kgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{rC(t,Obe);let a=new AbortController;try{await Promise.race([Jgt(s,e,a),Zgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Xgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),rC(t,-Obe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?$6(t):Qgt(t))},Jgt=async(t,e,{signal:r})=>{try{await t,r.aborted||$6(e)}catch(n){r.aborted||Nbe(e,n)}},Zgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Cbe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;kbe(o)?i.add(e):$be(t,o)}},Xgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Ibe(t,i,{signal:s}),!t.readable)return Ibe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Qgt=t=>{t.writable&&t.end()},Nbe=(t,e)=>{kbe(e)?$6(t):$be(t,e)},kbe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",$6=t=>{(t.readable||t.writable)&&t.destroy()},$be=(t,e)=>{t.destroyed||(t.once("error",e_t),t.destroy(e))},e_t=()=>{},rC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Pbe=2,Obe=1;import{finished as Lbe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),t_t(t,e),r_t(t,e)},t_t=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await Lbe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}L6(e)}},L6=t=>{t.writable&&t.end()},r_t=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await Lbe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}D6(t)}},D6=t=>{t.readable&&t.destroy()};var Dbe=(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)))n_t(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!vs.has(c)))s_t({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]:Ff(s);jg(o,i)}},n_t=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=i_t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},i_t=["stdin","stdout","stderr"],s_t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;o_t(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},o_t=(t,{signal:e})=>{Zs(t)&&Lf(t,a_t,e)},a_t=2;import{addAbortListener as u_t}from"events";var jf=[];jf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&jf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&jf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var nC=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",M6=Symbol.for("signal-exit emitter"),U6=globalThis,c_t=Object.defineProperty.bind(Object),F6=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(U6[M6])return U6[M6];c_t(U6,M6,{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}},iC=class{},l_t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),j6=class extends iC{onExit(){return()=>{}}load(){}unload(){}},q6=class extends iC{#e=B6.platform==="win32"?"SIGINT":"SIGHUP";#r=new F6;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of jf)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(!nC(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 jf)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,jf.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 nC(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"&&nC(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)}},B6=globalThis.process,{onExit:Mbe,load:Oir,unload:Cir}=l_t(nC(B6)?new q6(B6):new j6);var Ube=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Mbe(()=>{t.kill()});u_t(n,()=>{i()})};var jbe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=mO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=d_t(r,n,i),{sourceStream:d,sourceError:f}=p_t(t,l),{options:p,fileDescriptors:h}=na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},d_t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=f_t(t,e,...r),a=RO(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},f_t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Fbe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||CG(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]=sO(r,...n);return{destination:e(Fbe)(i,s,o),pipeOptions:o}}if(na.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Fbe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),p_t=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var Bbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=h_t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw z6({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},h_t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return D6(t),n;if(e!==void 0)return L6(r),e},z6=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:qbe,escapedCommand:qbe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),qbe="source.pipe(destination)";var zbe=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 m_t}from"stream/promises";var Vbe=(t,e,r)=>{let n=sC.has(e)?__t(t,e):g_t(t,e);return Lf(t,S_t,r.signal),Lf(e,E_t,r.signal),y_t(e),n},g_t=(t,e)=>{let r=Ff([t]);return jg(r,e),sC.set(e,r),r},__t=(t,e)=>{let r=sC.get(e);return r.add(t),r},y_t=async t=>{try{await m_t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}sC.delete(t)},sC=new WeakMap,S_t=2,E_t=1;import{aborted as v_t}from"util";var Hbe=(t,e)=>t===void 0?[]:[b_t(t,e)],b_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await v_t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw z6({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var oC=(t,...e)=>{if(yr(e[0]))return oC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=jbe(t,...e),i=T_t({...n,destination:r});return i.pipe=oC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},T_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=w_t(t,i);Bbe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Vbe(e,s,d);return await Promise.race([zbe(u),...Hbe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},w_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as C_t}from"timers/promises";import{on as R_t}from"events";import{getDefaultHighWaterMark as A_t}from"stream";var aC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return x_t(e,o),Wbe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},x_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},V6=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;I_t(e,o,t);let a=t.readableObjectMode&&!s;return Wbe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},I_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Wbe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=R_t(t,"data",{signal:e.signal,highWaterMark:Gbe,highWatermark:Gbe});return P_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},H6=A_t(!0),Gbe=H6,P_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=O_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Uf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Ob(a)}},O_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[ZO(t,r,!e),JO(t,i,!n,{})].filter(Boolean);var Ybe=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([k_t(t),d]);return}let f=b6(c,r),p=V6({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([$_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(!eC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=V6({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await sbe(a,t,r,s)},k_t=async t=>{await C_t(),t.readableFlowing===null&&t.resume()},$_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qO(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await BO(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return Kbe(sve({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},G6=async t=>{try{return await t}catch(e){return Kbe(e)}},Kbe=({bufferedData:t})=>vye(t)?new Uint8Array(t):t;import{finished as L_t}from"stream/promises";var $b=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=D_t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],L_t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||F_t(a,e,r,n)}finally{o.abort()}},D_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&M_t(t,r,n),n},M_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{U_t(e,r),n.call(t,...i)}},U_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},F_t=(t,e,r,n)=>{if(!j_t(t,e,r,n))throw t},j_t=(t,e,r,n=!0)=>r.propagating?Jbe(t)||cC(t):(r.propagating=!0,W6(r,e)===n?Jbe(t):cC(t)),W6=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",cC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Jbe=t=>t?.code==="EPIPE";var Zbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>Y6({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),Y6=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=$b(t,e,l);if(W6(l,e)){await u;return}let[d]=await Promise.all([Ybe({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 Xbe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ff([t,e].filter(Boolean)):void 0,Qbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>Y6({...q_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:B_t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),q_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}},B_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as z_t}from"events";var eTe=t=>Ig(t,"ipc"),tTe=(t,e)=>{let r=hO(t);ta({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var rTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=eTe(s),a=vc(e,"ipc"),c=vc(r,"ipc");for await(let l of C6({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ove(t,i,c),i.push(l)),o&&tTe(l,s);return i},nTe=async(t,e)=>(await Promise.allSettled([t]),e);var iTe=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=ube(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Zbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=Qbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),P=[],x=rTe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),R=V_t(m,t,S),O=H_t(h,S);try{return await Promise.race([Promise.all([{},fbe(v),Promise.all(g),w,x,UEe(t,d),...R,...O]),_,G_t(t,y),...kEe(t,s,f,y),...eEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...CEe({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=>G6(b))),G6(w),nTe(x,P),Promise.allSettled(R),Promise.allSettled(O)])}},V_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:$b(n,i,r)),H_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>eo(s,{checkOpen:!1})&&!Zs(s)).map(({type:i,value:s,stream:o=s})=>$b(o,n,e,{isSameDirection:vs.has(i),stopOnExit:i==="native"}))),G_t=async(t,{signal:e})=>{let[r]=await z_t(t,"error",{signal:e});throw r};var sTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Lb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ra();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},qg=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as W_t}from"stream";import{callbackify as Y_t}from"util";import{finished as oTe}from"stream/promises";var K6=async t=>{if(t!==void 0)try{await J6(t)}catch{}},aTe=async t=>{if(t!==void 0)try{await Z6(t)}catch{}},J6=async t=>{await oTe(t,{cleanup:!0,readable:!1,writable:!0})},Z6=async t=>{await oTe(t,{cleanup:!0,readable:!0,writable:!1})},lC=async(t,e)=>{if(await t,e)throw e},uC=(t,e,r)=>{r&&!cC(r)?t.destroy(r):e&&t.destroy()};var cTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Di.has(r),{subprocessStdout:a,waitReadableDestroy:c}=X6(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Q6(a,o),{read:f,onStdoutDataDone:p}=e3({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new W_t({read:f,destroy:Y_t(r3.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return t3({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},X6=(t,e,r)=>{let n=kg(t,e),i=Lb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Q6=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:H6},e3=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ra(),o=aC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){K_t(this,o,s)},onStdoutDataDone:s}},K_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},t3=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Z6(t),await n,await K6(i),await e,r.readable&&r.push(null)}catch(s){await K6(i),lTe(r,s)}},r3=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await qg(r,e)&&(lTe(t,n),await lC(e,n))},lTe=(t,e)=>{uC(t,t.readable,e)};import{Writable as J_t}from"stream";import{callbackify as uTe}from"util";var dTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=n3(t,r,e),o=new J_t({...i3(n,t,i),destroy:uTe(o3.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return s3(n,o),o},n3=(t,e,r)=>{let n=RO(t,e),i=Lb(r,n,"writableFinal"),s=Lb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},i3=(t,e,r)=>({write:Z_t.bind(void 0,t),final:uTe(X_t.bind(void 0,t,e,r))}),Z_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},X_t=async(t,e,r)=>{await qg(r,e)&&(t.writable&&t.end(),await e)},s3=async(t,e,r)=>{try{await J6(t),e.writable&&e.end()}catch(n){await aTe(r),fTe(e,n)}},o3=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await qg(r,e),await qg(n,e)&&(fTe(t,i),await lC(e,i))},fTe=(t,e)=>{uC(t,t.writable,e)};import{Duplex as Q_t}from"stream";import{callbackify as eyt}from"util";var pTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Di.has(r),{subprocessStdout:c,waitReadableDestroy:l}=X6(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=n3(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Q6(c,a),{read:_,onStdoutDataDone:y}=e3({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new Q_t({read:_,...i3(u,t,d),destroy:eyt(tyt.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 t3({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),s3(u,v,c),v},tyt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([r3({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),o3({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var a3=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Di.has(e),o=kg(t,r),a=aC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return ryt(a,o,t)},ryt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var hTe=(t,{encoding:e})=>{let r=sTe();t.readable=cTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=dTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=pTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=a3.bind(void 0,t,e),t[Symbol.asyncIterator]=a3.bind(void 0,t,e,{})};var mTe=(t,e)=>{for(let[r,n]of iyt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},nyt=(async()=>{})().constructor.prototype,iyt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(nyt,t)]);var gTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=ayt(t,e,r),{subprocess:f,promise:p}=lyt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=oC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),mTe(f,p),na.set(f,{options:u,fileDescriptors:d}),f},ayt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gO(t,e,r),{file:a,commandArguments:c,options:l}=DO(t,e,r),u=cyt(l),d=xbe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},cyt=({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}},lyt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=oyt(...MO(t,e,r))}catch(h){return Tbe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;syt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Dbe(c,a,l),Ube(c,r,l);let d={},f=ra();c.kill=XSe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Xbe(c,r),hTe(c,r),Ebe(c,r);let p=uyt({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}},uyt=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 iTe({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)=>Tc(g,e,w)),v=Tc(m,e,"all"),S=dyt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(S,n,e)},dyt=({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?Pb({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 ia,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):HO({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var dC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,fyt(n,t[n],i)]));return{...t,...r}},fyt=(t,e,r)=>pyt.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,pyt=new Set(["env",...MG]);var bu=(t,e,r,n)=>{let i=(o,a,c)=>bu(o,a,r,c),s=(...o)=>hyt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},hyt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,dC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=myt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?hbe(a,c,l):gTe(a,c,l,i)},myt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=xye(e)?Iye(e,r):[e,...r],[o,a,c]=sO(...s),l=dC(dC(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 _Te=({file:t,commandArguments:e})=>STe(t,e),yTe=({file:t,commandArguments:e})=>({...STe(t,e),isSync:!0}),STe=(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]=gyt(t);return{file:r,commandArguments:n}},gyt=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(_yt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},_yt=/ +/g;var ETe=(t,e,r)=>{t.sync=e(yyt,r),t.s=t.sync},vTe=({options:t})=>bTe(t),yyt=({options:t})=>({...bTe(t),isSync:!0}),bTe=t=>({options:{...Syt(t),...t}}),Syt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},TTe={preferLocal:!0};var wTe=bu(()=>({})),bar=bu(()=>({isSync:!0})),RTe=bu(_Te),Tar=bu(yTe),war=bu(LEe),Rar=bu(vTe,{},TTe,ETe),{sendMessage:Aar,getOneMessage:xar,getEachMessage:Iar,getCancelSignal:Par}=vbe();import{Transform as Eyt}from"stream";var vyt=["NETLIFY_AI_GATEWAY_KEY"];function byt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...vyt])]}function Tyt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function wyt(){let e=byt().map(r=>process.env[r]).filter(r=>!(!r||Tyt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function bs(t){if(typeof t!="string")return t;let e=wyt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(Ryt(n),"g");r=r.replace(i,"******")}),r}function Ryt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Db=class extends Eyt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=bs(i);n(null,s)}},fC=Symbol("maskedWrite");function ATe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[fC]){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[fC]=!0,process.stdout.write=r}if(!process.stderr.write[fC]){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[fC]=!0,process.stderr.write=r}}}var xTe=!1,ITe=()=>{xTe=!0},gi=()=>xTe;var Mb=null,PTe=t=>(Mb&&Mb.destroy(),Mb=new wc({totalAllowedTime:t}),Mb),OTe=()=>Mb;var wc=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&&gi())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 nO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Se.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 CTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.7",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.2","@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 Pyt=xyt(import.meta.url),Oyt=Rc.dirname(Pyt),Cyt=Iyt(import.meta.url),Bg=ve("shell"),c3=new Set,NTe={preferLocal:!0},Gn=(t,e,r)=>{let[n,i]=Nyt(e,r),s={...NTe,...i},o=wTe(t,n,s);$Te(o,s),MTe(o);let a=r?.idleTimeout;return a&&a>0&&DTe(o,a),o},kTe=(t,e)=>{let r={...NTe,...e},n=RTe(t,r);return $Te(n,r),MTe(n),e?.idleTimeout&&e.idleTimeout>0&&DTe(n,e.idleTimeout),n},Nyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},$Te=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ac.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Db).pipe(Ac.stdout),t.stderr?.pipe(new Db).pipe(Ac.stderr);return}t.stdout?.pipe(Ac.stdout),t.stderr?.pipe(Ac.stderr)},l3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ac.kill(-t.pid,e),Bg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bg.error("Error killing process:",r),!1}},LTe=t=>l3(t,"SIGKILL"),DTe=(t,e)=>{let r=null,n=()=>{Bg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),l3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing idle process ${t.pid}`),LTe(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)},MTe=t=>{c3.add(t);let e=OTe();if(e){let r=e.onTimesUp(()=>{Bg.log(`Global timer expired, killing process ${t.pid}`),l3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing process ${t.pid} after timeout`),LTe(t))},5e3)});t.on("exit",()=>{c3.delete(t),r()}),t.on("error",()=>{c3.delete(t),r()})}};function oa(t,e){if(!Ac.env.NETLIFY_LOCAL_MODE)try{let i=Cyt.resolve(CTe.name),s=Rc.dirname(i);for(;s!==Rc.dirname(s);){let o=Rc.dirname(s);if(Rc.basename(o)==="node_modules"){let a=Rc.join(o,".bin",e);if(pC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ac.env.NODE_PATH){let i=Rc.join(Ac.env.NODE_PATH,".bin",e);if(pC.existsSync(i))return i}let r=Rc.join(t,"node_modules",".bin",e);if(pC.existsSync(r))return r;let n=Rc.join(Oyt,"..","node_modules",".bin",e);if(pC.existsSync(n))return n}import _L from"process";import{fileURLToPath as vCt}from"url";import{createRequire as bCt}from"module";import yL from"path";var kyt="__netlify__getTracer",$yt="__netlify__shutdownTracers",ht=(t,e)=>globalThis[kyt]?.(t,e),UTe=async()=>globalThis[$yt]?.();function qf(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 mCt}from"timers/promises";import OEt from"process";var FTe=typeof globalThis=="object"?globalThis:global;var xc="1.9.0";var jTe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Lyt(t){var e=new Set([t]),r=new Set,n=t.match(jTe);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(jTe);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 qTe=Lyt(xc);var Dyt=xc.split(".")[0],Ub=Symbol.for("opentelemetry.js.api."+Dyt),Fb=FTe;function Tu(t,e,r,n){var i;n===void 0&&(n=!1);var s=Fb[Ub]=(i=Fb[Ub])!==null&&i!==void 0?i:{version:xc};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!==xc){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+xc);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+xc+"."),!0}function to(t){var e,r,n=(e=Fb[Ub])===null||e===void 0?void 0:e.version;if(!(!n||!qTe(n)))return(r=Fb[Ub])===null||r===void 0?void 0:r[t]}function wu(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+xc+".");var r=Fb[Ub];r&&delete r[t]}var Myt=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},Uyt=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))},BTe=(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 jb("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("verbose",this._namespace,e)},t})();function jb(t,e,r){var n=to("diag");if(n)return r.unshift(e),n[t].apply(n,Uyt([],Myt(r),!1))}var Wn;(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"})(Wn||(Wn={}));function zTe(t,e){t<Wn.NONE?t=Wn.NONE:t>Wn.ALL&&(t=Wn.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",Wn.ERROR),warn:r("warn",Wn.WARN),info:r("info",Wn.INFO),debug:r("debug",Wn.DEBUG),verbose:r("verbose",Wn.VERBOSE)}}var Fyt=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},jyt=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))},qyt="diag",Mi=(function(){function t(){function e(i){return function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];var a=to("diag");if(a)return a[i].apply(a,jyt([],Fyt(s),!1))}}var r=this,n=function(i,s){var o,a,c;if(s===void 0&&(s={logLevel:Wn.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=to("diag"),d=zTe((a=s.logLevel)!==null&&a!==void 0?a:Wn.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 Tu("diag",d,r,!0)};r.setLogger=n,r.disable=function(){wu(qyt,r)},r.createComponentLogger=function(i){return new BTe(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 Byt=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},zyt=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.")},VTe=(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=Byt(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=zyt(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 ycr=Mi.instance();function HTe(t){return t===void 0&&(t={}),new VTe(new Map(Object.entries(t)))}function hC(t){return Symbol.for(t)}var Vyt=(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})(),GTe=new Vyt;var WTe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},YTe={set:function(t,e,r){t!=null&&(t[e]=r)}};var Hyt=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},Gyt=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))},KTe=(function(){function t(){}return t.prototype.active=function(){return GTe},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,Gyt([n],Hyt(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var Wyt=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},Yyt=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))},u3="context",Kyt=new KTe,Ru=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Tu(u3,e,Mi.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,Yyt([e,r,n],Wyt(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return to(u3)||Kyt},t.prototype.disable=function(){this._getContextManager().disable(),wu(u3,Mi.instance())},t})();var mC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(mC||(mC={}));var d3="0000000000000000",f3="00000000000000000000000000000000",JTe={traceId:f3,spanId:d3,traceFlags:mC.NONE};var Au=(function(){function t(e){e===void 0&&(e=JTe),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 p3=hC("OpenTelemetry Context Key SPAN");function gC(t){return t.getValue(p3)||void 0}function ZTe(){return gC(Ru.getInstance().active())}function qb(t,e){return t.setValue(p3,e)}function XTe(t){return t.deleteValue(p3)}function QTe(t,e){return qb(t,new Au(e))}function _C(t){var e;return(e=gC(t))===null||e===void 0?void 0:e.spanContext()}var Jyt=/^([0-9a-f]{32})$/i,Zyt=/^[0-9a-f]{16}$/i;function Xyt(t){return Jyt.test(t)&&t!==f3}function Qyt(t){return Zyt.test(t)&&t!==d3}function yC(t){return Xyt(t.traceId)&&Qyt(t.spanId)}function ewe(t){return new Au(t)}var h3=Ru.getInstance(),SC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=h3.active());var i=!!r?.root;if(i)return new Au;var s=n&&_C(n);return eSt(s)&&yC(s)?new Au(s):new Au},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??h3.active(),l=this.startSpan(e,s,c),u=qb(c,l);return h3.with(u,a,void 0,l)}},t})();function eSt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var tSt=new SC,twe=(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):tSt},t})();var rwe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new SC},t})();var rSt=new rwe,m3=(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 twe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:rSt},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 xu;(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"})(xu||(xu={}));var aa;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(aa||(aa={}));var Ic=Ru.getInstance();var g3=Mi.instance();var nwe=(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 _3=hC("OpenTelemetry Baggage Key");function y3(t){return t.getValue(_3)||void 0}function iwe(){return y3(Ru.getInstance().active())}function swe(t,e){return t.setValue(_3,e)}function owe(t){return t.deleteValue(_3)}var S3="propagation",nSt=new nwe,awe=(function(){function t(){this.createBaggage=HTe,this.getBaggage=y3,this.getActiveBaggage=iwe,this.setBaggage=swe,this.deleteBaggage=owe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Tu(S3,e,Mi.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=YTe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=WTe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){wu(S3,Mi.instance())},t.prototype._getGlobalPropagator=function(){return to(S3)||nSt},t})();var Bb=awe.getInstance();var E3="trace",cwe=(function(){function t(){this._proxyTracerProvider=new m3,this.wrapSpanContext=ewe,this.isSpanContextValid=yC,this.deleteSpan=XTe,this.getSpan=gC,this.getActiveSpan=ZTe,this.getSpanContext=_C,this.setSpan=qb,this.setSpanContext=QTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Tu(E3,this._proxyTracerProvider,Mi.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return to(E3)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){wu(E3,Mi.instance()),this._proxyTracerProvider=new m3},t})();var zb=cwe.getInstance();var sSt=function(t,e){e.recordException(t),e.setStatus({code:aa.ERROR})};var Bf=(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=lwe(r,n,i),o=s.opts,a=s.ctx,c=s.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return uwe(l,o,c)})},t.prototype.withSpan=function(e,r,n,i){var s=lwe(r,n,i),o=s.opts,a=s.ctx,c=s.fn,l=this._tracer.startSpan(e,o,a);return uwe(l,o,c)},t})();function lwe(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??Ic.active(),{opts:n,ctx:i,fn:s}}function uwe(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:sSt,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)}}_W();et();var hT=class{emit(e){}enabled(){return!1}},TRe=new hT;var mT=Symbol.for("io.opentelemetry.js.api.logs"),Xg=globalThis;function wRe(t,e,r){return n=>n===t?e:r}var yW=1;var SW=class{getLogger(e,r,n){return new hT}},uN=new SW;var dN=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):TRe}};var gT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new dN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:uN}_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 fN=class t{constructor(){this._proxyLoggerProvider=new gT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Xg[mT]?this.getLoggerProvider():(Xg[mT]=wRe(yW,e,uN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Xg[mT])===null||e===void 0?void 0:e.call(Xg,yW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Xg[mT],this._proxyLoggerProvider=new gT}};var RRe=fN.getInstance();function ARe(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 xRe(t){t.forEach(e=>e.disable())}function EW(t){let e=t.tracerProvider||Or.getTracerProvider(),r=t.meterProvider||eT.getMeterProvider(),n=t.loggerProvider||RRe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return ARe(i,e,r,n),()=>{xRe(i)}}dr();var $N=Ln(DW(),1);dr();var oAe=t=>{throw TypeError(t)},jW=(t,e,r)=>e.has(t)||oAe("Cannot "+r),kN=(t,e,r)=>(jW(t,e,"read from private field"),r?r.call(t):e.get(t)),MW=(t,e,r)=>e.has(t)?oAe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),nAe=(t,e,r,n)=>(jW(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),PEt=(t,e,r)=>(jW(t,e,"access private method"),r),iAe="__netlify__getTracer",CEt="__netlify__shutdownTracers",NEt="__nfOTLPTrace",yT,ST,FW,aAe,kEt=class{constructor(){MW(this,FW),MW(this,yT),MW(this,ST),nAe(this,yT,new ha(PEt(this,FW,aAe),this)),nAe(this,ST,g3.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(kN(this,ST).debug(`export ${t.length.toString()} spans`),kN(this,yT).isCalled){e({code:Qt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(NEt,JSON.stringify($Et(t))),e({code:Qt.SUCCESS})}shutdown(){return kN(this,yT).call()}};yT=new WeakMap;ST=new WeakMap;FW=new WeakSet;aAe=function(){return kN(this,ST).debug("Shutting down"),Promise.resolve()};function $Et(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:NN(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||xu.SERVER,startTimeUnixNano:UW(e.startTime),endTimeUnixNano:UW(e.endTime),attributes:NN(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:UW(n.time),attributes:NN(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:NN(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function NN(t){return Object.keys(t).map(e=>cAe(e,t[e]))}function cAe(t,e){return{key:t,value:lAe(e)}}function lAe(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(lAe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>cAe(r,n))}}:{}}function UW(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var sAe={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"}},uAe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,iAe))return;let e=OEt.version.slice(1),r=lN({"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??[LEt()],i=new $N.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new kc});let s=t.instrumentations??[];EW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,iAe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Bf(zb.getTracer(a,c)):new Bf(zb.getTracer(sAe.name,sAe.version))}}),Object.defineProperty(globalThis,CEt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},LEt=()=>new $N.SimpleSpanProcessor(new kEt);dr();var ET=Ln(DW(),1);import*as LN from"diagnostics_channel";var dAe=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?aa.ERROR:aa.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 Bf?t:new Bf(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){LN.subscribe(t,e);let r=()=>LN.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:xu.CLIENT},Ic.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:aa.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 Tke=Ln(vke(),1);var mL=ve("tracing"),bke=8e3,gCt=5e3,kw=async(t=gCt)=>{try{await Promise.race([UTe(),mCt(t)])}catch(e){mL.warn("Failed to flush tracers on shutdown",e)}},wke=async(t,e,r)=>{if(!ht()){let n=[new ET.SimpleSpanProcessor(new w9),new ET.SimpleSpanProcessor(new Tke.OTLPTraceExporter({url:r.exporterUrl}))];await uAe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new dAe({skipHeaders:!0})]})}return r.traceparent?(Bb.setGlobalPropagator(new kc),Bb.extract(Ic.active(),{traceparent:r.traceparent,isRemote:!0})):Ic.active()};function Vt(t,e,r){return mL.log(`\u23F3 TRACE: ${e} starting...`),qf(t,e,r)}var w9=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(", ")}]`:"";mL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&mL.log(` \u274C Error: ${e.status.message}`)}};function R9(){return rt().captureLlmContentEnabled}function Rke(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function gL(t,e,r){let n={role:t,parts:[{type:"text",content:bs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function Ake(t,e,r,n){if(!t.length)return;let i=ht();if(!i)return;let s=R9(),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>bke?`${a.message.slice(0,bke)}\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":gL("assistant",p)}:{}}}).end(u)})}import{readdir as _Ct,rm as yCt}from"fs/promises";import{join as SCt}from"path";async function xke(t,e=[]){let n=(await _Ct(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>yCt(SCt(t,i),{recursive:!0,force:!0})))}var ECt=700,Ike=t=>t.mode==="create"&&(t.accountType===wl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=ECt);var TCt=yL.dirname(vCt(import.meta.url)),Pke=bCt(import.meta.url),wCt=yL.resolve(TCt,"scripts/scaffold.js"),RCt="scripts/scaffold.js",ACt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,A9=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},xCt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),ICt=t=>{let e=A9(t);return e==="node"||e.endsWith("/node")},el=t=>{if(typeof t!="string")return!1;let e=t.match(ACt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&xCt(A9(e[r]));)r+=1;if(r>=e.length||!ICt(e[r]))return!1;let n=e[r+1];return n?A9(n).includes(RCt):!1},K_=ve("create_stage"),Oke="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.",PCt=`${Oke}
|
|
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.`,OCt=`${Oke}
|
|
584
584
|
|
|
@@ -876,12 +876,12 @@ You're an AI agent designed to assist with tasks related to a Netlify project. P
|
|
|
876
876
|
</request>
|
|
877
877
|
|
|
878
878
|
Use the following file for the complete context of the ask, the environment, and what's available. ${u} You MUST READ ALL OF IT. Make sure to read it first. Never cite or paraphrase private context.
|
|
879
|
-
`),S};var C$t=ve("prompt"),qLe=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:s})=>{let o=await jLe({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:s});return process.env.AGENT_RUNNER_DEBUG&&C$t.log("Contextful Prompt:",o),{prompt:o}};var BLe=t=>{let e=t.previousSession;return e?e.agent!==t.runner?{viable:!1,outcome:"agent_switch"}:e.nativeSessionId?{viable:!0,outcome:"resumed"}:{viable:!1,outcome:"missing_native_session_id"}:{viable:!1,outcome:"not_eligible"}};import{randomUUID as N$t}from"crypto";var k$t=ve("interactions"),zLe=async(t,e,r)=>{let n=N$t();return await Ti(t.id,t.sessionId,{state:"await_input",interactions:{[n]:{type:"question",status:"pending",payload:e.questions,nativeToolId:e.toolUseId}},steps:[{id:n,refId:n,category:ne.Question}],...r?.nativeSessionId?{native_session_id:r.nativeSessionId}:{},...r?.nativeSessionS3Key?{native_session_s3_key:r.nativeSessionS3Key}:{}}),n},VLe=async t=>{let e;try{e=await rD(t.id,t.sessionId)}catch(o){return k$t.warn("Failed to fetch session for the full answer fold",{error:o?.message}),Se.inc("inference.answer_fetch_failed",1),null}let r=e?.interactions;if(!r)return[];let n=[],i=new Set,s=(o,a)=>{!a||i.has(o)||(i.add(o),a.type==="question"&&a.status==="answered"&&n.push({refId:o,questions:a.payload??[],responses:a.response??[]}))};for(let o of e?.steps??[])o?.refId&&s(o.refId,r[o.refId]);for(let[o,a]of Object.entries(r))s(o,a);return n},HLe=()=>({counted:!1}),GLe=(t,e)=>{let r=e.map(
|
|
880
|
-
A: ${
|
|
879
|
+
`),S};var C$t=ve("prompt"),qLe=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:s})=>{let o=await jLe({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:s});return process.env.AGENT_RUNNER_DEBUG&&C$t.log("Contextful Prompt:",o),{prompt:o}};var BLe=t=>{let e=t.previousSession;return e?e.agent!==t.runner?{viable:!1,outcome:"agent_switch"}:e.nativeSessionId?{viable:!0,outcome:"resumed"}:{viable:!1,outcome:"missing_native_session_id"}:{viable:!1,outcome:"not_eligible"}};import{randomUUID as N$t}from"crypto";var k$t=ve("interactions"),zLe=async(t,e,r)=>{let n=N$t();return await Ti(t.id,t.sessionId,{state:"await_input",interactions:{[n]:{type:"question",status:"pending",payload:e.questions,nativeToolId:e.toolUseId}},steps:[{id:n,refId:n,category:ne.Question}],...r?.nativeSessionId?{native_session_id:r.nativeSessionId}:{},...r?.nativeSessionS3Key?{native_session_s3_key:r.nativeSessionS3Key}:{}}),n},VLe=async t=>{let e;try{e=await rD(t.id,t.sessionId)}catch(o){return k$t.warn("Failed to fetch session for the full answer fold",{error:o?.message}),Se.inc("inference.answer_fetch_failed",1),null}let r=e?.interactions;if(!r)return[];let n=[],i=new Set,s=(o,a)=>{!a||i.has(o)||(i.add(o),a.type==="question"&&(a.status==="answered"||a.status==="skipped")&&n.push({refId:o,questions:a.payload??[],responses:a.response??[]}))};for(let o of e?.steps??[])o?.refId&&s(o.refId,r[o.refId]);for(let[o,a]of Object.entries(r))s(o,a);return n},HLe=()=>({counted:!1}),GLe=(t,e)=>{let r=!1,n=e.map(s=>s.questions.map((o,a)=>{let c=s.responses[a];c==null&&(r=!0);let l=c==null?"(skipped)":Array.isArray(c)?c.join(", "):c;return`Q: ${o.question}
|
|
880
|
+
A: ${l}`}).join(`
|
|
881
881
|
|
|
882
882
|
`)).join(`
|
|
883
883
|
|
|
884
|
-
`);return[t,"You previously paused to ask the user for clarification. Here are their answers:",
|
|
884
|
+
`);return[t,"You previously paused to ask the user for clarification. Here are their answers:",n,`Continue with the task using these answers.${r?' A "(skipped)" answer means the user chose not to answer; proceed with your best judgment there.':""} Do not ask these questions again.`].filter(Boolean).join(`
|
|
885
885
|
|
|
886
886
|
`)};import _l from"fs/promises";import HFe from"os";import yl from"path";import{rm as _X}from"fs/promises";import{resolve as $$t}from"path";var L$t=".netlify/cache/",Qp=function({cacheDir:t=L$t,cwd:e="."}={}){return $$t(e,t)};import{promises as jFt}from"fs";import{basename as SFe,dirname as EFe,join as qFt}from"path";import rFt from"process";import nFt from"events";import Tt from"path";import iFt from"os";async function h0(t,e,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:n=!0,signal:i}={}){return new Promise((s,o)=>{if(t[Symbol.iterator]===void 0&&t[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`);if(typeof e!="function")throw new TypeError("Mapper function is required");if(!(Number.isSafeInteger(r)&&r>=1||r===Number.POSITIVE_INFINITY))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let a=[],c=[],l=new Map,u=!1,d=!1,f=!1,p=0,h=0,m=t[Symbol.iterator]===void 0?t[Symbol.asyncIterator]():t[Symbol.iterator](),_=()=>{S(i.reason)},y=()=>{i?.removeEventListener("abort",_)},v=w=>{s(w),y()},S=w=>{u=!0,d=!0,o(w),y()};i&&(i.aborted&&S(i.reason),i.addEventListener("abort",_,{once:!0}));let g=async()=>{if(d)return;let w=await m.next(),P=h;if(h++,w.done){if(f=!0,p===0&&!d){if(!n&&c.length>0){S(new AggregateError(c));return}if(d=!0,l.size===0){v(a);return}let x=[];for(let[R,O]of a.entries())l.get(R)!==WLe&&x.push(O);v(x)}return}p++,(async()=>{try{let x=await w.value;if(d)return;let R=await e(x,P);R===WLe&&l.set(P,R),a[P]=R,p--,await g()}catch(x){if(n)S(x);else{c.push(x),p--;try{await g()}catch(R){S(R)}}}})()};(async()=>{for(let w=0;w<r;w++){try{await g()}catch(P){S(P);break}if(f||u)break}})()})}var WLe=Symbol("skip");import th from"path";import JNr,{constants as WJ}from"fs";import YJ from"fs/promises";var FJ=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},jJ=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},YLe=t=>globalThis.DOMException===void 0?new jJ(t):new DOMException(t),KLe=t=>{let e=t.reason===void 0?YLe("This operation was aborted."):t.reason;return e instanceof Error?e:YLe(e)};function qJ(t,e){let{milliseconds:r,fallback:n,message:i,customTimers:s={setTimeout,clearTimeout}}=e,o,a,l=new Promise((u,d)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:p}=e;p.aborted&&d(KLe(p)),a=()=>{d(KLe(p))},p.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let f=new FJ;o=s.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(p){d(p)}return}typeof t.cancel=="function"&&t.cancel(),i===!1?u():i instanceof Error?d(i):(f.message=i??`Promise timed out after ${r} milliseconds`,d(f))},r),(async()=>{try{u(await t)}catch(p){d(p)}})()}).finally(()=>{l.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return l.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},l}var D$t=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function M$t(t,e,r){let n,i=new Promise((s,o)=>{if(r={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:l,removeListener:u}=D$t(t),d=(...p)=>{let h=r.multiArgs?p:p[0];r.filter&&!r.filter(h)||(c.push(h),r.count===c.length&&(n(),s(c)))},f=p=>{n(),o(p)};n=()=>{for(let p of a)u(p,d);for(let p of r.rejectionEvents)u(p,f)};for(let p of a)l(p,d);for(let p of r.rejectionEvents)l(p,f);r.signal&&r.signal.addEventListener("abort",()=>{f(r.signal.reason)},{once:!0}),r.resolveImmediately&&s(c)});if(i.cancel=n,typeof r.timeout=="number"){let s=qJ(i,{milliseconds:r.timeout});return s.cancel=n,s}return i}function uD(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=M$t(t,e,r),i=n.then(s=>s[0]);return i.cancel=n.cancel,i}var ti=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CopyFileError"}};var Ao=Ln(oDe(),1);import{promisify as m0}from"util";var zNr=m0(Ao.default.stat),Y$t=m0(Ao.default.lstat),K$t=m0(Ao.default.utimes),J$t=m0(Ao.default.chmod),Z$t=m0(Ao.default.mkdir),VNr=Ao.default.closeSync.bind(Ao.default),aDe=Ao.default.createWriteStream.bind(Ao.default);async function cDe(t,e){let r=Ao.default.createReadStream(t,e);try{await uD(r,["readable","end"])}catch(n){throw new ti(`Cannot read from \`${t}\`: ${n.message}`,{cause:n})}return r}var GJ=t=>Y$t(t).catch(e=>{throw new ti(`lstat \`${t}\` failed: ${e.message}`,{cause:e})}),lDe=(t,e,r)=>K$t(t,e,r).catch(n=>{throw new ti(`utimes \`${t}\` failed: ${n.message}`,{cause:n})}),uDe=(t,e)=>J$t(t,e).catch(r=>{throw new ti(`chmod \`${t}\` failed: ${r.message}`,{cause:r})});var dDe=(t,e)=>Z$t(t,{...e,recursive:!0}).catch(r=>{throw new ti(`Cannot create directory \`${t}\`: ${r.message}`,{cause:r})});var Q$t=(t,e,r)=>({sourcePath:th.resolve(t,e),destinationPath:th.resolve(t,r)}),eLt=(t,e)=>{if(!t.isFile())throw Object.assign(new ti(`EISDIR: illegal operation on a directory '${e}'`),{errno:-21,code:"EISDIR",source:e})};async function fDe(t,e,r={}){if(!t||!e)throw new ti("`source` and `destination` required");r.cwd&&({sourcePath:t,destinationPath:e}=Q$t(r.cwd,t,e)),r={overwrite:!0,...r};let n=await GJ(t),{size:i}=n;eLt(n,t);let s=th.dirname(e);if(th.parse(s).root===s||await dDe(th.dirname(e),{mode:r.directoryMode}),typeof r.onProgress=="function"){let a=await cDe(t),c=aDe(e,{flags:r.overwrite?"w":"wx"}),l=p=>{r.onProgress({sourcePath:th.resolve(t),destinationPath:th.resolve(e),size:i,writtenBytes:p,percent:p===i?1:p/i})},u=-1;a.on("data",()=>{let p=c.bytesWritten,h=p===i?1:p/i;(h===1||h-u>=.01)&&(u=h,l(p))});let d;a.once("error",p=>{d=new ti(`Cannot read from \`${t}\`: ${p.message}`,{cause:p})});let f=!1;try{let p=uD(c,"close");a.pipe(c),await p,l(i),f=!0}catch(p){throw new ti(`Cannot write to \`${e}\`: ${p.message}`,{cause:p})}if(d)throw d;if(f){let p=await GJ(t);return Promise.all([lDe(e,p.atime,p.mtime).catch(h=>{if(h.code!=="EPERM")throw h}),uDe(e,p.mode)])}}else{let a=r.overwrite?WJ.COPYFILE_FICLONE:WJ.COPYFILE_FICLONE|WJ.COPYFILE_EXCL;try{await YJ.copyFile(t,e,a),await Promise.all([YJ.utimes(e,n.atime,n.mtime).catch(c=>{if(c.code!=="EPERM")throw c}),YJ.chmod(e,n.mode)])}catch(c){throw new ti(c.message,{cause:c})}}}async function KJ(t,e,r){return(await h0(t,(i,s)=>Promise.all([e(i,s),i]),r)).filter(i=>!!i[0]).map(i=>i[1])}import RUe from"process";import KUt from"fs";import cS from"path";import{on as tLt,once as rLt}from"events";import{PassThrough as nLt}from"stream";import{finished as mDe}from"stream/promises";function QJ(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)ZJ(i);let e=t.some(({readableObjectMode:i})=>i),r=iLt(t,e),n=new JJ({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&yDe(n),n}var iLt=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},JJ=class extends nLt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){ZJ(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=sLt(this,this.#e),cLt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return ZJ(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},sLt=async(t,e)=>{mD(t,pDe);let r=new AbortController;try{await Promise.race([oLt(t,r),aLt(t,e,r)])}finally{r.abort(),mD(t,-pDe)}},oLt=async(t,{signal:e})=>{await mDe(t,{signal:e,cleanup:!0})},aLt=async(t,e,{signal:r})=>{for await(let[n]of tLt(t,"unpipe",{signal:r}))e.has(n)&&n.emit(_De)},ZJ=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},cLt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s})=>{mD(t,hDe);let o=new AbortController;try{await Promise.race([lLt(s,e),uLt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:o}),dLt({stream:e,streams:r,ended:n,aborted:i,controller:o})])}finally{o.abort(),mD(t,-hDe)}r.size===n.size+i.size&&(n.size===0&&i.size>0?XJ(t):yDe(t))},gDe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",lLt=async(t,e)=>{try{await t,XJ(e)}catch(r){gDe(r)?XJ(e):SDe(e,r)}},uLt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await mDe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;gDe(o)?i.add(e):SDe(t,o)}},dLt=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await rLt(t,_De,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},_De=Symbol("unpipe"),yDe=t=>{t.writable&&t.end()},XJ=t=>{(t.readable||t.writable)&&t.destroy()},SDe=(t,e)=>{t.destroyed||(t.once("error",fLt),t.destroy(e))},fLt=()=>{},mD=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},pDe=2,hDe=1;var lS=Ln(b0(),1);import EUt from"fs";import vUt from"fs/promises";async function U7(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await vUt[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function F7(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return EUt[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var x$r=U7.bind(void 0,"stat","isFile"),oUe=U7.bind(void 0,"stat","isDirectory"),I$r=U7.bind(void 0,"lstat","isSymbolicLink"),P$r=F7.bind(void 0,"statSync","isFile"),aUe=F7.bind(void 0,"statSync","isDirectory"),O$r=F7.bind(void 0,"lstatSync","isSymbolicLink");var W7=Ln(b0(),1),gUe=Ln(G7(),1);import BUt from"process";import zUt from"fs";import VUt from"fs/promises";import aS from"path";function oS(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var w0=t=>t[0]==="!";var HUt=["**/node_modules","**/flow-typed","**/coverage","**/.git"],_Ue={absolute:!0,dot:!0},yUe="**/.gitignore",GUt=(t,e)=>w0(t)?"!"+aS.posix.join(e,t.slice(1)):aS.posix.join(e,t),WUt=(t,e)=>{let r=oS(aS.relative(e,aS.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>GUt(n,r))},YUt=(t,e)=>{if(e=oS(e),aS.isAbsolute(t)){if(oS(t).startsWith(e))return aS.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},SUe=(t,e)=>{let r=t.flatMap(i=>WUt(i,e)),n=(0,gUe.default)().add(r);return i=>(i=mi(i),i=YUt(i,e),i?n.ignores(oS(i)):!1)},EUe=(t={})=>({cwd:mi(t.cwd)??BUt.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...HUt]}),vUe=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:s}=EUe(e),o=await(0,W7.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:s,..._Ue}),a=await Promise.all(o.map(async c=>({filePath:c,content:await VUt.readFile(c,"utf8")})));return SUe(a,r)},bUe=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:s}=EUe(e),a=W7.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:s,..._Ue}).map(c=>({filePath:c,content:zUt.readFileSync(c,"utf8")}));return SUe(a,r)};var JUt=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},AUe=(t,e)=>{let r=w0(t)?t.slice(1):t;return cS.isAbsolute(r)?r:cS.join(e,r)},xUe=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>cS.posix.join(t,`**/${cS.extname(i)?i:`${i}${n}`}`)):[cS.posix.join(t,`**${n?`/*${n}`:""}`)]},TUe=async(t,{cwd:e=RUe.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async s=>await oUe(AUe(s,e))?xUe({directoryPath:s,files:r,extensions:n}):s))).flat(),wUe=(t,{cwd:e=RUe.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>aUe(AUe(i,e))?xUe({directoryPath:i,files:r,extensions:n}):i),Y7=t=>(t=[...new Set([t].flat())],JUt(t),t),ZUt=t=>{if(!t)return;let e;try{e=KUt.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},IUe=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:mi(t.cwd)},ZUt(t.cwd),t),PUe=t=>async(e,r)=>t(Y7(e),IUe(r)),WD=t=>(e,r)=>t(Y7(e),IUe(r)),OUe=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?Y7(e):[];return r&&n.push(yUe),n},XUt=async t=>{let e=OUe(t);return NUe(e.length>0&&await vUe(e,t))},CUe=t=>{let e=OUe(t);return NUe(e.length>0&&bUe(e,t))},NUe=t=>{let e=new Set;return r=>{let n=cS.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},kUe=(t,e)=>t.flat().filter(r=>e(r)),$Ue=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(s=>w0(s));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let s of r)s.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},LUe=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),DUe=async(t,e)=>{let r=$Ue(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let s=LUe(i,n);return Promise.all(r.map(async o=>{let{patterns:a,options:c}=o;return[a,c.ignore]=await Promise.all([TUe(a,s),TUe(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},K7=(t,e)=>{let r=$Ue(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let s=LUe(i,n);return r.map(o=>{let{patterns:a,options:c}=o;return a=wUe(a,s),c.ignore=wUe(c.ignore,{cwd:n}),{patterns:a,options:c}})},Z$r=PUe(async(t,e)=>{let[r,n]=await Promise.all([DUe(t,e),XUt(e)]),i=await Promise.all(r.map(s=>(0,lS.default)(s.patterns,s.options)));return kUe(i,n)}),MUe=WD((t,e)=>{let r=K7(t,e),n=CUe(e),i=r.map(s=>lS.default.sync(s.patterns,s.options));return kUe(i,n)}),X$r=WD((t,e)=>{let r=K7(t,e),n=CUe(e),i=r.map(o=>lS.default.stream(o.patterns,o.options));return QJ(i).filter(o=>n(o))}),sh=WD((t,e)=>t.some(r=>lS.default.isDynamicPattern(r,e))),Q$r=PUe(DUe),eLr=WD(K7),{convertPathToPattern:tLr}=lS.default;var FUe=Ln(vZ(),1);var xd=class extends Error{constructor(e,{cause:r}={}){super(e,{cause:r}),Object.assign(this,r),this.name="CpyError"}};import KD from"path";import UUe from"fs";var QUt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],eFt=new RegExp(QUt.join("|"));function tFt(t){return eFt.test(t)}function YD(t){return!tFt(t)}var R0=class{constructor(e,r,n){this.path=e,this.originalPath=e,this.destination=r,this.options=n,this.isDirectory=!1,!sh(e)&&UUe.existsSync(e)&&UUe.lstatSync(e).isDirectory()&&(this.path=[e,"**"].join("/"),this.isDirectory=!0)}get name(){return KD.basename(this.originalPath)}get normalizedPath(){let e=this.originalPath.split("/"),r=e.findIndex(i=>i?sh(i):!1),n=e.slice(0,r).join("/");return n?KD.isAbsolute(n)?n:KD.join(this.options.cwd,n):this.destination}hasMagic(){return sh(this.options.flat?this.path:this.originalPath)}getMatches(){let e=MUe(this.path,{...this.options,dot:!0,absolute:!0,onlyFiles:!0});return this.options.ignoreJunk&&(e=e.filter(r=>YD(KD.basename(r)))),e}};var sFt={ignoreJunk:!0,flat:!1,cwd:rFt.cwd()},J7=class{constructor(e,r,n){this.path=e.split("/").join(Tt.sep),this.relativePath=r.split("/").join(Tt.sep),this.pattern=n,Object.freeze(this)}get name(){return Tt.basename(this.path)}get nameWithoutExtension(){return Tt.basename(this.path,Tt.extname(this.path))}get extension(){return Tt.extname(this.path).slice(1)}},oFt=t=>t.flatMap(e=>FUe.default.braces(e,{expand:!0,nodupes:!0})),aFt=({entry:t,destination:e,options:r})=>t.pattern.hasMagic()?r.flat?Tt.isAbsolute(e)?Tt.join(e,t.name):Tt.join(r.cwd,e,t.name):Tt.join(e,Tt.relative(t.pattern.normalizedPath,t.path)):Tt.isAbsolute(e)?Tt.join(e,t.name):t.pattern.isDirectory&&Tt.relative(r.cwd,t.path).startsWith("..")?Tt.join(r.cwd,e,Tt.basename(t.pattern.originalPath),Tt.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&t.path===t.relativePath?Tt.join(r.cwd,e,Tt.basename(t.pattern.originalPath),Tt.relative(t.pattern.originalPath,t.path)):!t.pattern.isDirectory&&r.flat?Tt.join(r.cwd,e,Tt.basename(t.pattern.originalPath)):Tt.join(r.cwd,e,Tt.relative(r.cwd,t.path)),cFt=(t,e)=>{let r=Tt.dirname(t);if(typeof e=="string")return Tt.join(r,e);if(typeof e=="function"){let n=Tt.basename(t);return Tt.join(r,e(n))}return t};function Z7(t,e,{concurrency:r=iFt.availableParallelism(),...n}={}){let i=new Map,s=new nFt;n={...sFt,...n};let o=(async()=>{let a=[],c=0,l=0,u=oFt([t??[]].flat()).map(h=>h.replaceAll("\\","/")),d=u.filter(h=>!h.startsWith("!")),f=u.filter(h=>h.startsWith("!"));if(d.length===0||!e)throw new xd("`source` and `destination` required");u=u.map(h=>new R0(h,e,{...n,ignore:f}));for(let h of u){let m=[];try{m=h.getMatches()}catch(_){throw new xd(`Cannot glob \`${h.originalPath}\`: ${_.message}`,{cause:_})}if(m.length===0&&!sh(h.originalPath)&&!sh(f))throw new xd(`Cannot copy \`${h.originalPath}\`: the file doesn't exist`);a=[...a,...m.map(_=>new J7(_,Tt.relative(n.cwd,_),h))]}n.filter!==void 0&&(a=await KJ(a,n.filter,{concurrency:1024})),a.length===0&&s.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0});let p=h=>{let m=i.get(h.sourcePath)||{writtenBytes:0,percent:0};(m.writtenBytes!==h.writtenBytes||m.percent!==h.percent)&&(l-=m.writtenBytes,l+=h.writtenBytes,h.percent===1&&m.percent!==1&&c++,i.set(h.sourcePath,{writtenBytes:h.writtenBytes,percent:h.percent}),s.emit("progress",{totalFiles:a.length,percent:c/a.length,completedFiles:c,completedSize:l,sourcePath:h.sourcePath,destinationPath:h.destinationPath}))};return h0(a,async h=>{let m=cFt(aFt({entry:h,destination:e,options:n}),n.rename);try{await fDe(h.path,m,{...n,onProgress:p})}catch(_){throw new xd(`Cannot copy from \`${h.relativePath}\` to \`${m}\`: ${_.message}`,{cause:_})}return m},{concurrency:r})})();return o.on=(...a)=>(s.on(...a),o),o}import iFe from"process";import OFt from"fs";import fS from"path";import{on as lFt,once as uFt}from"events";import{PassThrough as dFt}from"stream";import{finished as BUe}from"stream/promises";function tX(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Q7(i);let e=t.some(({readableObjectMode:i})=>i),r=fFt(t,e),n=new X7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return t.length===0&&HUe(n),n}var fFt=(t,e)=>{if(t.length===0)return 16384;let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},X7=class extends dFt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;add(e){Q7(e),!this.#e.has(e)&&(this.#e.add(e),this.#n??=pFt(this,this.#e),gFt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n}),e.pipe(this,{end:!1}))}remove(e){return Q7(e),this.#e.has(e)?(e.unpipe(this),!0):!1}},pFt=async(t,e)=>{JD(t,jUe);let r=new AbortController;try{await Promise.race([hFt(t,r),mFt(t,e,r)])}finally{r.abort(),JD(t,-jUe)}},hFt=async(t,{signal:e})=>{await BUe(t,{signal:e,cleanup:!0})},mFt=async(t,e,{signal:r})=>{for await(let[n]of lFt(t,"unpipe",{signal:r}))e.has(n)&&n.emit(VUe)},Q7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},gFt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s})=>{JD(t,qUe);let o=new AbortController;try{await Promise.race([_Ft(s,e),yFt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:o}),SFt({stream:e,streams:r,ended:n,aborted:i,controller:o})])}finally{o.abort(),JD(t,-qUe)}r.size===n.size+i.size&&(n.size===0&&i.size>0?eX(t):HUe(t))},zUe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_Ft=async(t,e)=>{try{await t,eX(e)}catch(r){zUe(r)?eX(e):GUe(e,r)}},yFt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await BUe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;zUe(o)?i.add(e):GUe(t,o)}},SFt=async({stream:t,streams:e,ended:r,aborted:n,controller:{signal:i}})=>{await uFt(t,VUe,{signal:i}),e.delete(t),r.delete(t),n.delete(t)},VUe=Symbol("unpipe"),HUe=t=>{t.writable&&t.end()},eX=t=>{(t.readable||t.writable)&&t.destroy()},GUe=(t,e)=>{t.destroyed||(t.once("error",EFt),t.destroy(e))},EFt=()=>{},JD=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},jUe=2,qUe=1;var pS=Ln(b0(),1);import vFt from"fs";import bFt from"fs/promises";async function rX(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await bFt[t](r))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function nX(t,e,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return vFt[t](r)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var xLr=rX.bind(void 0,"stat","isFile"),WUe=rX.bind(void 0,"stat","isDirectory"),ILr=rX.bind(void 0,"lstat","isSymbolicLink"),PLr=nX.bind(void 0,"statSync","isFile"),YUe=nX.bind(void 0,"statSync","isDirectory"),OLr=nX.bind(void 0,"lstatSync","isSymbolicLink");var iX=Ln(b0(),1),KUe=Ln(G7(),1);import TFt from"process";import wFt from"fs";import RFt from"fs/promises";import dS from"path";function uS(t){return t.startsWith("\\\\?\\")?t:t.replace(/\\/g,"/")}var A0=t=>t[0]==="!";var AFt=["**/node_modules","**/flow-typed","**/coverage","**/.git"],JUe={absolute:!0,dot:!0},ZUe="**/.gitignore",xFt=(t,e)=>A0(t)?"!"+dS.posix.join(e,t.slice(1)):dS.posix.join(e,t),IFt=(t,e)=>{let r=uS(dS.relative(e,dS.dirname(t.filePath)));return t.content.split(/\r?\n/).filter(n=>n&&!n.startsWith("#")).map(n=>xFt(n,r))},PFt=(t,e)=>{if(e=uS(e),dS.isAbsolute(t)){if(uS(t).startsWith(e))return dS.relative(e,t);throw new Error(`Path ${t} is not in cwd ${e}`)}return t},XUe=(t,e)=>{let r=t.flatMap(i=>IFt(i,e)),n=(0,KUe.default)().add(r);return i=>(i=mi(i),i=PFt(i,e),i?n.ignores(uS(i)):!1)},QUe=(t={})=>({cwd:mi(t.cwd)??TFt.cwd(),suppressErrors:!!t.suppressErrors,deep:typeof t.deep=="number"?t.deep:Number.POSITIVE_INFINITY,ignore:[...t.ignore??[],...AFt]}),eFe=async(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:s}=QUe(e),o=await(0,iX.default)(t,{cwd:r,suppressErrors:n,deep:i,ignore:s,...JUe}),a=await Promise.all(o.map(async c=>({filePath:c,content:await RFt.readFile(c,"utf8")})));return XUe(a,r)},tFe=(t,e)=>{let{cwd:r,suppressErrors:n,deep:i,ignore:s}=QUe(e),a=iX.default.sync(t,{cwd:r,suppressErrors:n,deep:i,ignore:s,...JUe}).map(c=>({filePath:c,content:wFt.readFileSync(c,"utf8")}));return XUe(a,r)};var CFt=t=>{if(t.some(e=>typeof e!="string"))throw new TypeError("Patterns must be a string or an array of strings")},sFe=(t,e)=>{let r=A0(t)?t.slice(1):t;return fS.isAbsolute(r)?r:fS.join(e,r)},oFe=({directoryPath:t,files:e,extensions:r})=>{let n=r?.length>0?`.${r.length>1?`{${r.join(",")}}`:r[0]}`:"";return e?e.map(i=>fS.posix.join(t,`**/${fS.extname(i)?i:`${i}${n}`}`)):[fS.posix.join(t,`**${n?`/*${n}`:""}`)]},rFe=async(t,{cwd:e=iFe.cwd(),files:r,extensions:n}={})=>(await Promise.all(t.map(async s=>await WUe(sFe(s,e))?oFe({directoryPath:s,files:r,extensions:n}):s))).flat(),nFe=(t,{cwd:e=iFe.cwd(),files:r,extensions:n}={})=>t.flatMap(i=>YUe(sFe(i,e))?oFe({directoryPath:i,files:r,extensions:n}):i),sX=t=>(t=[...new Set([t].flat())],CFt(t),t),NFt=t=>{if(!t)return;let e;try{e=OFt.statSync(t)}catch{return}if(!e.isDirectory())throw new Error("The `cwd` option must be a path to a directory")},aFe=(t={})=>(t={...t,ignore:t.ignore??[],expandDirectories:t.expandDirectories??!0,cwd:mi(t.cwd)},NFt(t.cwd),t),cFe=t=>async(e,r)=>t(sX(e),aFe(r)),ZD=t=>(e,r)=>t(sX(e),aFe(r)),lFe=t=>{let{ignoreFiles:e,gitignore:r}=t,n=e?sX(e):[];return r&&n.push(ZUe),n},kFt=async t=>{let e=lFe(t);return dFe(e.length>0&&await eFe(e,t))},uFe=t=>{let e=lFe(t);return dFe(e.length>0&&tFe(e,t))},dFe=t=>{let e=new Set;return r=>{let n=fS.normalize(r.path??r);return e.has(n)||t&&t(n)?!1:(e.add(n),!0)}},fFe=(t,e)=>t.flat().filter(r=>e(r)),pFe=(t,e)=>{let r=[];for(;t.length>0;){let n=t.findIndex(s=>A0(s));if(n===-1){r.push({patterns:t,options:e});break}let i=t[n].slice(1);for(let s of r)s.options.ignore.push(i);n!==0&&r.push({patterns:t.slice(0,n),options:{...e,ignore:[...e.ignore,i]}}),t=t.slice(n+1)}return r},hFe=(t,e)=>({...e?{cwd:e}:{},...Array.isArray(t)?{files:t}:t}),mFe=async(t,e)=>{let r=pFe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let s=hFe(i,n);return Promise.all(r.map(async o=>{let{patterns:a,options:c}=o;return[a,c.ignore]=await Promise.all([rFe(a,s),rFe(c.ignore,{cwd:n})]),{patterns:a,options:c}}))},oX=(t,e)=>{let r=pFe(t,e),{cwd:n,expandDirectories:i}=e;if(!i)return r;let s=hFe(i,n);return r.map(o=>{let{patterns:a,options:c}=o;return a=nFe(a,s),c.ignore=nFe(c.ignore,{cwd:n}),{patterns:a,options:c}})},gFe=cFe(async(t,e)=>{let[r,n]=await Promise.all([mFe(t,e),kFt(e)]),i=await Promise.all(r.map(s=>(0,pS.default)(s.patterns,s.options)));return fFe(i,n)}),JLr=ZD((t,e)=>{let r=oX(t,e),n=uFe(e),i=r.map(s=>pS.default.sync(s.patterns,s.options));return fFe(i,n)}),ZLr=ZD((t,e)=>{let r=oX(t,e),n=uFe(e),i=r.map(o=>pS.default.stream(o.patterns,o.options));return tX(i).filter(o=>n(o))}),XLr=ZD((t,e)=>t.some(r=>pS.default.isDynamicPattern(r,e))),QLr=cFe(mFe),eDr=ZD(oX),{convertPathToPattern:tDr}=pS.default;import LFt from"process";import x0 from"path";import lDr,{promises as XD}from"fs";import iDr,{promises as $Ft}from"fs";async function _Fe(t){try{return await $Ft.access(t),!0}catch{return!1}}var DFt=(t,e,r)=>(e=x0.resolve(t,e),r=x0.resolve(t,r),{sourcePath:e,destinationPath:r}),MFt=(t,e,r="Path")=>{if(!t||!e)throw new TypeError(`\`source${r}\` and \`destination${r}\` required`)},UFt=(t,e)=>{if(x0.dirname(t)!==x0.dirname(e))throw new Error("`source` and `destination` must be in the same directory")},FFt=async(t,e,{overwrite:r=!0,cwd:n=LFt.cwd(),directoryMode:i,validateDirectory:s=!1}={})=>{if(n&&({sourcePath:t,destinationPath:e}=DFt(n,t,e)),s&&UFt(t,e),!r&&await _Fe(e))throw new Error(`The destination file exists: ${e}`);await XD.mkdir(x0.dirname(e),{recursive:!0,mode:i});try{await XD.rename(t,e)}catch(o){if(o.code==="EXDEV")await XD.copyFile(t,e),await XD.unlink(t);else throw o}};async function yFe(t,e,r){return MFt(t,e),FFt(t,e,r)}var aX=async function(t,e,r=!1){if(r)return yFe(t,e,{overwrite:!1});let{srcGlob:n,dest:i,...s}=await vFe(t,EFe(e));if(n&&i)return Z7(n,i,{...s,overwrite:!1})},I0=async function(t){let{srcGlob:e,isDir:r,dest:n,...i}=await vFe(t,"");return e!==void 0&&!await BFt(e,r,i)},BFt=async function(t,e,r){return e?(await gFe(t,r)).filter(s=>YD(SFe(s))).length===0:!1},vFe=async function(t,e){let r=await zFt(t);if(r===void 0)return{srcGlob:void 0,isDir:!1,cwd:""};let n=r.isDirectory(),i=SFe(t),s=EFe(t),o={srcGlob:i,dest:e,isDir:n,cwd:s,dot:!0};return n?{...o,srcGlob:`${i}/**`,dest:qFt(e,i)}:o},zFt=async t=>{try{return await jFt.stat(t)}catch{return}};import{join as Ujt}from"path";import{stat as VFt,lstat as bFe,readdir as HFt,realpath as GFt}from"fs/promises";import{Readable as WFt}from"stream";import{resolve as TFe,relative as YFt,join as KFt,sep as JFt}from"path";var Qi={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},cX={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:Qi.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(cX);var xFe="READDIRP_RECURSIVE_ERROR",ZFt=new Set(["ENOENT","EPERM","EACCES","ELOOP",xFe]),wFe=[Qi.DIR_TYPE,Qi.EVERYTHING_TYPE,Qi.FILE_DIR_TYPE,Qi.FILE_TYPE],XFt=new Set([Qi.DIR_TYPE,Qi.EVERYTHING_TYPE,Qi.FILE_DIR_TYPE]),QFt=new Set([Qi.EVERYTHING_TYPE,Qi.FILE_DIR_TYPE,Qi.FILE_TYPE]),ejt=t=>ZFt.has(t.code),tjt=process.platform==="win32",RFe=t=>!0,AFe=t=>{if(t===void 0)return RFe;if(typeof t=="function")return t;if(typeof t=="string"){let e=t.trim();return r=>r.basename===e}if(Array.isArray(t)){let e=t.map(r=>r.trim());return r=>e.some(n=>r.basename===n)}return RFe},lX=class extends WFt{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let r={...cX,...e},{root:n,type:i}=r;this._fileFilter=AFe(r.fileFilter),this._directoryFilter=AFe(r.directoryFilter);let s=r.lstat?bFe:VFt;tjt?this._stat=o=>s(o,{bigint:!0}):this._stat=s,this._maxDepth=r.depth??cX.depth,this._wantsDir=i?XFt.has(i):!1,this._wantsFile=i?QFt.has(i):!1,this._wantsEverything=i===Qi.EVERYTHING_TYPE,this._root=TFe(n),this._isDirent=!r.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let r=this.parent,n=r&&r.files;if(n&&n.length>0){let{path:i,depth:s}=r,o=n.splice(0,e).map(c=>this._formatEntry(c,i)),a=await Promise.all(o);for(let c of a){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(s<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,s+1)),this._wantsDir&&(this.push(c),e--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let i=this.parents.pop();if(!i){this.push(null);break}if(this.parent=await i,this.destroyed)return}}}catch(r){this.destroy(r)}finally{this.reading=!1}}}async _exploreDir(e,r){let n;try{n=await HFt(e,this._rdOptions)}catch(i){this._onError(i)}return{files:n,depth:r,path:e}}async _formatEntry(e,r){let n,i=this._isDirent?e.name:e;try{let s=TFe(KFt(r,i));n={path:YFt(this._root,s),fullPath:s,basename:i},n[this._statsProp]=this._isDirent?e:await this._stat(s)}catch(s){this._onError(s);return}return n}_onError(e){ejt(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let r=e[this._statsProp];if(r.isFile())return"file";if(r.isDirectory())return"directory";if(r&&r.isSymbolicLink()){let n=e.fullPath;try{let i=await GFt(n),s=await bFe(i);if(s.isFile())return"file";if(s.isDirectory()){let o=i.length;if(n.startsWith(i)&&n.substr(o,1)===JFt){let a=new Error(`Circular symlink detected: "${n}" points to "${i}"`);return a.code=xFe,this._onError(a)}return"directory"}}catch(i){return this._onError(i),""}}}_includeAsFile(e){let r=e&&e[this._statsProp];return r&&this._wantsEverything&&!r.isDirectory()}};function rjt(t,e={}){let r=e.entryType||e.type;if(r==="both"&&(r=Qi.FILE_DIR_TYPE),r&&(e.type=r),t){if(typeof t!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(r&&!wFe.includes(r))throw new Error(`readdirp: Invalid type passed. Use one of ${wFe.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new lX(e)}function IFe(t,e={}){return new Promise((r,n)=>{let i=[];rjt(t,e).on("data",s=>i.push(s)).on("end",()=>r(i)).on("error",s=>n(s))})}import{mkdir as mjt,readFile as LFe,rm as gjt,writeFile as _jt}from"fs/promises";import{existsSync as DFe}from"fs";import{dirname as yjt}from"path";var PFe=t=>{if(!(!Number.isInteger(t)||t<1))return Date.now()+t*1e3},OFe=t=>t!==void 0&&Date.now()>t;import{createHash as djt}from"crypto";import{createReadStream as fjt}from"fs";import sjt from"process";import ojt from"path";import NDr,{promises as CFe}from"fs";import{fileURLToPath as ajt}from"url";var uX=class{value;next;constructor(e){this.value=e}},P0=class{#e;#r;#t;constructor(){this.clear()}enqueue(e){let r=new uX(e);this.#e?(this.#r.next=r,this.#r=r):(this.#e=r,this.#r=r),this.#t++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#t--,this.#e||(this.#r=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#r=void 0,this.#t=0}get size(){return this.#t}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}};function QD(t){if(!((Number.isInteger(t)||t===Number.POSITIVE_INFINITY)&&t>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new P0,r=0,n=()=>{r--,e.size>0&&e.dequeue()()},i=async(a,c,l)=>{r++;let u=(async()=>a(...l))();c(u);try{await u}catch{}n()},s=(a,c,l)=>{e.enqueue(i.bind(void 0,a,c,l)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.dequeue()()))()},o=(a,...c)=>new Promise(l=>{s(a,l,c)});return Object.defineProperties(o,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}var eM=class extends Error{constructor(e){super(),this.value=e}},njt=async(t,e)=>e(await t),ijt=async t=>{let e=await Promise.all(t);if(e[1]===!0)throw new eM(e[0]);return!1};async function dX(t,e,{concurrency:r=Number.POSITIVE_INFINITY,preserveOrder:n=!0}={}){let i=QD(r),s=[...t].map(a=>[a,i(njt,a,e)]),o=QD(n?1:Number.POSITIVE_INFINITY);try{await Promise.all(s.map(a=>o(ijt,a)))}catch(a){if(a instanceof eM)return a.value;throw a}}var NFe={directory:"isDirectory",file:"isFile"};function cjt(t){if(!Object.hasOwnProperty.call(NFe,t))throw new Error(`Invalid type specified: ${t}`)}var ljt=(t,e)=>e[NFe[t]](),ujt=t=>t instanceof URL?ajt(t):t;async function kFe(t,{cwd:e=sjt.cwd(),type:r="file",allowSymlinks:n=!0,concurrency:i,preserveOrder:s}={}){cjt(r),e=ujt(e);let o=n?CFe.stat:CFe.lstat;return dX(t,async a=>{try{let c=await o(ojt.resolve(e,a));return ljt(r,c)}catch{return!1}},{concurrency:i,preserveOrder:s})}var pjt="sha1",$Fe=async function(t,e){if(e||t.length===0)return;let r=await kFe(t);return r===void 0?void 0:await hjt(r)},hjt=async function(t){let e=fjt(t,"utf8"),r=djt(pjt,{encoding:"hex"});return e.pipe(r),await Dg(r)};var MFe=async function({cachePath:t,move:e,ttl:r,digests:n}){let i=tM(t),s=PFe(r),o=await $Fe(n,e),c=`${JSON.stringify({expires:s,hash:o},null,2)}
|
|
887
887
|
`,l=await Sjt({hash:o,manifestPath:i,manifestString:c});return{manifestInfo:{manifestPath:i,manifestString:c},identical:l}},Sjt=async function({hash:t,manifestPath:e,manifestString:r}){return t===void 0||!DFe(e)?!1:await LFe(e,"utf8")===r},UFe=async function({manifestPath:t,manifestString:e}){await mjt(yjt(t),{recursive:!0}),await _jt(t,e)},FFe=async function(t){let e=tM(t);await gjt(e,{force:!0,recursive:!0,maxRetries:3})},tM=function(t){return`${t}${qFe}`},jFe=function(t){return t.endsWith(qFe)},qFe=".netlify.cache.json",fX=async function(t){let e=tM(t);if(!DFe(e))return!1;let{expires:r}=await Ejt(t);return OFe(r)},Ejt=async function(t){let e=tM(t),r=await LFe(e,"utf-8");return JSON.parse(r)};import{homedir as Rjt}from"os";import{resolve as BFe,isAbsolute as Ajt,join as xjt,sep as hX}from"path";import{normalize as vjt}from"path";import{existsSync as bjt}from"fs";import Tjt from"process";var pX=function(t){try{let e=wjt(t);return bjt(e)?Promise.resolve(e):Promise.resolve("")}catch{return Promise.resolve("")}},wjt=function(t=Tjt.cwd()){return vjt(t)};var O0=async function({path:t,cacheDir:e,cwdOpt:r}){let n=await Ijt(t,r),i=await Njt({srcPath:n,cacheDir:e,cwdOpt:r});return{srcPath:n,cachePath:i}},Ijt=async function(t,e){let r=await pX(e),n=Pjt(t,r);return Ojt(n,r),n},Pjt=function(t,e){if(Ajt(t))return BFe(t);if(e!=="")return BFe(e,t);throw new Error(`Current directory does not exist: ${e}`)},Ojt=function(t,e){if(e!==""&&Cjt(t,e))throw new Error(`Cannot cache ${t} because it is the current directory (${e}) or a parent directory`)},Cjt=function(t,e){return`${e}${hX}`.startsWith(`${t}${hX}`)},Njt=async function({srcPath:t,cacheDir:e,cwdOpt:r}){let n=Qp({cacheDir:e,cwd:r}),{name:i,relPath:s}=await kjt(t,r);return xjt(n,i,s)},kjt=async function(t,e){let r=await mX(e),n=$jt(t);return r.map(({name:i,base:s})=>Djt(i,s,n)).find(Boolean)},$jt=function(t){return t.replace(Ljt,"\\")},Ljt=/^[a-zA-Z]:\\/,Djt=function(t,e,r){if(r===e||!r.startsWith(e))return;let n=r.replace(e,"");return{name:t,relPath:n}},mX=async function(t){return[...await Mjt(t),{name:"home",base:Rjt()},{name:"root",base:hX}]},Mjt=async function(t){let e=await pX(t);return e===""?[]:[{name:"cwd",base:e}]};var Fjt=1,gX=async function({cacheDir:t,cwd:e,depth:r=Fjt}={}){let n=await mX(e),i=Qp({cacheDir:t,cwd:e});return(await Promise.all(n.map(({name:a,base:c})=>jjt({name:a,base:c,cacheDir:i,depth:r})))).flat()},jjt=async function({name:t,base:e,cacheDir:r,depth:n}){return(await IFe(`${r}/${t}`,{fileFilter:qjt,depth:n,type:"files_directories"})).map(({path:o})=>Ujt(e,o))},qjt=function({basename:t}){return!jFe(t)};var Bjt=async function(t,{move:e=zFe,ttl:r=Gjt,digests:n=[],cacheDir:i,cwd:s}={}){let{srcPath:o,cachePath:a}=await O0({path:t,cacheDir:i,cwdOpt:s});if(!await I0(o))return!1;let{manifestInfo:c,identical:l}=await MFe({cachePath:a,move:e,ttl:r,digests:n});return l||(await _X(a,{force:!0,recursive:!0,maxRetries:3}),await aX(o,a,e),await UFe(c)),!0},zjt=async function(t,{move:e=zFe,cacheDir:r,cwd:n}={}){let{srcPath:i,cachePath:s}=await O0({path:t,cacheDir:r,cwdOpt:n});return!await I0(s)||await fX(s)?!1:(await _X(i,{force:!0,recursive:!0,maxRetries:3}),await aX(s,i,e),!0)},Vjt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await O0({path:t,cacheDir:e,cwdOpt:r});return await I0(n)?(await _X(n,{force:!0,recursive:!0,maxRetries:3}),await FFe(n),!0):!1},Hjt=async function(t,{cacheDir:e,cwd:r}={}){let{cachePath:n}=await O0({path:t,cacheDir:e,cwdOpt:r});return await I0(n)&&!await fX(n)},zFe=!1,Gjt=void 0,rM=async function(t,e,...r){return Array.isArray(e)?(await Promise.all(e.map(i=>t(i,...r)))).some(Boolean):t(e,...r)},Wjt=rM.bind(null,Bjt),Yjt=rM.bind(null,zjt),Kjt=rM.bind(null,Vjt),Jjt=rM.bind(null,Hjt),VFe=function(t){return{save:(e,r)=>Wjt(e,{...t,...r}),restore:(e,r)=>Yjt(e,{...t,...r}),remove:(e,r)=>Kjt(e,{...t,...r}),has:(e,r)=>Jjt(e,{...t,...r}),list:e=>gX({...t,...e}),getCacheDir:e=>Qp({...t,...e})}};var Jr=ve("native_session"),yX=async(t,e)=>(await Promise.all(e.map(async n=>{try{return await _l.stat(yl.join(t,n)),n}catch{return null}}))).filter(n=>n!==null),oh=async({runnerId:t,sessionId:e,archive:r,nativeSessionId:n})=>{if(!r)return Jr.log("No native session archive descriptor for this runner, skipping"),null;let{baseDir:i,include:s}=r,o=!1;try{o=(await _l.stat(i)).isDirectory()}catch{}if(!o)return Jr.log(`Native session base dir ${i} not found, skipping`),null;let a=await yX(i,s);if(a.length===0)return Jr.log(`No native session history found under ${i}, skipping`),null;let c=yl.join(HFe.tmpdir(),`native-session-${e}.zip`);try{await Gn("zip",["-r","-q","-X",c,...a],{cwd:i});let l=await _l.readFile(c);Jr.log(`Zipped native session (${l.length} bytes) from ${a.join(", ")}`,{nativeSessionId:n});let{upload_url:u,s3_key:d}=await gLe(t,e);return await l0(u,l,{contentType:"application/zip"}),Jr.log("Successfully uploaded native session to S3"),d}catch(l){return Jr.error("Failed to archive/upload native session, continuing without it:",l),null}finally{await _l.rm(c,{force:!0}).catch(()=>{})}},GFe=async t=>{if(!t)return!1;let{baseDir:e,include:r}=t,n=await yX(e,r);for(let i of n)if((await _l.readdir(yl.join(e,i)).catch(()=>[])).length>0)return!0;return!1},Zjt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),WFe=async(t,e)=>{let r=await _l.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of r)if(n.isDirectory()){if(await WFe(yl.join(t,n.name),e))return!0}else if(e.test(n.name))return!0;return!1},YFe=async(t,e)=>{if(!t||!e)return!1;let r=new RegExp(`(^|[^a-zA-Z0-9])${Zjt(e)}([^a-zA-Z0-9]|$)`),{baseDir:n,include:i}=t,s=await yX(n,i);for(let o of s)if(await WFe(yl.join(n,o),r))return!0;return!1},KFe=async({runnerId:t,sessionId:e,archive:r})=>{if(!r)return Jr.log("No native session archive descriptor for this runner, skipping restore"),!1;let{baseDir:n}=r,i=yl.join(HFe.tmpdir(),`native-session-restore-${e}.zip`);try{let s=await _Le(t,e);if(!s?.download_url)return Jr.log("No native session available to restore, skipping"),!1;let o=await wLe(s.download_url);return await _l.writeFile(i,o),Jr.log(`Downloaded native session (${o.length} bytes) to ${i}`),await _l.mkdir(n,{recursive:!0}),await Gn("unzip",["-o","-q",i,"-d",n]),Jr.log(`Restored native session into ${n}`),!0}catch(s){return Jr.error("Failed to fetch/restore native session, continuing without it:",s),!1}finally{await _l.rm(i,{force:!0}).catch(()=>{})}},Xjt="native-sessions",JFe=(t,e)=>VFe({cacheDir:yl.join(e.dir,Xjt),cwd:t}),ZFe=async({archive:t,cache:e})=>{if(!e?.dir||!t)return!1;let{baseDir:r,include:n}=t;try{return await JFe(r,e).restore(n.map(s=>yl.join(r,s)),{})?(Jr.log(`Restored native session from buildbot cache into ${r}`),!0):(Jr.log("No native session in buildbot cache, skipping restore"),!1)}catch(i){return Jr.error("Failed to restore native session from buildbot cache, continuing without it:",i),!1}},hS=async({archive:t,cache:e,nativeSessionId:r})=>{if(!e?.dir||!t)return Jr.log("No buildbot cache configured for the native session, skipping cache seed",{nativeSessionId:r}),!1;let{baseDir:n,include:i}=t;try{return await JFe(n,e).save(i.map(o=>yl.join(n,o)),{})?(Jr.log(`Saved native session to buildbot cache under ${e.dir}`,{nativeSessionId:r}),!0):(Jr.log("No native session history to save to buildbot cache, skipping"),!1)}catch(s){return Jr.error("Failed to save native session to buildbot cache, continuing:",s),!1}};var mS=ve("inference_stage"),XFe=5,Va=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:_,answerFold:y}=t;if(gi())throw new Error("Shutdown in progress, aborting inference stage");mS.log(`Running inference stage, attempt ${l} of ${XFe}`);let v=!1,S=await Vt(ht(),"inference-stage",async g=>{g?.setAttributes({"inference.attempt":l||1}),ATe();let w=!!(l&&l>1),P=await Qjt(n,w),x=!!m&&!!d;x&&n.runner==="gemini"&&!await o0(d)&&(x=!1);let R=P.viable||x;v=R,P.outcome!=="not_eligible"&&Se.inc("inference.native_resume",1,{outcome:P.outcome,...P.source?{source:P.source}:{}});let O=n;if("prompt"in n&&n.answeredInteraction&&rt().questionsEnabled){let I=n.answeredInteraction,N=R||w&&!!d,F=[I];if(!N){y.allAnswered??=VLe(n);let V=await y.allAnswered;V===null&&(y.allAnswered=void 0),V&&V.length>0&&(F=V.some(oe=>oe.refId===I.refId)?V:[...V,I])}O={...n,prompt:GLe(n.prompt,F)},!w&&!y.counted&&(y.counted=!0,mS.log("Resuming session with answered questions",{sessionId:n.sessionId,interactionCount:F.length}),Se.inc("inference.answer_resume",1,{fold:N?"latest":"all"}))}let{prompt:A}=await Vt(ht(),"compose-prompt",async()=>await qLe({cliPath:r,config:O,buildErrorContext:eqt(s),netlify:i,additionalContext:e,resumePrompt:R})),b=`
|