@netlify/agent-runner-cli 2.18.0-smtp.0 → 2.18.0-smtp.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.js CHANGED
@@ -602,7 +602,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
602
602
  `,LF:`
603
603
  `,concatBytes:E7},oBt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},aBt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:oBt};import{Buffer as cBt}from"buffer";var OMe=(t,e)=>t?void 0:uBt.bind(void 0,e),uBt=function*(t,e){if(typeof e!="string"&&!In(e)&&!cBt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},PMe=(t,e)=>t?lBt.bind(void 0,e):dBt.bind(void 0,e),lBt=function*(t,e){CMe(t,e),yield e},dBt=function*(t,e){if(CMe(t,e),typeof e!="string"&&!In(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},CMe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
604
604
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
605
- if (condition) { yield value; }`)};import{Buffer as fBt}from"buffer";import{StringDecoder as pBt}from"string_decoder";var OU=(t,e,r)=>{if(r)return;if(t)return{transform:hBt.bind(void 0,new TextEncoder)};let n=new pBt(e);return{transform:mBt.bind(void 0,n),final:gBt.bind(void 0,n)}},hBt=function*(t,e){fBt.isBuffer(e)?yield kl(e):typeof e=="string"?yield t.encode(e):yield e},mBt=function*(t,e){yield In(e)?t.write(e):e},gBt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as kMe}from"util";var w7=kMe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),PU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=yBt}=e[r];for await(let i of n(t))yield*PU(i,e,r+1)},NMe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*_Bt(r,Number(e),t)},_Bt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*PU(n,r,e+1)},$Me=kMe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),yBt=function*(t){yield t};var T7=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},DMe=(t,e)=>[...e.flatMap(r=>[...zm(r,t,0)]),...Dx(t)],zm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=vBt}=e[r];for(let i of n(t))yield*zm(i,e,r+1)},Dx=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*SBt(r,Number(e),t)},SBt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*zm(n,r,e+1)},vBt=function*(t){yield t};var R7=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=MMe(t,o,s),u=jm(e),l=jm(r),d=u?w7.bind(void 0,PU,a):T7.bind(void 0,zm),f=u||l?w7.bind(void 0,NMe,a):T7.bind(void 0,Dx),p=u||l?$Me.bind(void 0,a):void 0;return{stream:new EBt({writableObjectMode:n,writableHighWaterMark:LMe(n),readableObjectMode:i,readableHighWaterMark:LMe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},CU=(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=MMe(o,r,a);t=DMe(c,t)}return t},MMe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:OMe(n,a)},OU(r,o,n),xU(r,s,n,c),{transform:t,final:e},{transform:PMe(i,a)},xMe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var UMe=(t,e)=>{for(let r of bBt(t))wBt(t,r,e)},bBt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),wBt=(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 ${Ff[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>TBt(a,n));r.input=Rx(o)},TBt=(t,e)=>{let r=CU(t,e,"utf8",!0);return RBt(r),Rx(r)},RBt=t=>{let e=t.find(r=>typeof r!="string"&&!In(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 OBt,appendFileSync as PBt}from"fs";var kU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sv(r,n)&&!so.has(e)&&ABt(n)&&(t.some(({type:i,value:s})=>i==="native"&&IBt.has(s))||t.every(({type:i})=>na.has(i))),ABt=t=>t===1||t===2,IBt=new Set(["pipe","overlapped"]),FMe=async(t,e,r,n)=>{for await(let i of t)xBt(e)||zMe(i,r,n)},jMe=(t,e,r)=>{for(let n of t)zMe(n,e,r)},xBt=t=>t._readableState.pipes.length>0,zMe=(t,e,r)=>{let n=G1(t);uu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var qMe=({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,u)=>CBt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},CBt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=BLe(t,s,d),p=kl(f),{stdioItems:h,objectMode:m}=e[r],g=kBt([p],h,c,n),{serializedResult:y,finalResult:v=y}=NBt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});$Bt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&DBt(y,h,i),S}catch(_){return n.error=_,S}},kBt=(t,e,r,n)=>{try{return CU(t,e,r,!1)}catch(i){return n.error=i,t}},NBt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Rx(t)};let o=n$e(t,r);return n[s]?{serializedResult:o,finalResult:b7(o,!i[s],e)}:{serializedResult:o}},$Bt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!kU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=b7(t,!1,o);try{jMe(a,e,n)}catch(c){r.error??=c}},DBt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>AU.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?PBt(n,t):(r.add(s),OBt(n,t))}};var BMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Dl(e,r,"all")]:Array.isArray(e)?[Dl(t,r,"all"),...e]:In(t)&&In(e)?CQ([t,e]):`${t}${e}`};import{once as A7}from"events";var VMe=async(t,e)=>{let[r,n]=await LBt(t);return e.isForcefullyTerminated??=!1,[r,n]},LBt=async t=>{let[e,r]=await Promise.allSettled([A7(t,"spawn"),A7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?HMe(t):r.value},HMe=async t=>{try{return await A7(t,"exit")}catch{return HMe(t)}},GMe=async t=>{let[e,r]=await t;if(!MBt(e,r)&&I7(e,r))throw new tc;return[e,r]},MBt=(t,e)=>t===void 0&&e===void 0,I7=(t,e)=>t!==0||e!==null;var WMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=UBt(t,e,r),o=s?.code==="ETIMEDOUT",a=qLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},UBt=(t,e,r)=>t!==void 0?t:I7(e,r)?new tc:void 0;var KMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=jBt(t,e,r),d=BBt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return Ov(d,c,u)},jBt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=K1(t,e,r),a=zBt(r),{file:c,commandArguments:u,options:l}=hU(t,e,a);qBt(l);let d=TMe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},zBt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,qBt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&NU("ipcInput"),t&&NU("ipc: true"),r&&NU("detached: true"),n&&NU("cancelSignal")},NU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},BBt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=VBt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=WMe(c,r),{output:h,error:m=u}=qMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((v,S)=>Dl(v,r,S)),y=Dl(BMe(h,r),r,"all");return GBt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},VBt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{UMe(s,r);let a=HBt(r);return FBt(...mU(t,e,a))}catch(a){return xv({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},HBt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:bU(e)}),GBt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?wU({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):$x({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as NVt}from"events";import{spawn as $Vt}from"child_process";import QMe from"process";import{once as x7,on as WBt}from"events";var YMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(bv({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:cU(t)}),KBt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),KBt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{iU(e,i);let s=Uf(t,e,r),o=new AbortController;try{return await Promise.race([YBt(s,n,o),JBt(s,r,o),ZBt(s,r,o)])}catch(a){throw wv(t),a}finally{o.abort(),sU(e,i)}},YBt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await x7(t,"message",{signal:r});return n}for await(let[n]of WBt(t,"message",{signal:r}))if(e(n))return n},JBt=async(t,e,{signal:r})=>{await x7(t,"disconnect",{signal:r}),DDe(e)},ZBt=async(t,e,{signal:r})=>{let[n]=await x7(t,"strict:error",{signal:r});throw tU(n,e)};import{once as ZMe,on as XBt}from"events";var XMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>O7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),O7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{bv({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:cU(t)}),iU(e,s);let o=Uf(t,e,r),a=new AbortController,c={};return QBt(t,o,a),e2t({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),t2t({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},QBt=async(t,e,r)=>{try{await ZMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},e2t=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ZMe(t,"strict:error",{signal:r.signal});n.error=tU(i,e),r.abort()}catch{}},t2t=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of XBt(r,"message",{signal:s.signal}))JMe(o),yield c}catch{JMe(o)}finally{s.abort(),sU(e,a),n||wv(t),i&&await t}},JMe=({error:t})=>{if(t)throw t};var e1e=(t,{ipc:e})=>{Object.assign(t,r1e(t,!1,e))},t1e=()=>{let t=QMe,e=!0,r=QMe.channel!==void 0;return{...r1e(t,e,r),getCancelSignal:cLe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},r1e=(t,e,r)=>({sendMessage:fU.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:YMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:XMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as r2t}from"child_process";import{PassThrough as n2t,Readable as i2t,Writable as s2t,Duplex as o2t}from"stream";var n1e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{S7(n);let a=new r2t;a2t(a,n),Object.assign(a,{readable:c2t,writable:u2t,duplex:l2t});let c=xv({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=d2t(c,o,i);return{subprocess:a,promise:u}},a2t=(t,e)=>{let r=Lx(),n=Lx(),i=Lx(),s=Array.from({length:e.length-3},Lx),o=Lx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Lx=()=>{let t=new n2t;return t.end(),t},c2t=()=>new i2t({read(){}}),u2t=()=>new s2t({write(){}}),l2t=()=>new o2t({read(){},write(){}}),d2t=async(t,e,r)=>Ov(t,e,r);import{createReadStream as i1e,createWriteStream as s1e}from"fs";import{Buffer as f2t}from"buffer";import{Readable as Mx,Writable as p2t,Duplex as h2t}from"stream";var a1e=(t,e)=>IU(m2t,t,e,!1),Ux=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ff[t]}.`)},o1e={fileNumber:Ux,generator:R7,asyncGenerator:R7,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:h2t.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},m2t={input:{...o1e,fileUrl:({value:t})=>({stream:i1e(t)}),filePath:({value:{file:t}})=>({stream:i1e(t)}),webStream:({value:t})=>({stream:Mx.fromWeb(t)}),iterable:({value:t})=>({stream:Mx.from(t)}),asyncIterable:({value:t})=>({stream:Mx.from(t)}),string:({value:t})=>({stream:Mx.from(t)}),uint8Array:({value:t})=>({stream:Mx.from(f2t.from(t))})},output:{...o1e,fileUrl:({value:t})=>({stream:s1e(t)}),filePath:({value:{file:t,append:e}})=>({stream:s1e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:p2t.fromWeb(t)}),iterable:Ux,asyncIterable:Ux,string:Ux,uint8Array:Ux}};import{on as g2t,once as c1e}from"events";import{PassThrough as _2t,getDefaultHighWaterMark as y2t}from"stream";import{finished as d1e}from"stream/promises";function qm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)C7(i);let e=t.some(({readableObjectMode:i})=>i),r=S2t(t,e),n=new P7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var S2t=(t,e)=>{if(t.length===0)return y2t(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},P7=class extends _2t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(C7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=v2t(this,this.#e,this.#s);let r=w2t({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(C7(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)}},v2t=async(t,e,r)=>{$U(t,u1e);let n=new AbortController;try{await Promise.race([E2t(t,n),b2t(t,e,r,n)])}finally{n.abort(),$U(t,-u1e)}},E2t=async(t,{signal:e})=>{try{await d1e(t,{signal:e,cleanup:!0})}catch(r){throw f1e(t,r),r}},b2t=async(t,e,r,{signal:n})=>{for await(let[i]of g2t(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},C7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},w2t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{$U(t,l1e);let a=new AbortController;try{await Promise.race([T2t(s,e,a),R2t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),A2t({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),$U(t,-l1e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?k7(t):I2t(t))},T2t=async(t,e,{signal:r})=>{try{await t,r.aborted||k7(e)}catch(n){r.aborted||f1e(e,n)}},R2t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await d1e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;p1e(o)?i.add(e):h1e(t,o)}},A2t=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await c1e(t,i,{signal:s}),!t.readable)return c1e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},I2t=t=>{t.writable&&t.end()},f1e=(t,e)=>{p1e(e)?k7(t):h1e(t,e)},p1e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",k7=t=>{(t.readable||t.writable)&&t.destroy()},h1e=(t,e)=>{t.destroyed||(t.once("error",x2t),t.destroy(e))},x2t=()=>{},$U=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},u1e=2,l1e=1;import{finished as m1e}from"stream/promises";var Cv=(t,e)=>{t.pipe(e),O2t(t,e),P2t(t,e)},O2t=async(t,e)=>{if(!(ec(t)||ec(e))){try{await m1e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}N7(e)}},N7=t=>{t.writable&&t.end()},P2t=async(t,e)=>{if(!(ec(t)||ec(e))){try{await m1e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}$7(t)}},$7=t=>{t.readable&&t.destroy()};var g1e=(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})=>na.has(c)))C2t(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!na.has(c)))N2t({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]:qm(s);Cv(o,i)}},C2t=(t,e,r,n)=>{r==="output"?Cv(t.stdio[n],e):Cv(e,t.stdio[n]);let i=k2t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},k2t=["stdin","stdout","stderr"],N2t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;$2t(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},$2t=(t,{signal:e})=>{ec(t)&&Um(t,D2t,e)},D2t=2;import{addAbortListener as U2t}from"events";var Bm=[];Bm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var DU=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",D7=Symbol.for("signal-exit emitter"),L7=globalThis,L2t=Object.defineProperty.bind(Object),M7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(L7[D7])return L7[D7];L2t(L7,D7,{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}},LU=class{},M2t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),U7=class extends LU{onExit(){return()=>{}}load(){}unload(){}},F7=class extends LU{#e=j7.platform==="win32"?"SIGINT":"SIGHUP";#r=new M7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Bm)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(!DU(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 Bm)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,Bm.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 DU(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"&&DU(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)}},j7=globalThis.process,{onExit:_1e,load:hHr,unload:mHr}=M2t(DU(j7)?new F7(j7):new U7);var y1e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=_1e(()=>{t.kill()});U2t(n,()=>{i()})};var v1e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=W1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=F2t(r,n,i),{sourceStream:d,sourceError:f}=z2t(t,u),{options:p,fileDescriptors:h}=du.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},F2t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=j2t(t,e,...r),a=nU(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},j2t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(S1e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||OQ(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]=M1(r,...n);return{destination:e(S1e)(i,s,o),pipeOptions:o}}if(du.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}`)},S1e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),z2t=(t,e)=>{try{return{sourceStream:Tv(t,e)}}catch(r){return{sourceError:r}}};var b1e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=q2t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw z7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},q2t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return $7(t),n;if(e!==void 0)return N7(r),e},z7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>xv({error:t,command:E1e,escapedCommand:E1e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),E1e="source.pipe(destination)";var w1e=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 B2t}from"stream/promises";var T1e=(t,e,r)=>{let n=MU.has(e)?H2t(t,e):V2t(t,e);return Um(t,W2t,r.signal),Um(e,K2t,r.signal),G2t(e),n},V2t=(t,e)=>{let r=qm([t]);return Cv(r,e),MU.set(e,r),r},H2t=(t,e)=>{let r=MU.get(e);return r.add(t),r},G2t=async t=>{try{await B2t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}MU.delete(t)},MU=new WeakMap,W2t=2,K2t=1;import{aborted as Y2t}from"util";var R1e=(t,e)=>t===void 0?[]:[J2t(t,e)],J2t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Y2t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw z7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var UU=(t,...e)=>{if(rn(e[0]))return UU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=v1e(t,...e),i=Z2t({...n,destination:r});return i.pipe=UU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Z2t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=X2t(t,i);b1e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=T1e(e,s,d);return await Promise.race([w1e(l),...R1e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},X2t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as sVt}from"timers/promises";import{on as Q2t}from"events";import{getDefaultHighWaterMark as eVt}from"stream";var FU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return tVt(e,o),I1e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},tVt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},q7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;rVt(e,o,t);let a=t.readableObjectMode&&!s;return I1e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},rVt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},I1e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=Q2t(t,"data",{signal:e.signal,highWaterMark:A1e,highWatermark:A1e});return nVt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},B7=eVt(!0),A1e=B7,nVt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=iVt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*zm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Dx(a)}},iVt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[OU(t,r,!e),xU(t,i,!n,{})].filter(Boolean);var x1e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=oVt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([aVt(t),d]);return}let f=v7(c,r),p=q7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([cVt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},oVt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!kU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=q7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await FMe(a,t,r,s)},aVt=async t=>{await sVt(),t.readableFlowing===null&&t.resume()},cVt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await SU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await vU(r,{maxBuffer:s})):await Iv(r,{maxBuffer:s})}catch(a){return O1e(FLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},V7=async t=>{try{return await t}catch(e){return O1e(e)}},O1e=({bufferedData:t})=>t$e(t)?new Uint8Array(t):t;import{finished as uVt}from"stream/promises";var Fx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=lVt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],uVt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||pVt(a,e,r,n)}finally{o.abort()}},lVt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&dVt(t,r,n),n},dVt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{fVt(e,r),n.call(t,...i)}},fVt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},pVt=(t,e,r,n)=>{if(!hVt(t,e,r,n))throw t},hVt=(t,e,r,n=!0)=>r.propagating?P1e(t)||jU(t):(r.propagating=!0,H7(r,e)===n?P1e(t):jU(t)),H7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",jU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",P1e=t=>t?.code==="EPIPE";var C1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>G7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),G7=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=Fx(t,e,u);if(H7(u,e)){await l;return}let[d]=await Promise.all([x1e({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var k1e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?qm([t,e].filter(Boolean)):void 0,N1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>G7({...mVt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:gVt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),mVt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},gVt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as _Vt}from"events";var $1e=t=>Sv(t,"ipc"),D1e=(t,e)=>{let r=G1(t);uu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var L1e=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=$1e(s),a=Nl(e,"ipc"),c=Nl(r,"ipc");for await(let u of O7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(jLe(t,i,c),i.push(u)),o&&D1e(u,s);return i},M1e=async(t,e)=>(await Promise.allSettled([t]),e);var U1e=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:y})=>{let v=VMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},_=C1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=N1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=L1e({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=yVt(m,t,S),x=SVt(h,S);try{return await Promise.race([Promise.all([{},GMe(v),Promise.all(_),w,R,yLe(t,d),...T,...x]),g,vVt(t,y),...pLe(t,s,f,y),...$De({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...dLe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},v,Promise.all(_.map(O=>V7(O))),V7(w),M1e(R,b),Promise.allSettled(T),Promise.allSettled(x)])}},yVt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Fx(n,i,r)),SVt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>nc(s,{checkOpen:!1})&&!ec(s)).map(({type:i,value:s,stream:o=s})=>Fx(o,n,e,{isSameDirection:na.has(i),stopOnExit:i==="native"}))),vVt=async(t,{signal:e})=>{let[r]=await _Vt(t,"error",{signal:e});throw r};var F1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),jx=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=lu();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},kv=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 EVt}from"stream";import{callbackify as bVt}from"util";import{finished as j1e}from"stream/promises";var W7=async t=>{if(t!==void 0)try{await K7(t)}catch{}},z1e=async t=>{if(t!==void 0)try{await Y7(t)}catch{}},K7=async t=>{await j1e(t,{cleanup:!0,readable:!1,writable:!0})},Y7=async t=>{await j1e(t,{cleanup:!0,readable:!0,writable:!1})},zU=async(t,e)=>{if(await t,e)throw e},qU=(t,e,r)=>{r&&!jU(r)?t.destroy(r):e&&t.destroy()};var q1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||so.has(r),{subprocessStdout:a,waitReadableDestroy:c}=J7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=Z7(a,o),{read:f,onStdoutDataDone:p}=X7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new EVt({read:f,destroy:bVt(eee.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return Q7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},J7=(t,e,r)=>{let n=Tv(t,e),i=jx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Z7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:B7},X7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=lu(),o=FU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){wVt(this,o,s)},onStdoutDataDone:s}},wVt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Q7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Y7(t),await n,await W7(i),await e,r.readable&&r.push(null)}catch(s){await W7(i),B1e(r,s)}},eee=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await kv(r,e)&&(B1e(t,n),await zU(e,n))},B1e=(t,e)=>{qU(t,t.readable,e)};import{Writable as TVt}from"stream";import{callbackify as V1e}from"util";var H1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=tee(t,r,e),o=new TVt({...ree(n,t,i),destroy:V1e(iee.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return nee(n,o),o},tee=(t,e,r)=>{let n=nU(t,e),i=jx(r,n,"writableFinal"),s=jx(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},ree=(t,e,r)=>({write:RVt.bind(void 0,t),final:V1e(AVt.bind(void 0,t,e,r))}),RVt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},AVt=async(t,e,r)=>{await kv(r,e)&&(t.writable&&t.end(),await e)},nee=async(t,e,r)=>{try{await K7(t),e.writable&&e.end()}catch(n){await z1e(r),G1e(e,n)}},iee=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await kv(r,e),await kv(n,e)&&(G1e(t,i),await zU(e,i))},G1e=(t,e)=>{qU(t,t.writable,e)};import{Duplex as IVt}from"stream";import{callbackify as xVt}from"util";var W1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||so.has(r),{subprocessStdout:c,waitReadableDestroy:u}=J7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=tee(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Z7(c,a),{read:g,onStdoutDataDone:y}=X7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new IVt({read:g,...ree(l,t,d),destroy:xVt(OVt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return Q7({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),nee(l,v,c),v},OVt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([eee({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),iee({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var see=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||so.has(e),o=Tv(t,r),a=FU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return PVt(a,o,t)},PVt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var K1e=(t,{encoding:e})=>{let r=F1e();t.readable=q1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=H1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=W1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=see.bind(void 0,t,e),t[Symbol.asyncIterator]=see.bind(void 0,t,e,{})};var Y1e=(t,e)=>{for(let[r,n]of kVt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},CVt=(async()=>{})().constructor.prototype,kVt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(CVt,t)]);var J1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=DVt(t,e,r),{subprocess:f,promise:p}=MVt({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=UU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Y1e(f,p),du.set(f,{options:l,fileDescriptors:d}),f},DVt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=K1(t,e,r),{file:a,commandArguments:c,options:u}=hU(t,e,r),l=LVt(u),d=a1e(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},LVt=({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}},MVt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=$Vt(...mU(t,e,r))}catch(h){return n1e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;NVt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];g1e(c,a,u),y1e(c,r,u);let d={},f=lu();c.kill=kDe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=k1e(c,r),K1e(c,r),e1e(c,r);let p=UVt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},UVt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,g]=await U1e({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((_,w)=>Dl(_,e,w)),v=Dl(m,e,"all"),S=FVt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ov(S,n,e)},FVt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?$x({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof fu,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):wU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var BU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,jVt(n,t[n],i)]));return{...t,...r}},jVt=(t,e,r)=>zVt.has(t)&&rn(e)&&rn(r)?{...e,...r}:r,zVt=new Set(["env",...DQ]);var jf=(t,e,r,n)=>{let i=(o,a,c)=>jf(o,a,r,c),s=(...o)=>qVt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},qVt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(rn(s))return i(t,BU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=BVt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?KMe(a,c,u):J1e(a,c,u,i)},BVt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=a$e(e)?c$e(e,r):[e,...r],[o,a,c]=M1(...s),u=BU(BU(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var Z1e=({file:t,commandArguments:e})=>Q1e(t,e),X1e=({file:t,commandArguments:e})=>({...Q1e(t,e),isSync:!0}),Q1e=(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]=VVt(t);return{file:r,commandArguments:n}},VVt=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(HVt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},HVt=/ +/g;var eUe=(t,e,r)=>{t.sync=e(GVt,r),t.s=t.sync},tUe=({options:t})=>rUe(t),GVt=({options:t})=>({...rUe(t),isSync:!0}),rUe=t=>({options:{...WVt(t),...t}}),WVt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},nUe={preferLocal:!0};var iUe=jf(()=>({})),i6r=jf(()=>({isSync:!0})),sUe=jf(Z1e),s6r=jf(X1e),o6r=jf(mLe),a6r=jf(tUe,{},nUe,eUe),{sendMessage:c6r,getOneMessage:u6r,getEachMessage:l6r,getCancelSignal:d6r}=t1e();import{Transform as KVt}from"stream";var YVt=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function JVt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...YVt])]}function ZVt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function XVt(){let e=JVt().map(r=>process.env[r]).filter(r=>!(!r||ZVt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function vi(t){if(typeof t!="string")return t;let e=XVt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(QVt(n),"g");r=r.replace(i,"******")}),r}function QVt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var zx=class extends KVt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=vi(i);n(null,s)}},VU=Symbol("maskedWrite");function oUe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[VU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?vi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[VU]=!0,process.stdout.write=r}if(!process.stderr.write[VU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?vi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[VU]=!0,process.stderr.write=r}}}var aUe=!1,cUe,oee=t=>{cUe??=t},uUe=t=>{aUe=!0,oee(t)},nn=()=>aUe,ia=()=>cUe,lUe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var qx=null,dUe=t=>(qx&&qx.destroy(),qx=new sa({totalAllowedTime:t}),qx),fUe=()=>qx;var sa=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&&nn())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((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await zD({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),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 pUe={name:"@netlify/agent-runner-cli",type:"module",version:"2.18.0-smtp.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","build:bundle":"tsup --no-dts",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build:bundle 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:antigravity":"vitest run test/integration/antigravity.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",prompts:"LOG=0 vitest run --config vitest.prompts.config.js","site:build":"npm run prompts && node site/build.mjs","site:dev":"npm run site:build && netlify dev --dir site/dist",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.7","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.8.0","@opentelemetry/sdk-trace-base":"2.9.0","@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.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.3","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var nHt=tHt(import.meta.url),iHt=Ll.dirname(nHt),sHt=rHt(import.meta.url),Nv=he("shell"),aee=new Set,hUe={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=oHt(e,r),s={...hUe,...i},o=iUe(t,n,s);gUe(o,s),SUe(o);let a=r?.idleTimeout;return a&&a>0&&yUe(o,a),o},mUe=(t,e)=>{let r={...hUe,...e},n=sUe(t,r);return gUe(n,r),SUe(n),e?.idleTimeout&&e.idleTimeout>0&&yUe(n,e.idleTimeout),n},oHt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},gUe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||hu.env.NETLIFY_LOCAL_QUIET==="true")return;if(hu.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new zx).pipe(hu.stdout),t.stderr?.pipe(new zx).pipe(hu.stderr);return}t.stdout?.pipe(hu.stdout),t.stderr?.pipe(hu.stderr)},cee=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(hu.kill(-t.pid,e),Nv.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Nv.error("Error killing process:",r),!1}},_Ue=t=>cee(t,"SIGKILL"),yUe=(t,e)=>{let r=null,n=()=>{Nv.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),cee(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nv.log(`Force killing idle process ${t.pid}`),_Ue(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)},SUe=t=>{aee.add(t);let e=fUe();if(e){let r=e.onTimesUp(()=>{Nv.log(`Global timer expired, killing process ${t.pid}`),cee(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nv.log(`Force killing process ${t.pid} after timeout`),_Ue(t))},5e3)});t.on("exit",()=>{aee.delete(t),r()}),t.on("error",()=>{aee.delete(t),r()})}};function mu(t,e){if(!hu.env.NETLIFY_LOCAL_MODE)try{let i=sHt.resolve(pUe.name),s=Ll.dirname(i);for(;s!==Ll.dirname(s);){let o=Ll.dirname(s);if(Ll.basename(o)==="node_modules"){let a=Ll.join(o,".bin",e);if(HU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(hu.env.NODE_PATH){let i=Ll.join(hu.env.NODE_PATH,".bin",e);if(HU.existsSync(i))return i}let r=Ll.join(t,"node_modules",".bin",e);if(HU.existsSync(r))return r;let n=Ll.join(iHt,"..","node_modules",".bin",e);if(HU.existsSync(n))return n}import Wq from"process";import{fileURLToPath as AQt}from"url";import{createRequire as IQt}from"module";import zO from"path";import{readFileSync as xQt}from"fs";var aHt="__netlify__getTracer",cHt="__netlify__shutdownTracers",Lt=(t,e)=>globalThis[aHt]?.(t,e),vUe=async()=>globalThis[cHt]?.();function Bx(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{createHash as pQt}from"crypto";import{setTimeout as hQt}from"timers/promises";Fe();import rGt from"process";Fe();var uHt=(t,e)=>{e.recordException(t),e.setStatus({code:Fn.ERROR})};var Ml=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}=EUe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>bUe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=EUe(r,n,i),c=this._tracer.startSpan(e,s,o);return bUe(c,s,a)}};function EUe(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??ir.active(),{opts:n,ctx:i,fn:s}}function bUe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:uHt,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)}}Fe();var Dv=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var lee=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=kUe(e),n._asyncAttributesPending=e.filter(([i,s])=>Dv(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Dv(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=kUe(this._rawAttributes),this._schemaUrl=lHt(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,Dv(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ge.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Dv(n)){ge.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=dHt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function dee(t,e){return lee.FromAttributeList(Object.entries(t),e)}function kUe(t){return t.map(([e,r])=>Dv(r)?[e,r.catch(n=>{ge.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function lHt(t){if(typeof t=="string"||t===void 0)return t;ge.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function dHt(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;ge.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Fe();var Vx=class{emit(e){}enabled(){return!1}},NUe=new Vx;var Hx=Symbol.for("io.opentelemetry.js.api.logs"),Lv=globalThis;function $Ue(t,e,r){return n=>n===t?e:r}var fee=1;var pee=class{getLogger(e,r,n){return new Vx}},KU=new pee;var YU=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):NUe}};var Gx=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new YU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:KU}_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 JU=class t{constructor(){this._proxyLoggerProvider=new Gx}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Lv[Hx]?this.getLoggerProvider():(Lv[Hx]=$Ue(fee,e,KU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Lv[Hx])===null||e===void 0?void 0:e.call(Lv,fee))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Lv[Hx],this._proxyLoggerProvider=new Gx}};var DUe=JU.getInstance();function LUe(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 MUe(t){t.forEach(e=>e.disable())}function hee(t){let e=t.tracerProvider||jt.getTracerProvider(),r=t.meterProvider||VA.getMeterProvider(),n=t.loggerProvider||DUe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return LUe(i,e,r,n),()=>{MUe(i)}}Fe();var fHt=Un("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function UUe(t){return t.getValue(fHt)===!0}var Mv;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Mv||(Mv={}));Fe();var mee="[_0-9a-z-*/]",pHt=`[a-z]${mee}{0,255}`,hHt=`[a-z0-9]${mee}{0,240}@[a-z]${mee}{0,13}`,mHt=new RegExp(`^(?:${pHt}|${hHt})$`),gHt=/^[ -~]{0,255}[!-~]$/,_Ht=/,|=/;function gee(t){return mHt.test(t)}function _ee(t){return gHt.test(t)&&!_Ht.test(t)}var yHt=32,FUe=512,jUe=",",zUe="=",ZU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!gee(e)||!_ee(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>FUe)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=jUe+e),e=`${n[0]}${zUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(jUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(zUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!gee(a)||!_ee(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>FUe)&&(r.set(a,c),n=u,r.size>=yHt))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 XU="traceparent",QU="tracestate",SHt="00",vHt="(?!ff)[\\da-f]{2}",EHt="(?![0]{32})[\\da-f]{32}",bHt="(?![0]{16})[\\da-f]{16}",wHt="[\\da-f]{2}",THt=new RegExp(`^\\s?(${vHt})-(${EHt})-(${bHt})-(${wHt})(-.*)?\\s?$`);function qUe(t){let e=THt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var zf=class{inject(e,r,n){let i=jt.getSpanContext(e);if(!i||UUe(e)||!Rs(i))return;let s=`${SHt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Cr.NONE).toString(16)}`;n.set(r,XU,s),i.traceState&&n.set(r,QU,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,XU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=qUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,QU);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new ZU(typeof c=="string"?c:void 0)}return jt.setSpanContext(e,o)}fields(){return[XU,QU]}};var eF=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 Wx=class{_isCalled=!1;_deferred=new eF;_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 WF=bn(ste(),1);Fe();var jze=t=>{throw TypeError(t)},ute=(t,e,r)=>e.has(t)||jze("Cannot "+r),GF=(t,e,r)=>(ute(t,e,"read from private field"),r?r.call(t):e.get(t)),ote=(t,e,r)=>e.has(t)?jze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Mze=(t,e,r,n)=>(ute(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),tGt=(t,e,r)=>(ute(t,e,"access private method"),r),Uze="__netlify__getTracer",nGt="__netlify__shutdownTracers",iGt="__nfOTLPTrace",f0,p0,cte,zze,sGt=class{constructor(){ote(this,cte),ote(this,f0),ote(this,p0),Mze(this,f0,new Wx(tGt(this,cte,zze),this)),Mze(this,p0,ge.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(GF(this,p0).debug(`export ${t.length.toString()} spans`),GF(this,f0).isCalled){e({code:Mv.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(iGt,JSON.stringify(oGt(t))),e({code:Mv.SUCCESS})}shutdown(){return GF(this,f0).call()}};f0=new WeakMap;p0=new WeakMap;cte=new WeakSet;zze=function(){return GF(this,p0).debug("Shutting down"),Promise.resolve()};function oGt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:HF(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||Ka.SERVER,startTimeUnixNano:ate(e.startTime),endTimeUnixNano:ate(e.endTime),attributes:HF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:ate(n.time),attributes:HF(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:HF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function HF(t){return Object.keys(t).map(e=>qze(e,t[e]))}function qze(t,e){return{key:t,value:Bze(e)}}function Bze(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(Bze)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>qze(r,n))}}:{}}function ate(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var Fze={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"}},Vze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Uze))return;let e=rGt.version.slice(1),r=dee({"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??[aGt()],i=new WF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new zf});let s=t.instrumentations??[];hee({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,Uze,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Ml(jt.getTracer(a,c)):new Ml(jt.getTracer(Fze.name,Fze.version))}}),Object.defineProperty(globalThis,nGt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},aGt=()=>new WF.SimpleSpanProcessor(new sGt);Fe();var Yv=bn(ste(),1);Fe();import*as KF from"diagnostics_channel";var Hze=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?Fn.ERROR:Fn.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],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.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 Ml?t:new Ml(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){KF.subscribe(t,e);let r=()=>KF.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:Ka.CLIENT},ir.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:Fn.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 NWe=bn(OWe(),1);Fe();ioe();var PWe=0;var dQt=3*1024*1024,fQt=t=>LO.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Hq=class{constructor(e,r=dQt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=fQt(c);i.length&&s+u>this.maxBytes&&(n.push(i),i=[],s=0),i.push(c),s+=u}i.length&&n.push(i);let o,a=c=>{if(c===n.length){r(o??{code:PWe});return}this.inner.export(n[c],u=>{u.code!==PWe&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var YE=he("tracing"),CWe=8e3,mQt=5e3,kWe=t=>t.length>CWe?`${t.slice(0,CWe)}\u2026`:t,JE={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},gQt=Math.ceil(JE.maxQueueSize/JE.maxExportBatchSize)+1,$We=0,aoe=()=>$We,_Qt=t=>{let e=0,r=new Hq(new NWe.OTLPTraceExporter({url:t,concurrencyLimit:gQt})),n=new Yv.BatchSpanProcessor({export:(i,s)=>{e=Math.max(0,e-i.length),r.export(i,s)},shutdown:()=>r.shutdown(),forceFlush:()=>r.forceFlush()},JE);return{onStart:(i,s)=>n.onStart(i,s),onEnd:i=>{i.spanContext().traceFlags&Cr.SAMPLED&&(e>=JE.maxQueueSize?$We+=1:e+=1),n.onEnd(i)},forceFlush:()=>n.forceFlush(),shutdown:()=>n.shutdown()}},Tg=async(t=mQt)=>{try{let e=Symbol("timed out");await Promise.race([vUe(),hQt(t,e)])===e&&YE.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){YE.warn("Failed to flush tracers on shutdown",e)}},DWe=async(t,e,r)=>{if(!Lt()){let n=[new Yv.SimpleSpanProcessor(new ooe),_Qt(r.exporterUrl)];await Vze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new Hze({skipHeaders:!0})]})}return r.traceparent?(Zi.setGlobalPropagator(new zf),Zi.extract(ir.active(),{traceparent:r.traceparent,isRemote:!0})):ir.active()};function gr(t,e,r){return YE.log(`\u23F3 TRACE: ${e} starting...`),Bx(t,e,r)}var ooe=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(", ")}]`:"";YE.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&YE.log(` \u274C Error: ${e.status.message}`)}};function coe(){return He().captureLlmContentEnabled}function LWe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function Gq(t,e,r){let n={role:t,parts:[{type:"text",content:vi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var yQt=new Set([X.Task,X.RunCommand,X.Explore,X.FileRead,X.FileWrite,X.Notebook,X.Web,X.Todo,X.Skill,X.Tool,X.Memorize,X.Deployment,X.SiteGeneration]),SQt=new Set(["claude","codex"]),vQt=(t,e)=>JSON.stringify([t,e.operation,e.path??null]),EQt=t=>pQt("sha256").update(t.map(e=>Buffer.from(e)).sort(Buffer.compare).join(`
605
+ if (condition) { yield value; }`)};import{Buffer as fBt}from"buffer";import{StringDecoder as pBt}from"string_decoder";var OU=(t,e,r)=>{if(r)return;if(t)return{transform:hBt.bind(void 0,new TextEncoder)};let n=new pBt(e);return{transform:mBt.bind(void 0,n),final:gBt.bind(void 0,n)}},hBt=function*(t,e){fBt.isBuffer(e)?yield kl(e):typeof e=="string"?yield t.encode(e):yield e},mBt=function*(t,e){yield In(e)?t.write(e):e},gBt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as kMe}from"util";var w7=kMe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),PU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=yBt}=e[r];for await(let i of n(t))yield*PU(i,e,r+1)},NMe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*_Bt(r,Number(e),t)},_Bt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*PU(n,r,e+1)},$Me=kMe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),yBt=function*(t){yield t};var T7=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},DMe=(t,e)=>[...e.flatMap(r=>[...zm(r,t,0)]),...Dx(t)],zm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=vBt}=e[r];for(let i of n(t))yield*zm(i,e,r+1)},Dx=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*SBt(r,Number(e),t)},SBt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*zm(n,r,e+1)},vBt=function*(t){yield t};var R7=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=MMe(t,o,s),u=jm(e),l=jm(r),d=u?w7.bind(void 0,PU,a):T7.bind(void 0,zm),f=u||l?w7.bind(void 0,NMe,a):T7.bind(void 0,Dx),p=u||l?$Me.bind(void 0,a):void 0;return{stream:new EBt({writableObjectMode:n,writableHighWaterMark:LMe(n),readableObjectMode:i,readableHighWaterMark:LMe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},CU=(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=MMe(o,r,a);t=DMe(c,t)}return t},MMe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:OMe(n,a)},OU(r,o,n),xU(r,s,n,c),{transform:t,final:e},{transform:PMe(i,a)},xMe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var UMe=(t,e)=>{for(let r of bBt(t))wBt(t,r,e)},bBt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),wBt=(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 ${Ff[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>TBt(a,n));r.input=Rx(o)},TBt=(t,e)=>{let r=CU(t,e,"utf8",!0);return RBt(r),Rx(r)},RBt=t=>{let e=t.find(r=>typeof r!="string"&&!In(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 OBt,appendFileSync as PBt}from"fs";var kU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sv(r,n)&&!so.has(e)&&ABt(n)&&(t.some(({type:i,value:s})=>i==="native"&&IBt.has(s))||t.every(({type:i})=>na.has(i))),ABt=t=>t===1||t===2,IBt=new Set(["pipe","overlapped"]),FMe=async(t,e,r,n)=>{for await(let i of t)xBt(e)||zMe(i,r,n)},jMe=(t,e,r)=>{for(let n of t)zMe(n,e,r)},xBt=t=>t._readableState.pipes.length>0,zMe=(t,e,r)=>{let n=G1(t);uu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var qMe=({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,u)=>CBt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},CBt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=BLe(t,s,d),p=kl(f),{stdioItems:h,objectMode:m}=e[r],g=kBt([p],h,c,n),{serializedResult:y,finalResult:v=y}=NBt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});$Bt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&DBt(y,h,i),S}catch(_){return n.error=_,S}},kBt=(t,e,r,n)=>{try{return CU(t,e,r,!1)}catch(i){return n.error=i,t}},NBt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Rx(t)};let o=n$e(t,r);return n[s]?{serializedResult:o,finalResult:b7(o,!i[s],e)}:{serializedResult:o}},$Bt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!kU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=b7(t,!1,o);try{jMe(a,e,n)}catch(c){r.error??=c}},DBt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>AU.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?PBt(n,t):(r.add(s),OBt(n,t))}};var BMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Dl(e,r,"all")]:Array.isArray(e)?[Dl(t,r,"all"),...e]:In(t)&&In(e)?CQ([t,e]):`${t}${e}`};import{once as A7}from"events";var VMe=async(t,e)=>{let[r,n]=await LBt(t);return e.isForcefullyTerminated??=!1,[r,n]},LBt=async t=>{let[e,r]=await Promise.allSettled([A7(t,"spawn"),A7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?HMe(t):r.value},HMe=async t=>{try{return await A7(t,"exit")}catch{return HMe(t)}},GMe=async t=>{let[e,r]=await t;if(!MBt(e,r)&&I7(e,r))throw new tc;return[e,r]},MBt=(t,e)=>t===void 0&&e===void 0,I7=(t,e)=>t!==0||e!==null;var WMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=UBt(t,e,r),o=s?.code==="ETIMEDOUT",a=qLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},UBt=(t,e,r)=>t!==void 0?t:I7(e,r)?new tc:void 0;var KMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=jBt(t,e,r),d=BBt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return Ov(d,c,u)},jBt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=K1(t,e,r),a=zBt(r),{file:c,commandArguments:u,options:l}=hU(t,e,a);qBt(l);let d=TMe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},zBt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,qBt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&NU("ipcInput"),t&&NU("ipc: true"),r&&NU("detached: true"),n&&NU("cancelSignal")},NU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},BBt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=VBt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=WMe(c,r),{output:h,error:m=u}=qMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((v,S)=>Dl(v,r,S)),y=Dl(BMe(h,r),r,"all");return GBt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},VBt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{UMe(s,r);let a=HBt(r);return FBt(...mU(t,e,a))}catch(a){return xv({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},HBt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:bU(e)}),GBt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?wU({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):$x({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as NVt}from"events";import{spawn as $Vt}from"child_process";import QMe from"process";import{once as x7,on as WBt}from"events";var YMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(bv({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:cU(t)}),KBt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),KBt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{iU(e,i);let s=Uf(t,e,r),o=new AbortController;try{return await Promise.race([YBt(s,n,o),JBt(s,r,o),ZBt(s,r,o)])}catch(a){throw wv(t),a}finally{o.abort(),sU(e,i)}},YBt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await x7(t,"message",{signal:r});return n}for await(let[n]of WBt(t,"message",{signal:r}))if(e(n))return n},JBt=async(t,e,{signal:r})=>{await x7(t,"disconnect",{signal:r}),DDe(e)},ZBt=async(t,e,{signal:r})=>{let[n]=await x7(t,"strict:error",{signal:r});throw tU(n,e)};import{once as ZMe,on as XBt}from"events";var XMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>O7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),O7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{bv({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:cU(t)}),iU(e,s);let o=Uf(t,e,r),a=new AbortController,c={};return QBt(t,o,a),e2t({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),t2t({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},QBt=async(t,e,r)=>{try{await ZMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},e2t=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ZMe(t,"strict:error",{signal:r.signal});n.error=tU(i,e),r.abort()}catch{}},t2t=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of XBt(r,"message",{signal:s.signal}))JMe(o),yield c}catch{JMe(o)}finally{s.abort(),sU(e,a),n||wv(t),i&&await t}},JMe=({error:t})=>{if(t)throw t};var e1e=(t,{ipc:e})=>{Object.assign(t,r1e(t,!1,e))},t1e=()=>{let t=QMe,e=!0,r=QMe.channel!==void 0;return{...r1e(t,e,r),getCancelSignal:cLe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},r1e=(t,e,r)=>({sendMessage:fU.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:YMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:XMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as r2t}from"child_process";import{PassThrough as n2t,Readable as i2t,Writable as s2t,Duplex as o2t}from"stream";var n1e=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{S7(n);let a=new r2t;a2t(a,n),Object.assign(a,{readable:c2t,writable:u2t,duplex:l2t});let c=xv({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=d2t(c,o,i);return{subprocess:a,promise:u}},a2t=(t,e)=>{let r=Lx(),n=Lx(),i=Lx(),s=Array.from({length:e.length-3},Lx),o=Lx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Lx=()=>{let t=new n2t;return t.end(),t},c2t=()=>new i2t({read(){}}),u2t=()=>new s2t({write(){}}),l2t=()=>new o2t({read(){},write(){}}),d2t=async(t,e,r)=>Ov(t,e,r);import{createReadStream as i1e,createWriteStream as s1e}from"fs";import{Buffer as f2t}from"buffer";import{Readable as Mx,Writable as p2t,Duplex as h2t}from"stream";var a1e=(t,e)=>IU(m2t,t,e,!1),Ux=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ff[t]}.`)},o1e={fileNumber:Ux,generator:R7,asyncGenerator:R7,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:h2t.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},m2t={input:{...o1e,fileUrl:({value:t})=>({stream:i1e(t)}),filePath:({value:{file:t}})=>({stream:i1e(t)}),webStream:({value:t})=>({stream:Mx.fromWeb(t)}),iterable:({value:t})=>({stream:Mx.from(t)}),asyncIterable:({value:t})=>({stream:Mx.from(t)}),string:({value:t})=>({stream:Mx.from(t)}),uint8Array:({value:t})=>({stream:Mx.from(f2t.from(t))})},output:{...o1e,fileUrl:({value:t})=>({stream:s1e(t)}),filePath:({value:{file:t,append:e}})=>({stream:s1e(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:p2t.fromWeb(t)}),iterable:Ux,asyncIterable:Ux,string:Ux,uint8Array:Ux}};import{on as g2t,once as c1e}from"events";import{PassThrough as _2t,getDefaultHighWaterMark as y2t}from"stream";import{finished as d1e}from"stream/promises";function qm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)C7(i);let e=t.some(({readableObjectMode:i})=>i),r=S2t(t,e),n=new P7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var S2t=(t,e)=>{if(t.length===0)return y2t(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},P7=class extends _2t{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(C7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=v2t(this,this.#e,this.#s);let r=w2t({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(C7(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)}},v2t=async(t,e,r)=>{$U(t,u1e);let n=new AbortController;try{await Promise.race([E2t(t,n),b2t(t,e,r,n)])}finally{n.abort(),$U(t,-u1e)}},E2t=async(t,{signal:e})=>{try{await d1e(t,{signal:e,cleanup:!0})}catch(r){throw f1e(t,r),r}},b2t=async(t,e,r,{signal:n})=>{for await(let[i]of g2t(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},C7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},w2t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{$U(t,l1e);let a=new AbortController;try{await Promise.race([T2t(s,e,a),R2t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),A2t({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),$U(t,-l1e)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?k7(t):I2t(t))},T2t=async(t,e,{signal:r})=>{try{await t,r.aborted||k7(e)}catch(n){r.aborted||f1e(e,n)}},R2t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await d1e(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;p1e(o)?i.add(e):h1e(t,o)}},A2t=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await c1e(t,i,{signal:s}),!t.readable)return c1e(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},I2t=t=>{t.writable&&t.end()},f1e=(t,e)=>{p1e(e)?k7(t):h1e(t,e)},p1e=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",k7=t=>{(t.readable||t.writable)&&t.destroy()},h1e=(t,e)=>{t.destroyed||(t.once("error",x2t),t.destroy(e))},x2t=()=>{},$U=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},u1e=2,l1e=1;import{finished as m1e}from"stream/promises";var Cv=(t,e)=>{t.pipe(e),O2t(t,e),P2t(t,e)},O2t=async(t,e)=>{if(!(ec(t)||ec(e))){try{await m1e(t,{cleanup:!0,readable:!0,writable:!1})}catch{}N7(e)}},N7=t=>{t.writable&&t.end()},P2t=async(t,e)=>{if(!(ec(t)||ec(e))){try{await m1e(e,{cleanup:!0,readable:!1,writable:!0})}catch{}$7(t)}},$7=t=>{t.readable&&t.destroy()};var g1e=(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})=>na.has(c)))C2t(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!na.has(c)))N2t({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]:qm(s);Cv(o,i)}},C2t=(t,e,r,n)=>{r==="output"?Cv(t.stdio[n],e):Cv(e,t.stdio[n]);let i=k2t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},k2t=["stdin","stdout","stderr"],N2t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;$2t(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},$2t=(t,{signal:e})=>{ec(t)&&Um(t,D2t,e)},D2t=2;import{addAbortListener as U2t}from"events";var Bm=[];Bm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Bm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Bm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var DU=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",D7=Symbol.for("signal-exit emitter"),L7=globalThis,L2t=Object.defineProperty.bind(Object),M7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(L7[D7])return L7[D7];L2t(L7,D7,{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}},LU=class{},M2t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),U7=class extends LU{onExit(){return()=>{}}load(){}unload(){}},F7=class extends LU{#e=j7.platform==="win32"?"SIGINT":"SIGHUP";#r=new M7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Bm)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(!DU(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 Bm)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,Bm.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 DU(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"&&DU(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)}},j7=globalThis.process,{onExit:_1e,load:hHr,unload:mHr}=M2t(DU(j7)?new F7(j7):new U7);var y1e=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=_1e(()=>{t.kill()});U2t(n,()=>{i()})};var v1e=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=W1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=F2t(r,n,i),{sourceStream:d,sourceError:f}=z2t(t,u),{options:p,fileDescriptors:h}=du.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},F2t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=j2t(t,e,...r),a=nU(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},j2t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(S1e,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||OQ(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]=M1(r,...n);return{destination:e(S1e)(i,s,o),pipeOptions:o}}if(du.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}`)},S1e=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),z2t=(t,e)=>{try{return{sourceStream:Tv(t,e)}}catch(r){return{sourceError:r}}};var b1e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=q2t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw z7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},q2t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return $7(t),n;if(e!==void 0)return N7(r),e},z7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>xv({error:t,command:E1e,escapedCommand:E1e,fileDescriptors:e,options:r,startTime:n,isSync:!1}),E1e="source.pipe(destination)";var w1e=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 B2t}from"stream/promises";var T1e=(t,e,r)=>{let n=MU.has(e)?H2t(t,e):V2t(t,e);return Um(t,W2t,r.signal),Um(e,K2t,r.signal),G2t(e),n},V2t=(t,e)=>{let r=qm([t]);return Cv(r,e),MU.set(e,r),r},H2t=(t,e)=>{let r=MU.get(e);return r.add(t),r},G2t=async t=>{try{await B2t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}MU.delete(t)},MU=new WeakMap,W2t=2,K2t=1;import{aborted as Y2t}from"util";var R1e=(t,e)=>t===void 0?[]:[J2t(t,e)],J2t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await Y2t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw z7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var UU=(t,...e)=>{if(rn(e[0]))return UU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=v1e(t,...e),i=Z2t({...n,destination:r});return i.pipe=UU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Z2t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=X2t(t,i);b1e({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=T1e(e,s,d);return await Promise.race([w1e(l),...R1e(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},X2t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as sVt}from"timers/promises";import{on as Q2t}from"events";import{getDefaultHighWaterMark as eVt}from"stream";var FU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return tVt(e,o),I1e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},tVt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},q7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;rVt(e,o,t);let a=t.readableObjectMode&&!s;return I1e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},rVt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},I1e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=Q2t(t,"data",{signal:e.signal,highWaterMark:A1e,highWatermark:A1e});return nVt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},B7=eVt(!0),A1e=B7,nVt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=iVt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*zm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Dx(a)}},iVt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[OU(t,r,!e),xU(t,i,!n,{})].filter(Boolean);var x1e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=oVt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([aVt(t),d]);return}let f=v7(c,r),p=q7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([cVt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},oVt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!kU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=q7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await FMe(a,t,r,s)},aVt=async t=>{await sVt(),t.readableFlowing===null&&t.resume()},cVt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await SU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await vU(r,{maxBuffer:s})):await Iv(r,{maxBuffer:s})}catch(a){return O1e(FLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},V7=async t=>{try{return await t}catch(e){return O1e(e)}},O1e=({bufferedData:t})=>t$e(t)?new Uint8Array(t):t;import{finished as uVt}from"stream/promises";var Fx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=lVt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],uVt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||pVt(a,e,r,n)}finally{o.abort()}},lVt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&dVt(t,r,n),n},dVt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{fVt(e,r),n.call(t,...i)}},fVt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},pVt=(t,e,r,n)=>{if(!hVt(t,e,r,n))throw t},hVt=(t,e,r,n=!0)=>r.propagating?P1e(t)||jU(t):(r.propagating=!0,H7(r,e)===n?P1e(t):jU(t)),H7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",jU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",P1e=t=>t?.code==="EPIPE";var C1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>G7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),G7=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=Fx(t,e,u);if(H7(u,e)){await l;return}let[d]=await Promise.all([x1e({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var k1e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?qm([t,e].filter(Boolean)):void 0,N1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>G7({...mVt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:gVt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),mVt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},gVt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as _Vt}from"events";var $1e=t=>Sv(t,"ipc"),D1e=(t,e)=>{let r=G1(t);uu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var L1e=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=$1e(s),a=Nl(e,"ipc"),c=Nl(r,"ipc");for await(let u of O7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(jLe(t,i,c),i.push(u)),o&&D1e(u,s);return i},M1e=async(t,e)=>(await Promise.allSettled([t]),e);var U1e=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:y})=>{let v=VMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},_=C1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=N1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=L1e({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=yVt(m,t,S),x=SVt(h,S);try{return await Promise.race([Promise.all([{},GMe(v),Promise.all(_),w,R,yLe(t,d),...T,...x]),g,vVt(t,y),...pLe(t,s,f,y),...$De({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...dLe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},v,Promise.all(_.map(O=>V7(O))),V7(w),M1e(R,b),Promise.allSettled(T),Promise.allSettled(x)])}},yVt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Fx(n,i,r)),SVt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>nc(s,{checkOpen:!1})&&!ec(s)).map(({type:i,value:s,stream:o=s})=>Fx(o,n,e,{isSameDirection:na.has(i),stopOnExit:i==="native"}))),vVt=async(t,{signal:e})=>{let[r]=await _Vt(t,"error",{signal:e});throw r};var F1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),jx=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=lu();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},kv=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 EVt}from"stream";import{callbackify as bVt}from"util";import{finished as j1e}from"stream/promises";var W7=async t=>{if(t!==void 0)try{await K7(t)}catch{}},z1e=async t=>{if(t!==void 0)try{await Y7(t)}catch{}},K7=async t=>{await j1e(t,{cleanup:!0,readable:!1,writable:!0})},Y7=async t=>{await j1e(t,{cleanup:!0,readable:!0,writable:!1})},zU=async(t,e)=>{if(await t,e)throw e},qU=(t,e,r)=>{r&&!jU(r)?t.destroy(r):e&&t.destroy()};var q1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||so.has(r),{subprocessStdout:a,waitReadableDestroy:c}=J7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=Z7(a,o),{read:f,onStdoutDataDone:p}=X7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new EVt({read:f,destroy:bVt(eee.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return Q7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},J7=(t,e,r)=>{let n=Tv(t,e),i=jx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Z7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:B7},X7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=lu(),o=FU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){wVt(this,o,s)},onStdoutDataDone:s}},wVt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Q7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Y7(t),await n,await W7(i),await e,r.readable&&r.push(null)}catch(s){await W7(i),B1e(r,s)}},eee=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await kv(r,e)&&(B1e(t,n),await zU(e,n))},B1e=(t,e)=>{qU(t,t.readable,e)};import{Writable as TVt}from"stream";import{callbackify as V1e}from"util";var H1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=tee(t,r,e),o=new TVt({...ree(n,t,i),destroy:V1e(iee.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return nee(n,o),o},tee=(t,e,r)=>{let n=nU(t,e),i=jx(r,n,"writableFinal"),s=jx(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},ree=(t,e,r)=>({write:RVt.bind(void 0,t),final:V1e(AVt.bind(void 0,t,e,r))}),RVt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},AVt=async(t,e,r)=>{await kv(r,e)&&(t.writable&&t.end(),await e)},nee=async(t,e,r)=>{try{await K7(t),e.writable&&e.end()}catch(n){await z1e(r),G1e(e,n)}},iee=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await kv(r,e),await kv(n,e)&&(G1e(t,i),await zU(e,i))},G1e=(t,e)=>{qU(t,t.writable,e)};import{Duplex as IVt}from"stream";import{callbackify as xVt}from"util";var W1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||so.has(r),{subprocessStdout:c,waitReadableDestroy:u}=J7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=tee(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Z7(c,a),{read:g,onStdoutDataDone:y}=X7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new IVt({read:g,...ree(l,t,d),destroy:xVt(OVt.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return Q7({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),nee(l,v,c),v},OVt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([eee({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),iee({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var see=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||so.has(e),o=Tv(t,r),a=FU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return PVt(a,o,t)},PVt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var K1e=(t,{encoding:e})=>{let r=F1e();t.readable=q1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=H1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=W1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=see.bind(void 0,t,e),t[Symbol.asyncIterator]=see.bind(void 0,t,e,{})};var Y1e=(t,e)=>{for(let[r,n]of kVt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},CVt=(async()=>{})().constructor.prototype,kVt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(CVt,t)]);var J1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=DVt(t,e,r),{subprocess:f,promise:p}=MVt({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=UU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Y1e(f,p),du.set(f,{options:l,fileDescriptors:d}),f},DVt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=K1(t,e,r),{file:a,commandArguments:c,options:u}=hU(t,e,r),l=LVt(u),d=a1e(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},LVt=({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}},MVt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=$Vt(...mU(t,e,r))}catch(h){return n1e({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;NVt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];g1e(c,a,u),y1e(c,r,u);let d={},f=lu();c.kill=kDe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=k1e(c,r),K1e(c,r),e1e(c,r);let p=UVt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},UVt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,g]=await U1e({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((_,w)=>Dl(_,e,w)),v=Dl(m,e,"all"),S=FVt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ov(S,n,e)},FVt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?$x({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof fu,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):wU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var BU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,jVt(n,t[n],i)]));return{...t,...r}},jVt=(t,e,r)=>zVt.has(t)&&rn(e)&&rn(r)?{...e,...r}:r,zVt=new Set(["env",...DQ]);var jf=(t,e,r,n)=>{let i=(o,a,c)=>jf(o,a,r,c),s=(...o)=>qVt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},qVt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(rn(s))return i(t,BU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=BVt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?KMe(a,c,u):J1e(a,c,u,i)},BVt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=a$e(e)?c$e(e,r):[e,...r],[o,a,c]=M1(...s),u=BU(BU(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var Z1e=({file:t,commandArguments:e})=>Q1e(t,e),X1e=({file:t,commandArguments:e})=>({...Q1e(t,e),isSync:!0}),Q1e=(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]=VVt(t);return{file:r,commandArguments:n}},VVt=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(HVt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},HVt=/ +/g;var eUe=(t,e,r)=>{t.sync=e(GVt,r),t.s=t.sync},tUe=({options:t})=>rUe(t),GVt=({options:t})=>({...rUe(t),isSync:!0}),rUe=t=>({options:{...WVt(t),...t}}),WVt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},nUe={preferLocal:!0};var iUe=jf(()=>({})),i6r=jf(()=>({isSync:!0})),sUe=jf(Z1e),s6r=jf(X1e),o6r=jf(mLe),a6r=jf(tUe,{},nUe,eUe),{sendMessage:c6r,getOneMessage:u6r,getEachMessage:l6r,getCancelSignal:d6r}=t1e();import{Transform as KVt}from"stream";var YVt=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function JVt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...YVt])]}function ZVt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function XVt(){let e=JVt().map(r=>process.env[r]).filter(r=>!(!r||ZVt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function vi(t){if(typeof t!="string")return t;let e=XVt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(QVt(n),"g");r=r.replace(i,"******")}),r}function QVt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var zx=class extends KVt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=vi(i);n(null,s)}},VU=Symbol("maskedWrite");function oUe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[VU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?vi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[VU]=!0,process.stdout.write=r}if(!process.stderr.write[VU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?vi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[VU]=!0,process.stderr.write=r}}}var aUe=!1,cUe,oee=t=>{cUe??=t},uUe=t=>{aUe=!0,oee(t)},nn=()=>aUe,ia=()=>cUe,lUe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var qx=null,dUe=t=>(qx&&qx.destroy(),qx=new sa({totalAllowedTime:t}),qx),fUe=()=>qx;var sa=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&&nn())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((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await zD({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),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 pUe={name:"@netlify/agent-runner-cli",type:"module",version:"2.18.0-smtp.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","build:bundle":"tsup --no-dts",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build:bundle 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:antigravity":"vitest run test/integration/antigravity.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",prompts:"LOG=0 vitest run --config vitest.prompts.config.js","site:build":"npm run prompts && node site/build.mjs","site:dev":"npm run site:build && netlify dev --dir site/dist",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.7","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.8.0","@opentelemetry/sdk-trace-base":"2.9.0","@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.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.3","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var nHt=tHt(import.meta.url),iHt=Ll.dirname(nHt),sHt=rHt(import.meta.url),Nv=he("shell"),aee=new Set,hUe={preferLocal:!0},zt=(t,e,r)=>{let[n,i]=oHt(e,r),s={...hUe,...i},o=iUe(t,n,s);gUe(o,s),SUe(o);let a=r?.idleTimeout;return a&&a>0&&yUe(o,a),o},mUe=(t,e)=>{let r={...hUe,...e},n=sUe(t,r);return gUe(n,r),SUe(n),e?.idleTimeout&&e.idleTimeout>0&&yUe(n,e.idleTimeout),n},oHt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},gUe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||hu.env.NETLIFY_LOCAL_QUIET==="true")return;if(hu.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new zx).pipe(hu.stdout),t.stderr?.pipe(new zx).pipe(hu.stderr);return}t.stdout?.pipe(hu.stdout),t.stderr?.pipe(hu.stderr)},cee=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(hu.kill(-t.pid,e),Nv.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Nv.error("Error killing process:",r),!1}},_Ue=t=>cee(t,"SIGKILL"),yUe=(t,e)=>{let r=null,n=()=>{Nv.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),cee(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nv.log(`Force killing idle process ${t.pid}`),_Ue(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)},SUe=t=>{aee.add(t);let e=fUe();if(e){let r=e.onTimesUp(()=>{Nv.log(`Global timer expired, killing process ${t.pid}`),cee(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Nv.log(`Force killing process ${t.pid} after timeout`),_Ue(t))},5e3)});t.on("exit",()=>{aee.delete(t),r()}),t.on("error",()=>{aee.delete(t),r()})}};function mu(t,e){if(!hu.env.NETLIFY_LOCAL_MODE)try{let i=sHt.resolve(pUe.name),s=Ll.dirname(i);for(;s!==Ll.dirname(s);){let o=Ll.dirname(s);if(Ll.basename(o)==="node_modules"){let a=Ll.join(o,".bin",e);if(HU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(hu.env.NODE_PATH){let i=Ll.join(hu.env.NODE_PATH,".bin",e);if(HU.existsSync(i))return i}let r=Ll.join(t,"node_modules",".bin",e);if(HU.existsSync(r))return r;let n=Ll.join(iHt,"..","node_modules",".bin",e);if(HU.existsSync(n))return n}import Wq from"process";import{fileURLToPath as AQt}from"url";import{createRequire as IQt}from"module";import zO from"path";import{readFileSync as xQt}from"fs";var aHt="__netlify__getTracer",cHt="__netlify__shutdownTracers",Lt=(t,e)=>globalThis[aHt]?.(t,e),vUe=async()=>globalThis[cHt]?.();function Bx(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{createHash as pQt}from"crypto";import{setTimeout as hQt}from"timers/promises";Fe();import rGt from"process";Fe();var uHt=(t,e)=>{e.recordException(t),e.setStatus({code:Fn.ERROR})};var Ml=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}=EUe(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>bUe(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=EUe(r,n,i),c=this._tracer.startSpan(e,s,o);return bUe(c,s,a)}};function EUe(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??ir.active(),{opts:n,ctx:i,fn:s}}function bUe(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:uHt,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)}}Fe();var Dv=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var lee=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=kUe(e),n._asyncAttributesPending=e.filter(([i,s])=>Dv(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Dv(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=kUe(this._rawAttributes),this._schemaUrl=lHt(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,Dv(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ge.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Dv(n)){ge.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=dHt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function dee(t,e){return lee.FromAttributeList(Object.entries(t),e)}function kUe(t){return t.map(([e,r])=>Dv(r)?[e,r.catch(n=>{ge.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function lHt(t){if(typeof t=="string"||t===void 0)return t;ge.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function dHt(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;ge.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Fe();var Vx=class{emit(e){}enabled(){return!1}},NUe=new Vx;var Hx=Symbol.for("io.opentelemetry.js.api.logs"),Lv=globalThis;function $Ue(t,e,r){return n=>n===t?e:r}var fee=1;var pee=class{getLogger(e,r,n){return new Vx}},KU=new pee;var YU=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):NUe}};var Gx=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new YU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:KU}_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 JU=class t{constructor(){this._proxyLoggerProvider=new Gx}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Lv[Hx]?this.getLoggerProvider():(Lv[Hx]=$Ue(fee,e,KU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Lv[Hx])===null||e===void 0?void 0:e.call(Lv,fee))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Lv[Hx],this._proxyLoggerProvider=new Gx}};var DUe=JU.getInstance();function LUe(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 MUe(t){t.forEach(e=>e.disable())}function hee(t){let e=t.tracerProvider||jt.getTracerProvider(),r=t.meterProvider||VA.getMeterProvider(),n=t.loggerProvider||DUe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return LUe(i,e,r,n),()=>{MUe(i)}}Fe();var fHt=Un("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function UUe(t){return t.getValue(fHt)===!0}var Mv;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Mv||(Mv={}));Fe();var mee="[_0-9a-z-*/]",pHt=`[a-z]${mee}{0,255}`,hHt=`[a-z0-9]${mee}{0,240}@[a-z]${mee}{0,13}`,mHt=new RegExp(`^(?:${pHt}|${hHt})$`),gHt=/^[ -~]{0,255}[!-~]$/,_Ht=/,|=/;function gee(t){return mHt.test(t)}function _ee(t){return gHt.test(t)&&!_Ht.test(t)}var yHt=32,FUe=512,jUe=",",zUe="=",ZU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!gee(e)||!_ee(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>FUe)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=jUe+e),e=`${n[0]}${zUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(jUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(zUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!gee(a)||!_ee(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>FUe)&&(r.set(a,c),n=u,r.size>=yHt))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 XU="traceparent",QU="tracestate",SHt="00",vHt="(?!ff)[\\da-f]{2}",EHt="(?![0]{32})[\\da-f]{32}",bHt="(?![0]{16})[\\da-f]{16}",wHt="[\\da-f]{2}",THt=new RegExp(`^\\s?(${vHt})-(${EHt})-(${bHt})-(${wHt})(-.*)?\\s?$`);function qUe(t){let e=THt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var zf=class{inject(e,r,n){let i=jt.getSpanContext(e);if(!i||UUe(e)||!Rs(i))return;let s=`${SHt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Cr.NONE).toString(16)}`;n.set(r,XU,s),i.traceState&&n.set(r,QU,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,XU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=qUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,QU);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new ZU(typeof c=="string"?c:void 0)}return jt.setSpanContext(e,o)}fields(){return[XU,QU]}};var eF=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 Wx=class{_isCalled=!1;_deferred=new eF;_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 WF=bn(ste(),1);Fe();var jze=t=>{throw TypeError(t)},ute=(t,e,r)=>e.has(t)||jze("Cannot "+r),GF=(t,e,r)=>(ute(t,e,"read from private field"),r?r.call(t):e.get(t)),ote=(t,e,r)=>e.has(t)?jze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Mze=(t,e,r,n)=>(ute(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),tGt=(t,e,r)=>(ute(t,e,"access private method"),r),Uze="__netlify__getTracer",nGt="__netlify__shutdownTracers",iGt="__nfOTLPTrace",f0,p0,cte,zze,sGt=class{constructor(){ote(this,cte),ote(this,f0),ote(this,p0),Mze(this,f0,new Wx(tGt(this,cte,zze),this)),Mze(this,p0,ge.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(GF(this,p0).debug(`export ${t.length.toString()} spans`),GF(this,f0).isCalled){e({code:Mv.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(iGt,JSON.stringify(oGt(t))),e({code:Mv.SUCCESS})}shutdown(){return GF(this,f0).call()}};f0=new WeakMap;p0=new WeakMap;cte=new WeakSet;zze=function(){return GF(this,p0).debug("Shutting down"),Promise.resolve()};function oGt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:HF(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||Ka.SERVER,startTimeUnixNano:ate(e.startTime),endTimeUnixNano:ate(e.endTime),attributes:HF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:ate(n.time),attributes:HF(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:HF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function HF(t){return Object.keys(t).map(e=>qze(e,t[e]))}function qze(t,e){return{key:t,value:Bze(e)}}function Bze(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(Bze)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>qze(r,n))}}:{}}function ate(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var Fze={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"}},Vze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Uze))return;let e=rGt.version.slice(1),r=dee({"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??[aGt()],i=new WF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new zf});let s=t.instrumentations??[];hee({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,Uze,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Ml(jt.getTracer(a,c)):new Ml(jt.getTracer(Fze.name,Fze.version))}}),Object.defineProperty(globalThis,nGt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},aGt=()=>new WF.SimpleSpanProcessor(new sGt);Fe();var Yv=bn(ste(),1);Fe();import*as KF from"diagnostics_channel";var Hze=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?Fn.ERROR:Fn.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],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.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 Ml?t:new Ml(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){KF.subscribe(t,e);let r=()=>KF.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:Ka.CLIENT},ir.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:Fn.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 NWe=bn(OWe(),1);Fe();ioe();var PWe=0;var dQt=3*1024*1024,fQt=t=>LO.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Hq=class{constructor(e,r=dQt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=fQt(c);i.length&&s+u>this.maxBytes&&(n.push(i),i=[],s=0),i.push(c),s+=u}i.length&&n.push(i);let o,a=c=>{if(c===n.length){r(o??{code:PWe});return}this.inner.export(n[c],u=>{u.code!==PWe&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var YE=he("tracing"),CWe=8e3,mQt=5e3,kWe=t=>t.length>CWe?`${t.slice(0,CWe)}\u2026`:t,JE={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},gQt=Math.ceil(JE.maxQueueSize/JE.maxExportBatchSize)+1,$We=0,aoe=()=>$We,_Qt=t=>{let e=0,r=new Hq(new NWe.OTLPTraceExporter({url:t,concurrencyLimit:gQt})),n=new Yv.BatchSpanProcessor({export:(i,s)=>{e=Math.max(0,e-i.length),r.export(i,s)},shutdown:()=>r.shutdown(),forceFlush:()=>r.forceFlush()},JE);return{onStart:(i,s)=>n.onStart(i,s),onEnd:i=>{i.spanContext().traceFlags&Cr.SAMPLED&&(e>=JE.maxQueueSize?$We+=1:e+=1),n.onEnd(i)},forceFlush:()=>n.forceFlush(),shutdown:()=>n.shutdown()}},Tg=async(t=mQt)=>{try{let e=Symbol("timed out");await Promise.race([vUe(),hQt(t,e)])===e&&YE.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){YE.warn("Failed to flush tracers on shutdown",e)}},DWe=async(t,e,r)=>{if(!Lt()){let n=[new Yv.SimpleSpanProcessor(new ooe),_Qt(r.exporterUrl)];await Vze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new Hze({skipHeaders:!0})]})}return r.traceparent?(Zi.setGlobalPropagator(new zf),Zi.extract(ir.active(),{traceparent:r.traceparent,isRemote:!0})):ir.active()};function gr(t,e,r){return YE.log(`\u23F3 TRACE: ${e} starting...`),Bx(t,e,r)}var ooe=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(", ")}]`:"";YE.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&YE.log(` \u274C Error: ${e.status.message}`)}};function coe(){return He().captureLlmContentEnabled}function LWe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function Gq(t,e,r){let n={role:t,parts:[{type:"text",content:vi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var yQt=new Set([X.Task,X.RunCommand,X.Explore,X.FileRead,X.FileWrite,X.Notebook,X.Web,X.Todo,X.Skill,X.Tool,X.Memorize,X.Deployment,X.SiteGeneration]),SQt=new Set(["claude","codex"]),vQt=(t,e)=>JSON.stringify([t,e.operation,e.path??null]),EQt=t=>pQt("sha256").update(t.map(e=>Buffer.from(e)).sort(Buffer.compare).join(`
606
606
  `)).digest("hex"),MWe=(t,e,r)=>({"spark.trace.file_operations_recorded":SQt.has(t)&&!e.fileOperationsIncomplete,...r?{"spark.file_operations.count":r.count,"spark.file_operations.digest":r.digest}:{}});function UWe(t,e,r,n){let i=[],s=()=>({count:i.length,digest:EQt(i)});if(!t.length)return s();let o=Lt();if(!o)return s();let a=t.reduce((l,d)=>l+1+(d.fileOperations?.length??0),0);a>JE.maxQueueSize&&YE.warn(`${a} step spans exceed the span queue of ${JE.maxQueueSize}; spans may be dropped`);let c=coe(),u=Math.max(1,(n-r)/t.length);return t.forEach((l,d)=>{let f=l.timingSource?to(l.startedAtMs,l.endedAtMs,l.timingSource):{},p=f.startedAtMs??Math.min(n,r+d*u),h=f.endedAtMs??Math.min(n,p+u),m=f.timingSource??"even-split",g=l.type==="tool_use"||l.type==="tool_result"||l.category!=null&&yQt.has(l.category)||l.category===X.AgentMessage&&l.toolCallId!==void 0,y=g?"execute_tool":"chat",v=kWe(l.title||l.type||`step-${l.id??d}`),S=l.category||"unknown",_=g?`${y} ${S}`:y,w=l.message?kWe(l.message):void 0,b=o.startSpan(_,{startTime:p,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":vi(v),"gen_ai.operation.name":y,...g?{"gen_ai.tool.name":S}:{},"spark.step.id":l.id??-1,"spark.step.timing":m,"spark.file_operations.count":l.fileOperations?.length??0,...l.type?{"spark.step.type":l.type}:{},...l.category?{"spark.step.category":l.category}:{},...l.groupId?{"spark.step.group_id":l.groupId}:{},...l.parentGroupId?{"spark.step.parent_group_id":l.parentGroupId}:{},...l.skillId?{"spark.skill.id":l.skillId}:{},...c&&w?g?{"gen_ai.tool.call.result":vi(w)}:{"gen_ai.output.messages":Gq("assistant",w)}:{}}});g&&(l.toolCallId!==void 0&&b.setAttribute("gen_ai.tool.call.id",l.toolCallId),l.toolStatus!==void 0&&b.setAttribute("spark.step.tool_status",l.toolStatus),l.exitCode!==void 0&&b.setAttribute("spark.step.exit_code",l.exitCode),l.toolStatus==="error"&&(b.setAttribute("error.type","tool_error"),b.setStatus({code:Fn.ERROR})));let R=l.fileOperations?.length?jt.setSpan(ir.active(),b):void 0;for(let T of l.fileOperations??[])i.push(vQt(l.id??-1,T)),o.startSpan("file_operation",{startTime:p,attributes:{"gen_ai.capability.name":e,"spark.step.id":l.id??-1,"spark.file.operation":T.operation,...T.path!==void 0?{"spark.file.path":T.path}:T.unresolved?{"spark.file.path_unresolved":!0}:{"spark.file.outside_repo":!0},...l.toolCallId!==void 0?{"gen_ai.tool.call.id":l.toolCallId}:{}}},R).end(h);b.end(h)}),s()}import{readdir as bQt,rm as wQt}from"fs/promises";import{join as TQt}from"path";async function FWe(t,e=[]){let n=(await bQt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>wQt(TQt(t,i),{recursive:!0,force:!0})))}var RQt=300,FO=t=>He().budgetCreditThresholds[t.mode]?.[t.runner]??RQt,jO=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var uoe=t=>{let e=FO(t);if(!jO(t,e))return"default";let r=He();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},jWe=t=>{let e=uoe(t),r=FO(t);return{budget_eligible:jO(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var OQt=zO.dirname(AQt(import.meta.url)),zWe=IQt(import.meta.url),PQt=zO.resolve(OQt,"scripts/scaffold.js"),CQt="scripts/scaffold.js",kQt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,loe=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},NQt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),$Qt=t=>{let e=loe(t);return e==="node"||e.endsWith("/node")},ho=t=>{if(typeof t!="string")return!1;let e=t.match(kQt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&NQt(loe(e[r]));)r+=1;if(r>=e.length||!$Qt(e[r]))return!1;let n=e[r+1];return n?loe(n).includes(CQt):!1},Rg=he("create_stage"),doe="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.",DQt=`${doe}
607
607
 
608
608
  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.`,LQt=`${doe}
@@ -1078,7 +1078,7 @@ ${v}`:v;if(S.length>5e5&&y){let _=Met.join(u,`agent-task-context-${l_r()}.md`);a
1078
1078
  `)}};var Fet=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 d_r}from"crypto";var NT=he("interactions"),jet="question",zet="authorization",qet="setup_request",f_r=["answered","skipped","dismissed"],p_r=({setupRequest:t,authorization:e,questions:r})=>t?{type:qet,payload:{setup_request_id:t.setupRequestId},category:X.SetupRequest}:e?{type:zet,payload:{...e},category:X.Authorization}:{type:jet,payload:r,category:X.Question},ode=async(t,e,r)=>{let{setupRequest:n}=e,i=n?.refId??d_r(),{type:s,payload:o,category:a}=p_r(e);return await wn(t.id,t.sessionId,{state:"await_input",interactions:{[i]:{type:s,status:"pending",payload:o}},steps:[{id:i,refId:i,category:a}],...r?.diffFields,...r?.nativeSessionId?{native_session_id:r.nativeSessionId}:{},...r?.nativeSessionS3Key?{native_session_s3_key:r.nativeSessionS3Key}:{}}),i},ade=(t,e,r)=>{if(t.setupRequest){NT.log("Agent paused on a setup request; session set to await_input",{sessionId:e,refId:r,setupRequestId:t.setupRequest.setupRequestId}),ee.inc("inference.pending_setup_request",1);return}if(t.authorization){NT.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;NT.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)},Bet=async(t,e)=>{try{let r=await Qxe(t);return{satisfied:r.satisfied,items:r.items??[]}}catch(r){NT.warn("Failed to fetch a setup request for the resume",{refId:e,setupRequestId:t,error:r?.message}),ee.inc("inference.setup_request_fetch_failed",1);return}},cde=async t=>{let e;try{e=await am(t.id,t.sessionId)}catch(o){return NT.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=async(o,a)=>{if(!(!a||i.has(o))&&(i.add(o),!!f_r.includes(a.status??""))){if(a.type===qet){let c=a.payload??{};if(!c.setup_request_id)return;let u=await Bet(c.setup_request_id,o);n.push({refId:o,questions:[],responses:[],setupRequest:{completed:a.status==="answered",skipped:a.status==="skipped"},...a.instruction?{instruction:a.instruction}:{},...u?{setupOutcome:u}:{}});return}if(a.type===zet){let c=a.payload??{};n.push({refId:o,questions:[],responses:[],authorization:{service:c.service,granted:a.status==="answered"}});return}a.type===jet&&n.push({refId:o,questions:a.payload??[],responses:a.response??[],...a.instruction?{instruction:a.instruction}:{}})}};for(let o of e?.steps??[])o?.refId&&await s(o.refId,r[o.refId]);for(let[o,a]of Object.entries(r))await s(o,a);return n},ude=async(t,e)=>{let r;try{r=await am(t.id,t.sessionId)}catch(s){return NT.warn("Failed to fetch session for the setup request outcome",{error:s?.message}),ee.inc("inference.setup_request_session_fetch_failed",1),e}let n=r?.interactions?.[e.refId]?.payload;if(!n?.setup_request_id)return e;let i=await Bet(n.setup_request_id,e.refId);return i?{...e,setupOutcome:i}:e},lde=()=>({counted:!1});var h_r=(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"},dde=t=>{let e=0;t.questions.forEach((r,n)=>{let i=h_r(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),t.setupRequest?.skipped&&ee.inc("interaction.setup_request_skipped",1)},Vet=t=>{let e=!1,r=t.flatMap(s=>s.questions.map((o,a)=>{let c=s.responses[a];c==null&&(e=!0);let u=c==null?"(skipped)":Array.isArray(c)?c.join(", "):c;return{question:o.question,answer:u}})),n=t.filter(s=>!s.setupRequest).map(s=>s.instruction?.trim()).filter(s=>!!s).join(`
1079
1079
 
1080
1080
  `),i=e&&!n?'A "(skipped)" answer means the user chose not to answer; proceed with your best judgment there.':"";return r.length?HNe(r,{skipNote:i,overrideInstruction:n||void 0}):""};var Het=t=>{let e=t.map(r=>r.authorization).filter(r=>!!r).map(r=>r.granted?`- ${r.service} is now authorized. Its tools are available to you.`:`- The user declined to authorize ${r.service}. Continue without it and do not request authorization for ${r.service} again in this run.`);return e.length?["## Service authorization","",...e].join(`
1081
- `):""};var m_r="At least one target must be required. Mark the context the task actually needs this in as required, and drop the item entirely if the task works without it everywhere.",$T=(t,e)=>Ue.array(Ue.object({name:t,required:Ue.boolean().default(!0).describe("Set false only if the task is genuinely complete without it in that context. Every item needs at least one required target.")})).min(1).refine(r=>r.some(n=>n.required),{message:m_r}).describe(e),$a=Ue.string().min(1).describe("One sentence, shown to the user next to the field: what you are building and why it needs this."),Get=t=>Ue.array(t).min(1).max(10).describe("Everything this project is missing for the task. Send them in one call, not one call per item");var Wet=Ue.strictObject({kind:Ue.literal("identity_signup_settings"),reason:$a,proposed:Ue.strictObject({disable_signup:Ue.boolean().describe("True for invite-only registration; false to allow visitors to sign up."),autoconfirm:Ue.boolean().describe("True to allow login without email confirmation; false to require it.")})}),Ket=t=>t.kind==="identity_signup_settings";var Yet=Ue.strictObject({kind:Ue.literal("identity_provider"),reason:$a,provider:Ue.enum(["google","github","gitlab","bitbucket"]),operation:Ue.enum(["enable","remove","use_defaults"]).describe("Enable or remove a login provider while preserving stored credentials. Only use_defaults explicitly enables the provider and removes custom credentials in favor of Netlify defaults.")}),Jet=t=>t.kind==="identity_provider";var g_r=t=>{let e=`disable_signup=${t.proposed.disable_signup}, autoconfirm=${t.proposed.autoconfirm}`;switch(t.state){case"applied":return`- Netlify applied and verified the approved Identity signup settings: ${e}. Check whether this solved the user's problem and continue the task.`;case"satisfied":return`- Identity signup settings already match the proposal: ${e}. They were configured elsewhere; this approval did not apply them. Check whether this solved the user's problem and continue the task.`;case"declined":return"- The user declined to change Identity signup settings. Netlify did not apply this proposal. Continue with the existing settings and do not request the same change again in this run.";case"failed":return`- The Identity signup settings request failed.${t.result?` ${t.result}`:""} Do not assume the proposal was applied. Read the current settings before relying on them and do not retry the change without a new approval.`;default:return"- The Identity signup settings approval has not finished. Do not assume the proposal was applied or apply it yourself."}},__r=t=>{switch(t.state){case"applied":return"- Netlify reset Identity outgoing email to its defaults and verified the result. The custom SMTP credentials and sender were removed. Check whether this solved the email delivery problem and continue the task.";case"satisfied":return"- Identity outgoing email already uses Netlify defaults. This request did not reset it. Check whether this solved the email delivery problem and continue the task.";case"declined":return"- The user declined the Identity email reset. Netlify did not change email settings. Continue with the existing settings and do not request the same reset again in this run.";case"failed":return`- The Identity email reset failed.${t.result?` ${t.result}`:""} Do not assume email settings changed. Read the current settings before relying on them and do not retry without a new approval.`;default:return"- The Identity email reset approval has not finished. Do not assume settings changed or reset them yourself."}},y_r=t=>{let e=`${t.provider} (${t.operation})`;switch(t.state){case"applied":return`- Netlify applied and verified the approved Identity provider change: ${e}. This verifies saved configuration, not a completed login. Check the supported login flow before reporting that login works.`;case"satisfied":return`- Identity provider ${t.provider} already matches the proposal. This request did not apply the change. Check the supported login flow before reporting that login works.`;case"declined":return`- The user declined the Identity provider change: ${e}. Netlify did not change provider settings. Continue with the existing settings and do not request the same change again in this run.`;case"failed":return`- The Identity provider change failed: ${e}.${t.result?` ${t.result}`:""} Do not assume settings changed. Read the current settings before relying on them and do not retry without a new approval.`;default:return`- The Identity provider approval has not finished: ${e}. Do not assume settings changed or apply the change yourself.`}},Zet=t=>t.flatMap(e=>Ket(e)?[g_r(e)]:e.kind==="identity_email_reset"?[__r(e)]:Jet(e)?[y_r(e)]:[]);var Xet=["production","deploy-preview","branch-deploy","dev"],Qet=["exist","change"],ett=Ue.object({kind:Ue.literal("env_var"),reason:$a,key:Ue.string().min(1).regex(/^[A-Za-z_][A-Za-z0-9_]*$/).describe("The variable name exactly as the code reads it, e.g. STRIPE_SECRET_KEY."),secret:Ue.boolean().default(!0).describe("True for anything that must not be shown again once set: API keys, tokens, passwords."),mode:Ue.enum(Qet).default("exist").describe('"exist" when the key just needs a value: the user is asked only when nothing is set. "change" when a value is set but must be replaced, because it is revoked, expired, rotated, or wrong for this task. Only "change" asks the user to replace a value that is already there.'),targets:$T(Ue.enum(Xet),"The deploy contexts the task actually needs this in. Do not list contexts the task does not touch.")}),mH=t=>t.kind==="env_var";var ttt=["full_name","email","roles"],rtt=Ue.object({kind:Ue.literal("identity_user"),reason:$a,user_id:Ue.string().min(1).describe("The id of the Identity user to change, exactly as Identity returns it."),proposed:Ue.object({full_name:Ue.string().min(1).optional(),email:Ue.string().min(1).optional(),roles:Ue.array(Ue.string().min(1)).optional().describe("Every role the user should end up with, not only the ones you are adding.")}).describe("The value you are proposing for each field you ask about. The user sees these filled in and can change them before saving, so propose your best guess rather than leaving a field out."),targets:$T(Ue.enum(ttt),"The fields the task actually needs changed. Do not list fields the task does not depend on.")}),gH=t=>t.kind==="identity_user";var ntt=["admin_email","host","port","user"],itt=Ue.strictObject({kind:Ue.literal("identity_smtp"),reason:$a,proposed:Ue.strictObject({admin_email:Ue.string().min(1).optional().describe("The address Identity sends from, e.g. noreply@example.com."),host:Ue.string().min(1).optional().describe("The SMTP host of the provider, e.g. smtp.sendgrid.net."),port:Ue.number().int().min(1).max(65535).optional().describe("The SMTP port, e.g. 587."),user:Ue.string().min(1).optional().describe("The SMTP username.")}).describe("The value you are proposing for each field you ask about. The user sees these filled in and can change them before saving. Propose your best guess based on what the user is asking for or leave the field blank if it is unclear. There is no password field: the user types the SMTP password in themselves and it is never sent to you."),targets:$T(Ue.enum(ntt),"The outgoing email settings the task actually needs. Do not list settings the task does not depend on, and do not ask for the password: the user supplies it via the Netlify UI alongside these settings.")}),_H=t=>t.kind==="identity_smtp";var stt=Ue.strictObject({kind:Ue.literal("identity_email_reset"),reason:$a});var S_r=Ue.discriminatedUnion("kind",[ett,rtt,itt,Wet,stt,Yet]),v_r={items:Get(S_r)},yOn=Ue.object(v_r);var fde=t=>t.map(e=>e.name).join(", "),DT=t=>t.map(e=>`\`${e.name}\``).join(", "),pde="Do not raise a setup request for a skipped value again in this run. Carry on without it: where the code needs the value, use mock or sample data, or a clearly labelled placeholder, behind a check for the variable so the real value takes over once it is set. In your summary, say what is mocked and which variables to set to make it real.",E_r="Do not raise a setup request for an Identity user again in this run as the user skipped. Carry on with the Identity user exactly as it reads now, and say in your summary what you left unchanged.",b_r="Do not raise a setup request for Identity outgoing email again in this run as the user skipped. Carry on with the outgoing email settings exactly as they read now, and say in your summary what you left unconfigured.",w_r="A configured setting holds whatever the user saved, which need not be what you proposed: they can edit the values before saving. Read the outgoing email settings back from Identity rather than assuming your proposed values are in place. The SMTP password was never sent to you and cannot be read back.",T_r="An updated field holds whatever the user saved, which need not be what you proposed: they can edit the values before saving. Read the user back from Identity rather than assuming your proposed values are in place.",R_r=t=>mH(t)||gH(t)||_H(t),A_r=(t,e)=>{let r=t.targets.filter(s=>s.state==="satisfied"),n=t.targets.filter(s=>s.state==="missing");if(!r.length)return`- \`${t.key}\` was not set. Continue without it and do not assume a value exists.`;if(!n.length)return`- \`${t.key}\` is now set for ${fde(r)}.`;let i=e?" The user skipped setting the rest.":"";return`- \`${t.key}\` is now set for ${fde(r)}, but not for ${fde(n)}. Anything that reads it will fail there.${i}`},I_r=(t,e)=>{let r=t.targets.filter(o=>o.state==="satisfied"),n=t.targets.filter(o=>o.state==="missing"),i=`The Identity user \`${t.user_id}\``;if(!r.length)return`- ${i} was not changed. Continue without the change and do not assume any field was updated.`;if(!n.length)return`- ${i} was updated: ${DT(r)}.`;let s=e?" The user skipped the rest.":"";return`- ${i} was updated: ${DT(r)}, but ${DT(n)} still reads as it did before.${s}`},x_r=(t,e)=>{let r=t.targets.filter(s=>s.state==="satisfied"),n=t.targets.filter(s=>s.state==="missing");if(!r.length)return"- Identity outgoing email was not configured. Identity is still sending from its default address: continue without it and do not assume any setting changed.";if(!n.length)return`- Identity outgoing email is now configured: ${DT(r)}.`;let i=e?" The user skipped the rest.":"";return`- Identity outgoing email is now configured: ${DT(r)}, but ${DT(n)} still reads as it did before.${i}`},O_r={match:mH,skippedId:t=>t.key,line:(t,e)=>A_r(t,e),skippedSummary:t=>`- The user skipped setting ${t.map(e=>`\`${e}\``).join(", ")}. They don't have the value, or don't want to configure it yet.`,leftMissingGuidance:pde,reportedNotes:t=>t.some(e=>e.secret)?["Values marked secret can be used but never read back: do not echo one, write it into a file or a command, or commit it. Setting a secret turns on secret scanning of the build output, so an inlined value fails the next deploy."]:[]},P_r={match:gH,skippedId:t=>t.user_id,line:(t,e)=>I_r(t,e),skippedSummary:t=>`- The user skipped changing the Identity ${t.length>1?"users":"user"} ${t.map(e=>`\`${e}\``).join(", ")}. Proceed with the record as it stands.`,leftMissingGuidance:E_r,reportedNotes:t=>t.some(e=>e.targets.some(r=>r.state==="satisfied"))?[T_r]:[]},C_r={match:_H,skippedId:t=>t.kind,line:(t,e)=>x_r(t,e),skippedSummary:()=>"- The user skipped configuring Identity outgoing email. Proceed with the settings as they stand.",leftMissingGuidance:b_r,reportedNotes:t=>t.some(e=>e.targets.some(r=>r.state==="satisfied"))?[w_r]:[]},k_r=[O_r,P_r,C_r],ott=t=>{let e=t.flatMap(({item:i,skipped:s})=>R_r(i)?[{item:i,skipped:s}]:[]),r=[],n=new Set;for(let i of k_r){let s=[],o=[],a=!1;for(let{item:c,skipped:u}of e.filter(l=>i.match(l.item))){if(!c.targets.some(d=>d.state==="satisfied")&&u){s.push(i.skippedId(c));continue}o.push(c),a||=u&&c.targets.some(d=>d.state==="missing"),r.push(i.line(c,u))}s.length&&r.push(i.skippedSummary(s)),(s.length||a)&&n.add(i.leftMissingGuidance),i.reportedNotes(o).forEach(c=>n.add(c))}return{lines:r,guidance:n}};var att=t=>{let e=[],r=[];for(let{setupRequest:u,setupOutcome:l}of t)for(let d of l?.items??[])switch(d.interaction){case"input":e.push({item:d,skipped:!!u?.skipped});break;case"approval":r.push(d);break}let n=ott(e),i=[...Zet(r),...n.lines],s=n.guidance,o=t.filter(u=>u.setupRequest).map(u=>u.instruction?.trim()).filter(u=>!!u),a=t.some(({setupRequest:u,setupOutcome:l})=>u&&!u.skipped&&!l),c=t.some(({setupRequest:u,setupOutcome:l})=>u?.skipped&&!l);return!i.length&&!o.length&&!a&&!c?"":(c&&(i.push("- The user skipped a setup request in this run, and Netlify could not report which values it covered."),s.add(pde)),a&&i.push("- A setup request in this run finished, but Netlify could not report what it configured. Check with the `netlify` CLI before assuming any value is set."),["## Project setup","",...i,...[...s,...o].flatMap(u=>["",u])].join(`
1081
+ `):""};var m_r="At least one target must be required. Mark the context the task actually needs this in as required, and drop the item entirely if the task works without it everywhere.",$T=(t,e)=>Ue.array(Ue.object({name:t,required:Ue.boolean().default(!0).describe("Set false only if the task is genuinely complete without it in that context. Every item needs at least one required target.")})).min(1).refine(r=>r.some(n=>n.required),{message:m_r}).describe(e),$a=Ue.string().min(1).describe("One sentence, shown to the user next to the field: what you are building and why it needs this."),Get=t=>Ue.array(t).min(1).max(10).describe("Everything this project is missing for the task. Send them in one call, not one call per item");var Wet=Ue.strictObject({kind:Ue.literal("identity_signup_settings"),reason:$a,proposed:Ue.strictObject({disable_signup:Ue.boolean().describe("True for invite-only registration; false to allow visitors to sign up."),autoconfirm:Ue.boolean().describe("True to allow login without email confirmation; false to require it.")})}),Ket=t=>t.kind==="identity_signup_settings";var Yet=Ue.strictObject({kind:Ue.literal("identity_provider"),reason:$a,provider:Ue.enum(["google","github","gitlab","bitbucket"]),operation:Ue.enum(["enable","remove","use_defaults"]).describe("Enable or remove a login provider while preserving stored credentials. Only use_defaults explicitly enables the provider and removes custom credentials in favor of Netlify defaults.")}),Jet=t=>t.kind==="identity_provider";var g_r=t=>{let e=`disable_signup=${t.proposed.disable_signup}, autoconfirm=${t.proposed.autoconfirm}`;switch(t.state){case"applied":return`- Netlify applied and verified the approved Identity signup settings: ${e}. Check whether this solved the user's problem and continue the task.`;case"satisfied":return`- Identity signup settings already match the proposal: ${e}. They were configured elsewhere; this approval did not apply them. Check whether this solved the user's problem and continue the task.`;case"declined":return"- The user declined to change Identity signup settings. Netlify did not apply this proposal. Continue with the existing settings and do not request the same change again in this run.";case"failed":return`- The Identity signup settings request failed.${t.result?` ${t.result}`:""} Do not assume the proposal was applied. Read the current settings before relying on them and do not retry the change without a new approval.`;default:return"- The Identity signup settings approval has not finished. Do not assume the proposal was applied or apply it yourself."}},__r=t=>{switch(t.state){case"applied":return"- Netlify reset Identity outgoing email to its defaults and verified the result. The custom SMTP credentials and sender were removed. Check whether this solved the email delivery problem and continue the task.";case"satisfied":return"- Identity outgoing email already uses Netlify defaults. This request did not reset it. Check whether this solved the email delivery problem and continue the task.";case"declined":return"- The user declined the Identity email reset. Netlify did not change email settings. Continue with the existing settings and do not request the same reset again in this run.";case"failed":return`- The Identity email reset failed.${t.result?` ${t.result}`:""} Do not assume email settings changed. Read the current settings before relying on them and do not retry without a new approval.`;default:return"- The Identity email reset approval has not finished. Do not assume settings changed or reset them yourself."}},y_r=t=>{let e=`${t.provider} (${t.operation})`;switch(t.state){case"applied":return`- Netlify applied and verified the approved Identity provider change: ${e}. This verifies saved configuration, not a completed login. Check the supported login flow before reporting that login works.`;case"satisfied":return`- Identity provider ${t.provider} already matches the proposal. This request did not apply the change. Check the supported login flow before reporting that login works.`;case"declined":return`- The user declined the Identity provider change: ${e}. Netlify did not change provider settings. Continue with the existing settings and do not request the same change again in this run.`;case"failed":return`- The Identity provider change failed: ${e}.${t.result?` ${t.result}`:""} Do not assume settings changed. Read the current settings before relying on them and do not retry without a new approval.`;default:return`- The Identity provider approval has not finished: ${e}. Do not assume settings changed or apply the change yourself.`}},Zet=t=>t.flatMap(e=>Ket(e)?[g_r(e)]:e.kind==="identity_email_reset"?[__r(e)]:Jet(e)?[y_r(e)]:[]);var Xet=["production","deploy-preview","branch-deploy","dev"],Qet=["exist","change"],ett=Ue.object({kind:Ue.literal("env_var"),reason:$a,key:Ue.string().min(1).regex(/^[A-Za-z_][A-Za-z0-9_]*$/).describe("The variable name exactly as the code reads it, e.g. STRIPE_SECRET_KEY."),secret:Ue.boolean().default(!0).describe("True for anything that must not be shown again once set: API keys, tokens, passwords."),mode:Ue.enum(Qet).default("exist").describe('"exist" when the key just needs a value: the user is asked only when nothing is set. "change" when a value is set but must be replaced, because it is revoked, expired, rotated, or wrong for this task. Only "change" asks the user to replace a value that is already there.'),targets:$T(Ue.enum(Xet),"The deploy contexts the task actually needs this in. Do not list contexts the task does not touch.")}),mH=t=>t.kind==="env_var";var ttt=["full_name","email","roles"],rtt=Ue.object({kind:Ue.literal("identity_user"),reason:$a,user_id:Ue.string().min(1).describe("The id of the Identity user to change, exactly as Identity returns it."),proposed:Ue.object({full_name:Ue.string().min(1).optional(),email:Ue.string().min(1).optional(),roles:Ue.array(Ue.string().min(1)).optional().describe("Every role the user should end up with, not only the ones you are adding.")}).describe("The value you are proposing for each field you ask about. The user sees these filled in and can change them before saving, so propose your best guess rather than leaving a field out."),targets:$T(Ue.enum(ttt),"The fields the task actually needs changed. Do not list fields the task does not depend on.")}),gH=t=>t.kind==="identity_user";var ntt=["admin_email","host","port","user"],itt=Ue.strictObject({kind:Ue.literal("identity_smtp"),reason:$a,proposed:Ue.strictObject({admin_email:Ue.string().min(1).optional().describe("The address Identity sends from, e.g. noreply@example.com."),host:Ue.string().min(1).optional().describe("The SMTP host of the provider, e.g. smtp.sendgrid.net."),port:Ue.number().int().min(1).max(65535).optional().describe("The SMTP port, e.g. 587."),user:Ue.string().min(1).optional().describe("The SMTP username.")}).describe("The value you are proposing for each field you ask about. The user sees these filled in and can change them before saving. Propose your best guess based on what the user is asking for or leave the field blank if it is unclear. There is no password field: the user types the SMTP password in themselves and it is never sent to you."),targets:$T(Ue.enum(ntt),"The outgoing email settings the task actually needs. Do not list settings the task does not depend on, and do not ask for the password: the user supplies it via the Netlify UI alongside these settings.")}),_H=t=>t.kind==="identity_smtp";var stt=Ue.strictObject({kind:Ue.literal("identity_email_reset"),reason:$a});var S_r=Ue.discriminatedUnion("kind",[ett,rtt,itt,Wet,stt,Yet]),v_r={items:Get(S_r)},yOn=Ue.object(v_r);var fde=t=>t.map(e=>e.name).join(", "),DT=t=>t.map(e=>`\`${e.name}\``).join(", "),pde="Do not raise a setup request for a skipped value again in this run. Carry on without it: where the code needs the value, use mock or sample data, or a clearly labelled placeholder, behind a check for the variable so the real value takes over once it is set. In your summary, say what is mocked and which variables to set to make it real.",E_r="Do not raise a setup request for an Identity user again in this run as the user skipped. Carry on with the Identity user exactly as it reads now, and say in your summary what you left unchanged.",b_r="Do not raise a setup request for Identity outgoing email again in this run as the user skipped. Carry on with the outgoing email settings exactly as they read now, and say in your summary what you left unconfigured.",w_r="A configured setting holds whatever the user saved, which need not be what you proposed: they can edit the values before saving. Read them back from the project's Identity service instance \u2014 `GET /api/v1/sites/$SITE_ID/services/identity/instances/$IDENTITY_ID`, where `$IDENTITY_ID` is the project's `identity_instance_id`, with the settings at `config.config.smtp` \u2014 rather than assuming your proposed values are in place, and rather than raising another setup request to find out. The SMTP password is never returned by that read and cannot be checked.",T_r="An updated field holds whatever the user saved, which need not be what you proposed: they can edit the values before saving. Read the user back from Identity rather than assuming your proposed values are in place.",R_r=t=>mH(t)||gH(t)||_H(t),A_r=(t,e)=>{let r=t.targets.filter(s=>s.state==="satisfied"),n=t.targets.filter(s=>s.state==="missing");if(!r.length)return`- \`${t.key}\` was not set. Continue without it and do not assume a value exists.`;if(!n.length)return`- \`${t.key}\` is now set for ${fde(r)}.`;let i=e?" The user skipped setting the rest.":"";return`- \`${t.key}\` is now set for ${fde(r)}, but not for ${fde(n)}. Anything that reads it will fail there.${i}`},I_r=(t,e)=>{let r=t.targets.filter(o=>o.state==="satisfied"),n=t.targets.filter(o=>o.state==="missing"),i=`The Identity user \`${t.user_id}\``;if(!r.length)return`- ${i} was not changed. Continue without the change and do not assume any field was updated.`;if(!n.length)return`- ${i} was updated: ${DT(r)}.`;let s=e?" The user skipped the rest.":"";return`- ${i} was updated: ${DT(r)}, but ${DT(n)} still reads as it did before.${s}`},x_r=(t,e)=>{let r=t.targets.filter(s=>s.state==="satisfied"),n=t.targets.filter(s=>s.state==="missing");if(!r.length)return"- Identity outgoing email was not configured. Identity is still sending from its default address: continue without it and do not assume any setting changed.";if(!n.length)return`- Identity outgoing email is now configured: ${DT(r)}.`;let i=e?" The user skipped the rest.":"";return`- Identity outgoing email is now configured: ${DT(r)}, but ${DT(n)} still reads as it did before.${i}`},O_r={match:mH,skippedId:t=>t.key,line:(t,e)=>A_r(t,e),skippedSummary:t=>`- The user skipped setting ${t.map(e=>`\`${e}\``).join(", ")}. They don't have the value, or don't want to configure it yet.`,leftMissingGuidance:pde,reportedNotes:t=>t.some(e=>e.secret)?["Values marked secret can be used but never read back: do not echo one, write it into a file or a command, or commit it. Setting a secret turns on secret scanning of the build output, so an inlined value fails the next deploy."]:[]},P_r={match:gH,skippedId:t=>t.user_id,line:(t,e)=>I_r(t,e),skippedSummary:t=>`- The user skipped changing the Identity ${t.length>1?"users":"user"} ${t.map(e=>`\`${e}\``).join(", ")}. Proceed with the record as it stands.`,leftMissingGuidance:E_r,reportedNotes:t=>t.some(e=>e.targets.some(r=>r.state==="satisfied"))?[T_r]:[]},C_r={match:_H,skippedId:t=>t.kind,line:(t,e)=>x_r(t,e),skippedSummary:()=>"- The user skipped configuring Identity outgoing email. Proceed with the settings as they stand.",leftMissingGuidance:b_r,reportedNotes:t=>t.some(e=>e.targets.some(r=>r.state==="satisfied"))?[w_r]:[]},k_r=[O_r,P_r,C_r],ott=t=>{let e=t.flatMap(({item:i,skipped:s})=>R_r(i)?[{item:i,skipped:s}]:[]),r=[],n=new Set;for(let i of k_r){let s=[],o=[],a=!1;for(let{item:c,skipped:u}of e.filter(l=>i.match(l.item))){if(!c.targets.some(d=>d.state==="satisfied")&&u){s.push(i.skippedId(c));continue}o.push(c),a||=u&&c.targets.some(d=>d.state==="missing"),r.push(i.line(c,u))}s.length&&r.push(i.skippedSummary(s)),(s.length||a)&&n.add(i.leftMissingGuidance),i.reportedNotes(o).forEach(c=>n.add(c))}return{lines:r,guidance:n}};var att=t=>{let e=[],r=[];for(let{setupRequest:u,setupOutcome:l}of t)for(let d of l?.items??[])switch(d.interaction){case"input":e.push({item:d,skipped:!!u?.skipped});break;case"approval":r.push(d);break}let n=ott(e),i=[...Zet(r),...n.lines],s=n.guidance,o=t.filter(u=>u.setupRequest).map(u=>u.instruction?.trim()).filter(u=>!!u),a=t.some(({setupRequest:u,setupOutcome:l})=>u&&!u.skipped&&!l),c=t.some(({setupRequest:u,setupOutcome:l})=>u?.skipped&&!l);return!i.length&&!o.length&&!a&&!c?"":(c&&(i.push("- The user skipped a setup request in this run, and Netlify could not report which values it covered."),s.add(pde)),a&&i.push("- A setup request in this run finished, but Netlify could not report what it configured. Check with the `netlify` CLI before assuming any value is set."),["## Project setup","",...i,...[...s,...o].flatMap(u=>["",u])].join(`
1082
1082
  `))};var ctt=(t,e)=>[t,Vet(e),Het(e),att(e)].filter(Boolean).join(`
1083
1083
 
1084
1084
  `);var N_r=new Set(["claude","codex","opencode","antigravity","muse"]),utt="The agent has already started on this work but ran into networking errors trying to complete it. Please continue from where it left off (you can use git commands to see what's currently changed thus far) and do not start over.",dtt=t=>N_r.has(t),$_r=t=>dtt(t)?utt:`<important> ${utt} Here is the full prompt for context: </important>`,D_r=async({buildErrors:t,contextPrefix:e,...r})=>{if(dtt(r.config.runner))return Uet({...r,buildErrors:t,contextPrefix:e});let{prompt:n}=await Let({...r,buildErrorContext:L_r(t)});return{prompt:`${e||""}