@netlify/agent-runner-cli 2.12.0-nb87df2e9baa9e.0 → 2.12.0-nb987b7e96221d.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -594,7 +594,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
594
594
  `,LF:`
595
595
  `,concatBytes:YQ},qzt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Bzt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:qzt};import{Buffer as Vzt}from"buffer";var VLe=(t,e)=>t?void 0:Hzt.bind(void 0,e),Hzt=function*(t,e){if(typeof e!="string"&&!xn(e)&&!Vzt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},HLe=(t,e)=>t?Gzt.bind(void 0,e):Wzt.bind(void 0,e),Gzt=function*(t,e){GLe(t,e),yield e},Wzt=function*(t,e){if(GLe(t,e),typeof e!="string"&&!xn(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},GLe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
596
596
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
597
- if (condition) { yield value; }`)};import{Buffer as Kzt}from"buffer";import{StringDecoder as Yzt}from"string_decoder";var lU=(t,e,r)=>{if(r)return;if(t)return{transform:Jzt.bind(void 0,new TextEncoder)};let n=new Yzt(e);return{transform:Zzt.bind(void 0,n),final:Xzt.bind(void 0,n)}},Jzt=function*(t,e){Kzt.isBuffer(e)?yield Rl(e):typeof e=="string"?yield t.encode(e):yield e},Zzt=function*(t,e){yield xn(e)?t.write(e):e},Xzt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as WLe}from"util";var ZQ=WLe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),dU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=eqt}=e[r];for await(let i of n(t))yield*dU(i,e,r+1)},KLe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Qzt(r,Number(e),t)},Qzt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*dU(n,r,e+1)},YLe=WLe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),eqt=function*(t){yield t};var XQ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},JLe=(t,e)=>[...e.flatMap(r=>[...Dm(r,t,0)]),...yx(t)],Dm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=rqt}=e[r];for(let i of n(t))yield*Dm(i,e,r+1)},yx=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*tqt(r,Number(e),t)},tqt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Dm(n,r,e+1)},rqt=function*(t){yield t};var QQ=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=XLe(t,o,s),u=$m(e),l=$m(r),d=u?ZQ.bind(void 0,dU,a):XQ.bind(void 0,Dm),f=u||l?ZQ.bind(void 0,KLe,a):XQ.bind(void 0,yx),p=u||l?YLe.bind(void 0,a):void 0;return{stream:new nqt({writableObjectMode:n,writableHighWaterMark:ZLe(n),readableObjectMode:i,readableHighWaterMark:ZLe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},fU=(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=XLe(o,r,a);t=JLe(c,t)}return t},XLe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:VLe(n,a)},lU(r,o,n),uU(r,s,n,c),{transform:t,final:e},{transform:HLe(i,a)},BLe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var QLe=(t,e)=>{for(let r of iqt(t))sqt(t,r,e)},iqt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),sqt=(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 ${$f[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>oqt(a,n));r.input=cx(o)},oqt=(t,e)=>{let r=fU(t,e,"utf8",!0);return aqt(r),cx(r)},aqt=t=>{let e=t.find(r=>typeof r!="string"&&!xn(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 dqt,appendFileSync as fqt}from"fs";var pU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&oE(r,n)&&!ro.has(e)&&cqt(n)&&(t.some(({type:i,value:s})=>i==="native"&&uqt.has(s))||t.every(({type:i})=>Zo.has(i))),cqt=t=>t===1||t===2,uqt=new Set(["pipe","overlapped"]),eMe=async(t,e,r,n)=>{for await(let i of t)lqt(e)||rMe(i,r,n)},tMe=(t,e,r)=>{for(let n of t)rMe(n,e,r)},lqt=t=>t._readableState.pipes.length>0,rMe=(t,e,r)=>{let n=x1(t);iu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var nMe=({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)=>pqt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},pqt=({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=iLe(t,s,d),p=Rl(f),{stdioItems:h,objectMode:m}=e[r],g=hqt([p],h,c,n),{serializedResult:y,finalResult:E=y}=mqt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});gqt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&_qt(y,h,i),S}catch(_){return n.error=_,S}},hqt=(t,e,r,n)=>{try{return fU(t,e,r,!1)}catch(i){return n.error=i,t}},mqt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:cx(t)};let o=yNe(t,r);return n[s]?{serializedResult:o,finalResult:JQ(o,!i[s],e)}:{serializedResult:o}},gqt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!pU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=JQ(t,!1,o);try{tMe(a,e,n)}catch(c){r.error??=c}},_qt=(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)?fqt(n,t):(r.add(s),dqt(n,t))}};var iMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Il(e,r,"all")]:Array.isArray(e)?[Il(t,r,"all"),...e]:xn(t)&&xn(e)?sQ([t,e]):`${t}${e}`};import{once as e7}from"events";var sMe=async(t,e)=>{let[r,n]=await yqt(t);return e.isForcefullyTerminated??=!1,[r,n]},yqt=async t=>{let[e,r]=await Promise.allSettled([e7(t,"spawn"),e7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?oMe(t):r.value},oMe=async t=>{try{return await e7(t,"exit")}catch{return oMe(t)}},aMe=async t=>{let[e,r]=await t;if(!Sqt(e,r)&&t7(e,r))throw new Ka;return[e,r]},Sqt=(t,e)=>t===void 0&&e===void 0,t7=(t,e)=>t!==0||e!==null;var cMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Eqt(t,e,r),o=s?.code==="ETIMEDOUT",a=nLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Eqt=(t,e,r)=>t!==void 0?t:t7(e,r)?new Ka:void 0;var uMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=bqt(t,e,r),d=Aqt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return gE(d,c,u)},bqt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),a=wqt(r),{file:c,commandArguments:u,options:l}=Y1(t,e,a);Tqt(l);let d=FLe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},wqt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Tqt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&hU("ipcInput"),t&&hU("ipc: true"),r&&hU("detached: true"),n&&hU("cancelSignal")},hU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Aqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Rqt({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}=cMe(c,r),{output:h,error:m=u}=nMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,S)=>Il(E,r,S)),y=Il(iMe(h,r),r,"all");return Oqt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Rqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{QLe(s,r);let a=xqt(r);return vqt(...J1(t,e,a))}catch(a){return mE({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},xqt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:nU(e)}),Oqt=({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?iU({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 m2t}from"events";import{spawn as g2t}from"child_process";import hMe from"process";import{once as r7,on as Iqt}from"events";var lMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(uE({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),Pqt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Pqt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{F1(e,i);let s=Nf(t,e,r),o=new AbortController;try{return await Promise.race([Cqt(s,n,o),kqt(s,r,o),Nqt(s,r,o)])}catch(a){throw lE(t),a}finally{o.abort(),j1(e,i)}},Cqt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await r7(t,"message",{signal:r});return n}for await(let[n]of Iqt(t,"message",{signal:r}))if(e(n))return n},kqt=async(t,e,{signal:r})=>{await r7(t,"disconnect",{signal:r}),J$e(e)},Nqt=async(t,e,{signal:r})=>{let[n]=await r7(t,"strict:error",{signal:r});throw L1(n,e)};import{once as fMe,on as $qt}from"events";var pMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>n7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),n7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{uE({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),F1(e,s);let o=Nf(t,e,r),a=new AbortController,c={};return Dqt(t,o,a),Lqt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Mqt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Dqt=async(t,e,r)=>{try{await fMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Lqt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await fMe(t,"strict:error",{signal:r.signal});n.error=L1(i,e),r.abort()}catch{}},Mqt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of $qt(r,"message",{signal:s.signal}))dMe(o),yield c}catch{dMe(o)}finally{s.abort(),j1(e,a),n||lE(t),i&&await t}},dMe=({error:t})=>{if(t)throw t};var mMe=(t,{ipc:e})=>{Object.assign(t,_Me(t,!1,e))},gMe=()=>{let t=hMe,e=!0,r=hMe.channel!==void 0;return{..._Me(t,e,r),getCancelSignal:wDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},_Me=(t,e,r)=>({sendMessage:W1.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:lMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:pMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Uqt}from"child_process";import{PassThrough as Fqt,Readable as jqt,Writable as zqt,Duplex as qqt}from"stream";var yMe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{WQ(n);let a=new Uqt;Bqt(a,n),Object.assign(a,{readable:Vqt,writable:Hqt,duplex:Gqt});let c=mE({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Wqt(c,o,i);return{subprocess:a,promise:u}},Bqt=(t,e)=>{let r=Sx(),n=Sx(),i=Sx(),s=Array.from({length:e.length-3},Sx),o=Sx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Sx=()=>{let t=new Fqt;return t.end(),t},Vqt=()=>new jqt({read(){}}),Hqt=()=>new zqt({write(){}}),Gqt=()=>new qqt({read(){},write(){}}),Wqt=async(t,e,r)=>gE(t,e,r);import{createReadStream as SMe,createWriteStream as EMe}from"fs";import{Buffer as Kqt}from"buffer";import{Readable as Ex,Writable as Yqt,Duplex as Jqt}from"stream";var bMe=(t,e)=>cU(Zqt,t,e,!1),vx=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$f[t]}.`)},vMe={fileNumber:vx,generator:QQ,asyncGenerator:QQ,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Jqt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Zqt={input:{...vMe,fileUrl:({value:t})=>({stream:SMe(t)}),filePath:({value:{file:t}})=>({stream:SMe(t)}),webStream:({value:t})=>({stream:Ex.fromWeb(t)}),iterable:({value:t})=>({stream:Ex.from(t)}),asyncIterable:({value:t})=>({stream:Ex.from(t)}),string:({value:t})=>({stream:Ex.from(t)}),uint8Array:({value:t})=>({stream:Ex.from(Kqt.from(t))})},output:{...vMe,fileUrl:({value:t})=>({stream:EMe(t)}),filePath:({value:{file:t,append:e}})=>({stream:EMe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Yqt.fromWeb(t)}),iterable:vx,asyncIterable:vx,string:vx,uint8Array:vx}};import{on as Xqt,once as wMe}from"events";import{PassThrough as Qqt,getDefaultHighWaterMark as eBt}from"stream";import{finished as RMe}from"stream/promises";function Lm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)s7(i);let e=t.some(({readableObjectMode:i})=>i),r=tBt(t,e),n=new i7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var tBt=(t,e)=>{if(t.length===0)return eBt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},i7=class extends Qqt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(s7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=rBt(this,this.#e,this.#s);let r=sBt({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(s7(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)}},rBt=async(t,e,r)=>{mU(t,TMe);let n=new AbortController;try{await Promise.race([nBt(t,n),iBt(t,e,r,n)])}finally{n.abort(),mU(t,-TMe)}},nBt=async(t,{signal:e})=>{try{await RMe(t,{signal:e,cleanup:!0})}catch(r){throw xMe(t,r),r}},iBt=async(t,e,r,{signal:n})=>{for await(let[i]of Xqt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},s7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},sBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{mU(t,AMe);let a=new AbortController;try{await Promise.race([oBt(s,e,a),aBt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),cBt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),mU(t,-AMe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?o7(t):uBt(t))},oBt=async(t,e,{signal:r})=>{try{await t,r.aborted||o7(e)}catch(n){r.aborted||xMe(e,n)}},aBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await RMe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;OMe(o)?i.add(e):IMe(t,o)}},cBt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await wMe(t,i,{signal:s}),!t.readable)return wMe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},uBt=t=>{t.writable&&t.end()},xMe=(t,e)=>{OMe(e)?o7(t):IMe(t,e)},OMe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",o7=t=>{(t.readable||t.writable)&&t.destroy()},IMe=(t,e)=>{t.destroyed||(t.once("error",lBt),t.destroy(e))},lBt=()=>{},mU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},TMe=2,AMe=1;import{finished as PMe}from"stream/promises";var yE=(t,e)=>{t.pipe(e),dBt(t,e),fBt(t,e)},dBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await PMe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}a7(e)}},a7=t=>{t.writable&&t.end()},fBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await PMe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}c7(t)}},c7=t=>{t.readable&&t.destroy()};var CMe=(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})=>Zo.has(c)))pBt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Zo.has(c)))mBt({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]:Lm(s);yE(o,i)}},pBt=(t,e,r,n)=>{r==="output"?yE(t.stdio[n],e):yE(e,t.stdio[n]);let i=hBt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},hBt=["stdin","stdout","stderr"],mBt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;gBt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},gBt=(t,{signal:e})=>{Wa(t)&&km(t,_Bt,e)},_Bt=2;import{addAbortListener as EBt}from"events";var Mm=[];Mm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Mm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Mm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var gU=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",u7=Symbol.for("signal-exit emitter"),l7=globalThis,yBt=Object.defineProperty.bind(Object),d7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(l7[u7])return l7[u7];yBt(l7,u7,{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}},_U=class{},SBt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),f7=class extends _U{onExit(){return()=>{}}load(){}unload(){}},p7=class extends _U{#e=h7.platform==="win32"?"SIGINT":"SIGHUP";#r=new d7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Mm)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(!gU(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 Mm)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,Mm.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 gU(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"&&gU(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)}},h7=globalThis.process,{onExit:kMe,load:g2r,unload:_2r}=SBt(gU(h7)?new p7(h7):new f7);var NMe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=kMe(()=>{t.kill()});EBt(n,()=>{i()})};var DMe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=O1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=vBt(r,n,i),{sourceStream:d,sourceError:f}=wBt(t,u),{options:p,fileDescriptors:h}=ou.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},vBt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=bBt(t,e,...r),a=U1(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},bBt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($Me,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||nQ(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]=y1(r,...n);return{destination:e($Me)(i,s,o),pipeOptions:o}}if(ou.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}`)},$Me=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),wBt=(t,e)=>{try{return{sourceStream:dE(t,e)}}catch(r){return{sourceError:r}}};var MMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=TBt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw m7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},TBt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return c7(t),n;if(e!==void 0)return a7(r),e},m7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>mE({error:t,command:LMe,escapedCommand:LMe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),LMe="source.pipe(destination)";var UMe=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 ABt}from"stream/promises";var FMe=(t,e,r)=>{let n=yU.has(e)?xBt(t,e):RBt(t,e);return km(t,IBt,r.signal),km(e,PBt,r.signal),OBt(e),n},RBt=(t,e)=>{let r=Lm([t]);return yE(r,e),yU.set(e,r),r},xBt=(t,e)=>{let r=yU.get(e);return r.add(t),r},OBt=async t=>{try{await ABt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}yU.delete(t)},yU=new WeakMap,IBt=2,PBt=1;import{aborted as CBt}from"util";var jMe=(t,e)=>t===void 0?[]:[kBt(t,e)],kBt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await CBt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw m7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var SU=(t,...e)=>{if(Qr(e[0]))return SU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=DMe(t,...e),i=NBt({...n,destination:r});return i.pipe=SU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},NBt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=$Bt(t,i);MMe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=FMe(e,s,d);return await Promise.race([UMe(l),...jMe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},$Bt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as zBt}from"timers/promises";import{on as DBt}from"events";import{getDefaultHighWaterMark as LBt}from"stream";var EU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return MBt(e,o),qMe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},MBt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},g7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;UBt(e,o,t);let a=t.readableObjectMode&&!s;return qMe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},UBt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},qMe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=DBt(t,"data",{signal:e.signal,highWaterMark:zMe,highWatermark:zMe});return FBt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},_7=LBt(!0),zMe=_7,FBt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=jBt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Dm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*yx(a)}},jBt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[lU(t,r,!e),uU(t,i,!n,{})].filter(Boolean);var BMe=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=qBt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([BBt(t),d]);return}let f=KQ(c,r),p=g7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([VBt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},qBt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!pU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=g7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await eMe(a,t,r,s)},BBt=async t=>{await zBt(),t.readableFlowing===null&&t.resume()},VBt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await eU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await tU(r,{maxBuffer:s})):await hE(r,{maxBuffer:s})}catch(a){return VMe(eLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},y7=async t=>{try{return await t}catch(e){return VMe(e)}},VMe=({bufferedData:t})=>gNe(t)?new Uint8Array(t):t;import{finished as HBt}from"stream/promises";var bx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=GBt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],HBt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||YBt(a,e,r,n)}finally{o.abort()}},GBt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&WBt(t,r,n),n},WBt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{KBt(e,r),n.call(t,...i)}},KBt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},YBt=(t,e,r,n)=>{if(!JBt(t,e,r,n))throw t},JBt=(t,e,r,n=!0)=>r.propagating?HMe(t)||vU(t):(r.propagating=!0,S7(r,e)===n?HMe(t):vU(t)),S7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",vU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",HMe=t=>t?.code==="EPIPE";var GMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>E7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),E7=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=bx(t,e,u);if(S7(u,e)){await l;return}let[d]=await Promise.all([BMe({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 WMe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Lm([t,e].filter(Boolean)):void 0,KMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>E7({...ZBt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:XBt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),ZBt=({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}},XBt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as QBt}from"events";var YMe=t=>oE(t,"ipc"),JMe=(t,e)=>{let r=x1(t);iu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ZMe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=YMe(s),a=xl(e,"ipc"),c=xl(r,"ipc");for await(let u of n7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(tLe(t,i,c),i.push(u)),o&&JMe(u,s);return i},XMe=async(t,e)=>(await Promise.allSettled([t]),e);var QMe=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 E=sMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=GMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=KMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=ZMe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=e2t(m,t,S),I=t2t(h,S);try{return await Promise.race([Promise.all([{},aMe(E),Promise.all(_),w,R,NDe(t,d),...T,...I]),g,r2t(t,y),...ODe(t,s,f,y),...Y$e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...RDe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(_.map(O=>y7(O))),y7(w),XMe(R,b),Promise.allSettled(T),Promise.allSettled(I)])}},e2t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:bx(n,i,r)),t2t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ja(s,{checkOpen:!1})&&!Wa(s)).map(({type:i,value:s,stream:o=s})=>bx(o,n,e,{isSameDirection:Zo.has(i),stopOnExit:i==="native"}))),r2t=async(t,{signal:e})=>{let[r]=await QBt(t,"error",{signal:e});throw r};var e1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),wx=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=su();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},SE=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 n2t}from"stream";import{callbackify as i2t}from"util";import{finished as t1e}from"stream/promises";var v7=async t=>{if(t!==void 0)try{await b7(t)}catch{}},r1e=async t=>{if(t!==void 0)try{await w7(t)}catch{}},b7=async t=>{await t1e(t,{cleanup:!0,readable:!1,writable:!0})},w7=async t=>{await t1e(t,{cleanup:!0,readable:!0,writable:!1})},bU=async(t,e)=>{if(await t,e)throw e},wU=(t,e,r)=>{r&&!vU(r)?t.destroy(r):e&&t.destroy()};var n1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ro.has(r),{subprocessStdout:a,waitReadableDestroy:c}=T7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=A7(a,o),{read:f,onStdoutDataDone:p}=R7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new n2t({read:f,destroy:i2t(O7.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return x7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},T7=(t,e,r)=>{let n=dE(t,e),i=wx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},A7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:_7},R7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=su(),o=EU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){s2t(this,o,s)},onStdoutDataDone:s}},s2t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},x7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await w7(t),await n,await v7(i),await e,r.readable&&r.push(null)}catch(s){await v7(i),i1e(r,s)}},O7=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await SE(r,e)&&(i1e(t,n),await bU(e,n))},i1e=(t,e)=>{wU(t,t.readable,e)};import{Writable as o2t}from"stream";import{callbackify as s1e}from"util";var o1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=I7(t,r,e),o=new o2t({...P7(n,t,i),destroy:s1e(k7.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return C7(n,o),o},I7=(t,e,r)=>{let n=U1(t,e),i=wx(r,n,"writableFinal"),s=wx(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},P7=(t,e,r)=>({write:a2t.bind(void 0,t),final:s1e(c2t.bind(void 0,t,e,r))}),a2t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},c2t=async(t,e,r)=>{await SE(r,e)&&(t.writable&&t.end(),await e)},C7=async(t,e,r)=>{try{await b7(t),e.writable&&e.end()}catch(n){await r1e(r),a1e(e,n)}},k7=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await SE(r,e),await SE(n,e)&&(a1e(t,i),await bU(e,i))},a1e=(t,e)=>{wU(t,t.writable,e)};import{Duplex as u2t}from"stream";import{callbackify as l2t}from"util";var c1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ro.has(r),{subprocessStdout:c,waitReadableDestroy:u}=T7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=I7(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=A7(c,a),{read:g,onStdoutDataDone:y}=R7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new u2t({read:g,...P7(l,t,d),destroy:l2t(d2t.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 x7({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:l}),C7(l,E,c),E},d2t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([O7({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),k7({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var N7=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ro.has(e),o=dE(t,r),a=EU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return f2t(a,o,t)},f2t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var u1e=(t,{encoding:e})=>{let r=e1e();t.readable=n1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=o1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=c1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=N7.bind(void 0,t,e),t[Symbol.asyncIterator]=N7.bind(void 0,t,e,{})};var l1e=(t,e)=>{for(let[r,n]of h2t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},p2t=(async()=>{})().constructor.prototype,h2t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(p2t,t)]);var d1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=_2t(t,e,r),{subprocess:f,promise:p}=S2t({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=SU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),l1e(f,p),ou.set(f,{options:l,fileDescriptors:d}),f},_2t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),{file:a,commandArguments:c,options:u}=Y1(t,e,r),l=y2t(u),d=bMe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},y2t=({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}},S2t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=g2t(...J1(t,e,r))}catch(h){return yMe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;m2t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];CMe(c,a,u),NMe(c,r,u);let d={},f=su();c.kill=W$e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=WMe(c,r),u1e(c,r),mMe(c,r);let p=E2t({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}},E2t=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 QMe({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)=>Il(_,e,w)),E=Il(m,e,"all"),S=v2t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return gE(S,n,e)},v2t=({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 au,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):iU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var TU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,b2t(n,t[n],i)]));return{...t,...r}},b2t=(t,e,r)=>w2t.has(t)&&Qr(e)&&Qr(r)?{...e,...r}:r,w2t=new Set(["env",...uQ]);var Df=(t,e,r,n)=>{let i=(o,a,c)=>Df(o,a,r,c),s=(...o)=>T2t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},T2t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Qr(s))return i(t,TU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=A2t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?uMe(a,c,u):d1e(a,c,u,i)},A2t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=bNe(e)?wNe(e,r):[e,...r],[o,a,c]=y1(...s),u=TU(TU(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 f1e=({file:t,commandArguments:e})=>h1e(t,e),p1e=({file:t,commandArguments:e})=>({...h1e(t,e),isSync:!0}),h1e=(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]=R2t(t);return{file:r,commandArguments:n}},R2t=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(x2t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},x2t=/ +/g;var m1e=(t,e,r)=>{t.sync=e(O2t,r),t.s=t.sync},g1e=({options:t})=>_1e(t),O2t=({options:t})=>({..._1e(t),isSync:!0}),_1e=t=>({options:{...I2t(t),...t}}),I2t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},y1e={preferLocal:!0};var S1e=Df(()=>({})),o4r=Df(()=>({isSync:!0})),E1e=Df(f1e),a4r=Df(p1e),c4r=Df(PDe),u4r=Df(g1e,{},y1e,m1e),{sendMessage:l4r,getOneMessage:d4r,getEachMessage:f4r,getCancelSignal:p4r}=gMe();import{Transform as P2t}from"stream";var C2t=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function k2t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...C2t])]}function N2t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function $2t(){let e=k2t().map(r=>process.env[r]).filter(r=>!(!r||N2t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ei(t){if(typeof t!="string")return t;let e=$2t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(D2t(n),"g");r=r.replace(i,"******")}),r}function D2t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Tx=class extends P2t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ei(i);n(null,s)}},AU=Symbol("maskedWrite");function v1e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[AU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stdout.write=r}if(!process.stderr.write[AU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stderr.write=r}}}var b1e=!1,w1e,$7=t=>{w1e??=t},T1e=t=>{b1e=!0,$7(t)},en=()=>b1e,Xo=()=>w1e,A1e=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Ax=null,R1e=t=>(Ax&&Ax.destroy(),Ax=new Qo({totalAllowedTime:t}),Ax),x1e=()=>Ax;var Qo=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&&en())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 vD({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{X.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 O1e={name:"@netlify/agent-runner-cli",type:"module",version:"2.12.0-nb87df2e9baa9e.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!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 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:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",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.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.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.2","@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 F2t=M2t(import.meta.url),j2t=Pl.dirname(F2t),z2t=U2t(import.meta.url),EE=he("shell"),D7=new Set,I1e={preferLocal:!0},Ut=(t,e,r)=>{let[n,i]=q2t(e,r),s={...I1e,...i},o=S1e(t,n,s);C1e(o,s),$1e(o);let a=r?.idleTimeout;return a&&a>0&&N1e(o,a),o},P1e=(t,e)=>{let r={...I1e,...e},n=E1e(t,r);return C1e(n,r),$1e(n),e?.idleTimeout&&e.idleTimeout>0&&N1e(n,e.idleTimeout),n},q2t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},C1e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||uu.env.NETLIFY_LOCAL_QUIET==="true")return;if(uu.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Tx).pipe(uu.stdout),t.stderr?.pipe(new Tx).pipe(uu.stderr);return}t.stdout?.pipe(uu.stdout),t.stderr?.pipe(uu.stderr)},L7=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(uu.kill(-t.pid,e),EE.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return EE.error("Error killing process:",r),!1}},k1e=t=>L7(t,"SIGKILL"),N1e=(t,e)=>{let r=null,n=()=>{EE.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),L7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing idle process ${t.pid}`),k1e(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)},$1e=t=>{D7.add(t);let e=x1e();if(e){let r=e.onTimesUp(()=>{EE.log(`Global timer expired, killing process ${t.pid}`),L7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing process ${t.pid} after timeout`),k1e(t))},5e3)});t.on("exit",()=>{D7.delete(t),r()}),t.on("error",()=>{D7.delete(t),r()})}};function lu(t,e){if(!uu.env.NETLIFY_LOCAL_MODE)try{let i=z2t.resolve(O1e.name),s=Pl.dirname(i);for(;s!==Pl.dirname(s);){let o=Pl.dirname(s);if(Pl.basename(o)==="node_modules"){let a=Pl.join(o,".bin",e);if(RU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(uu.env.NODE_PATH){let i=Pl.join(uu.env.NODE_PATH,".bin",e);if(RU.existsSync(i))return i}let r=Pl.join(t,"node_modules",".bin",e);if(RU.existsSync(r))return r;let n=Pl.join(j2t,"..","node_modules",".bin",e);if(RU.existsSync(n))return n}import Oq from"process";import{fileURLToPath as iXt}from"url";import{createRequire as sXt}from"module";import AI from"path";import{readFileSync as oXt}from"fs";var B2t="__netlify__getTracer",V2t="__netlify__shutdownTracers",$t=(t,e)=>globalThis[B2t]?.(t,e),D1e=async()=>globalThis[V2t]?.();function Rx(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as YZt}from"timers/promises";Ue();import UHt from"process";Ue();var H2t=(t,e)=>{e.recordException(t),e.setStatus({code:qn.ERROR})};var Cl=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}=L1e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>M1e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=L1e(r,n,i),c=this._tracer.startSpan(e,s,o);return M1e(c,s,a)}};function L1e(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??lr.active(),{opts:n,ctx:i,fn:s}}function M1e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:H2t,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)}}Ue();var bE=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var U7=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=W1e(e),n._asyncAttributesPending=e.filter(([i,s])=>bE(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(bE(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=W1e(this._rawAttributes),this._schemaUrl=G2t(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,bE(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&me.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(bE(n)){me.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=W2t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function F7(t,e){return U7.FromAttributeList(Object.entries(t),e)}function W1e(t){return t.map(([e,r])=>bE(r)?[e,r.catch(n=>{me.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function G2t(t){if(typeof t=="string"||t===void 0)return t;me.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function W2t(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;me.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ue();var xx=class{emit(e){}enabled(){return!1}},K1e=new xx;var Ox=Symbol.for("io.opentelemetry.js.api.logs"),wE=globalThis;function Y1e(t,e,r){return n=>n===t?e:r}var j7=1;var z7=class{getLogger(e,r,n){return new xx}},IU=new z7;var PU=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):K1e}};var Ix=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new PU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:IU}_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 CU=class t{constructor(){this._proxyLoggerProvider=new Ix}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return wE[Ox]?this.getLoggerProvider():(wE[Ox]=Y1e(j7,e,IU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=wE[Ox])===null||e===void 0?void 0:e.call(wE,j7))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete wE[Ox],this._proxyLoggerProvider=new Ix}};var J1e=CU.getInstance();function Z1e(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 X1e(t){t.forEach(e=>e.disable())}function q7(t){let e=t.tracerProvider||Wt.getTracerProvider(),r=t.meterProvider||xR.getMeterProvider(),n=t.loggerProvider||J1e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Z1e(i,e,r,n),()=>{X1e(i)}}Ue();var K2t=zn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Q1e(t){return t.getValue(K2t)===!0}var TE;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(TE||(TE={}));Ue();var B7="[_0-9a-z-*/]",Y2t=`[a-z]${B7}{0,255}`,J2t=`[a-z0-9]${B7}{0,240}@[a-z]${B7}{0,13}`,Z2t=new RegExp(`^(?:${Y2t}|${J2t})$`),X2t=/^[ -~]{0,255}[!-~]$/,Q2t=/,|=/;function V7(t){return Z2t.test(t)}function H7(t){return X2t.test(t)&&!Q2t.test(t)}var eVt=32,eUe=512,tUe=",",rUe="=",kU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!V7(e)||!H7(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>eUe)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=tUe+e),e=`${n[0]}${rUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(tUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(rUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!V7(a)||!H7(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>eUe)&&(r.set(a,c),n=u,r.size>=eVt))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 NU="traceparent",$U="tracestate",tVt="00",rVt="(?!ff)[\\da-f]{2}",nVt="(?![0]{32})[\\da-f]{32}",iVt="(?![0]{16})[\\da-f]{16}",sVt="[\\da-f]{2}",oVt=new RegExp(`^\\s?(${rVt})-(${nVt})-(${iVt})-(${sVt})(-.*)?\\s?$`);function nUe(t){let e=oVt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Lf=class{inject(e,r,n){let i=Wt.getSpanContext(e);if(!i||Q1e(e)||!ws(i))return;let s=`${tVt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||zr.NONE).toString(16)}`;n.set(r,NU,s),i.traceState&&n.set(r,$U,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,NU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=nUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,$U);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new kU(typeof c=="string"?c:void 0)}return Wt.setSpanContext(e,o)}fields(){return[NU,$U]}};var DU=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 Px=class{_isCalled=!1;_deferred=new DU;_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 OF=En(Nee(),1);Ue();var tze=t=>{throw TypeError(t)},Mee=(t,e,r)=>e.has(t)||tze("Cannot "+r),xF=(t,e,r)=>(Mee(t,e,"read from private field"),r?r.call(t):e.get(t)),$ee=(t,e,r)=>e.has(t)?tze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Xje=(t,e,r,n)=>(Mee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),MHt=(t,e,r)=>(Mee(t,e,"access private method"),r),Qje="__netlify__getTracer",FHt="__netlify__shutdownTracers",jHt="__nfOTLPTrace",Yx,Jx,Lee,rze,zHt=class{constructor(){$ee(this,Lee),$ee(this,Yx),$ee(this,Jx),Xje(this,Yx,new Px(MHt(this,Lee,rze),this)),Xje(this,Jx,me.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(xF(this,Jx).debug(`export ${t.length.toString()} spans`),xF(this,Yx).isCalled){e({code:TE.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(jHt,JSON.stringify(qHt(t))),e({code:TE.SUCCESS})}shutdown(){return xF(this,Yx).call()}};Yx=new WeakMap;Jx=new WeakMap;Lee=new WeakSet;rze=function(){return xF(this,Jx).debug("Shutting down"),Promise.resolve()};function qHt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:RF(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||qa.SERVER,startTimeUnixNano:Dee(e.startTime),endTimeUnixNano:Dee(e.endTime),attributes:RF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Dee(n.time),attributes:RF(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:RF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function RF(t){return Object.keys(t).map(e=>nze(e,t[e]))}function nze(t,e){return{key:t,value:ize(e)}}function ize(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(ize)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>nze(r,n))}}:{}}function Dee(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var eze={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"}},sze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Qje))return;let e=UHt.version.slice(1),r=F7({"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??[BHt()],i=new OF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Lf});let s=t.instrumentations??[];q7({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,Qje,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Cl(Wt.getTracer(a,c)):new Cl(Wt.getTracer(eze.name,eze.version))}}),Object.defineProperty(globalThis,FHt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},BHt=()=>new OF.SimpleSpanProcessor(new zHt);Ue();var LE=En(Nee(),1);Ue();import*as IF from"diagnostics_channel";var oze=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?qn.ERROR:qn.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 Cl?t:new Cl(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){IF.subscribe(t,e);let r=()=>IF.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:qa.CLIENT},lr.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:qn.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 K6e=En(V6e(),1);kse();var H6e=0;var WZt=3*1024*1024,KZt=t=>SI.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Rq=class{constructor(e,r=WZt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=KZt(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:H6e});return}this.inner.export(n[c],u=>{u.code!==H6e&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var Lv=he("tracing"),G6e=8e3,JZt=5e3,W6e=t=>t.length>G6e?`${t.slice(0,G6e)}\u2026`:t,bI={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},ZZt=Math.ceil(bI.maxQueueSize/bI.maxExportBatchSize)+1,XZt=t=>new LE.BatchSpanProcessor(new Rq(new K6e.OTLPTraceExporter({url:t,concurrencyLimit:ZZt})),bI),yg=async(t=JZt)=>{try{let e=Symbol("timed out");await Promise.race([D1e(),YZt(t,e)])===e&&Lv.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){Lv.warn("Failed to flush tracers on shutdown",e)}},Y6e=async(t,e,r)=>{if(!$t()){let n=[new LE.SimpleSpanProcessor(new $se),XZt(r.exporterUrl)];await sze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new oze({skipHeaders:!0})]})}return r.traceparent?(Ji.setGlobalPropagator(new Lf),Ji.extract(lr.active(),{traceparent:r.traceparent,isRemote:!0})):lr.active()};function hr(t,e,r){return Lv.log(`\u23F3 TRACE: ${e} starting...`),Rx(t,e,r)}var $se=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(", ")}]`:"";Lv.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&Lv.log(` \u274C Error: ${e.status.message}`)}};function Dse(){return We().captureLlmContentEnabled}function J6e(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 xq(t,e,r){let n={role:t,parts:[{type:"text",content:Ei(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var QZt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]);function Z6e(t,e,r,n){if(!t.length)return;let i=$t();if(!i)return;t.length>bI.maxQueueSize&&Lv.warn(`${t.length} step spans exceed the span queue of ${bI.maxQueueSize}; spans may be dropped`);let s=Dse(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let u=Math.min(n,r+c*o),l=Math.min(n,u+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&QZt.has(a.category)||a.category===ee.AgentMessage&&a.toolCallId!==void 0,f=d?"execute_tool":"chat",p=W6e(a.title||a.type||`step-${a.id??c}`),h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?W6e(a.message):void 0,y=i.startSpan(m,{startTime:u,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":Ei(p),"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&g?d?{"gen_ai.tool.call.result":Ei(g)}:{"gen_ai.output.messages":xq("assistant",g)}:{}}});d&&(a.toolCallId!==void 0&&y.setAttribute("gen_ai.tool.call.id",a.toolCallId),a.toolStatus!==void 0&&y.setAttribute("spark.step.tool_status",a.toolStatus),a.exitCode!==void 0&&y.setAttribute("spark.step.exit_code",a.exitCode),a.toolStatus==="error"&&(y.setAttribute("error.type","tool_error"),y.setStatus({code:qn.ERROR}))),y.end(l)})}import{readdir as eXt,rm as tXt}from"fs/promises";import{join as rXt}from"path";async function X6e(t,e=[]){let n=(await eXt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>tXt(rXt(t,i),{recursive:!0,force:!0})))}var nXt=300,wI=t=>We().budgetCreditThresholds[t.mode]?.[t.runner]??nXt,TI=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Lse=t=>{let e=wI(t);if(!TI(t,e))return"default";let r=We();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},Q6e=t=>{let e=Lse(t),r=wI(t);return{budget_eligible:TI(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var aXt=AI.dirname(iXt(import.meta.url)),eWe=sXt(import.meta.url),cXt=AI.resolve(aXt,"scripts/scaffold.js"),uXt="scripts/scaffold.js",lXt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,Mse=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},dXt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),fXt=t=>{let e=Mse(t);return e==="node"||e.endsWith("/node")},lo=t=>{if(typeof t!="string")return!1;let e=t.match(lXt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&dXt(Mse(e[r]));)r+=1;if(r>=e.length||!fXt(e[r]))return!1;let n=e[r+1];return n?Mse(n).includes(uXt):!1},Sg=he("create_stage"),Use="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.",pXt=`${Use}
597
+ if (condition) { yield value; }`)};import{Buffer as Kzt}from"buffer";import{StringDecoder as Yzt}from"string_decoder";var lU=(t,e,r)=>{if(r)return;if(t)return{transform:Jzt.bind(void 0,new TextEncoder)};let n=new Yzt(e);return{transform:Zzt.bind(void 0,n),final:Xzt.bind(void 0,n)}},Jzt=function*(t,e){Kzt.isBuffer(e)?yield Rl(e):typeof e=="string"?yield t.encode(e):yield e},Zzt=function*(t,e){yield xn(e)?t.write(e):e},Xzt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as WLe}from"util";var ZQ=WLe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),dU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=eqt}=e[r];for await(let i of n(t))yield*dU(i,e,r+1)},KLe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Qzt(r,Number(e),t)},Qzt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*dU(n,r,e+1)},YLe=WLe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),eqt=function*(t){yield t};var XQ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},JLe=(t,e)=>[...e.flatMap(r=>[...Dm(r,t,0)]),...yx(t)],Dm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=rqt}=e[r];for(let i of n(t))yield*Dm(i,e,r+1)},yx=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*tqt(r,Number(e),t)},tqt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Dm(n,r,e+1)},rqt=function*(t){yield t};var QQ=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=XLe(t,o,s),u=$m(e),l=$m(r),d=u?ZQ.bind(void 0,dU,a):XQ.bind(void 0,Dm),f=u||l?ZQ.bind(void 0,KLe,a):XQ.bind(void 0,yx),p=u||l?YLe.bind(void 0,a):void 0;return{stream:new nqt({writableObjectMode:n,writableHighWaterMark:ZLe(n),readableObjectMode:i,readableHighWaterMark:ZLe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},fU=(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=XLe(o,r,a);t=JLe(c,t)}return t},XLe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:VLe(n,a)},lU(r,o,n),uU(r,s,n,c),{transform:t,final:e},{transform:HLe(i,a)},BLe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var QLe=(t,e)=>{for(let r of iqt(t))sqt(t,r,e)},iqt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),sqt=(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 ${$f[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>oqt(a,n));r.input=cx(o)},oqt=(t,e)=>{let r=fU(t,e,"utf8",!0);return aqt(r),cx(r)},aqt=t=>{let e=t.find(r=>typeof r!="string"&&!xn(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 dqt,appendFileSync as fqt}from"fs";var pU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&oE(r,n)&&!ro.has(e)&&cqt(n)&&(t.some(({type:i,value:s})=>i==="native"&&uqt.has(s))||t.every(({type:i})=>Zo.has(i))),cqt=t=>t===1||t===2,uqt=new Set(["pipe","overlapped"]),eMe=async(t,e,r,n)=>{for await(let i of t)lqt(e)||rMe(i,r,n)},tMe=(t,e,r)=>{for(let n of t)rMe(n,e,r)},lqt=t=>t._readableState.pipes.length>0,rMe=(t,e,r)=>{let n=x1(t);iu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var nMe=({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)=>pqt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},pqt=({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=iLe(t,s,d),p=Rl(f),{stdioItems:h,objectMode:m}=e[r],g=hqt([p],h,c,n),{serializedResult:y,finalResult:E=y}=mqt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});gqt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&_qt(y,h,i),S}catch(_){return n.error=_,S}},hqt=(t,e,r,n)=>{try{return fU(t,e,r,!1)}catch(i){return n.error=i,t}},mqt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:cx(t)};let o=yNe(t,r);return n[s]?{serializedResult:o,finalResult:JQ(o,!i[s],e)}:{serializedResult:o}},gqt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!pU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=JQ(t,!1,o);try{tMe(a,e,n)}catch(c){r.error??=c}},_qt=(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)?fqt(n,t):(r.add(s),dqt(n,t))}};var iMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Il(e,r,"all")]:Array.isArray(e)?[Il(t,r,"all"),...e]:xn(t)&&xn(e)?sQ([t,e]):`${t}${e}`};import{once as e7}from"events";var sMe=async(t,e)=>{let[r,n]=await yqt(t);return e.isForcefullyTerminated??=!1,[r,n]},yqt=async t=>{let[e,r]=await Promise.allSettled([e7(t,"spawn"),e7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?oMe(t):r.value},oMe=async t=>{try{return await e7(t,"exit")}catch{return oMe(t)}},aMe=async t=>{let[e,r]=await t;if(!Sqt(e,r)&&t7(e,r))throw new Ka;return[e,r]},Sqt=(t,e)=>t===void 0&&e===void 0,t7=(t,e)=>t!==0||e!==null;var cMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Eqt(t,e,r),o=s?.code==="ETIMEDOUT",a=nLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Eqt=(t,e,r)=>t!==void 0?t:t7(e,r)?new Ka:void 0;var uMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=bqt(t,e,r),d=Aqt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return gE(d,c,u)},bqt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),a=wqt(r),{file:c,commandArguments:u,options:l}=Y1(t,e,a);Tqt(l);let d=FLe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},wqt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Tqt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&hU("ipcInput"),t&&hU("ipc: true"),r&&hU("detached: true"),n&&hU("cancelSignal")},hU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Aqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Rqt({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}=cMe(c,r),{output:h,error:m=u}=nMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,S)=>Il(E,r,S)),y=Il(iMe(h,r),r,"all");return Oqt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Rqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{QLe(s,r);let a=xqt(r);return vqt(...J1(t,e,a))}catch(a){return mE({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},xqt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:nU(e)}),Oqt=({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?iU({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 m2t}from"events";import{spawn as g2t}from"child_process";import hMe from"process";import{once as r7,on as Iqt}from"events";var lMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(uE({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),Pqt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Pqt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{F1(e,i);let s=Nf(t,e,r),o=new AbortController;try{return await Promise.race([Cqt(s,n,o),kqt(s,r,o),Nqt(s,r,o)])}catch(a){throw lE(t),a}finally{o.abort(),j1(e,i)}},Cqt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await r7(t,"message",{signal:r});return n}for await(let[n]of Iqt(t,"message",{signal:r}))if(e(n))return n},kqt=async(t,e,{signal:r})=>{await r7(t,"disconnect",{signal:r}),J$e(e)},Nqt=async(t,e,{signal:r})=>{let[n]=await r7(t,"strict:error",{signal:r});throw L1(n,e)};import{once as fMe,on as $qt}from"events";var pMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>n7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),n7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{uE({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),F1(e,s);let o=Nf(t,e,r),a=new AbortController,c={};return Dqt(t,o,a),Lqt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Mqt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Dqt=async(t,e,r)=>{try{await fMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Lqt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await fMe(t,"strict:error",{signal:r.signal});n.error=L1(i,e),r.abort()}catch{}},Mqt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of $qt(r,"message",{signal:s.signal}))dMe(o),yield c}catch{dMe(o)}finally{s.abort(),j1(e,a),n||lE(t),i&&await t}},dMe=({error:t})=>{if(t)throw t};var mMe=(t,{ipc:e})=>{Object.assign(t,_Me(t,!1,e))},gMe=()=>{let t=hMe,e=!0,r=hMe.channel!==void 0;return{..._Me(t,e,r),getCancelSignal:wDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},_Me=(t,e,r)=>({sendMessage:W1.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:lMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:pMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Uqt}from"child_process";import{PassThrough as Fqt,Readable as jqt,Writable as zqt,Duplex as qqt}from"stream";var yMe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{WQ(n);let a=new Uqt;Bqt(a,n),Object.assign(a,{readable:Vqt,writable:Hqt,duplex:Gqt});let c=mE({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Wqt(c,o,i);return{subprocess:a,promise:u}},Bqt=(t,e)=>{let r=Sx(),n=Sx(),i=Sx(),s=Array.from({length:e.length-3},Sx),o=Sx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Sx=()=>{let t=new Fqt;return t.end(),t},Vqt=()=>new jqt({read(){}}),Hqt=()=>new zqt({write(){}}),Gqt=()=>new qqt({read(){},write(){}}),Wqt=async(t,e,r)=>gE(t,e,r);import{createReadStream as SMe,createWriteStream as EMe}from"fs";import{Buffer as Kqt}from"buffer";import{Readable as Ex,Writable as Yqt,Duplex as Jqt}from"stream";var bMe=(t,e)=>cU(Zqt,t,e,!1),vx=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$f[t]}.`)},vMe={fileNumber:vx,generator:QQ,asyncGenerator:QQ,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Jqt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Zqt={input:{...vMe,fileUrl:({value:t})=>({stream:SMe(t)}),filePath:({value:{file:t}})=>({stream:SMe(t)}),webStream:({value:t})=>({stream:Ex.fromWeb(t)}),iterable:({value:t})=>({stream:Ex.from(t)}),asyncIterable:({value:t})=>({stream:Ex.from(t)}),string:({value:t})=>({stream:Ex.from(t)}),uint8Array:({value:t})=>({stream:Ex.from(Kqt.from(t))})},output:{...vMe,fileUrl:({value:t})=>({stream:EMe(t)}),filePath:({value:{file:t,append:e}})=>({stream:EMe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Yqt.fromWeb(t)}),iterable:vx,asyncIterable:vx,string:vx,uint8Array:vx}};import{on as Xqt,once as wMe}from"events";import{PassThrough as Qqt,getDefaultHighWaterMark as eBt}from"stream";import{finished as RMe}from"stream/promises";function Lm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)s7(i);let e=t.some(({readableObjectMode:i})=>i),r=tBt(t,e),n=new i7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var tBt=(t,e)=>{if(t.length===0)return eBt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},i7=class extends Qqt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(s7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=rBt(this,this.#e,this.#s);let r=sBt({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(s7(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)}},rBt=async(t,e,r)=>{mU(t,TMe);let n=new AbortController;try{await Promise.race([nBt(t,n),iBt(t,e,r,n)])}finally{n.abort(),mU(t,-TMe)}},nBt=async(t,{signal:e})=>{try{await RMe(t,{signal:e,cleanup:!0})}catch(r){throw xMe(t,r),r}},iBt=async(t,e,r,{signal:n})=>{for await(let[i]of Xqt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},s7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},sBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{mU(t,AMe);let a=new AbortController;try{await Promise.race([oBt(s,e,a),aBt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),cBt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),mU(t,-AMe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?o7(t):uBt(t))},oBt=async(t,e,{signal:r})=>{try{await t,r.aborted||o7(e)}catch(n){r.aborted||xMe(e,n)}},aBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await RMe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;OMe(o)?i.add(e):IMe(t,o)}},cBt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await wMe(t,i,{signal:s}),!t.readable)return wMe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},uBt=t=>{t.writable&&t.end()},xMe=(t,e)=>{OMe(e)?o7(t):IMe(t,e)},OMe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",o7=t=>{(t.readable||t.writable)&&t.destroy()},IMe=(t,e)=>{t.destroyed||(t.once("error",lBt),t.destroy(e))},lBt=()=>{},mU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},TMe=2,AMe=1;import{finished as PMe}from"stream/promises";var yE=(t,e)=>{t.pipe(e),dBt(t,e),fBt(t,e)},dBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await PMe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}a7(e)}},a7=t=>{t.writable&&t.end()},fBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await PMe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}c7(t)}},c7=t=>{t.readable&&t.destroy()};var CMe=(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})=>Zo.has(c)))pBt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Zo.has(c)))mBt({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]:Lm(s);yE(o,i)}},pBt=(t,e,r,n)=>{r==="output"?yE(t.stdio[n],e):yE(e,t.stdio[n]);let i=hBt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},hBt=["stdin","stdout","stderr"],mBt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;gBt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},gBt=(t,{signal:e})=>{Wa(t)&&km(t,_Bt,e)},_Bt=2;import{addAbortListener as EBt}from"events";var Mm=[];Mm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Mm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Mm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var gU=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",u7=Symbol.for("signal-exit emitter"),l7=globalThis,yBt=Object.defineProperty.bind(Object),d7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(l7[u7])return l7[u7];yBt(l7,u7,{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}},_U=class{},SBt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),f7=class extends _U{onExit(){return()=>{}}load(){}unload(){}},p7=class extends _U{#e=h7.platform==="win32"?"SIGINT":"SIGHUP";#r=new d7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Mm)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(!gU(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 Mm)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,Mm.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 gU(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"&&gU(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)}},h7=globalThis.process,{onExit:kMe,load:g2r,unload:_2r}=SBt(gU(h7)?new p7(h7):new f7);var NMe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=kMe(()=>{t.kill()});EBt(n,()=>{i()})};var DMe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=O1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=vBt(r,n,i),{sourceStream:d,sourceError:f}=wBt(t,u),{options:p,fileDescriptors:h}=ou.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},vBt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=bBt(t,e,...r),a=U1(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},bBt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($Me,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||nQ(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]=y1(r,...n);return{destination:e($Me)(i,s,o),pipeOptions:o}}if(ou.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}`)},$Me=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),wBt=(t,e)=>{try{return{sourceStream:dE(t,e)}}catch(r){return{sourceError:r}}};var MMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=TBt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw m7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},TBt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return c7(t),n;if(e!==void 0)return a7(r),e},m7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>mE({error:t,command:LMe,escapedCommand:LMe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),LMe="source.pipe(destination)";var UMe=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 ABt}from"stream/promises";var FMe=(t,e,r)=>{let n=yU.has(e)?xBt(t,e):RBt(t,e);return km(t,IBt,r.signal),km(e,PBt,r.signal),OBt(e),n},RBt=(t,e)=>{let r=Lm([t]);return yE(r,e),yU.set(e,r),r},xBt=(t,e)=>{let r=yU.get(e);return r.add(t),r},OBt=async t=>{try{await ABt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}yU.delete(t)},yU=new WeakMap,IBt=2,PBt=1;import{aborted as CBt}from"util";var jMe=(t,e)=>t===void 0?[]:[kBt(t,e)],kBt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await CBt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw m7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var SU=(t,...e)=>{if(Qr(e[0]))return SU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=DMe(t,...e),i=NBt({...n,destination:r});return i.pipe=SU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},NBt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=$Bt(t,i);MMe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=FMe(e,s,d);return await Promise.race([UMe(l),...jMe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},$Bt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as zBt}from"timers/promises";import{on as DBt}from"events";import{getDefaultHighWaterMark as LBt}from"stream";var EU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return MBt(e,o),qMe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},MBt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},g7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;UBt(e,o,t);let a=t.readableObjectMode&&!s;return qMe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},UBt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},qMe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=DBt(t,"data",{signal:e.signal,highWaterMark:zMe,highWatermark:zMe});return FBt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},_7=LBt(!0),zMe=_7,FBt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=jBt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Dm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*yx(a)}},jBt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[lU(t,r,!e),uU(t,i,!n,{})].filter(Boolean);var BMe=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=qBt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([BBt(t),d]);return}let f=KQ(c,r),p=g7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([VBt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},qBt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!pU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=g7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await eMe(a,t,r,s)},BBt=async t=>{await zBt(),t.readableFlowing===null&&t.resume()},VBt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await eU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await tU(r,{maxBuffer:s})):await hE(r,{maxBuffer:s})}catch(a){return VMe(eLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},y7=async t=>{try{return await t}catch(e){return VMe(e)}},VMe=({bufferedData:t})=>gNe(t)?new Uint8Array(t):t;import{finished as HBt}from"stream/promises";var bx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=GBt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],HBt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||YBt(a,e,r,n)}finally{o.abort()}},GBt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&WBt(t,r,n),n},WBt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{KBt(e,r),n.call(t,...i)}},KBt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},YBt=(t,e,r,n)=>{if(!JBt(t,e,r,n))throw t},JBt=(t,e,r,n=!0)=>r.propagating?HMe(t)||vU(t):(r.propagating=!0,S7(r,e)===n?HMe(t):vU(t)),S7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",vU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",HMe=t=>t?.code==="EPIPE";var GMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>E7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),E7=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=bx(t,e,u);if(S7(u,e)){await l;return}let[d]=await Promise.all([BMe({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 WMe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Lm([t,e].filter(Boolean)):void 0,KMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>E7({...ZBt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:XBt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),ZBt=({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}},XBt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as QBt}from"events";var YMe=t=>oE(t,"ipc"),JMe=(t,e)=>{let r=x1(t);iu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ZMe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=YMe(s),a=xl(e,"ipc"),c=xl(r,"ipc");for await(let u of n7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(tLe(t,i,c),i.push(u)),o&&JMe(u,s);return i},XMe=async(t,e)=>(await Promise.allSettled([t]),e);var QMe=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 E=sMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=GMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=KMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=ZMe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=e2t(m,t,S),I=t2t(h,S);try{return await Promise.race([Promise.all([{},aMe(E),Promise.all(_),w,R,NDe(t,d),...T,...I]),g,r2t(t,y),...ODe(t,s,f,y),...Y$e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...RDe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(_.map(O=>y7(O))),y7(w),XMe(R,b),Promise.allSettled(T),Promise.allSettled(I)])}},e2t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:bx(n,i,r)),t2t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ja(s,{checkOpen:!1})&&!Wa(s)).map(({type:i,value:s,stream:o=s})=>bx(o,n,e,{isSameDirection:Zo.has(i),stopOnExit:i==="native"}))),r2t=async(t,{signal:e})=>{let[r]=await QBt(t,"error",{signal:e});throw r};var e1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),wx=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=su();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},SE=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 n2t}from"stream";import{callbackify as i2t}from"util";import{finished as t1e}from"stream/promises";var v7=async t=>{if(t!==void 0)try{await b7(t)}catch{}},r1e=async t=>{if(t!==void 0)try{await w7(t)}catch{}},b7=async t=>{await t1e(t,{cleanup:!0,readable:!1,writable:!0})},w7=async t=>{await t1e(t,{cleanup:!0,readable:!0,writable:!1})},bU=async(t,e)=>{if(await t,e)throw e},wU=(t,e,r)=>{r&&!vU(r)?t.destroy(r):e&&t.destroy()};var n1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ro.has(r),{subprocessStdout:a,waitReadableDestroy:c}=T7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=A7(a,o),{read:f,onStdoutDataDone:p}=R7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new n2t({read:f,destroy:i2t(O7.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return x7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},T7=(t,e,r)=>{let n=dE(t,e),i=wx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},A7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:_7},R7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=su(),o=EU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){s2t(this,o,s)},onStdoutDataDone:s}},s2t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},x7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await w7(t),await n,await v7(i),await e,r.readable&&r.push(null)}catch(s){await v7(i),i1e(r,s)}},O7=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await SE(r,e)&&(i1e(t,n),await bU(e,n))},i1e=(t,e)=>{wU(t,t.readable,e)};import{Writable as o2t}from"stream";import{callbackify as s1e}from"util";var o1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=I7(t,r,e),o=new o2t({...P7(n,t,i),destroy:s1e(k7.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return C7(n,o),o},I7=(t,e,r)=>{let n=U1(t,e),i=wx(r,n,"writableFinal"),s=wx(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},P7=(t,e,r)=>({write:a2t.bind(void 0,t),final:s1e(c2t.bind(void 0,t,e,r))}),a2t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},c2t=async(t,e,r)=>{await SE(r,e)&&(t.writable&&t.end(),await e)},C7=async(t,e,r)=>{try{await b7(t),e.writable&&e.end()}catch(n){await r1e(r),a1e(e,n)}},k7=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await SE(r,e),await SE(n,e)&&(a1e(t,i),await bU(e,i))},a1e=(t,e)=>{wU(t,t.writable,e)};import{Duplex as u2t}from"stream";import{callbackify as l2t}from"util";var c1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ro.has(r),{subprocessStdout:c,waitReadableDestroy:u}=T7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=I7(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=A7(c,a),{read:g,onStdoutDataDone:y}=R7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new u2t({read:g,...P7(l,t,d),destroy:l2t(d2t.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 x7({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:l}),C7(l,E,c),E},d2t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([O7({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),k7({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var N7=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ro.has(e),o=dE(t,r),a=EU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return f2t(a,o,t)},f2t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var u1e=(t,{encoding:e})=>{let r=e1e();t.readable=n1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=o1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=c1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=N7.bind(void 0,t,e),t[Symbol.asyncIterator]=N7.bind(void 0,t,e,{})};var l1e=(t,e)=>{for(let[r,n]of h2t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},p2t=(async()=>{})().constructor.prototype,h2t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(p2t,t)]);var d1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=_2t(t,e,r),{subprocess:f,promise:p}=S2t({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=SU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),l1e(f,p),ou.set(f,{options:l,fileDescriptors:d}),f},_2t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),{file:a,commandArguments:c,options:u}=Y1(t,e,r),l=y2t(u),d=bMe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},y2t=({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}},S2t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=g2t(...J1(t,e,r))}catch(h){return yMe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;m2t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];CMe(c,a,u),NMe(c,r,u);let d={},f=su();c.kill=W$e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=WMe(c,r),u1e(c,r),mMe(c,r);let p=E2t({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}},E2t=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 QMe({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)=>Il(_,e,w)),E=Il(m,e,"all"),S=v2t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return gE(S,n,e)},v2t=({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 au,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):iU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var TU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,b2t(n,t[n],i)]));return{...t,...r}},b2t=(t,e,r)=>w2t.has(t)&&Qr(e)&&Qr(r)?{...e,...r}:r,w2t=new Set(["env",...uQ]);var Df=(t,e,r,n)=>{let i=(o,a,c)=>Df(o,a,r,c),s=(...o)=>T2t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},T2t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Qr(s))return i(t,TU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=A2t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?uMe(a,c,u):d1e(a,c,u,i)},A2t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=bNe(e)?wNe(e,r):[e,...r],[o,a,c]=y1(...s),u=TU(TU(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 f1e=({file:t,commandArguments:e})=>h1e(t,e),p1e=({file:t,commandArguments:e})=>({...h1e(t,e),isSync:!0}),h1e=(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]=R2t(t);return{file:r,commandArguments:n}},R2t=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(x2t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},x2t=/ +/g;var m1e=(t,e,r)=>{t.sync=e(O2t,r),t.s=t.sync},g1e=({options:t})=>_1e(t),O2t=({options:t})=>({..._1e(t),isSync:!0}),_1e=t=>({options:{...I2t(t),...t}}),I2t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},y1e={preferLocal:!0};var S1e=Df(()=>({})),o4r=Df(()=>({isSync:!0})),E1e=Df(f1e),a4r=Df(p1e),c4r=Df(PDe),u4r=Df(g1e,{},y1e,m1e),{sendMessage:l4r,getOneMessage:d4r,getEachMessage:f4r,getCancelSignal:p4r}=gMe();import{Transform as P2t}from"stream";var C2t=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function k2t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...C2t])]}function N2t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function $2t(){let e=k2t().map(r=>process.env[r]).filter(r=>!(!r||N2t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ei(t){if(typeof t!="string")return t;let e=$2t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(D2t(n),"g");r=r.replace(i,"******")}),r}function D2t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Tx=class extends P2t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ei(i);n(null,s)}},AU=Symbol("maskedWrite");function v1e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[AU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stdout.write=r}if(!process.stderr.write[AU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stderr.write=r}}}var b1e=!1,w1e,$7=t=>{w1e??=t},T1e=t=>{b1e=!0,$7(t)},en=()=>b1e,Xo=()=>w1e,A1e=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Ax=null,R1e=t=>(Ax&&Ax.destroy(),Ax=new Qo({totalAllowedTime:t}),Ax),x1e=()=>Ax;var Qo=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&&en())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 vD({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{X.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 O1e={name:"@netlify/agent-runner-cli",type:"module",version:"2.12.0-nb987b7e96221d.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!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 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:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",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.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.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.2","@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 F2t=M2t(import.meta.url),j2t=Pl.dirname(F2t),z2t=U2t(import.meta.url),EE=he("shell"),D7=new Set,I1e={preferLocal:!0},Ut=(t,e,r)=>{let[n,i]=q2t(e,r),s={...I1e,...i},o=S1e(t,n,s);C1e(o,s),$1e(o);let a=r?.idleTimeout;return a&&a>0&&N1e(o,a),o},P1e=(t,e)=>{let r={...I1e,...e},n=E1e(t,r);return C1e(n,r),$1e(n),e?.idleTimeout&&e.idleTimeout>0&&N1e(n,e.idleTimeout),n},q2t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},C1e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||uu.env.NETLIFY_LOCAL_QUIET==="true")return;if(uu.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Tx).pipe(uu.stdout),t.stderr?.pipe(new Tx).pipe(uu.stderr);return}t.stdout?.pipe(uu.stdout),t.stderr?.pipe(uu.stderr)},L7=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(uu.kill(-t.pid,e),EE.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return EE.error("Error killing process:",r),!1}},k1e=t=>L7(t,"SIGKILL"),N1e=(t,e)=>{let r=null,n=()=>{EE.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),L7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing idle process ${t.pid}`),k1e(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)},$1e=t=>{D7.add(t);let e=x1e();if(e){let r=e.onTimesUp(()=>{EE.log(`Global timer expired, killing process ${t.pid}`),L7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing process ${t.pid} after timeout`),k1e(t))},5e3)});t.on("exit",()=>{D7.delete(t),r()}),t.on("error",()=>{D7.delete(t),r()})}};function lu(t,e){if(!uu.env.NETLIFY_LOCAL_MODE)try{let i=z2t.resolve(O1e.name),s=Pl.dirname(i);for(;s!==Pl.dirname(s);){let o=Pl.dirname(s);if(Pl.basename(o)==="node_modules"){let a=Pl.join(o,".bin",e);if(RU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(uu.env.NODE_PATH){let i=Pl.join(uu.env.NODE_PATH,".bin",e);if(RU.existsSync(i))return i}let r=Pl.join(t,"node_modules",".bin",e);if(RU.existsSync(r))return r;let n=Pl.join(j2t,"..","node_modules",".bin",e);if(RU.existsSync(n))return n}import Oq from"process";import{fileURLToPath as iXt}from"url";import{createRequire as sXt}from"module";import AI from"path";import{readFileSync as oXt}from"fs";var B2t="__netlify__getTracer",V2t="__netlify__shutdownTracers",$t=(t,e)=>globalThis[B2t]?.(t,e),D1e=async()=>globalThis[V2t]?.();function Rx(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as YZt}from"timers/promises";Ue();import UHt from"process";Ue();var H2t=(t,e)=>{e.recordException(t),e.setStatus({code:qn.ERROR})};var Cl=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}=L1e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>M1e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=L1e(r,n,i),c=this._tracer.startSpan(e,s,o);return M1e(c,s,a)}};function L1e(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??lr.active(),{opts:n,ctx:i,fn:s}}function M1e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:H2t,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)}}Ue();var bE=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var U7=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=W1e(e),n._asyncAttributesPending=e.filter(([i,s])=>bE(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(bE(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=W1e(this._rawAttributes),this._schemaUrl=G2t(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,bE(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&me.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(bE(n)){me.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=W2t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function F7(t,e){return U7.FromAttributeList(Object.entries(t),e)}function W1e(t){return t.map(([e,r])=>bE(r)?[e,r.catch(n=>{me.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function G2t(t){if(typeof t=="string"||t===void 0)return t;me.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function W2t(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;me.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ue();var xx=class{emit(e){}enabled(){return!1}},K1e=new xx;var Ox=Symbol.for("io.opentelemetry.js.api.logs"),wE=globalThis;function Y1e(t,e,r){return n=>n===t?e:r}var j7=1;var z7=class{getLogger(e,r,n){return new xx}},IU=new z7;var PU=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):K1e}};var Ix=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new PU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:IU}_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 CU=class t{constructor(){this._proxyLoggerProvider=new Ix}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return wE[Ox]?this.getLoggerProvider():(wE[Ox]=Y1e(j7,e,IU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=wE[Ox])===null||e===void 0?void 0:e.call(wE,j7))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete wE[Ox],this._proxyLoggerProvider=new Ix}};var J1e=CU.getInstance();function Z1e(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 X1e(t){t.forEach(e=>e.disable())}function q7(t){let e=t.tracerProvider||Wt.getTracerProvider(),r=t.meterProvider||xR.getMeterProvider(),n=t.loggerProvider||J1e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Z1e(i,e,r,n),()=>{X1e(i)}}Ue();var K2t=zn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Q1e(t){return t.getValue(K2t)===!0}var TE;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(TE||(TE={}));Ue();var B7="[_0-9a-z-*/]",Y2t=`[a-z]${B7}{0,255}`,J2t=`[a-z0-9]${B7}{0,240}@[a-z]${B7}{0,13}`,Z2t=new RegExp(`^(?:${Y2t}|${J2t})$`),X2t=/^[ -~]{0,255}[!-~]$/,Q2t=/,|=/;function V7(t){return Z2t.test(t)}function H7(t){return X2t.test(t)&&!Q2t.test(t)}var eVt=32,eUe=512,tUe=",",rUe="=",kU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!V7(e)||!H7(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>eUe)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=tUe+e),e=`${n[0]}${rUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(tUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(rUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!V7(a)||!H7(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>eUe)&&(r.set(a,c),n=u,r.size>=eVt))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 NU="traceparent",$U="tracestate",tVt="00",rVt="(?!ff)[\\da-f]{2}",nVt="(?![0]{32})[\\da-f]{32}",iVt="(?![0]{16})[\\da-f]{16}",sVt="[\\da-f]{2}",oVt=new RegExp(`^\\s?(${rVt})-(${nVt})-(${iVt})-(${sVt})(-.*)?\\s?$`);function nUe(t){let e=oVt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var Lf=class{inject(e,r,n){let i=Wt.getSpanContext(e);if(!i||Q1e(e)||!ws(i))return;let s=`${tVt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||zr.NONE).toString(16)}`;n.set(r,NU,s),i.traceState&&n.set(r,$U,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,NU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=nUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,$U);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new kU(typeof c=="string"?c:void 0)}return Wt.setSpanContext(e,o)}fields(){return[NU,$U]}};var DU=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 Px=class{_isCalled=!1;_deferred=new DU;_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 OF=En(Nee(),1);Ue();var tze=t=>{throw TypeError(t)},Mee=(t,e,r)=>e.has(t)||tze("Cannot "+r),xF=(t,e,r)=>(Mee(t,e,"read from private field"),r?r.call(t):e.get(t)),$ee=(t,e,r)=>e.has(t)?tze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Xje=(t,e,r,n)=>(Mee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),MHt=(t,e,r)=>(Mee(t,e,"access private method"),r),Qje="__netlify__getTracer",FHt="__netlify__shutdownTracers",jHt="__nfOTLPTrace",Yx,Jx,Lee,rze,zHt=class{constructor(){$ee(this,Lee),$ee(this,Yx),$ee(this,Jx),Xje(this,Yx,new Px(MHt(this,Lee,rze),this)),Xje(this,Jx,me.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(xF(this,Jx).debug(`export ${t.length.toString()} spans`),xF(this,Yx).isCalled){e({code:TE.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(jHt,JSON.stringify(qHt(t))),e({code:TE.SUCCESS})}shutdown(){return xF(this,Yx).call()}};Yx=new WeakMap;Jx=new WeakMap;Lee=new WeakSet;rze=function(){return xF(this,Jx).debug("Shutting down"),Promise.resolve()};function qHt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:RF(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||qa.SERVER,startTimeUnixNano:Dee(e.startTime),endTimeUnixNano:Dee(e.endTime),attributes:RF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Dee(n.time),attributes:RF(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:RF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function RF(t){return Object.keys(t).map(e=>nze(e,t[e]))}function nze(t,e){return{key:t,value:ize(e)}}function ize(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(ize)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>nze(r,n))}}:{}}function Dee(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var eze={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"}},sze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Qje))return;let e=UHt.version.slice(1),r=F7({"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??[BHt()],i=new OF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Lf});let s=t.instrumentations??[];q7({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,Qje,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Cl(Wt.getTracer(a,c)):new Cl(Wt.getTracer(eze.name,eze.version))}}),Object.defineProperty(globalThis,FHt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},BHt=()=>new OF.SimpleSpanProcessor(new zHt);Ue();var LE=En(Nee(),1);Ue();import*as IF from"diagnostics_channel";var oze=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?qn.ERROR:qn.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 Cl?t:new Cl(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){IF.subscribe(t,e);let r=()=>IF.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:qa.CLIENT},lr.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:qn.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 K6e=En(V6e(),1);kse();var H6e=0;var WZt=3*1024*1024,KZt=t=>SI.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Rq=class{constructor(e,r=WZt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=KZt(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:H6e});return}this.inner.export(n[c],u=>{u.code!==H6e&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var Lv=he("tracing"),G6e=8e3,JZt=5e3,W6e=t=>t.length>G6e?`${t.slice(0,G6e)}\u2026`:t,bI={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},ZZt=Math.ceil(bI.maxQueueSize/bI.maxExportBatchSize)+1,XZt=t=>new LE.BatchSpanProcessor(new Rq(new K6e.OTLPTraceExporter({url:t,concurrencyLimit:ZZt})),bI),yg=async(t=JZt)=>{try{let e=Symbol("timed out");await Promise.race([D1e(),YZt(t,e)])===e&&Lv.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){Lv.warn("Failed to flush tracers on shutdown",e)}},Y6e=async(t,e,r)=>{if(!$t()){let n=[new LE.SimpleSpanProcessor(new $se),XZt(r.exporterUrl)];await sze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new oze({skipHeaders:!0})]})}return r.traceparent?(Ji.setGlobalPropagator(new Lf),Ji.extract(lr.active(),{traceparent:r.traceparent,isRemote:!0})):lr.active()};function hr(t,e,r){return Lv.log(`\u23F3 TRACE: ${e} starting...`),Rx(t,e,r)}var $se=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(", ")}]`:"";Lv.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&Lv.log(` \u274C Error: ${e.status.message}`)}};function Dse(){return We().captureLlmContentEnabled}function J6e(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 xq(t,e,r){let n={role:t,parts:[{type:"text",content:Ei(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var QZt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]);function Z6e(t,e,r,n){if(!t.length)return;let i=$t();if(!i)return;t.length>bI.maxQueueSize&&Lv.warn(`${t.length} step spans exceed the span queue of ${bI.maxQueueSize}; spans may be dropped`);let s=Dse(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let u=Math.min(n,r+c*o),l=Math.min(n,u+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&QZt.has(a.category)||a.category===ee.AgentMessage&&a.toolCallId!==void 0,f=d?"execute_tool":"chat",p=W6e(a.title||a.type||`step-${a.id??c}`),h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?W6e(a.message):void 0,y=i.startSpan(m,{startTime:u,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":Ei(p),"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&g?d?{"gen_ai.tool.call.result":Ei(g)}:{"gen_ai.output.messages":xq("assistant",g)}:{}}});d&&(a.toolCallId!==void 0&&y.setAttribute("gen_ai.tool.call.id",a.toolCallId),a.toolStatus!==void 0&&y.setAttribute("spark.step.tool_status",a.toolStatus),a.exitCode!==void 0&&y.setAttribute("spark.step.exit_code",a.exitCode),a.toolStatus==="error"&&(y.setAttribute("error.type","tool_error"),y.setStatus({code:qn.ERROR}))),y.end(l)})}import{readdir as eXt,rm as tXt}from"fs/promises";import{join as rXt}from"path";async function X6e(t,e=[]){let n=(await eXt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>tXt(rXt(t,i),{recursive:!0,force:!0})))}var nXt=300,wI=t=>We().budgetCreditThresholds[t.mode]?.[t.runner]??nXt,TI=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Lse=t=>{let e=wI(t);if(!TI(t,e))return"default";let r=We();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},Q6e=t=>{let e=Lse(t),r=wI(t);return{budget_eligible:TI(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var aXt=AI.dirname(iXt(import.meta.url)),eWe=sXt(import.meta.url),cXt=AI.resolve(aXt,"scripts/scaffold.js"),uXt="scripts/scaffold.js",lXt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,Mse=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},dXt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),fXt=t=>{let e=Mse(t);return e==="node"||e.endsWith("/node")},lo=t=>{if(typeof t!="string")return!1;let e=t.match(lXt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&dXt(Mse(e[r]));)r+=1;if(r>=e.length||!fXt(e[r]))return!1;let n=e[r+1];return n?Mse(n).includes(uXt):!1},Sg=he("create_stage"),Use="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.",pXt=`${Use}
598
598
 
599
599
  Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,hXt=`${Use}
600
600
 
@@ -867,6 +867,9 @@ ${r.join(`
867
867
  - Read files efficiently. Use glob first to find the right paths before reading
868
868
  - Prefer editing over writing entire files when possible
869
869
  - Do NOT run any build commands (e.g. \`netlify build\`, \`netlify functions:build\`, \`npm run build\`, \`yarn build\`, \`pnpm build\`). The system validates builds automatically after your changes. Running these commands can produce build artifacts that pollute the repository.
870
+ - When the task requires data storage or persistence, you MUST use Netlify platform primitives. Use the \`general-database\` skill to determine the right storage solution. NEVER use in-memory data structures, local JSON files, or external database services for data that needs to persist.
871
+ - You have access to Netlify specific skills in ${t}. Before implementing a feature, read the relevant skill's SKILL.md for instructions. Some skills have activation scripts (e.g. \`node scripts/enable.cjs\`) that you MUST run after implementing the feature. Currently, Netlify Forms and Netlify Identity have activation scripts. Skipping this step will cause the feature to not be enabled on deploy.
872
+ - Complete the task and meet its requirements without using Netlify Database; keep any required data another way.
870
873
  ${Y9e(t)}
871
874
  </rules>`,B2=({skillsDir:t,mode:e,runner:r})=>e==="ask"?Dor(t):J9e(t,r),Z9e=({cliPath:t,branch:e})=>["## Netlify Database (read-only)","",`This project has a Netlify Database (managed Postgres). You are connected to the \`${e}\` branch with a`,"read-only role, so you can answer questions about the schema and the data in it.","","Query it by running:","","```",`${t} db connect --query "SELECT count(*) FROM users"`,"```","",`Add \`--json\` for machine-readable output. Always pass \`--query\`: \`${t} db connect\` on its own opens an`,"interactive session that never returns.","","Rules for this run:","","- The connection is read-only. INSERT, UPDATE, DELETE, and DDL are refused by the database.","- Do NOT generate or run migrations, and do NOT run `drizzle-kit`. This run cannot change the schema.","- The branch is a fork of production taken when the branch was created, so data may lag production."," Say which branch you read when the answer depends on the data.","- Prefer schema queries (`information_schema`) and aggregates over selecting rows. When you do read rows,"," use a LIMIT and leave out columns holding personal data or secrets \u2014 query output is shown to the user"," and stored with the session."].join(`
872
875
  `),X9e=async(t,e)=>{let r=await Dke(e);return r?Mor(Uor(r,e.runner),t):t},Mor=(t,e)=>[t,e].filter(Boolean).join(`