@netlify/agent-runner-cli 1.191.0 → 1.191.1
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 +20 -12
- package/dist/bin.js +20 -12
- package/dist/index.js +20 -12
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -594,7 +594,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
594
594
|
`,LF:`
|
|
595
595
|
`,concatBytes:eW},Mbt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Ubt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Mbt};import{Buffer as Fbt}from"buffer";var Bwe=(t,e)=>t?void 0:jbt.bind(void 0,e),jbt=function*(t,e){if(typeof e!="string"&&!Br(e)&&!Fbt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Vwe=(t,e)=>t?zbt.bind(void 0,e):qbt.bind(void 0,e),zbt=function*(t,e){Hwe(t,e),yield e},qbt=function*(t,e){if(Hwe(t,e),typeof e!="string"&&!Br(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Hwe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
596
596
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
597
|
-
if (condition) { yield value; }`)};import{Buffer as Bbt}from"buffer";import{StringDecoder as Vbt}from"string_decoder";var kP=(t,e,r)=>{if(r)return;if(t)return{transform:Hbt.bind(void 0,new TextEncoder)};let n=new Vbt(e);return{transform:Gbt.bind(void 0,n),final:Wbt.bind(void 0,n)}},Hbt=function*(t,e){Bbt.isBuffer(e)?yield Nc(e):typeof e=="string"?yield t.encode(e):yield e},Gbt=function*(t,e){yield Br(e)?t.write(e):e},Wbt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Gwe}from"util";var rW=Gwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$P=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Kbt}=e[r];for await(let i of n(t))yield*$P(i,e,r+1)},Wwe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Ybt(r,Number(e),t)},Ybt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$P(n,r,e+1)},Ywe=Gwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Kbt=function*(t){yield t};var nW=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Kwe=(t,e)=>[...e.flatMap(r=>[...Kf(r,t,0)]),...YT(t)],Kf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Jbt}=e[r];for(let i of n(t))yield*Kf(i,e,r+1)},YT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Zbt(r,Number(e),t)},Zbt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Kf(n,r,e+1)},Jbt=function*(t){yield t};var iW=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Jwe(t,o,s),l=Yf(e),u=Yf(r),d=l?rW.bind(void 0,$P,a):nW.bind(void 0,Kf),f=l||u?rW.bind(void 0,Wwe,a):nW.bind(void 0,YT),p=l||u?Ywe.bind(void 0,a):void 0;return{stream:new Xbt({writableObjectMode:n,writableHighWaterMark:Zwe(n),readableObjectMode:i,readableHighWaterMark:Zwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},LP=(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=Jwe(o,r,a);t=Kwe(c,t)}return t},Jwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Bwe(n,a)},kP(r,o,n),NP(r,s,n,c),{transform:t,final:e},{transform:Vwe(i,a)},qwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Xwe=(t,e)=>{for(let r of Qbt(t))ewt(t,r,e)},Qbt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),ewt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Iu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>twt(a,n));r.input=UT(o)},twt=(t,e)=>{let r=LP(t,e,"utf8",!0);return rwt(r),UT(r)},rwt=t=>{let e=t.find(r=>typeof r!="string"&&!Br(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 owt,appendFileSync as awt}from"fs";var DP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cg(r,n)&&!Yi.has(e)&&nwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&iwt.has(s))||t.every(({type:i})=>Is.has(i))),nwt=t=>t===1||t===2,iwt=new Set(["pipe","overlapped"]),Qwe=async(t,e,r,n)=>{for await(let i of t)swt(e)||tRe(i,r,n)},eRe=(t,e,r)=>{for(let n of t)tRe(n,e,r)},swt=t=>t._readableState.pipes.length>0,tRe=(t,e,r)=>{let n=ZO(t);da({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var rRe=({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)=>cwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},cwt=({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=nwe(t,s,d),p=Nc(f),{stdioItems:h,objectMode:m}=e[r],_=lwt([p],h,c,n),{serializedResult:S,finalResult:E=S}=uwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});dwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?E:void 0;try{return n.error===void 0&&fwt(S,h,i),y}catch(g){return n.error=g,y}},lwt=(t,e,r,n)=>{try{return LP(t,e,r,!1)}catch(i){return n.error=i,t}},uwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:UT(t)};let o=_ve(t,r);return n[s]?{serializedResult:o,finalResult:tW(o,!i[s],e)}:{serializedResult:o}},dwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!DP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=tW(t,!1,o);try{eRe(a,e,n)}catch(c){r.error??=c}},fwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?awt(n,t):(r.add(s),owt(n,t))}};var nRe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Lc(e,r,"all")]:Array.isArray(e)?[Lc(t,r,"all"),...e]:Br(t)&&Br(e)?u3([t,e]):`${t}${e}`};import{once as sW}from"events";var iRe=async(t,e)=>{let[r,n]=await pwt(t);return e.isForcefullyTerminated??=!1,[r,n]},pwt=async t=>{let[e,r]=await Promise.allSettled([sW(t,"spawn"),sW(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?sRe(t):r.value},sRe=async t=>{try{return await sW(t,"exit")}catch{return sRe(t)}},oRe=async t=>{let[e,r]=await t;if(!hwt(e,r)&&oW(e,r))throw new co;return[e,r]},hwt=(t,e)=>t===void 0&&e===void 0,oW=(t,e)=>t!==0||e!==null;var aRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=mwt(t,e,r),o=s?.code==="ETIMEDOUT",a=rwe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},mwt=(t,e,r)=>t!==void 0?t:oW(e,r)?new co:void 0;var cRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=_wt(t,e,r),d=Ewt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},_wt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),a=ywt(r),{file:c,commandArguments:l,options:u}=yP(t,e,a);Swt(u);let d=Uwe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},ywt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Swt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&MP("ipcInput"),t&&MP("ipc: true"),r&&MP("detached: true"),n&&MP("cancelSignal")},MP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Ewt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=vwt({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}=aRe(c,r),{output:h,error:m=l}=rRe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,y)=>Lc(E,r,y)),S=Lc(nRe(h,r),r,"all");return bwt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},vwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Xwe(s,r);let a=Twt(r);return gwt(...SP(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Twt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:AP(e)}),bwt=({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?xP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):WT({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 uAt}from"events";import{spawn as dAt}from"child_process";import pRe from"process";import{once as aW,on as wwt}from"events";var lRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Pg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),Rwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Rwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cP(e,i);let s=Cu(t,e,r),o=new AbortController;try{return await Promise.race([Awt(s,n,o),xwt(s,r,o),Cwt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),lP(e,i)}},Awt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await aW(t,"message",{signal:r});return n}for await(let[n]of wwt(t,"message",{signal:r}))if(e(n))return n},xwt=async(t,e,{signal:r})=>{await aW(t,"disconnect",{signal:r}),KTe(e)},Cwt=async(t,e,{signal:r})=>{let[n]=await aW(t,"strict:error",{signal:r});throw sP(n,e)};import{once as dRe,on as Iwt}from"events";var fRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>cW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),cW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Pg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),cP(e,s);let o=Cu(t,e,r),a=new AbortController,c={};return Owt(t,o,a),Pwt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Nwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Owt=async(t,e,r)=>{try{await dRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Pwt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await dRe(t,"strict:error",{signal:r.signal});n.error=sP(i,e),r.abort()}catch{}},Nwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Iwt(r,"message",{signal:s.signal}))uRe(o),yield c}catch{uRe(o)}finally{s.abort(),lP(e,a),n||Ng(t),i&&await t}},uRe=({error:t})=>{if(t)throw t};var hRe=(t,{ipc:e})=>{Object.assign(t,gRe(t,!1,e))},mRe=()=>{let t=pRe,e=!0,r=pRe.channel!==void 0;return{...gRe(t,e,r),getCancelSignal:Tbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},gRe=(t,e,r)=>({sendMessage:gP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:lRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:fRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as kwt}from"child_process";import{PassThrough as $wt,Readable as Lwt,Writable as Dwt,Duplex as Mwt}from"stream";var _Re=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{X3(n);let a=new kwt;Uwt(a,n),Object.assign(a,{readable:Fwt,writable:jwt,duplex:zwt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=qwt(c,o,i);return{subprocess:a,promise:l}},Uwt=(t,e)=>{let r=KT(),n=KT(),i=KT(),s=Array.from({length:e.length-3},KT),o=KT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},KT=()=>{let t=new $wt;return t.end(),t},Fwt=()=>new Lwt({read(){}}),jwt=()=>new Dwt({write(){}}),zwt=()=>new Mwt({read(){},write(){}}),qwt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as yRe,createWriteStream as SRe}from"fs";import{Buffer as Bwt}from"buffer";import{Readable as ZT,Writable as Vwt,Duplex as Hwt}from"stream";var vRe=(t,e)=>PP(Gwt,t,e,!1),JT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Iu[t]}.`)},ERe={fileNumber:JT,generator:iW,asyncGenerator:iW,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Hwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Gwt={input:{...ERe,fileUrl:({value:t})=>({stream:yRe(t)}),filePath:({value:{file:t}})=>({stream:yRe(t)}),webStream:({value:t})=>({stream:ZT.fromWeb(t)}),iterable:({value:t})=>({stream:ZT.from(t)}),asyncIterable:({value:t})=>({stream:ZT.from(t)}),string:({value:t})=>({stream:ZT.from(t)}),uint8Array:({value:t})=>({stream:ZT.from(Bwt.from(t))})},output:{...ERe,fileUrl:({value:t})=>({stream:SRe(t)}),filePath:({value:{file:t,append:e}})=>({stream:SRe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Vwt.fromWeb(t)}),iterable:JT,asyncIterable:JT,string:JT,uint8Array:JT}};import{on as Wwt,once as TRe}from"events";import{PassThrough as Ywt,getDefaultHighWaterMark as Kwt}from"stream";import{finished as RRe}from"stream/promises";function Zf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)uW(i);let e=t.some(({readableObjectMode:i})=>i),r=Zwt(t,e),n=new lW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Zwt=(t,e)=>{if(t.length===0)return Kwt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},lW=class extends Ywt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(uW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Jwt(this,this.#e,this.#s);let r=eRt({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(uW(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)}},Jwt=async(t,e,r)=>{UP(t,bRe);let n=new AbortController;try{await Promise.race([Xwt(t,n),Qwt(t,e,r,n)])}finally{n.abort(),UP(t,-bRe)}},Xwt=async(t,{signal:e})=>{try{await RRe(t,{signal:e,cleanup:!0})}catch(r){throw ARe(t,r),r}},Qwt=async(t,e,r,{signal:n})=>{for await(let[i]of Wwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},uW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},eRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{UP(t,wRe);let a=new AbortController;try{await Promise.race([tRt(s,e,a),rRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),nRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),UP(t,-wRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?dW(t):iRt(t))},tRt=async(t,e,{signal:r})=>{try{await t,r.aborted||dW(e)}catch(n){r.aborted||ARe(e,n)}},rRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await RRe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;xRe(o)?i.add(e):CRe(t,o)}},nRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await TRe(t,i,{signal:s}),!t.readable)return TRe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},iRt=t=>{t.writable&&t.end()},ARe=(t,e)=>{xRe(e)?dW(t):CRe(t,e)},xRe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",dW=t=>{(t.readable||t.writable)&&t.destroy()},CRe=(t,e)=>{t.destroyed||(t.once("error",sRt),t.destroy(e))},sRt=()=>{},UP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},bRe=2,wRe=1;import{finished as IRe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),oRt(t,e),aRt(t,e)},oRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await IRe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}fW(e)}},fW=t=>{t.writable&&t.end()},aRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await IRe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}pW(t)}},pW=t=>{t.readable&&t.destroy()};var ORe=(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})=>Is.has(c)))cRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Is.has(c)))uRt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Zf(s);jg(o,i)}},cRt=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=lRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},lRt=["stdin","stdout","stderr"],uRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;dRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},dRt=(t,{signal:e})=>{ao(t)&&Gf(t,fRt,e)},fRt=2;import{addAbortListener as mRt}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 FP=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",hW=Symbol.for("signal-exit emitter"),mW=globalThis,pRt=Object.defineProperty.bind(Object),gW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(mW[hW])return mW[hW];pRt(mW,hW,{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}},jP=class{},hRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),_W=class extends jP{onExit(){return()=>{}}load(){}unload(){}},yW=class extends jP{#e=SW.platform==="win32"?"SIGINT":"SIGHUP";#r=new gW;#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(!FP(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 FP(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"&&FP(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)}},SW=globalThis.process,{onExit:PRe,load:Lmr,unload:Dmr}=hRt(FP(SW)?new yW(SW):new _W);var NRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=PRe(()=>{t.kill()});mRt(n,()=>{i()})};var $Re=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=JO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=gRt(r,n,i),{sourceStream:d,sourceError:f}=yRt(t,l),{options:p,fileDescriptors:h}=pa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},gRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=_Rt(t,e,...r),a=aP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},_Rt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(kRe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||c3(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]=zO(r,...n);return{destination:e(kRe)(i,s,o),pipeOptions:o}}if(pa.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}`)},kRe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),yRt=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var DRe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=SRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw EW({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},SRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return pW(t),n;if(e!==void 0)return fW(r),e},EW=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:LRe,escapedCommand:LRe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),LRe="source.pipe(destination)";var MRe=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 ERt}from"stream/promises";var URe=(t,e,r)=>{let n=zP.has(e)?TRt(t,e):vRt(t,e);return Gf(t,wRt,r.signal),Gf(e,RRt,r.signal),bRt(e),n},vRt=(t,e)=>{let r=Zf([t]);return jg(r,e),zP.set(e,r),r},TRt=(t,e)=>{let r=zP.get(e);return r.add(t),r},bRt=async t=>{try{await ERt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zP.delete(t)},zP=new WeakMap,wRt=2,RRt=1;import{aborted as ARt}from"util";var FRe=(t,e)=>t===void 0?[]:[xRt(t,e)],xRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await ARt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw EW({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var qP=(t,...e)=>{if(Cr(e[0]))return qP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=$Re(t,...e),i=CRt({...n,destination:r});return i.pipe=qP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},CRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=IRt(t,i);DRe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=URe(e,s,d);return await Promise.race([MRe(u),...FRe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},IRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as DRt}from"timers/promises";import{on as ORt}from"events";import{getDefaultHighWaterMark as PRt}from"stream";var BP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return NRt(e,o),zRe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},NRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},vW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;kRt(e,o,t);let a=t.readableObjectMode&&!s;return zRe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},kRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},zRe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=ORt(t,"data",{signal:e.signal,highWaterMark:jRe,highWatermark:jRe});return $Rt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},TW=PRt(!0),jRe=TW,$Rt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=LRt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Kf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*YT(a)}},LRt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[kP(t,r,!e),NP(t,i,!n,{})].filter(Boolean);var qRe=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=MRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([URt(t),d]);return}let f=Q3(c,r),p=vW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([FRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},MRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!DP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=vW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Qwe(a,t,r,s)},URt=async t=>{await DRt(),t.readableFlowing===null&&t.resume()},FRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await bP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await wP(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return BRe(Qbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},bW=async t=>{try{return await t}catch(e){return BRe(e)}},BRe=({bufferedData:t})=>mve(t)?new Uint8Array(t):t;import{finished as jRt}from"stream/promises";var XT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=zRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],jRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||VRt(a,e,r,n)}finally{o.abort()}},zRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&qRt(t,r,n),n},qRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{BRt(e,r),n.call(t,...i)}},BRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},VRt=(t,e,r,n)=>{if(!HRt(t,e,r,n))throw t},HRt=(t,e,r,n=!0)=>r.propagating?VRe(t)||VP(t):(r.propagating=!0,wW(r,e)===n?VRe(t):VP(t)),wW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",VRe=t=>t?.code==="EPIPE";var HRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>RW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),RW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=XT(t,e,l);if(wW(l,e)){await u;return}let[d]=await Promise.all([qRe({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 GRe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Zf([t,e].filter(Boolean)):void 0,WRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>RW({...GRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:WRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),GRt=({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}},WRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as YRt}from"events";var YRe=t=>Cg(t,"ipc"),KRe=(t,e)=>{let r=ZO(t);da({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ZRe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=YRe(s),a=kc(e,"ipc"),c=kc(r,"ipc");for await(let l of cW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ewe(t,i,c),i.push(l)),o&&KRe(l,s);return i},JRe=async(t,e)=>(await Promise.allSettled([t]),e);var XRe=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:S})=>{let E=iRe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=HRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=WRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],A=ZRe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=KRt(m,t,y),C=ZRt(h,y);try{return await Promise.race([Promise.all([{},oRe(E),Promise.all(g),T,A,Nbe(t,d),...b,...C]),_,JRt(t,S),...xbe(t,s,f,S),...YTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Rbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(g.map(x=>bW(x))),bW(T),JRe(A,w),Promise.allSettled(b),Promise.allSettled(C)])}},KRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:XT(n,i,r)),ZRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>uo(s,{checkOpen:!1})&&!ao(s)).map(({type:i,value:s,stream:o=s})=>XT(o,n,e,{isSameDirection:Is.has(i),stopOnExit:i==="native"}))),JRt=async(t,{signal:e})=>{let[r]=await YRt(t,"error",{signal:e});throw r};var QRe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),QT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=fa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},zg=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 XRt}from"stream";import{callbackify as QRt}from"util";import{finished as eAe}from"stream/promises";var AW=async t=>{if(t!==void 0)try{await xW(t)}catch{}},tAe=async t=>{if(t!==void 0)try{await CW(t)}catch{}},xW=async t=>{await eAe(t,{cleanup:!0,readable:!1,writable:!0})},CW=async t=>{await eAe(t,{cleanup:!0,readable:!0,writable:!1})},HP=async(t,e)=>{if(await t,e)throw e},GP=(t,e,r)=>{r&&!VP(r)?t.destroy(r):e&&t.destroy()};var rAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Yi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=IW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=OW(a,o),{read:f,onStdoutDataDone:p}=PW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new XRt({read:f,destroy:QRt(kW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return NW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},IW=(t,e,r)=>{let n=kg(t,e),i=QT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},OW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:TW},PW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=fa(),o=BP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){eAt(this,o,s)},onStdoutDataDone:s}},eAt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},NW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await CW(t),await n,await AW(i),await e,r.readable&&r.push(null)}catch(s){await AW(i),nAe(r,s)}},kW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await zg(r,e)&&(nAe(t,n),await HP(e,n))},nAe=(t,e)=>{GP(t,t.readable,e)};import{Writable as tAt}from"stream";import{callbackify as iAe}from"util";var sAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=$W(t,r,e),o=new tAt({...LW(n,t,i),destroy:iAe(MW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return DW(n,o),o},$W=(t,e,r)=>{let n=aP(t,e),i=QT(r,n,"writableFinal"),s=QT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},LW=(t,e,r)=>({write:rAt.bind(void 0,t),final:iAe(nAt.bind(void 0,t,e,r))}),rAt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},nAt=async(t,e,r)=>{await zg(r,e)&&(t.writable&&t.end(),await e)},DW=async(t,e,r)=>{try{await xW(t),e.writable&&e.end()}catch(n){await tAe(r),oAe(e,n)}},MW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await zg(r,e),await zg(n,e)&&(oAe(t,i),await HP(e,i))},oAe=(t,e)=>{GP(t,t.writable,e)};import{Duplex as iAt}from"stream";import{callbackify as sAt}from"util";var aAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Yi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=IW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=$W(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=OW(c,a),{read:_,onStdoutDataDone:S}=PW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new iAt({read:_,...LW(u,t,d),destroy:sAt(oAt.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 NW({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),DW(u,E,c),E},oAt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([kW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),MW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var UW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Yi.has(e),o=kg(t,r),a=BP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return aAt(a,o,t)},aAt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var cAe=(t,{encoding:e})=>{let r=QRe();t.readable=rAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=sAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=aAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=UW.bind(void 0,t,e),t[Symbol.asyncIterator]=UW.bind(void 0,t,e,{})};var lAe=(t,e)=>{for(let[r,n]of lAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},cAt=(async()=>{})().constructor.prototype,lAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(cAt,t)]);var uAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=fAt(t,e,r),{subprocess:f,promise:p}=hAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=qP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),lAe(f,p),pa.set(f,{options:u,fileDescriptors:d}),f},fAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),{file:a,commandArguments:c,options:l}=yP(t,e,r),u=pAt(l),d=vRe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},pAt=({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}},hAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=dAt(...SP(t,e,r))}catch(h){return _Re({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;uAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ORe(c,a,l),NRe(c,r,l);let d={},f=fa();c.kill=GTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=GRe(c,r),cAe(c,r),hRe(c,r);let p=mAt({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}},mAt=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 XRe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((g,T)=>Lc(g,e,T)),E=Lc(m,e,"all"),y=gAt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(y,n,e)},gAt=({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?WT({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 ha,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):xP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var WP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,_At(n,t[n],i)]));return{...t,...r}},_At=(t,e,r)=>yAt.has(t)&&Cr(e)&&Cr(r)?{...e,...r}:r,yAt=new Set(["env",...h3]);var Ou=(t,e,r,n)=>{let i=(o,a,c)=>Ou(o,a,r,c),s=(...o)=>SAt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},SAt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Cr(s))return i(t,WP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=EAt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?cRe(a,c,l):uAe(a,c,l,i)},EAt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=vve(e)?Tve(e,r):[e,...r],[o,a,c]=zO(...s),l=WP(WP(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 dAe=({file:t,commandArguments:e})=>pAe(t,e),fAe=({file:t,commandArguments:e})=>({...pAe(t,e),isSync:!0}),pAe=(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]=vAt(t);return{file:r,commandArguments:n}},vAt=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(TAt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},TAt=/ +/g;var hAe=(t,e,r)=>{t.sync=e(bAt,r),t.s=t.sync},mAe=({options:t})=>gAe(t),bAt=({options:t})=>({...gAe(t),isSync:!0}),gAe=t=>({options:{...wAt(t),...t}}),wAt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},_Ae={preferLocal:!0};var yAe=Ou(()=>({})),Ryr=Ou(()=>({isSync:!0})),SAe=Ou(dAe),Ayr=Ou(fAe),xyr=Ou(Ibe),Cyr=Ou(mAe,{},_Ae,hAe),{sendMessage:Iyr,getOneMessage:Oyr,getEachMessage:Pyr,getCancelSignal:Nyr}=mRe();import{Transform as RAt}from"stream";var AAt=["NETLIFY_AI_GATEWAY_KEY"];function xAt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...AAt])]}function CAt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function IAt(){let e=xAt().map(r=>process.env[r]).filter(r=>!(!r||CAt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Pi(t){if(typeof t!="string")return t;let e=IAt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(OAt(n),"g");r=r.replace(i,"******")}),r}function OAt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var eb=class extends RAt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Pi(i);n(null,s)}},YP=Symbol("maskedWrite");function EAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[YP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stdout.write=r}if(!process.stderr.write[YP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stderr.write=r}}}var vAe=!1,TAe,FW=t=>{TAe??=t},bAe=t=>{vAe=!0,FW(t)},Cn=()=>vAe,ga=()=>TAe,wAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var tb=null,RAe=t=>(tb&&tb.destroy(),tb=new fo({totalAllowedTime:t}),tb),AAe=()=>tb;var fo=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&&Cn())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 DO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ee.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 xAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.191.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.19.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var $At=NAt(import.meta.url),LAt=Dc.dirname($At),DAt=kAt(import.meta.url),qg=fe("shell"),jW=new Set,CAe={preferLocal:!0},sr=(t,e,r)=>{let[n,i]=MAt(e,r),s={...CAe,...i},o=yAe(t,n,s);OAe(o,s),kAe(o);let a=r?.idleTimeout;return a&&a>0&&NAe(o,a),o},IAe=(t,e)=>{let r={...CAe,...e},n=SAe(t,r);return OAe(n,r),kAe(n),e?.idleTimeout&&e.idleTimeout>0&&NAe(n,e.idleTimeout),n},MAt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},OAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||_a.env.NETLIFY_LOCAL_QUIET==="true")return;if(_a.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new eb).pipe(_a.stdout),t.stderr?.pipe(new eb).pipe(_a.stderr);return}t.stdout?.pipe(_a.stdout),t.stderr?.pipe(_a.stderr)},zW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_a.kill(-t.pid,e),qg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qg.error("Error killing process:",r),!1}},PAe=t=>zW(t,"SIGKILL"),NAe=(t,e)=>{let r=null,n=()=>{qg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing idle process ${t.pid}`),PAe(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)},kAe=t=>{jW.add(t);let e=AAe();if(e){let r=e.onTimesUp(()=>{qg.log(`Global timer expired, killing process ${t.pid}`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing process ${t.pid} after timeout`),PAe(t))},5e3)});t.on("exit",()=>{jW.delete(t),r()}),t.on("error",()=>{jW.delete(t),r()})}};function ya(t,e){if(!_a.env.NETLIFY_LOCAL_MODE)try{let i=DAt.resolve(xAe.name),s=Dc.dirname(i);for(;s!==Dc.dirname(s);){let o=Dc.dirname(s);if(Dc.basename(o)==="node_modules"){let a=Dc.join(o,".bin",e);if(KP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(_a.env.NODE_PATH){let i=Dc.join(_a.env.NODE_PATH,".bin",e);if(KP.existsSync(i))return i}let r=Dc.join(t,"node_modules",".bin",e);if(KP.existsSync(r))return r;let n=Dc.join(LAt,"..","node_modules",".bin",e);if(KP.existsSync(n))return n}import yD from"process";import{fileURLToPath as fFt}from"url";import{createRequire as pFt}from"module";import tR from"path";import{readFileSync as hFt}from"fs";var UAt="__netlify__getTracer",FAt="__netlify__shutdownTracers",Tt=(t,e)=>globalThis[UAt]?.(t,e),$Ae=async()=>globalThis[FAt]?.();function rb(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 sFt}from"timers/promises";Ne();import jxt from"process";Ne();var l0t=(t,e)=>{e.recordException(t),e.setStatus({code:Gn.ERROR})};var Fc=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=x0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>C0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=x0e(r,n,i),c=this._tracer.startSpan(e,s,o);return C0e(c,s,a)}};function x0e(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Gt.active(),{opts:n,ctx:i,fn:s}}function C0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:l0t,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ne();var Kg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var vY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=U0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Kg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Kg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=U0e(this._rawAttributes),this._schemaUrl=u0t(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,Kg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ue.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Kg(n)){ue.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=d0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function TY(t,e){return vY.FromAttributeList(Object.entries(t),e)}function U0e(t){return t.map(([e,r])=>Kg(r)?[e,r.catch(n=>{ue.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function u0t(t){if(typeof t=="string"||t===void 0)return t;ue.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function d0t(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ue.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var hb=class{emit(e){}enabled(){return!1}},F0e=new hb;var mb=Symbol.for("io.opentelemetry.js.api.logs"),Zg=globalThis;function j0e(t,e,r){return n=>n===t?e:r}var bY=1;var wY=class{getLogger(e,r,n){return new hb}},yN=new wY;var SN=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):F0e}};var gb=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new SN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:yN}_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 EN=class t{constructor(){this._proxyLoggerProvider=new gb}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Zg[mb]?this.getLoggerProvider():(Zg[mb]=j0e(bY,e,yN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Zg[mb])===null||e===void 0?void 0:e.call(Zg,bY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Zg[mb],this._proxyLoggerProvider=new gb}};var z0e=EN.getInstance();function q0e(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 B0e(t){t.forEach(e=>e.disable())}function RY(t){let e=t.tracerProvider||Ot.getTracerProvider(),r=t.meterProvider||pb.getMeterProvider(),n=t.loggerProvider||z0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return q0e(i,e,r,n),()=>{B0e(i)}}Ne();var f0t=Qr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function V0e(t){return t.getValue(f0t)===!0}var Jg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Jg||(Jg={}));Ne();var AY="[_0-9a-z-*/]",p0t=`[a-z]${AY}{0,255}`,h0t=`[a-z0-9]${AY}{0,240}@[a-z]${AY}{0,13}`,m0t=new RegExp(`^(?:${p0t}|${h0t})$`),g0t=/^[ -~]{0,255}[!-~]$/,_0t=/,|=/;function xY(t){return m0t.test(t)}function CY(t){return g0t.test(t)&&!_0t.test(t)}var y0t=32,H0e=512,G0e=",",W0e="=",vN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!xY(e)||!CY(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>H0e)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=G0e+e),e=`${n[0]}${W0e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(G0e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(W0e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!xY(a)||!CY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>H0e)&&(r.set(a,c),n=l,r.size>=y0t))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var TN="traceparent",bN="tracestate",S0t="00",E0t="(?!ff)[\\da-f]{2}",v0t="(?![0]{32})[\\da-f]{32}",T0t="(?![0]{16})[\\da-f]{16}",b0t="[\\da-f]{2}",w0t=new RegExp(`^\\s?(${E0t})-(${v0t})-(${T0t})-(${b0t})(-.*)?\\s?$`);function Y0e(t){let e=w0t.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ku=class{inject(e,r,n){let i=Ot.getSpanContext(e);if(!i||V0e(e)||!Ni(i))return;let s=`${S0t}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Er.NONE).toString(16)}`;n.set(r,TN,s),i.traceState&&n.set(r,bN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,TN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=Y0e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,bN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new vN(typeof c=="string"?c:void 0)}return Ot.setSpanContext(e,o)}fields(){return[TN,bN]}};var wN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var _b=class{_isCalled=!1;_deferred=new wN;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var mk=pn(pK(),1);Ne();var OIe=t=>{throw TypeError(t)},_K=(t,e,r)=>e.has(t)||OIe("Cannot "+r),hk=(t,e,r)=>(_K(t,e,"read from private field"),r?r.call(t):e.get(t)),hK=(t,e,r)=>e.has(t)?OIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),xIe=(t,e,r,n)=>(_K(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Fxt=(t,e,r)=>(_K(t,e,"access private method"),r),CIe="__netlify__getTracer",zxt="__netlify__shutdownTracers",qxt="__nfOTLPTrace",Nb,kb,gK,PIe,Bxt=class{constructor(){hK(this,gK),hK(this,Nb),hK(this,kb),xIe(this,Nb,new _b(Fxt(this,gK,PIe),this)),xIe(this,kb,ue.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(hk(this,kb).debug(`export ${t.length.toString()} spans`),hk(this,Nb).isCalled){e({code:Jg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(qxt,JSON.stringify(Vxt(t))),e({code:Jg.SUCCESS})}shutdown(){return hk(this,Nb).call()}};Nb=new WeakMap;kb=new WeakMap;gK=new WeakSet;PIe=function(){return hk(this,kb).debug("Shutting down"),Promise.resolve()};function Vxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:pk(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||po.SERVER,startTimeUnixNano:mK(e.startTime),endTimeUnixNano:mK(e.endTime),attributes:pk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:mK(n.time),attributes:pk(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:pk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function pk(t){return Object.keys(t).map(e=>NIe(e,t[e]))}function NIe(t,e){return{key:t,value:kIe(e)}}function kIe(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(kIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>NIe(r,n))}}:{}}function mK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var IIe={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},$Ie=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,CIe))return;let e=jxt.version.slice(1),r=TY({"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??[Hxt()],i=new mk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ku});let s=t.instrumentations??[];RY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,CIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Fc(Ot.getTracer(a,c)):new Fc(Ot.getTracer(IIe.name,IIe.version))}}),Object.defineProperty(globalThis,zxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Hxt=()=>new mk.SimpleSpanProcessor(new Bxt);Ne();var $b=pn(pK(),1);Ne();import*as gk from"diagnostics_channel";var LIe=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?Gn.ERROR:Gn.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 Fc?t:new Fc(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){gk.subscribe(t,e);let r=()=>gk.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:po.CLIENT},Gt.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:Gn.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 s1e=pn(n1e(),1);var gD=fe("tracing"),i1e=8e3,oFt=5e3,Xw=async(t=oFt)=>{try{await Promise.race([$Ae(),sFt(t)])}catch(e){gD.warn("Failed to flush tracers on shutdown",e)}},o1e=async(t,e,r)=>{if(!Tt()){let n=[new $b.SimpleSpanProcessor(new yJ),new $b.SimpleSpanProcessor(new s1e.OTLPTraceExporter({url:r.exporterUrl}))];await $Ie({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new LIe({skipHeaders:!0})]})}return r.traceparent?(ui.setGlobalPropagator(new ku),ui.extract(Gt.active(),{traceparent:r.traceparent,isRemote:!0})):Gt.active()};function Kt(t,e,r){return gD.log(`\u23F3 TRACE: ${e} starting...`),rb(t,e,r)}var yJ=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";gD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&gD.log(` \u274C Error: ${e.status.message}`)}};function SJ(){return Je().captureLlmContentEnabled}function a1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function _D(t,e,r){let n={role:t,parts:[{type:"text",content:Pi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var aFt=new Set([te.Task,te.RunCommand,te.Explore,te.FileRead,te.FileWrite,te.Notebook,te.Web,te.Todo,te.Skill,te.Tool,te.Memorize,te.Deployment,te.SiteGeneration]);function c1e(t,e,r,n){if(!t.length)return;let i=Tt();if(!i)return;let s=SJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&aFt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>i1e?`${a.message.slice(0,i1e)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Pi(_)}:{"gen_ai.output.messages":_D("assistant",_)}:{}}}).end(u)})}import{readdir as cFt,rm as lFt}from"fs/promises";import{join as uFt}from"path";async function l1e(t,e=[]){let n=(await cFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>lFt(uFt(t,i),{recursive:!0,force:!0})))}var dFt=300,Qw=t=>Je().budgetCreditThresholds[t.mode]?.[t.runner]??dFt,eR=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var EJ=t=>{let e=Qw(t);if(!eR(t,e))return"default";let r=Je();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},u1e=t=>{let e=EJ(t),r=Qw(t);return{budget_eligible:eR(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var mFt=tR.dirname(fFt(import.meta.url)),d1e=pFt(import.meta.url),gFt=tR.resolve(mFt,"scripts/scaffold.js"),_Ft="scripts/scaffold.js",yFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,vJ=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},SFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),EFt=t=>{let e=vJ(t);return e==="node"||e.endsWith("/node")},ll=t=>{if(typeof t!="string")return!1;let e=t.match(yFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&SFt(vJ(e[r]));)r+=1;if(r>=e.length||!EFt(e[r]))return!1;let n=e[r+1];return n?vJ(n).includes(_Ft):!1},Mp=fe("create_stage"),TJ="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.",vFt=`${TJ}
|
|
597
|
+
if (condition) { yield value; }`)};import{Buffer as Bbt}from"buffer";import{StringDecoder as Vbt}from"string_decoder";var kP=(t,e,r)=>{if(r)return;if(t)return{transform:Hbt.bind(void 0,new TextEncoder)};let n=new Vbt(e);return{transform:Gbt.bind(void 0,n),final:Wbt.bind(void 0,n)}},Hbt=function*(t,e){Bbt.isBuffer(e)?yield Nc(e):typeof e=="string"?yield t.encode(e):yield e},Gbt=function*(t,e){yield Br(e)?t.write(e):e},Wbt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Gwe}from"util";var rW=Gwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$P=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Kbt}=e[r];for await(let i of n(t))yield*$P(i,e,r+1)},Wwe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Ybt(r,Number(e),t)},Ybt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$P(n,r,e+1)},Ywe=Gwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Kbt=function*(t){yield t};var nW=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Kwe=(t,e)=>[...e.flatMap(r=>[...Kf(r,t,0)]),...YT(t)],Kf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Jbt}=e[r];for(let i of n(t))yield*Kf(i,e,r+1)},YT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Zbt(r,Number(e),t)},Zbt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Kf(n,r,e+1)},Jbt=function*(t){yield t};var iW=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Jwe(t,o,s),l=Yf(e),u=Yf(r),d=l?rW.bind(void 0,$P,a):nW.bind(void 0,Kf),f=l||u?rW.bind(void 0,Wwe,a):nW.bind(void 0,YT),p=l||u?Ywe.bind(void 0,a):void 0;return{stream:new Xbt({writableObjectMode:n,writableHighWaterMark:Zwe(n),readableObjectMode:i,readableHighWaterMark:Zwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},LP=(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=Jwe(o,r,a);t=Kwe(c,t)}return t},Jwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Bwe(n,a)},kP(r,o,n),NP(r,s,n,c),{transform:t,final:e},{transform:Vwe(i,a)},qwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Xwe=(t,e)=>{for(let r of Qbt(t))ewt(t,r,e)},Qbt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),ewt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Iu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>twt(a,n));r.input=UT(o)},twt=(t,e)=>{let r=LP(t,e,"utf8",!0);return rwt(r),UT(r)},rwt=t=>{let e=t.find(r=>typeof r!="string"&&!Br(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 owt,appendFileSync as awt}from"fs";var DP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cg(r,n)&&!Yi.has(e)&&nwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&iwt.has(s))||t.every(({type:i})=>Is.has(i))),nwt=t=>t===1||t===2,iwt=new Set(["pipe","overlapped"]),Qwe=async(t,e,r,n)=>{for await(let i of t)swt(e)||tRe(i,r,n)},eRe=(t,e,r)=>{for(let n of t)tRe(n,e,r)},swt=t=>t._readableState.pipes.length>0,tRe=(t,e,r)=>{let n=ZO(t);da({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var rRe=({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)=>cwt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},cwt=({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=nwe(t,s,d),p=Nc(f),{stdioItems:h,objectMode:m}=e[r],_=lwt([p],h,c,n),{serializedResult:S,finalResult:E=S}=uwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});dwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?E:void 0;try{return n.error===void 0&&fwt(S,h,i),y}catch(g){return n.error=g,y}},lwt=(t,e,r,n)=>{try{return LP(t,e,r,!1)}catch(i){return n.error=i,t}},uwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:UT(t)};let o=_ve(t,r);return n[s]?{serializedResult:o,finalResult:tW(o,!i[s],e)}:{serializedResult:o}},dwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!DP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=tW(t,!1,o);try{eRe(a,e,n)}catch(c){r.error??=c}},fwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?awt(n,t):(r.add(s),owt(n,t))}};var nRe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Lc(e,r,"all")]:Array.isArray(e)?[Lc(t,r,"all"),...e]:Br(t)&&Br(e)?u3([t,e]):`${t}${e}`};import{once as sW}from"events";var iRe=async(t,e)=>{let[r,n]=await pwt(t);return e.isForcefullyTerminated??=!1,[r,n]},pwt=async t=>{let[e,r]=await Promise.allSettled([sW(t,"spawn"),sW(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?sRe(t):r.value},sRe=async t=>{try{return await sW(t,"exit")}catch{return sRe(t)}},oRe=async t=>{let[e,r]=await t;if(!hwt(e,r)&&oW(e,r))throw new co;return[e,r]},hwt=(t,e)=>t===void 0&&e===void 0,oW=(t,e)=>t!==0||e!==null;var aRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=mwt(t,e,r),o=s?.code==="ETIMEDOUT",a=rwe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},mwt=(t,e,r)=>t!==void 0?t:oW(e,r)?new co:void 0;var cRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=_wt(t,e,r),d=Ewt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},_wt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),a=ywt(r),{file:c,commandArguments:l,options:u}=yP(t,e,a);Swt(u);let d=Uwe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},ywt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Swt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&MP("ipcInput"),t&&MP("ipc: true"),r&&MP("detached: true"),n&&MP("cancelSignal")},MP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Ewt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=vwt({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}=aRe(c,r),{output:h,error:m=l}=rRe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,y)=>Lc(E,r,y)),S=Lc(nRe(h,r),r,"all");return bwt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},vwt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Xwe(s,r);let a=Twt(r);return gwt(...SP(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Twt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:AP(e)}),bwt=({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?xP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):WT({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 uAt}from"events";import{spawn as dAt}from"child_process";import pRe from"process";import{once as aW,on as wwt}from"events";var lRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Pg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),Rwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Rwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cP(e,i);let s=Cu(t,e,r),o=new AbortController;try{return await Promise.race([Awt(s,n,o),xwt(s,r,o),Cwt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),lP(e,i)}},Awt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await aW(t,"message",{signal:r});return n}for await(let[n]of wwt(t,"message",{signal:r}))if(e(n))return n},xwt=async(t,e,{signal:r})=>{await aW(t,"disconnect",{signal:r}),KTe(e)},Cwt=async(t,e,{signal:r})=>{let[n]=await aW(t,"strict:error",{signal:r});throw sP(n,e)};import{once as dRe,on as Iwt}from"events";var fRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>cW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),cW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Pg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),cP(e,s);let o=Cu(t,e,r),a=new AbortController,c={};return Owt(t,o,a),Pwt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Nwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Owt=async(t,e,r)=>{try{await dRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Pwt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await dRe(t,"strict:error",{signal:r.signal});n.error=sP(i,e),r.abort()}catch{}},Nwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Iwt(r,"message",{signal:s.signal}))uRe(o),yield c}catch{uRe(o)}finally{s.abort(),lP(e,a),n||Ng(t),i&&await t}},uRe=({error:t})=>{if(t)throw t};var hRe=(t,{ipc:e})=>{Object.assign(t,gRe(t,!1,e))},mRe=()=>{let t=pRe,e=!0,r=pRe.channel!==void 0;return{...gRe(t,e,r),getCancelSignal:Tbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},gRe=(t,e,r)=>({sendMessage:gP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:lRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:fRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as kwt}from"child_process";import{PassThrough as $wt,Readable as Lwt,Writable as Dwt,Duplex as Mwt}from"stream";var _Re=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{X3(n);let a=new kwt;Uwt(a,n),Object.assign(a,{readable:Fwt,writable:jwt,duplex:zwt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=qwt(c,o,i);return{subprocess:a,promise:l}},Uwt=(t,e)=>{let r=KT(),n=KT(),i=KT(),s=Array.from({length:e.length-3},KT),o=KT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},KT=()=>{let t=new $wt;return t.end(),t},Fwt=()=>new Lwt({read(){}}),jwt=()=>new Dwt({write(){}}),zwt=()=>new Mwt({read(){},write(){}}),qwt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as yRe,createWriteStream as SRe}from"fs";import{Buffer as Bwt}from"buffer";import{Readable as ZT,Writable as Vwt,Duplex as Hwt}from"stream";var vRe=(t,e)=>PP(Gwt,t,e,!1),JT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Iu[t]}.`)},ERe={fileNumber:JT,generator:iW,asyncGenerator:iW,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Hwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Gwt={input:{...ERe,fileUrl:({value:t})=>({stream:yRe(t)}),filePath:({value:{file:t}})=>({stream:yRe(t)}),webStream:({value:t})=>({stream:ZT.fromWeb(t)}),iterable:({value:t})=>({stream:ZT.from(t)}),asyncIterable:({value:t})=>({stream:ZT.from(t)}),string:({value:t})=>({stream:ZT.from(t)}),uint8Array:({value:t})=>({stream:ZT.from(Bwt.from(t))})},output:{...ERe,fileUrl:({value:t})=>({stream:SRe(t)}),filePath:({value:{file:t,append:e}})=>({stream:SRe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Vwt.fromWeb(t)}),iterable:JT,asyncIterable:JT,string:JT,uint8Array:JT}};import{on as Wwt,once as TRe}from"events";import{PassThrough as Ywt,getDefaultHighWaterMark as Kwt}from"stream";import{finished as RRe}from"stream/promises";function Zf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)uW(i);let e=t.some(({readableObjectMode:i})=>i),r=Zwt(t,e),n=new lW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Zwt=(t,e)=>{if(t.length===0)return Kwt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},lW=class extends Ywt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(uW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Jwt(this,this.#e,this.#s);let r=eRt({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(uW(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)}},Jwt=async(t,e,r)=>{UP(t,bRe);let n=new AbortController;try{await Promise.race([Xwt(t,n),Qwt(t,e,r,n)])}finally{n.abort(),UP(t,-bRe)}},Xwt=async(t,{signal:e})=>{try{await RRe(t,{signal:e,cleanup:!0})}catch(r){throw ARe(t,r),r}},Qwt=async(t,e,r,{signal:n})=>{for await(let[i]of Wwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},uW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},eRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{UP(t,wRe);let a=new AbortController;try{await Promise.race([tRt(s,e,a),rRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),nRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),UP(t,-wRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?dW(t):iRt(t))},tRt=async(t,e,{signal:r})=>{try{await t,r.aborted||dW(e)}catch(n){r.aborted||ARe(e,n)}},rRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await RRe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;xRe(o)?i.add(e):CRe(t,o)}},nRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await TRe(t,i,{signal:s}),!t.readable)return TRe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},iRt=t=>{t.writable&&t.end()},ARe=(t,e)=>{xRe(e)?dW(t):CRe(t,e)},xRe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",dW=t=>{(t.readable||t.writable)&&t.destroy()},CRe=(t,e)=>{t.destroyed||(t.once("error",sRt),t.destroy(e))},sRt=()=>{},UP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},bRe=2,wRe=1;import{finished as IRe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),oRt(t,e),aRt(t,e)},oRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await IRe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}fW(e)}},fW=t=>{t.writable&&t.end()},aRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await IRe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}pW(t)}},pW=t=>{t.readable&&t.destroy()};var ORe=(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})=>Is.has(c)))cRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Is.has(c)))uRt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Zf(s);jg(o,i)}},cRt=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=lRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},lRt=["stdin","stdout","stderr"],uRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;dRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},dRt=(t,{signal:e})=>{ao(t)&&Gf(t,fRt,e)},fRt=2;import{addAbortListener as mRt}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 FP=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",hW=Symbol.for("signal-exit emitter"),mW=globalThis,pRt=Object.defineProperty.bind(Object),gW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(mW[hW])return mW[hW];pRt(mW,hW,{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}},jP=class{},hRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),_W=class extends jP{onExit(){return()=>{}}load(){}unload(){}},yW=class extends jP{#e=SW.platform==="win32"?"SIGINT":"SIGHUP";#r=new gW;#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(!FP(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 FP(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"&&FP(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)}},SW=globalThis.process,{onExit:PRe,load:Lmr,unload:Dmr}=hRt(FP(SW)?new yW(SW):new _W);var NRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=PRe(()=>{t.kill()});mRt(n,()=>{i()})};var $Re=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=JO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=gRt(r,n,i),{sourceStream:d,sourceError:f}=yRt(t,l),{options:p,fileDescriptors:h}=pa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},gRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=_Rt(t,e,...r),a=aP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},_Rt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(kRe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||c3(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]=zO(r,...n);return{destination:e(kRe)(i,s,o),pipeOptions:o}}if(pa.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}`)},kRe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),yRt=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var DRe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=SRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw EW({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},SRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return pW(t),n;if(e!==void 0)return fW(r),e},EW=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:LRe,escapedCommand:LRe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),LRe="source.pipe(destination)";var MRe=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 ERt}from"stream/promises";var URe=(t,e,r)=>{let n=zP.has(e)?TRt(t,e):vRt(t,e);return Gf(t,wRt,r.signal),Gf(e,RRt,r.signal),bRt(e),n},vRt=(t,e)=>{let r=Zf([t]);return jg(r,e),zP.set(e,r),r},TRt=(t,e)=>{let r=zP.get(e);return r.add(t),r},bRt=async t=>{try{await ERt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zP.delete(t)},zP=new WeakMap,wRt=2,RRt=1;import{aborted as ARt}from"util";var FRe=(t,e)=>t===void 0?[]:[xRt(t,e)],xRt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await ARt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw EW({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var qP=(t,...e)=>{if(Cr(e[0]))return qP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=$Re(t,...e),i=CRt({...n,destination:r});return i.pipe=qP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},CRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=IRt(t,i);DRe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=URe(e,s,d);return await Promise.race([MRe(u),...FRe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},IRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as DRt}from"timers/promises";import{on as ORt}from"events";import{getDefaultHighWaterMark as PRt}from"stream";var BP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return NRt(e,o),zRe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},NRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},vW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;kRt(e,o,t);let a=t.readableObjectMode&&!s;return zRe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},kRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},zRe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=ORt(t,"data",{signal:e.signal,highWaterMark:jRe,highWatermark:jRe});return $Rt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},TW=PRt(!0),jRe=TW,$Rt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=LRt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Kf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*YT(a)}},LRt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[kP(t,r,!e),NP(t,i,!n,{})].filter(Boolean);var qRe=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=MRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([URt(t),d]);return}let f=Q3(c,r),p=vW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([FRt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},MRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!DP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=vW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Qwe(a,t,r,s)},URt=async t=>{await DRt(),t.readableFlowing===null&&t.resume()},FRt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await bP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await wP(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return BRe(Qbe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},bW=async t=>{try{return await t}catch(e){return BRe(e)}},BRe=({bufferedData:t})=>mve(t)?new Uint8Array(t):t;import{finished as jRt}from"stream/promises";var XT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=zRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],jRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||VRt(a,e,r,n)}finally{o.abort()}},zRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&qRt(t,r,n),n},qRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{BRt(e,r),n.call(t,...i)}},BRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},VRt=(t,e,r,n)=>{if(!HRt(t,e,r,n))throw t},HRt=(t,e,r,n=!0)=>r.propagating?VRe(t)||VP(t):(r.propagating=!0,wW(r,e)===n?VRe(t):VP(t)),wW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",VRe=t=>t?.code==="EPIPE";var HRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>RW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),RW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=XT(t,e,l);if(wW(l,e)){await u;return}let[d]=await Promise.all([qRe({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 GRe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Zf([t,e].filter(Boolean)):void 0,WRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>RW({...GRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:WRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),GRt=({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}},WRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as YRt}from"events";var YRe=t=>Cg(t,"ipc"),KRe=(t,e)=>{let r=ZO(t);da({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ZRe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=YRe(s),a=kc(e,"ipc"),c=kc(r,"ipc");for await(let l of cW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ewe(t,i,c),i.push(l)),o&&KRe(l,s);return i},JRe=async(t,e)=>(await Promise.allSettled([t]),e);var XRe=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:S})=>{let E=iRe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=HRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=WRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],A=ZRe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=KRt(m,t,y),C=ZRt(h,y);try{return await Promise.race([Promise.all([{},oRe(E),Promise.all(g),T,A,Nbe(t,d),...b,...C]),_,JRt(t,S),...xbe(t,s,f,S),...YTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Rbe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(g.map(x=>bW(x))),bW(T),JRe(A,w),Promise.allSettled(b),Promise.allSettled(C)])}},KRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:XT(n,i,r)),ZRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>uo(s,{checkOpen:!1})&&!ao(s)).map(({type:i,value:s,stream:o=s})=>XT(o,n,e,{isSameDirection:Is.has(i),stopOnExit:i==="native"}))),JRt=async(t,{signal:e})=>{let[r]=await YRt(t,"error",{signal:e});throw r};var QRe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),QT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=fa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},zg=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 XRt}from"stream";import{callbackify as QRt}from"util";import{finished as eAe}from"stream/promises";var AW=async t=>{if(t!==void 0)try{await xW(t)}catch{}},tAe=async t=>{if(t!==void 0)try{await CW(t)}catch{}},xW=async t=>{await eAe(t,{cleanup:!0,readable:!1,writable:!0})},CW=async t=>{await eAe(t,{cleanup:!0,readable:!0,writable:!1})},HP=async(t,e)=>{if(await t,e)throw e},GP=(t,e,r)=>{r&&!VP(r)?t.destroy(r):e&&t.destroy()};var rAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Yi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=IW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=OW(a,o),{read:f,onStdoutDataDone:p}=PW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new XRt({read:f,destroy:QRt(kW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return NW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},IW=(t,e,r)=>{let n=kg(t,e),i=QT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},OW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:TW},PW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=fa(),o=BP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){eAt(this,o,s)},onStdoutDataDone:s}},eAt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},NW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await CW(t),await n,await AW(i),await e,r.readable&&r.push(null)}catch(s){await AW(i),nAe(r,s)}},kW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await zg(r,e)&&(nAe(t,n),await HP(e,n))},nAe=(t,e)=>{GP(t,t.readable,e)};import{Writable as tAt}from"stream";import{callbackify as iAe}from"util";var sAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=$W(t,r,e),o=new tAt({...LW(n,t,i),destroy:iAe(MW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return DW(n,o),o},$W=(t,e,r)=>{let n=aP(t,e),i=QT(r,n,"writableFinal"),s=QT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},LW=(t,e,r)=>({write:rAt.bind(void 0,t),final:iAe(nAt.bind(void 0,t,e,r))}),rAt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},nAt=async(t,e,r)=>{await zg(r,e)&&(t.writable&&t.end(),await e)},DW=async(t,e,r)=>{try{await xW(t),e.writable&&e.end()}catch(n){await tAe(r),oAe(e,n)}},MW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await zg(r,e),await zg(n,e)&&(oAe(t,i),await HP(e,i))},oAe=(t,e)=>{GP(t,t.writable,e)};import{Duplex as iAt}from"stream";import{callbackify as sAt}from"util";var aAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Yi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=IW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=$W(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=OW(c,a),{read:_,onStdoutDataDone:S}=PW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new iAt({read:_,...LW(u,t,d),destroy:sAt(oAt.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 NW({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),DW(u,E,c),E},oAt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([kW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),MW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var UW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Yi.has(e),o=kg(t,r),a=BP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return aAt(a,o,t)},aAt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var cAe=(t,{encoding:e})=>{let r=QRe();t.readable=rAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=sAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=aAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=UW.bind(void 0,t,e),t[Symbol.asyncIterator]=UW.bind(void 0,t,e,{})};var lAe=(t,e)=>{for(let[r,n]of lAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},cAt=(async()=>{})().constructor.prototype,lAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(cAt,t)]);var uAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=fAt(t,e,r),{subprocess:f,promise:p}=hAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=qP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),lAe(f,p),pa.set(f,{options:u,fileDescriptors:d}),f},fAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),{file:a,commandArguments:c,options:l}=yP(t,e,r),u=pAt(l),d=vRe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},pAt=({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}},hAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=dAt(...SP(t,e,r))}catch(h){return _Re({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;uAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ORe(c,a,l),NRe(c,r,l);let d={},f=fa();c.kill=GTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=GRe(c,r),cAe(c,r),hRe(c,r);let p=mAt({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}},mAt=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 XRe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((g,T)=>Lc(g,e,T)),E=Lc(m,e,"all"),y=gAt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(y,n,e)},gAt=({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?WT({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 ha,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):xP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var WP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,_At(n,t[n],i)]));return{...t,...r}},_At=(t,e,r)=>yAt.has(t)&&Cr(e)&&Cr(r)?{...e,...r}:r,yAt=new Set(["env",...h3]);var Ou=(t,e,r,n)=>{let i=(o,a,c)=>Ou(o,a,r,c),s=(...o)=>SAt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},SAt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Cr(s))return i(t,WP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=EAt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?cRe(a,c,l):uAe(a,c,l,i)},EAt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=vve(e)?Tve(e,r):[e,...r],[o,a,c]=zO(...s),l=WP(WP(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 dAe=({file:t,commandArguments:e})=>pAe(t,e),fAe=({file:t,commandArguments:e})=>({...pAe(t,e),isSync:!0}),pAe=(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]=vAt(t);return{file:r,commandArguments:n}},vAt=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(TAt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},TAt=/ +/g;var hAe=(t,e,r)=>{t.sync=e(bAt,r),t.s=t.sync},mAe=({options:t})=>gAe(t),bAt=({options:t})=>({...gAe(t),isSync:!0}),gAe=t=>({options:{...wAt(t),...t}}),wAt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},_Ae={preferLocal:!0};var yAe=Ou(()=>({})),Ryr=Ou(()=>({isSync:!0})),SAe=Ou(dAe),Ayr=Ou(fAe),xyr=Ou(Ibe),Cyr=Ou(mAe,{},_Ae,hAe),{sendMessage:Iyr,getOneMessage:Oyr,getEachMessage:Pyr,getCancelSignal:Nyr}=mRe();import{Transform as RAt}from"stream";var AAt=["NETLIFY_AI_GATEWAY_KEY"];function xAt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...AAt])]}function CAt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function IAt(){let e=xAt().map(r=>process.env[r]).filter(r=>!(!r||CAt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Pi(t){if(typeof t!="string")return t;let e=IAt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(OAt(n),"g");r=r.replace(i,"******")}),r}function OAt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var eb=class extends RAt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Pi(i);n(null,s)}},YP=Symbol("maskedWrite");function EAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[YP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stdout.write=r}if(!process.stderr.write[YP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stderr.write=r}}}var vAe=!1,TAe,FW=t=>{TAe??=t},bAe=t=>{vAe=!0,FW(t)},Cn=()=>vAe,ga=()=>TAe,wAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var tb=null,RAe=t=>(tb&&tb.destroy(),tb=new fo({totalAllowedTime:t}),tb),AAe=()=>tb;var fo=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&&Cn())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 DO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ee.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 xAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.191.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.19.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var $At=NAt(import.meta.url),LAt=Dc.dirname($At),DAt=kAt(import.meta.url),qg=fe("shell"),jW=new Set,CAe={preferLocal:!0},sr=(t,e,r)=>{let[n,i]=MAt(e,r),s={...CAe,...i},o=yAe(t,n,s);OAe(o,s),kAe(o);let a=r?.idleTimeout;return a&&a>0&&NAe(o,a),o},IAe=(t,e)=>{let r={...CAe,...e},n=SAe(t,r);return OAe(n,r),kAe(n),e?.idleTimeout&&e.idleTimeout>0&&NAe(n,e.idleTimeout),n},MAt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},OAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||_a.env.NETLIFY_LOCAL_QUIET==="true")return;if(_a.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new eb).pipe(_a.stdout),t.stderr?.pipe(new eb).pipe(_a.stderr);return}t.stdout?.pipe(_a.stdout),t.stderr?.pipe(_a.stderr)},zW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_a.kill(-t.pid,e),qg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qg.error("Error killing process:",r),!1}},PAe=t=>zW(t,"SIGKILL"),NAe=(t,e)=>{let r=null,n=()=>{qg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing idle process ${t.pid}`),PAe(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)},kAe=t=>{jW.add(t);let e=AAe();if(e){let r=e.onTimesUp(()=>{qg.log(`Global timer expired, killing process ${t.pid}`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing process ${t.pid} after timeout`),PAe(t))},5e3)});t.on("exit",()=>{jW.delete(t),r()}),t.on("error",()=>{jW.delete(t),r()})}};function ya(t,e){if(!_a.env.NETLIFY_LOCAL_MODE)try{let i=DAt.resolve(xAe.name),s=Dc.dirname(i);for(;s!==Dc.dirname(s);){let o=Dc.dirname(s);if(Dc.basename(o)==="node_modules"){let a=Dc.join(o,".bin",e);if(KP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(_a.env.NODE_PATH){let i=Dc.join(_a.env.NODE_PATH,".bin",e);if(KP.existsSync(i))return i}let r=Dc.join(t,"node_modules",".bin",e);if(KP.existsSync(r))return r;let n=Dc.join(LAt,"..","node_modules",".bin",e);if(KP.existsSync(n))return n}import yD from"process";import{fileURLToPath as fFt}from"url";import{createRequire as pFt}from"module";import tR from"path";import{readFileSync as hFt}from"fs";var UAt="__netlify__getTracer",FAt="__netlify__shutdownTracers",Tt=(t,e)=>globalThis[UAt]?.(t,e),$Ae=async()=>globalThis[FAt]?.();function rb(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 sFt}from"timers/promises";Ne();import jxt from"process";Ne();var l0t=(t,e)=>{e.recordException(t),e.setStatus({code:Gn.ERROR})};var Fc=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=x0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>C0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=x0e(r,n,i),c=this._tracer.startSpan(e,s,o);return C0e(c,s,a)}};function x0e(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Gt.active(),{opts:n,ctx:i,fn:s}}function C0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:l0t,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ne();var Kg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var vY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=U0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Kg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Kg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=U0e(this._rawAttributes),this._schemaUrl=u0t(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,Kg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ue.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Kg(n)){ue.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=d0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function TY(t,e){return vY.FromAttributeList(Object.entries(t),e)}function U0e(t){return t.map(([e,r])=>Kg(r)?[e,r.catch(n=>{ue.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function u0t(t){if(typeof t=="string"||t===void 0)return t;ue.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function d0t(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ue.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var hb=class{emit(e){}enabled(){return!1}},F0e=new hb;var mb=Symbol.for("io.opentelemetry.js.api.logs"),Zg=globalThis;function j0e(t,e,r){return n=>n===t?e:r}var bY=1;var wY=class{getLogger(e,r,n){return new hb}},yN=new wY;var SN=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):F0e}};var gb=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new SN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:yN}_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 EN=class t{constructor(){this._proxyLoggerProvider=new gb}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Zg[mb]?this.getLoggerProvider():(Zg[mb]=j0e(bY,e,yN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Zg[mb])===null||e===void 0?void 0:e.call(Zg,bY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Zg[mb],this._proxyLoggerProvider=new gb}};var z0e=EN.getInstance();function q0e(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 B0e(t){t.forEach(e=>e.disable())}function RY(t){let e=t.tracerProvider||Ot.getTracerProvider(),r=t.meterProvider||pb.getMeterProvider(),n=t.loggerProvider||z0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return q0e(i,e,r,n),()=>{B0e(i)}}Ne();var f0t=Qr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function V0e(t){return t.getValue(f0t)===!0}var Jg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Jg||(Jg={}));Ne();var AY="[_0-9a-z-*/]",p0t=`[a-z]${AY}{0,255}`,h0t=`[a-z0-9]${AY}{0,240}@[a-z]${AY}{0,13}`,m0t=new RegExp(`^(?:${p0t}|${h0t})$`),g0t=/^[ -~]{0,255}[!-~]$/,_0t=/,|=/;function xY(t){return m0t.test(t)}function CY(t){return g0t.test(t)&&!_0t.test(t)}var y0t=32,H0e=512,G0e=",",W0e="=",vN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!xY(e)||!CY(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>H0e)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=G0e+e),e=`${n[0]}${W0e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(G0e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(W0e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!xY(a)||!CY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>H0e)&&(r.set(a,c),n=l,r.size>=y0t))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var TN="traceparent",bN="tracestate",S0t="00",E0t="(?!ff)[\\da-f]{2}",v0t="(?![0]{32})[\\da-f]{32}",T0t="(?![0]{16})[\\da-f]{16}",b0t="[\\da-f]{2}",w0t=new RegExp(`^\\s?(${E0t})-(${v0t})-(${T0t})-(${b0t})(-.*)?\\s?$`);function Y0e(t){let e=w0t.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ku=class{inject(e,r,n){let i=Ot.getSpanContext(e);if(!i||V0e(e)||!Ni(i))return;let s=`${S0t}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Er.NONE).toString(16)}`;n.set(r,TN,s),i.traceState&&n.set(r,bN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,TN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=Y0e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,bN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new vN(typeof c=="string"?c:void 0)}return Ot.setSpanContext(e,o)}fields(){return[TN,bN]}};var wN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var _b=class{_isCalled=!1;_deferred=new wN;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var mk=pn(pK(),1);Ne();var OIe=t=>{throw TypeError(t)},_K=(t,e,r)=>e.has(t)||OIe("Cannot "+r),hk=(t,e,r)=>(_K(t,e,"read from private field"),r?r.call(t):e.get(t)),hK=(t,e,r)=>e.has(t)?OIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),xIe=(t,e,r,n)=>(_K(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Fxt=(t,e,r)=>(_K(t,e,"access private method"),r),CIe="__netlify__getTracer",zxt="__netlify__shutdownTracers",qxt="__nfOTLPTrace",Nb,kb,gK,PIe,Bxt=class{constructor(){hK(this,gK),hK(this,Nb),hK(this,kb),xIe(this,Nb,new _b(Fxt(this,gK,PIe),this)),xIe(this,kb,ue.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(hk(this,kb).debug(`export ${t.length.toString()} spans`),hk(this,Nb).isCalled){e({code:Jg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(qxt,JSON.stringify(Vxt(t))),e({code:Jg.SUCCESS})}shutdown(){return hk(this,Nb).call()}};Nb=new WeakMap;kb=new WeakMap;gK=new WeakSet;PIe=function(){return hk(this,kb).debug("Shutting down"),Promise.resolve()};function Vxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:pk(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||po.SERVER,startTimeUnixNano:mK(e.startTime),endTimeUnixNano:mK(e.endTime),attributes:pk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:mK(n.time),attributes:pk(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:pk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function pk(t){return Object.keys(t).map(e=>NIe(e,t[e]))}function NIe(t,e){return{key:t,value:kIe(e)}}function kIe(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(kIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>NIe(r,n))}}:{}}function mK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var IIe={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},$Ie=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,CIe))return;let e=jxt.version.slice(1),r=TY({"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??[Hxt()],i=new mk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ku});let s=t.instrumentations??[];RY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,CIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Fc(Ot.getTracer(a,c)):new Fc(Ot.getTracer(IIe.name,IIe.version))}}),Object.defineProperty(globalThis,zxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Hxt=()=>new mk.SimpleSpanProcessor(new Bxt);Ne();var $b=pn(pK(),1);Ne();import*as gk from"diagnostics_channel";var LIe=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?Gn.ERROR:Gn.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 Fc?t:new Fc(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){gk.subscribe(t,e);let r=()=>gk.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:po.CLIENT},Gt.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:Gn.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 s1e=pn(n1e(),1);var gD=fe("tracing"),i1e=8e3,oFt=5e3,Xw=async(t=oFt)=>{try{await Promise.race([$Ae(),sFt(t)])}catch(e){gD.warn("Failed to flush tracers on shutdown",e)}},o1e=async(t,e,r)=>{if(!Tt()){let n=[new $b.SimpleSpanProcessor(new yJ),new $b.SimpleSpanProcessor(new s1e.OTLPTraceExporter({url:r.exporterUrl}))];await $Ie({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new LIe({skipHeaders:!0})]})}return r.traceparent?(ui.setGlobalPropagator(new ku),ui.extract(Gt.active(),{traceparent:r.traceparent,isRemote:!0})):Gt.active()};function Kt(t,e,r){return gD.log(`\u23F3 TRACE: ${e} starting...`),rb(t,e,r)}var yJ=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";gD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&gD.log(` \u274C Error: ${e.status.message}`)}};function SJ(){return Je().captureLlmContentEnabled}function a1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function _D(t,e,r){let n={role:t,parts:[{type:"text",content:Pi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var aFt=new Set([te.Task,te.RunCommand,te.Explore,te.FileRead,te.FileWrite,te.Notebook,te.Web,te.Todo,te.Skill,te.Tool,te.Memorize,te.Deployment,te.SiteGeneration]);function c1e(t,e,r,n){if(!t.length)return;let i=Tt();if(!i)return;let s=SJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&aFt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>i1e?`${a.message.slice(0,i1e)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Pi(_)}:{"gen_ai.output.messages":_D("assistant",_)}:{}}}).end(u)})}import{readdir as cFt,rm as lFt}from"fs/promises";import{join as uFt}from"path";async function l1e(t,e=[]){let n=(await cFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>lFt(uFt(t,i),{recursive:!0,force:!0})))}var dFt=300,Qw=t=>Je().budgetCreditThresholds[t.mode]?.[t.runner]??dFt,eR=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var EJ=t=>{let e=Qw(t);if(!eR(t,e))return"default";let r=Je();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},u1e=t=>{let e=EJ(t),r=Qw(t);return{budget_eligible:eR(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var mFt=tR.dirname(fFt(import.meta.url)),d1e=pFt(import.meta.url),gFt=tR.resolve(mFt,"scripts/scaffold.js"),_Ft="scripts/scaffold.js",yFt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,vJ=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},SFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),EFt=t=>{let e=vJ(t);return e==="node"||e.endsWith("/node")},ll=t=>{if(typeof t!="string")return!1;let e=t.match(yFt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&SFt(vJ(e[r]));)r+=1;if(r>=e.length||!EFt(e[r]))return!1;let n=e[r+1];return n?vJ(n).includes(_Ft):!1},Mp=fe("create_stage"),TJ="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.",vFt=`${TJ}
|
|
598
598
|
|
|
599
599
|
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.`,TFt=`${TJ}
|
|
600
600
|
|
|
@@ -876,13 +876,21 @@ ${t}
|
|
|
876
876
|
Earlier turns in this session ran in "Ask mode". Those restrictions no longer apply; ignore them and follow the instructions below instead:
|
|
877
877
|
${K2e({netlifyFolder:t,resultsFilename:rc})}
|
|
878
878
|
${J2e(e,n)}${tVe(r)}
|
|
879
|
-
</mode_reminder>`,sVe=({dirPath:t,config:e,skillsDir:r,cliPath:n})=>e.mode==="ask"?z3t($3t.basename(t)):e.previousSession?.mode==="ask"?q3t({netlifyFolder:t,skillsDir:r,cliPath:n,runner:e.runner}):"",oVe=({
|
|
879
|
+
</mode_reminder>`,sVe=({dirPath:t,config:e,skillsDir:r,cliPath:n})=>e.mode==="ask"?z3t($3t.basename(t)):e.previousSession?.mode==="ask"?q3t({netlifyFolder:t,skillsDir:r,cliPath:n,runner:e.runner}):"",oVe=({userRequestLast:t=!1,sanitizedPrompt:e,buildErrorContextText:r,assetsSection:n,modeReminder:i})=>t?`
|
|
880
|
+
${n}${i}
|
|
880
881
|
<request>
|
|
882
|
+
${r}
|
|
881
883
|
<user_request>
|
|
882
|
-
${
|
|
884
|
+
${e}
|
|
883
885
|
</user_request>
|
|
884
|
-
|
|
885
|
-
|
|
886
|
+
</request>
|
|
887
|
+
`.trim():`
|
|
888
|
+
<request>
|
|
889
|
+
<user_request>
|
|
890
|
+
${e}
|
|
891
|
+
</user_request>
|
|
892
|
+
${r}
|
|
893
|
+
</request>${n}${i}
|
|
886
894
|
`.trim();var zi=fe("context"),H3t=V3t(import.meta.url),G3t=xt.dirname(H3t),aVe={claude:xt.join(a1.homedir(),".claude","skills"),gemini:xt.join(a1.homedir(),".agents","skills"),codex:xt.join(a1.homedir(),".agents","skills"),opencode:xt.join(a1.homedir(),".agents","skills")},W3t=xt.join(G3t,"skills"),cVe=t=>t.replace(/<\/user_request/gi,"</user_request"),l1=t=>typeof t=="string"&&/^[A-Za-z0-9_-]+$/.test(t)?t:null,lVe=(t,e,r)=>{let n=` <user_request>
|
|
887
895
|
${cVe(t)}
|
|
888
896
|
</user_request>`,i=` ${e}`;return`<request>
|
|
@@ -931,16 +939,16 @@ ${b}
|
|
|
931
939
|
${m.models.map(_=>`- \`${_}\``).join(`
|
|
932
940
|
`)}`).join(`
|
|
933
941
|
|
|
934
|
-
`);f=f.replace("<!-- AVAILABLE_MODELS -->",p),await jr.writeFile(d,f,"utf-8"),zi.log("Injected dynamic model list into AI Gateway skill",{modelList:p})}}catch(u){zi.warn("Failed to inject dynamic model list into AI Gateway skill:",u.message),ee.inc("context.degraded",1,{component:"model_list"})}return l.length>0&&(zi.log(`Installed ${l.length} skills for ${t}: ${l.join(", ")}`,{runner:t,skills:l,targetDir:i}),Ot.getActiveSpan()?.setAttributes({"agent.skills_loaded":l,"agent.skills_loaded_count":l.length})),gee={key:c,skills:l},l},eWt=t=>{let e=t?.constants||{};return{siteId:e.SITE_ID,accountId:ec.env.NETLIFY_TEAM_ID,userId:ec.env.NETLIFY_AGENT_RUNNER_USER_ID,siteSlug:ec.env.SITE_NAME,apiHost:e.NETLIFY_API_HOST,functionsDir:e.FUNCTIONS_DIST}},tWt=10,rWt=async t=>{let{name:e,ext:r}=xt.parse(t),n=t,i=xt.join(ec.cwd(),hn,n),s=0;for(;await nWt(i);){if(s>=tWt)throw new Error("Failed to generate context file");n=`${e}-${B3t.randomUUID().slice(0,5)}${r}`,i=xt.join(ec.cwd(),hn,n),s+=1}return n},nWt=async t=>{try{return await jr.access(t),!0}catch{return!1}},c1=async t=>{try{return(await jr.readdir(t)).length>0}catch{return!1}},dVe=async({cliPath:t,netlify:e,config:r,buildErrorContext:n,additionalContext:i,resumePrompt:s,preserveResultsFile:o})=>{let a=eWt(e),c=await rWt(Gte),l=xt.join(ec.cwd(),hn);await jr.mkdir(l,{recursive:!0});let u=xt.join(hn,c),d=xt.join(ec.cwd(),u);if(!o){let w=xt.join(ec.cwd(),hn,rc);try{await jr.unlink(w),zi.log(`Deleted old results file: ${w}`)}catch{}}let f=iVe(n),p=r.skillsTargetDir||aVe[r.runner];
|
|
942
|
+
`);f=f.replace("<!-- AVAILABLE_MODELS -->",p),await jr.writeFile(d,f,"utf-8"),zi.log("Injected dynamic model list into AI Gateway skill",{modelList:p})}}catch(u){zi.warn("Failed to inject dynamic model list into AI Gateway skill:",u.message),ee.inc("context.degraded",1,{component:"model_list"})}return l.length>0&&(zi.log(`Installed ${l.length} skills for ${t}: ${l.join(", ")}`,{runner:t,skills:l,targetDir:i}),Ot.getActiveSpan()?.setAttributes({"agent.skills_loaded":l,"agent.skills_loaded_count":l.length})),gee={key:c,skills:l},l},eWt=t=>{let e=t?.constants||{};return{siteId:e.SITE_ID,accountId:ec.env.NETLIFY_TEAM_ID,userId:ec.env.NETLIFY_AGENT_RUNNER_USER_ID,siteSlug:ec.env.SITE_NAME,apiHost:e.NETLIFY_API_HOST,functionsDir:e.FUNCTIONS_DIST}},tWt=10,rWt=async t=>{let{name:e,ext:r}=xt.parse(t),n=t,i=xt.join(ec.cwd(),hn,n),s=0;for(;await nWt(i);){if(s>=tWt)throw new Error("Failed to generate context file");n=`${e}-${B3t.randomUUID().slice(0,5)}${r}`,i=xt.join(ec.cwd(),hn,n),s+=1}return n},nWt=async t=>{try{return await jr.access(t),!0}catch{return!1}},c1=async t=>{try{return(await jr.readdir(t)).length>0}catch{return!1}},dVe=async({cliPath:t,netlify:e,config:r,buildErrorContext:n,additionalContext:i,resumePrompt:s,preserveResultsFile:o})=>{let a=eWt(e),c=await rWt(Gte),l=xt.join(ec.cwd(),hn);await jr.mkdir(l,{recursive:!0});let u=xt.join(hn,c),d=xt.join(ec.cwd(),u);if(!o){let w=xt.join(ec.cwd(),hn,rc);try{await jr.unlink(w),zi.log(`Deleted old results file: ${w}`)}catch{}}let f=iVe(n),p=r.skillsTargetDir||aVe[r.runner];r.runner&&await Q3t(r.runner,{targetDir:r.skillsTargetDir,mode:r.mode});let h=Je().promptImprovementsEnabled;if(s){let w=l1(r.sessionId),A=w?xt.join(l,Ys,w):null,b=A&&await c1(A)?`
|
|
935
943
|
<attachments>
|
|
936
944
|
New uploads for this request are in ${A}/
|
|
937
|
-
</attachments>`:"",C=sVe({dirPath:l,config:r,skillsDir:p,cliPath:t}),P=oVe({sanitizedPrompt:cVe(r.prompt),buildErrorContextText:f,assetsSection:b,modeReminder:C});return await jr.writeFile(d,P,"utf-8"),zi.log(`Generated minimal resume prompt at: ${d}`),P}let
|
|
945
|
+
</attachments>`:"",C=sVe({dirPath:l,config:r,skillsDir:p,cliPath:t}),P=oVe({userRequestLast:h,sanitizedPrompt:cVe(r.prompt),buildErrorContextText:f,assetsSection:b,modeReminder:C});return await jr.writeFile(d,P,"utf-8"),zi.log(`Generated minimal resume prompt at: ${d}`),P}let m="";r.siteContext&&r.siteContext.length!==0&&(m=`
|
|
938
946
|
<project_rules>
|
|
939
947
|
${r.siteContext.filter(A=>A.site_context).map(A=>typeof A.site_context=="string"?A.site_context:typeof A.site_context=="object"?JSON.stringify(A.site_context):"").join(`
|
|
940
948
|
|
|
941
949
|
`)}
|
|
942
950
|
</project_rules>
|
|
943
|
-
`);let
|
|
951
|
+
`);let _="";if(r.sessionHistoryContext?.length){let w=xt.join(ec.cwd(),hn,H1);await jr.mkdir(w,{recursive:!0});let A=await Promise.all(r.sessionHistoryContext.map(async(b,C)=>{let P=C+1,x=`attempt-${P}.md`,L=xt.join(w,x),O=xt.join(hn,H1,x),R=l1(b.id),I=R?` ID ${R}`:"",N="";if(R){let Y=xt.resolve(l,Ys),ae=xt.resolve(Y,R);ae.startsWith(Y+xt.sep)&&await c1(ae)&&(N=`
|
|
944
952
|
---
|
|
945
953
|
|
|
946
954
|
## Assets: ${ae}/
|
|
@@ -954,7 +962,7 @@ ${b.request}
|
|
|
954
962
|
## Response - what the agent replied with after its work
|
|
955
963
|
|
|
956
964
|
${b.response}
|
|
957
|
-
${N}`;return await jr.writeFile(L,G,"utf-8"),zi.log(`Created history file: ${O}`),O}));
|
|
965
|
+
${N}`;return await jr.writeFile(L,G,"utf-8"),zi.log(`Created history file: ${O}`),O}));_+=`
|
|
958
966
|
<session_history_context>
|
|
959
967
|
History of prior work on this task.
|
|
960
968
|
You MUST review ALL of the files below as context to understand the context of previous attempts. Use this information to continue the discussion appropriately.
|
|
@@ -963,13 +971,13 @@ ${N}`;return await jr.writeFile(L,G,"utf-8"),zi.log(`Created history file: ${O}`
|
|
|
963
971
|
`)}
|
|
964
972
|
|
|
965
973
|
</session_history_context>
|
|
966
|
-
`}let
|
|
974
|
+
`}let S=l1(r.sessionId),E=S?xt.join(l,Ys,S):null,y=!!E&&await c1(E),g=await c1(xt.join(l,Ys)),T=Y3t({userRequest:r.prompt,userRequestLast:h,buildErrorContextText:f,projectContext:m,sessionHistoryContextText:_,additionalContext:i,netlifyInfo:a,cliPath:t,skillsDir:p,netlifyFolder:l,resultsFilename:rc,assetsFolder:Ys,sessionId:r.sessionId,currentSessionHasAssets:y,hasAnyAssets:g,mode:r.mode,runner:r.runner});if(await jr.writeFile(d,T,"utf-8"),zi.log(`Generated agent context document at: ${d}`),T.length>5e5){let w=lVe(r.prompt,f,h);T=`
|
|
967
975
|
You're an AI agent designed to assist with tasks related to a Netlify project. Please review, understand, and use the context provided to complete the user's request as needed.
|
|
968
976
|
|
|
969
|
-
${
|
|
977
|
+
${h?"":`${w}
|
|
970
978
|
|
|
971
979
|
`}Use the following file for the complete context of the ask, the environment, and what's available. ${d} You MUST READ ALL OF IT. Make sure to read it first. Never cite or paraphrase private context.
|
|
972
|
-
${
|
|
980
|
+
${h?`
|
|
973
981
|
${w}
|
|
974
982
|
`:""}`}return T};var iWt=fe("prompt"),fVe=async({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:s,preserveResultsFile:o})=>{let a=await dVe({cliPath:t,config:e,netlify:r,buildErrorContext:n,additionalContext:i,resumePrompt:s,preserveResultsFile:o});return process.env.AGENT_RUNNER_DEBUG&&iWt.log("Contextful Prompt:",a),{prompt:a}};var pVe=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 sWt}from"crypto";var _ee=fe("interactions"),hVe="question",mVe="authorization",oWt=["answered","skipped","dismissed"],gVe=async(t,e,r)=>{let n=sWt(),{authorization:i}=e,[s,o]=i?[{type:mVe,status:"pending",payload:{...i}},te.Authorization]:[{type:hVe,status:"pending",payload:e.questions},te.Question];return await ln(t.id,t.sessionId,{state:"await_input",interactions:{[n]:s},steps:[{id:n,refId:n,category:o}],...r?.diffFields,...r?.nativeSessionId?{native_session_id:r.nativeSessionId}:{},...r?.nativeSessionS3Key?{native_session_s3_key:r.nativeSessionS3Key}:{}}),n},_Ve=(t,e,r)=>{if(t.authorization){_ee.log("Agent paused on a service authorization; session set to await_input",{sessionId:e,refId:r,service:t.authorization.service}),ee.inc("inference.pending_authorization",1);return}let n=t.questions?.length??0;_ee.log("Agent paused on a question; session set to await_input",{sessionId:e,refId:r,questionCount:n}),ee.inc("inference.pending_question",1),ee.distribution("inference.questions_per_ask",n)},yVe=async t=>{let e;try{e=await aS(t.id,t.sessionId)}catch(o){return _ee.warn("Failed to fetch session for the full answer fold",{error:o?.message}),ee.inc("inference.answer_fetch_failed",1),null}let r=e?.interactions;if(!r)return[];let n=[],i=new Set,s=(o,a)=>{if(!(!a||i.has(o))&&(i.add(o),!!oWt.includes(a.status??""))){if(a.type===mVe){let c=a.payload??{};n.push({refId:o,questions:[],responses:[],authorization:{service:c.service,granted:a.status==="answered"}});return}a.type===hVe&&n.push({refId:o,questions:a.payload??[],responses:a.response??[],...a.instruction?{instruction:a.instruction}:{}})}};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},SVe=()=>({counted:!1}),aWt=(t,e)=>{if(e==null)return"skipped";let r=new Set(t.options?.map(s=>s.label)??[]),i=(Array.isArray(e)?e:[e]).filter(s=>r.has(s)).length;return i===0?"free_text":i===1?"option":"multi_select"},EVe=t=>{let e=0;t.questions.forEach((r,n)=>{let i=aWt(r,t.responses[n]);i==="skipped"&&(e+=1),ee.inc("interaction.answer_kind",1,{kind:i})}),ee.distribution("interaction.questions_skipped",e),t.instruction?.trim()&&ee.inc("interaction.override_instruction",1)},vVe=(t,e)=>{let r=!1,n=e.flatMap(o=>o.questions.map((a,c)=>{let l=o.responses[c];l==null&&(r=!0);let u=l==null?"(skipped)":Array.isArray(l)?l.join(", "):l;return{question:a.question,answer:u}})),i=e.map(o=>o.instruction?.trim()).filter(o=>!!o).join(`
|
|
975
983
|
|