@netlify/agent-runner-cli 1.189.4 → 1.190.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-local.js +2 -2
- package/dist/bin.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -594,7 +594,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
594
594
|
`,LF:`
|
|
595
595
|
`,concatBytes:eW},Dbt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Mbt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Dbt};import{Buffer as Ubt}from"buffer";var Vwe=(t,e)=>t?void 0:Fbt.bind(void 0,e),Fbt=function*(t,e){if(typeof e!="string"&&!Br(e)&&!Ubt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Hwe=(t,e)=>t?jbt.bind(void 0,e):zbt.bind(void 0,e),jbt=function*(t,e){Gwe(t,e),yield e},zbt=function*(t,e){if(Gwe(t,e),typeof e!="string"&&!Br(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Gwe=(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 qbt}from"buffer";import{StringDecoder as Bbt}from"string_decoder";var kP=(t,e,r)=>{if(r)return;if(t)return{transform:Vbt.bind(void 0,new TextEncoder)};let n=new Bbt(e);return{transform:Hbt.bind(void 0,n),final:Gbt.bind(void 0,n)}},Vbt=function*(t,e){qbt.isBuffer(e)?yield Nc(e):typeof e=="string"?yield t.encode(e):yield e},Hbt=function*(t,e){yield Br(e)?t.write(e):e},Gbt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Wwe}from"util";var rW=Wwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$P=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Ybt}=e[r];for await(let i of n(t))yield*$P(i,e,r+1)},Ywe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Wbt(r,Number(e),t)},Wbt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$P(n,r,e+1)},Kwe=Wwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Ybt=function*(t){yield t};var nW=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Zwe=(t,e)=>[...e.flatMap(r=>[...Kf(r,t,0)]),...YT(t)],Kf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Zbt}=e[r];for(let i of n(t))yield*Kf(i,e,r+1)},YT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kbt(r,Number(e),t)},Kbt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Kf(n,r,e+1)},Zbt=function*(t){yield t};var iW=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Xwe(t,o,s),l=Yf(e),u=Yf(r),d=l?rW.bind(void 0,$P,a):nW.bind(void 0,Kf),f=l||u?rW.bind(void 0,Ywe,a):nW.bind(void 0,YT),p=l||u?Kwe.bind(void 0,a):void 0;return{stream:new Jbt({writableObjectMode:n,writableHighWaterMark:Jwe(n),readableObjectMode:i,readableHighWaterMark:Jwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},LP=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=Xwe(o,r,a);t=Zwe(c,t)}return t},Xwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Vwe(n,a)},kP(r,o,n),NP(r,s,n,c),{transform:t,final:e},{transform:Hwe(i,a)},Bwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Qwe=(t,e)=>{for(let r of Xbt(t))Qbt(t,r,e)},Xbt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Qbt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Iu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>ewt(a,n));r.input=UT(o)},ewt=(t,e)=>{let r=LP(t,e,"utf8",!0);return twt(r),UT(r)},twt=t=>{let e=t.find(r=>typeof r!="string"&&!Br(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as swt,appendFileSync as owt}from"fs";var DP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cg(r,n)&&!Yi.has(e)&&rwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&nwt.has(s))||t.every(({type:i})=>Is.has(i))),rwt=t=>t===1||t===2,nwt=new Set(["pipe","overlapped"]),eRe=async(t,e,r,n)=>{for await(let i of t)iwt(e)||rRe(i,r,n)},tRe=(t,e,r)=>{for(let n of t)rRe(n,e,r)},iwt=t=>t._readableState.pipes.length>0,rRe=(t,e,r)=>{let n=ZO(t);da({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var nRe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>awt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},awt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=iwe(t,s,d),p=Nc(f),{stdioItems:h,objectMode:m}=e[r],_=cwt([p],h,c,n),{serializedResult:S,finalResult:E=S}=lwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?E:void 0;try{return n.error===void 0&&dwt(S,h,i),y}catch(g){return n.error=g,y}},cwt=(t,e,r,n)=>{try{return LP(t,e,r,!1)}catch(i){return n.error=i,t}},lwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:UT(t)};let o=yve(t,r);return n[s]?{serializedResult:o,finalResult:tW(o,!i[s],e)}:{serializedResult:o}},uwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!DP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=tW(t,!1,o);try{tRe(a,e,n)}catch(c){r.error??=c}},dwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?owt(n,t):(r.add(s),swt(n,t))}};var iRe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Lc(e,r,"all")]:Array.isArray(e)?[Lc(t,r,"all"),...e]:Br(t)&&Br(e)?u3([t,e]):`${t}${e}`};import{once as sW}from"events";var sRe=async(t,e)=>{let[r,n]=await fwt(t);return e.isForcefullyTerminated??=!1,[r,n]},fwt=async t=>{let[e,r]=await Promise.allSettled([sW(t,"spawn"),sW(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?oRe(t):r.value},oRe=async t=>{try{return await sW(t,"exit")}catch{return oRe(t)}},aRe=async t=>{let[e,r]=await t;if(!pwt(e,r)&&oW(e,r))throw new co;return[e,r]},pwt=(t,e)=>t===void 0&&e===void 0,oW=(t,e)=>t!==0||e!==null;var cRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=hwt(t,e,r),o=s?.code==="ETIMEDOUT",a=nwe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},hwt=(t,e,r)=>t!==void 0?t:oW(e,r)?new co:void 0;var lRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gwt(t,e,r),d=Swt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},gwt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),a=_wt(r),{file:c,commandArguments:l,options:u}=yP(t,e,a);ywt(u);let d=Fwe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_wt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ywt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&MP("ipcInput"),t&&MP("ipc: true"),r&&MP("detached: true"),n&&MP("cancelSignal")},MP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Swt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Ewt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=cRe(c,r),{output:h,error:m=l}=nRe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,y)=>Lc(E,r,y)),S=Lc(iRe(h,r),r,"all");return Twt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},Ewt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Qwe(s,r);let a=vwt(r);return mwt(...SP(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},vwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:AP(e)}),Twt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?xP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):WT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as lAt}from"events";import{spawn as uAt}from"child_process";import hRe from"process";import{once as aW,on as bwt}from"events";var uRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Pg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),wwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),wwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cP(e,i);let s=Cu(t,e,r),o=new AbortController;try{return await Promise.race([Rwt(s,n,o),Awt(s,r,o),xwt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),lP(e,i)}},Rwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await aW(t,"message",{signal:r});return n}for await(let[n]of bwt(t,"message",{signal:r}))if(e(n))return n},Awt=async(t,e,{signal:r})=>{await aW(t,"disconnect",{signal:r}),ZTe(e)},xwt=async(t,e,{signal:r})=>{let[n]=await aW(t,"strict:error",{signal:r});throw sP(n,e)};import{once as fRe,on as Cwt}from"events";var pRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>cW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),cW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Pg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),cP(e,s);let o=Cu(t,e,r),a=new AbortController,c={};return Iwt(t,o,a),Owt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Pwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Iwt=async(t,e,r)=>{try{await fRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Owt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await fRe(t,"strict:error",{signal:r.signal});n.error=sP(i,e),r.abort()}catch{}},Pwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Cwt(r,"message",{signal:s.signal}))dRe(o),yield c}catch{dRe(o)}finally{s.abort(),lP(e,a),n||Ng(t),i&&await t}},dRe=({error:t})=>{if(t)throw t};var mRe=(t,{ipc:e})=>{Object.assign(t,_Re(t,!1,e))},gRe=()=>{let t=hRe,e=!0,r=hRe.channel!==void 0;return{..._Re(t,e,r),getCancelSignal:bbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},_Re=(t,e,r)=>({sendMessage:gP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:uRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:pRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Nwt}from"child_process";import{PassThrough as kwt,Readable as $wt,Writable as Lwt,Duplex as Dwt}from"stream";var yRe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{X3(n);let a=new Nwt;Mwt(a,n),Object.assign(a,{readable:Uwt,writable:Fwt,duplex:jwt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=zwt(c,o,i);return{subprocess:a,promise:l}},Mwt=(t,e)=>{let r=KT(),n=KT(),i=KT(),s=Array.from({length:e.length-3},KT),o=KT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},KT=()=>{let t=new kwt;return t.end(),t},Uwt=()=>new $wt({read(){}}),Fwt=()=>new Lwt({write(){}}),jwt=()=>new Dwt({read(){},write(){}}),zwt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as SRe,createWriteStream as ERe}from"fs";import{Buffer as qwt}from"buffer";import{Readable as ZT,Writable as Bwt,Duplex as Vwt}from"stream";var TRe=(t,e)=>PP(Hwt,t,e,!1),JT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Iu[t]}.`)},vRe={fileNumber:JT,generator:iW,asyncGenerator:iW,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Vwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Hwt={input:{...vRe,fileUrl:({value:t})=>({stream:SRe(t)}),filePath:({value:{file:t}})=>({stream:SRe(t)}),webStream:({value:t})=>({stream:ZT.fromWeb(t)}),iterable:({value:t})=>({stream:ZT.from(t)}),asyncIterable:({value:t})=>({stream:ZT.from(t)}),string:({value:t})=>({stream:ZT.from(t)}),uint8Array:({value:t})=>({stream:ZT.from(qwt.from(t))})},output:{...vRe,fileUrl:({value:t})=>({stream:ERe(t)}),filePath:({value:{file:t,append:e}})=>({stream:ERe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Bwt.fromWeb(t)}),iterable:JT,asyncIterable:JT,string:JT,uint8Array:JT}};import{on as Gwt,once as bRe}from"events";import{PassThrough as Wwt,getDefaultHighWaterMark as Ywt}from"stream";import{finished as ARe}from"stream/promises";function Zf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)uW(i);let e=t.some(({readableObjectMode:i})=>i),r=Kwt(t,e),n=new lW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Kwt=(t,e)=>{if(t.length===0)return Ywt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},lW=class extends Wwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(uW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Zwt(this,this.#e,this.#s);let r=Qwt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(uW(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},Zwt=async(t,e,r)=>{UP(t,wRe);let n=new AbortController;try{await Promise.race([Jwt(t,n),Xwt(t,e,r,n)])}finally{n.abort(),UP(t,-wRe)}},Jwt=async(t,{signal:e})=>{try{await ARe(t,{signal:e,cleanup:!0})}catch(r){throw xRe(t,r),r}},Xwt=async(t,e,r,{signal:n})=>{for await(let[i]of Gwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},uW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Qwt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{UP(t,RRe);let a=new AbortController;try{await Promise.race([eRt(s,e,a),tRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),rRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),UP(t,-RRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?dW(t):nRt(t))},eRt=async(t,e,{signal:r})=>{try{await t,r.aborted||dW(e)}catch(n){r.aborted||xRe(e,n)}},tRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await ARe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;CRe(o)?i.add(e):IRe(t,o)}},rRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await bRe(t,i,{signal:s}),!t.readable)return bRe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},nRt=t=>{t.writable&&t.end()},xRe=(t,e)=>{CRe(e)?dW(t):IRe(t,e)},CRe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",dW=t=>{(t.readable||t.writable)&&t.destroy()},IRe=(t,e)=>{t.destroyed||(t.once("error",iRt),t.destroy(e))},iRt=()=>{},UP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},wRe=2,RRe=1;import{finished as ORe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),sRt(t,e),oRt(t,e)},sRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await ORe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}fW(e)}},fW=t=>{t.writable&&t.end()},oRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await ORe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}pW(t)}},pW=t=>{t.readable&&t.destroy()};var PRe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Is.has(c)))aRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Is.has(c)))lRt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Zf(s);jg(o,i)}},aRt=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=cRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},cRt=["stdin","stdout","stderr"],lRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;uRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},uRt=(t,{signal:e})=>{ao(t)&&Gf(t,dRt,e)},dRt=2;import{addAbortListener as hRt}from"events";var Jf=[];Jf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Jf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Jf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FP=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",hW=Symbol.for("signal-exit emitter"),mW=globalThis,fRt=Object.defineProperty.bind(Object),gW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(mW[hW])return mW[hW];fRt(mW,hW,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},jP=class{},pRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),_W=class extends jP{onExit(){return()=>{}}load(){}unload(){}},yW=class extends jP{#e=SW.platform==="win32"?"SIGINT":"SIGHUP";#r=new gW;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Jf)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!FP(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Jf)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Jf.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return FP(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&FP(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},SW=globalThis.process,{onExit:NRe,load:$mr,unload:Lmr}=pRt(FP(SW)?new yW(SW):new _W);var kRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=NRe(()=>{t.kill()});hRt(n,()=>{i()})};var LRe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=JO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mRt(r,n,i),{sourceStream:d,sourceError:f}=_Rt(t,l),{options:p,fileDescriptors:h}=pa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},mRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=gRt(t,e,...r),a=aP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},gRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($Re,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||c3(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=zO(r,...n);return{destination:e($Re)(i,s,o),pipeOptions:o}}if(pa.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},$Re=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_Rt=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var MRe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=yRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw EW({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},yRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return pW(t),n;if(e!==void 0)return fW(r),e},EW=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:DRe,escapedCommand:DRe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),DRe="source.pipe(destination)";var URe=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 SRt}from"stream/promises";var FRe=(t,e,r)=>{let n=zP.has(e)?vRt(t,e):ERt(t,e);return Gf(t,bRt,r.signal),Gf(e,wRt,r.signal),TRt(e),n},ERt=(t,e)=>{let r=Zf([t]);return jg(r,e),zP.set(e,r),r},vRt=(t,e)=>{let r=zP.get(e);return r.add(t),r},TRt=async t=>{try{await SRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zP.delete(t)},zP=new WeakMap,bRt=2,wRt=1;import{aborted as RRt}from"util";var jRe=(t,e)=>t===void 0?[]:[ARt(t,e)],ARt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await RRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw EW({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var qP=(t,...e)=>{if(Cr(e[0]))return qP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=LRe(t,...e),i=xRt({...n,destination:r});return i.pipe=qP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},xRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=CRt(t,i);MRe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=FRe(e,s,d);return await Promise.race([URe(u),...jRe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},CRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as LRt}from"timers/promises";import{on as IRt}from"events";import{getDefaultHighWaterMark as ORt}from"stream";var BP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return PRt(e,o),qRe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},PRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},vW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;NRt(e,o,t);let a=t.readableObjectMode&&!s;return qRe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},NRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},qRe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=IRt(t,"data",{signal:e.signal,highWaterMark:zRe,highWatermark:zRe});return kRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},TW=ORt(!0),zRe=TW,kRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=$Rt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Kf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*YT(a)}},$Rt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[kP(t,r,!e),NP(t,i,!n,{})].filter(Boolean);var BRe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=DRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([MRt(t),d]);return}let f=Q3(c,r),p=vW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([URt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},DRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!DP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=vW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await eRe(a,t,r,s)},MRt=async t=>{await LRt(),t.readableFlowing===null&&t.resume()},URt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await bP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await wP(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return VRe(ewe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},bW=async t=>{try{return await t}catch(e){return VRe(e)}},VRe=({bufferedData:t})=>gve(t)?new Uint8Array(t):t;import{finished as FRt}from"stream/promises";var XT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=jRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],FRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||BRt(a,e,r,n)}finally{o.abort()}},jRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&zRt(t,r,n),n},zRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qRt(e,r),n.call(t,...i)}},qRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},BRt=(t,e,r,n)=>{if(!VRt(t,e,r,n))throw t},VRt=(t,e,r,n=!0)=>r.propagating?HRe(t)||VP(t):(r.propagating=!0,wW(r,e)===n?HRe(t):VP(t)),wW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",HRe=t=>t?.code==="EPIPE";var GRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>RW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),RW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=XT(t,e,l);if(wW(l,e)){await u;return}let[d]=await Promise.all([BRe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var WRe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Zf([t,e].filter(Boolean)):void 0,YRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>RW({...HRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:GRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),HRt=({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}},GRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as WRt}from"events";var KRe=t=>Cg(t,"ipc"),ZRe=(t,e)=>{let r=ZO(t);da({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var JRe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=KRe(s),a=kc(e,"ipc"),c=kc(r,"ipc");for await(let l of cW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(twe(t,i,c),i.push(l)),o&&ZRe(l,s);return i},XRe=async(t,e)=>(await Promise.allSettled([t]),e);var QRe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let E=sRe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=GRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=YRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],A=JRe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=YRt(m,t,y),C=KRt(h,y);try{return await Promise.race([Promise.all([{},aRe(E),Promise.all(g),T,A,kbe(t,d),...b,...C]),_,ZRt(t,S),...Cbe(t,s,f,S),...KTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Abe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(g.map(x=>bW(x))),bW(T),XRe(A,w),Promise.allSettled(b),Promise.allSettled(C)])}},YRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:XT(n,i,r)),KRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>uo(s,{checkOpen:!1})&&!ao(s)).map(({type:i,value:s,stream:o=s})=>XT(o,n,e,{isSameDirection:Is.has(i),stopOnExit:i==="native"}))),ZRt=async(t,{signal:e})=>{let[r]=await WRt(t,"error",{signal:e});throw r};var eAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),QT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=fa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},zg=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as JRt}from"stream";import{callbackify as XRt}from"util";import{finished as tAe}from"stream/promises";var AW=async t=>{if(t!==void 0)try{await xW(t)}catch{}},rAe=async t=>{if(t!==void 0)try{await CW(t)}catch{}},xW=async t=>{await tAe(t,{cleanup:!0,readable:!1,writable:!0})},CW=async t=>{await tAe(t,{cleanup:!0,readable:!0,writable:!1})},HP=async(t,e)=>{if(await t,e)throw e},GP=(t,e,r)=>{r&&!VP(r)?t.destroy(r):e&&t.destroy()};var nAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Yi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=IW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=OW(a,o),{read:f,onStdoutDataDone:p}=PW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new JRt({read:f,destroy:XRt(kW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return NW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},IW=(t,e,r)=>{let n=kg(t,e),i=QT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},OW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:TW},PW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=fa(),o=BP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){QRt(this,o,s)},onStdoutDataDone:s}},QRt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},NW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await CW(t),await n,await AW(i),await e,r.readable&&r.push(null)}catch(s){await AW(i),iAe(r,s)}},kW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await zg(r,e)&&(iAe(t,n),await HP(e,n))},iAe=(t,e)=>{GP(t,t.readable,e)};import{Writable as eAt}from"stream";import{callbackify as sAe}from"util";var oAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=$W(t,r,e),o=new eAt({...LW(n,t,i),destroy:sAe(MW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return DW(n,o),o},$W=(t,e,r)=>{let n=aP(t,e),i=QT(r,n,"writableFinal"),s=QT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},LW=(t,e,r)=>({write:tAt.bind(void 0,t),final:sAe(rAt.bind(void 0,t,e,r))}),tAt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rAt=async(t,e,r)=>{await zg(r,e)&&(t.writable&&t.end(),await e)},DW=async(t,e,r)=>{try{await xW(t),e.writable&&e.end()}catch(n){await rAe(r),aAe(e,n)}},MW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await zg(r,e),await zg(n,e)&&(aAe(t,i),await HP(e,i))},aAe=(t,e)=>{GP(t,t.writable,e)};import{Duplex as nAt}from"stream";import{callbackify as iAt}from"util";var cAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Yi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=IW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=$W(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=OW(c,a),{read:_,onStdoutDataDone:S}=PW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new nAt({read:_,...LW(u,t,d),destroy:iAt(sAt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return NW({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),DW(u,E,c),E},sAt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([kW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),MW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var UW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Yi.has(e),o=kg(t,r),a=BP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return oAt(a,o,t)},oAt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var lAe=(t,{encoding:e})=>{let r=eAe();t.readable=nAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=oAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=cAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=UW.bind(void 0,t,e),t[Symbol.asyncIterator]=UW.bind(void 0,t,e,{})};var uAe=(t,e)=>{for(let[r,n]of cAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},aAt=(async()=>{})().constructor.prototype,cAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aAt,t)]);var dAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dAt(t,e,r),{subprocess:f,promise:p}=pAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=qP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),uAe(f,p),pa.set(f,{options:u,fileDescriptors:d}),f},dAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),{file:a,commandArguments:c,options:l}=yP(t,e,r),u=fAt(l),d=TRe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},fAt=({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}},pAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uAt(...SP(t,e,r))}catch(h){return yRe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;lAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];PRe(c,a,l),kRe(c,r,l);let d={},f=fa();c.kill=WTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=WRe(c,r),lAe(c,r),mRe(c,r);let p=hAt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},hAt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await QRe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((g,T)=>Lc(g,e,T)),E=Lc(m,e,"all"),y=mAt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(y,n,e)},mAt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?WT({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ha,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):xP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var WP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,gAt(n,t[n],i)]));return{...t,...r}},gAt=(t,e,r)=>_At.has(t)&&Cr(e)&&Cr(r)?{...e,...r}:r,_At=new Set(["env",...h3]);var Ou=(t,e,r,n)=>{let i=(o,a,c)=>Ou(o,a,r,c),s=(...o)=>yAt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},yAt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Cr(s))return i(t,WP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=SAt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?lRe(a,c,l):dAe(a,c,l,i)},SAt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Tve(e)?bve(e,r):[e,...r],[o,a,c]=zO(...s),l=WP(WP(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var fAe=({file:t,commandArguments:e})=>hAe(t,e),pAe=({file:t,commandArguments:e})=>({...hAe(t,e),isSync:!0}),hAe=(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]=EAt(t);return{file:r,commandArguments:n}},EAt=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(vAt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},vAt=/ +/g;var mAe=(t,e,r)=>{t.sync=e(TAt,r),t.s=t.sync},gAe=({options:t})=>_Ae(t),TAt=({options:t})=>({..._Ae(t),isSync:!0}),_Ae=t=>({options:{...bAt(t),...t}}),bAt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},yAe={preferLocal:!0};var SAe=Ou(()=>({})),wyr=Ou(()=>({isSync:!0})),EAe=Ou(fAe),Ryr=Ou(pAe),Ayr=Ou(Obe),xyr=Ou(gAe,{},yAe,mAe),{sendMessage:Cyr,getOneMessage:Iyr,getEachMessage:Oyr,getCancelSignal:Pyr}=gRe();import{Transform as wAt}from"stream";var RAt=["NETLIFY_AI_GATEWAY_KEY"];function AAt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...RAt])]}function xAt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function CAt(){let e=AAt().map(r=>process.env[r]).filter(r=>!(!r||xAt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Pi(t){if(typeof t!="string")return t;let e=CAt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(IAt(n),"g");r=r.replace(i,"******")}),r}function IAt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var eb=class extends wAt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Pi(i);n(null,s)}},YP=Symbol("maskedWrite");function vAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[YP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stdout.write=r}if(!process.stderr.write[YP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stderr.write=r}}}var TAe=!1,bAe,FW=t=>{bAe??=t},wAe=t=>{TAe=!0,FW(t)},Cn=()=>TAe,ga=()=>bAe,RAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var tb=null,AAe=t=>(tb&&tb.destroy(),tb=new fo({totalAllowedTime:t}),tb),xAe=()=>tb;var fo=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Cn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await DO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var CAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.189.4",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var kAt=PAt(import.meta.url),$At=Dc.dirname(kAt),LAt=NAt(import.meta.url),qg=fe("shell"),jW=new Set,IAe={preferLocal:!0},sr=(t,e,r)=>{let[n,i]=DAt(e,r),s={...IAe,...i},o=SAe(t,n,s);PAe(o,s),$Ae(o);let a=r?.idleTimeout;return a&&a>0&&kAe(o,a),o},OAe=(t,e)=>{let r={...IAe,...e},n=EAe(t,r);return PAe(n,r),$Ae(n),e?.idleTimeout&&e.idleTimeout>0&&kAe(n,e.idleTimeout),n},DAt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},PAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||_a.env.NETLIFY_LOCAL_QUIET==="true")return;if(_a.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new eb).pipe(_a.stdout),t.stderr?.pipe(new eb).pipe(_a.stderr);return}t.stdout?.pipe(_a.stdout),t.stderr?.pipe(_a.stderr)},zW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_a.kill(-t.pid,e),qg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qg.error("Error killing process:",r),!1}},NAe=t=>zW(t,"SIGKILL"),kAe=(t,e)=>{let r=null,n=()=>{qg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing idle process ${t.pid}`),NAe(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)},$Ae=t=>{jW.add(t);let e=xAe();if(e){let r=e.onTimesUp(()=>{qg.log(`Global timer expired, killing process ${t.pid}`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing process ${t.pid} after timeout`),NAe(t))},5e3)});t.on("exit",()=>{jW.delete(t),r()}),t.on("error",()=>{jW.delete(t),r()})}};function ya(t,e){if(!_a.env.NETLIFY_LOCAL_MODE)try{let i=LAt.resolve(CAe.name),s=Dc.dirname(i);for(;s!==Dc.dirname(s);){let o=Dc.dirname(s);if(Dc.basename(o)==="node_modules"){let a=Dc.join(o,".bin",e);if(KP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(_a.env.NODE_PATH){let i=Dc.join(_a.env.NODE_PATH,".bin",e);if(KP.existsSync(i))return i}let r=Dc.join(t,"node_modules",".bin",e);if(KP.existsSync(r))return r;let n=Dc.join($At,"..","node_modules",".bin",e);if(KP.existsSync(n))return n}import yD from"process";import{fileURLToPath as dFt}from"url";import{createRequire as fFt}from"module";import tR from"path";import{readFileSync as pFt}from"fs";var MAt="__netlify__getTracer",UAt="__netlify__shutdownTracers",Tt=(t,e)=>globalThis[MAt]?.(t,e),LAe=async()=>globalThis[UAt]?.();function rb(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as iFt}from"timers/promises";Ne();import Fxt from"process";Ne();var c0t=(t,e)=>{e.recordException(t),e.setStatus({code:Gn.ERROR})};var Fc=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=C0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>I0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=C0e(r,n,i),c=this._tracer.startSpan(e,s,o);return I0e(c,s,a)}};function C0e(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Gt.active(),{opts:n,ctx:i,fn:s}}function I0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:c0t,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ne();var Kg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var vY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=F0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Kg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Kg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=F0e(this._rawAttributes),this._schemaUrl=l0t(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,Kg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ue.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Kg(n)){ue.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=u0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function TY(t,e){return vY.FromAttributeList(Object.entries(t),e)}function F0e(t){return t.map(([e,r])=>Kg(r)?[e,r.catch(n=>{ue.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function l0t(t){if(typeof t=="string"||t===void 0)return t;ue.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function u0t(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ue.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var hb=class{emit(e){}enabled(){return!1}},j0e=new hb;var mb=Symbol.for("io.opentelemetry.js.api.logs"),Zg=globalThis;function z0e(t,e,r){return n=>n===t?e:r}var bY=1;var wY=class{getLogger(e,r,n){return new hb}},yN=new wY;var SN=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):j0e}};var gb=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new SN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:yN}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var EN=class t{constructor(){this._proxyLoggerProvider=new gb}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Zg[mb]?this.getLoggerProvider():(Zg[mb]=z0e(bY,e,yN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Zg[mb])===null||e===void 0?void 0:e.call(Zg,bY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Zg[mb],this._proxyLoggerProvider=new gb}};var q0e=EN.getInstance();function B0e(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 V0e(t){t.forEach(e=>e.disable())}function RY(t){let e=t.tracerProvider||Ot.getTracerProvider(),r=t.meterProvider||pb.getMeterProvider(),n=t.loggerProvider||q0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return B0e(i,e,r,n),()=>{V0e(i)}}Ne();var d0t=Qr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function H0e(t){return t.getValue(d0t)===!0}var Jg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Jg||(Jg={}));Ne();var AY="[_0-9a-z-*/]",f0t=`[a-z]${AY}{0,255}`,p0t=`[a-z0-9]${AY}{0,240}@[a-z]${AY}{0,13}`,h0t=new RegExp(`^(?:${f0t}|${p0t})$`),m0t=/^[ -~]{0,255}[!-~]$/,g0t=/,|=/;function xY(t){return h0t.test(t)}function CY(t){return m0t.test(t)&&!g0t.test(t)}var _0t=32,G0e=512,W0e=",",Y0e="=",vN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!xY(e)||!CY(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>G0e)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=W0e+e),e=`${n[0]}${Y0e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(W0e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Y0e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!xY(a)||!CY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>G0e)&&(r.set(a,c),n=l,r.size>=_0t))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var TN="traceparent",bN="tracestate",y0t="00",S0t="(?!ff)[\\da-f]{2}",E0t="(?![0]{32})[\\da-f]{32}",v0t="(?![0]{16})[\\da-f]{16}",T0t="[\\da-f]{2}",b0t=new RegExp(`^\\s?(${S0t})-(${E0t})-(${v0t})-(${T0t})(-.*)?\\s?$`);function K0e(t){let e=b0t.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ku=class{inject(e,r,n){let i=Ot.getSpanContext(e);if(!i||H0e(e)||!Ni(i))return;let s=`${y0t}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Er.NONE).toString(16)}`;n.set(r,TN,s),i.traceState&&n.set(r,bN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,TN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=K0e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,bN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new vN(typeof c=="string"?c:void 0)}return Ot.setSpanContext(e,o)}fields(){return[TN,bN]}};var wN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var _b=class{_isCalled=!1;_deferred=new wN;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var mk=pn(pK(),1);Ne();var PIe=t=>{throw TypeError(t)},_K=(t,e,r)=>e.has(t)||PIe("Cannot "+r),hk=(t,e,r)=>(_K(t,e,"read from private field"),r?r.call(t):e.get(t)),hK=(t,e,r)=>e.has(t)?PIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),CIe=(t,e,r,n)=>(_K(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Uxt=(t,e,r)=>(_K(t,e,"access private method"),r),IIe="__netlify__getTracer",jxt="__netlify__shutdownTracers",zxt="__nfOTLPTrace",Nb,kb,gK,NIe,qxt=class{constructor(){hK(this,gK),hK(this,Nb),hK(this,kb),CIe(this,Nb,new _b(Uxt(this,gK,NIe),this)),CIe(this,kb,ue.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(hk(this,kb).debug(`export ${t.length.toString()} spans`),hk(this,Nb).isCalled){e({code:Jg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zxt,JSON.stringify(Bxt(t))),e({code:Jg.SUCCESS})}shutdown(){return hk(this,Nb).call()}};Nb=new WeakMap;kb=new WeakMap;gK=new WeakSet;NIe=function(){return hk(this,kb).debug("Shutting down"),Promise.resolve()};function Bxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:pk(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||po.SERVER,startTimeUnixNano:mK(e.startTime),endTimeUnixNano:mK(e.endTime),attributes:pk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:mK(n.time),attributes:pk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:pk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function pk(t){return Object.keys(t).map(e=>kIe(e,t[e]))}function kIe(t,e){return{key:t,value:$Ie(e)}}function $Ie(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($Ie)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>kIe(r,n))}}:{}}function mK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var OIe={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"}},LIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,IIe))return;let e=Fxt.version.slice(1),r=TY({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[Vxt()],i=new mk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ku});let s=t.instrumentations??[];RY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,IIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Fc(Ot.getTracer(a,c)):new Fc(Ot.getTracer(OIe.name,OIe.version))}}),Object.defineProperty(globalThis,jxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Vxt=()=>new mk.SimpleSpanProcessor(new qxt);Ne();var $b=pn(pK(),1);Ne();import*as gk from"diagnostics_channel";var DIe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Gn.ERROR:Gn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Fc?t:new Fc(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){gk.subscribe(t,e);let r=()=>gk.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:po.CLIENT},Gt.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Gn.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var o1e=pn(i1e(),1);var gD=fe("tracing"),s1e=8e3,sFt=5e3,Xw=async(t=sFt)=>{try{await Promise.race([LAe(),iFt(t)])}catch(e){gD.warn("Failed to flush tracers on shutdown",e)}},a1e=async(t,e,r)=>{if(!Tt()){let n=[new $b.SimpleSpanProcessor(new yJ),new $b.SimpleSpanProcessor(new o1e.OTLPTraceExporter({url:r.exporterUrl}))];await LIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new DIe({skipHeaders:!0})]})}return r.traceparent?(li.setGlobalPropagator(new ku),li.extract(Gt.active(),{traceparent:r.traceparent,isRemote:!0})):Gt.active()};function Kt(t,e,r){return gD.log(`\u23F3 TRACE: ${e} starting...`),rb(t,e,r)}var yJ=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";gD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&gD.log(` \u274C Error: ${e.status.message}`)}};function SJ(){return Xe().captureLlmContentEnabled}function c1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function _D(t,e,r){let n={role:t,parts:[{type:"text",content:Pi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var oFt=new Set([te.Task,te.RunCommand,te.Explore,te.FileRead,te.FileWrite,te.Notebook,te.Web,te.Todo,te.Skill,te.Tool,te.Memorize,te.Deployment,te.SiteGeneration]);function l1e(t,e,r,n){if(!t.length)return;let i=Tt();if(!i)return;let s=SJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&oFt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>s1e?`${a.message.slice(0,s1e)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Pi(_)}:{"gen_ai.output.messages":_D("assistant",_)}:{}}}).end(u)})}import{readdir as aFt,rm as cFt}from"fs/promises";import{join as lFt}from"path";async function u1e(t,e=[]){let n=(await aFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>cFt(lFt(t,i),{recursive:!0,force:!0})))}var uFt=300,Qw=t=>Xe().budgetCreditThresholds[t.mode]?.[t.runner]??uFt,eR=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var EJ=t=>{let e=Qw(t);if(!eR(t,e))return"default";let r=Xe();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},d1e=t=>{let e=EJ(t),r=Qw(t);return{budget_eligible:eR(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var hFt=tR.dirname(dFt(import.meta.url)),f1e=fFt(import.meta.url),mFt=tR.resolve(hFt,"scripts/scaffold.js"),gFt="scripts/scaffold.js",_Ft=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,vJ=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},yFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),SFt=t=>{let e=vJ(t);return e==="node"||e.endsWith("/node")},ll=t=>{if(typeof t!="string")return!1;let e=t.match(_Ft)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&yFt(vJ(e[r]));)r+=1;if(r>=e.length||!SFt(e[r]))return!1;let n=e[r+1];return n?vJ(n).includes(gFt):!1},Mp=fe("create_stage"),TJ="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",EFt=`${TJ}
|
|
597
|
+
if (condition) { yield value; }`)};import{Buffer as qbt}from"buffer";import{StringDecoder as Bbt}from"string_decoder";var kP=(t,e,r)=>{if(r)return;if(t)return{transform:Vbt.bind(void 0,new TextEncoder)};let n=new Bbt(e);return{transform:Hbt.bind(void 0,n),final:Gbt.bind(void 0,n)}},Vbt=function*(t,e){qbt.isBuffer(e)?yield Nc(e):typeof e=="string"?yield t.encode(e):yield e},Hbt=function*(t,e){yield Br(e)?t.write(e):e},Gbt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Wwe}from"util";var rW=Wwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$P=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Ybt}=e[r];for await(let i of n(t))yield*$P(i,e,r+1)},Ywe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Wbt(r,Number(e),t)},Wbt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$P(n,r,e+1)},Kwe=Wwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Ybt=function*(t){yield t};var nW=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Zwe=(t,e)=>[...e.flatMap(r=>[...Kf(r,t,0)]),...YT(t)],Kf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Zbt}=e[r];for(let i of n(t))yield*Kf(i,e,r+1)},YT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kbt(r,Number(e),t)},Kbt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Kf(n,r,e+1)},Zbt=function*(t){yield t};var iW=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Xwe(t,o,s),l=Yf(e),u=Yf(r),d=l?rW.bind(void 0,$P,a):nW.bind(void 0,Kf),f=l||u?rW.bind(void 0,Ywe,a):nW.bind(void 0,YT),p=l||u?Kwe.bind(void 0,a):void 0;return{stream:new Jbt({writableObjectMode:n,writableHighWaterMark:Jwe(n),readableObjectMode:i,readableHighWaterMark:Jwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},LP=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=Xwe(o,r,a);t=Zwe(c,t)}return t},Xwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Vwe(n,a)},kP(r,o,n),NP(r,s,n,c),{transform:t,final:e},{transform:Hwe(i,a)},Bwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Qwe=(t,e)=>{for(let r of Xbt(t))Qbt(t,r,e)},Xbt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Qbt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Iu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>ewt(a,n));r.input=UT(o)},ewt=(t,e)=>{let r=LP(t,e,"utf8",!0);return twt(r),UT(r)},twt=t=>{let e=t.find(r=>typeof r!="string"&&!Br(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as swt,appendFileSync as owt}from"fs";var DP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cg(r,n)&&!Yi.has(e)&&rwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&nwt.has(s))||t.every(({type:i})=>Is.has(i))),rwt=t=>t===1||t===2,nwt=new Set(["pipe","overlapped"]),eRe=async(t,e,r,n)=>{for await(let i of t)iwt(e)||rRe(i,r,n)},tRe=(t,e,r)=>{for(let n of t)rRe(n,e,r)},iwt=t=>t._readableState.pipes.length>0,rRe=(t,e,r)=>{let n=ZO(t);da({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var nRe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>awt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},awt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=iwe(t,s,d),p=Nc(f),{stdioItems:h,objectMode:m}=e[r],_=cwt([p],h,c,n),{serializedResult:S,finalResult:E=S}=lwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?E:void 0;try{return n.error===void 0&&dwt(S,h,i),y}catch(g){return n.error=g,y}},cwt=(t,e,r,n)=>{try{return LP(t,e,r,!1)}catch(i){return n.error=i,t}},lwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:UT(t)};let o=yve(t,r);return n[s]?{serializedResult:o,finalResult:tW(o,!i[s],e)}:{serializedResult:o}},uwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!DP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=tW(t,!1,o);try{tRe(a,e,n)}catch(c){r.error??=c}},dwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?owt(n,t):(r.add(s),swt(n,t))}};var iRe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Lc(e,r,"all")]:Array.isArray(e)?[Lc(t,r,"all"),...e]:Br(t)&&Br(e)?u3([t,e]):`${t}${e}`};import{once as sW}from"events";var sRe=async(t,e)=>{let[r,n]=await fwt(t);return e.isForcefullyTerminated??=!1,[r,n]},fwt=async t=>{let[e,r]=await Promise.allSettled([sW(t,"spawn"),sW(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?oRe(t):r.value},oRe=async t=>{try{return await sW(t,"exit")}catch{return oRe(t)}},aRe=async t=>{let[e,r]=await t;if(!pwt(e,r)&&oW(e,r))throw new co;return[e,r]},pwt=(t,e)=>t===void 0&&e===void 0,oW=(t,e)=>t!==0||e!==null;var cRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=hwt(t,e,r),o=s?.code==="ETIMEDOUT",a=nwe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},hwt=(t,e,r)=>t!==void 0?t:oW(e,r)?new co:void 0;var lRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gwt(t,e,r),d=Swt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},gwt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),a=_wt(r),{file:c,commandArguments:l,options:u}=yP(t,e,a);ywt(u);let d=Fwe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_wt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ywt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&MP("ipcInput"),t&&MP("ipc: true"),r&&MP("detached: true"),n&&MP("cancelSignal")},MP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Swt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Ewt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=cRe(c,r),{output:h,error:m=l}=nRe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,y)=>Lc(E,r,y)),S=Lc(iRe(h,r),r,"all");return Twt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},Ewt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Qwe(s,r);let a=vwt(r);return mwt(...SP(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},vwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:AP(e)}),Twt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?xP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):WT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as lAt}from"events";import{spawn as uAt}from"child_process";import hRe from"process";import{once as aW,on as bwt}from"events";var uRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Pg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),wwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),wwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cP(e,i);let s=Cu(t,e,r),o=new AbortController;try{return await Promise.race([Rwt(s,n,o),Awt(s,r,o),xwt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),lP(e,i)}},Rwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await aW(t,"message",{signal:r});return n}for await(let[n]of bwt(t,"message",{signal:r}))if(e(n))return n},Awt=async(t,e,{signal:r})=>{await aW(t,"disconnect",{signal:r}),ZTe(e)},xwt=async(t,e,{signal:r})=>{let[n]=await aW(t,"strict:error",{signal:r});throw sP(n,e)};import{once as fRe,on as Cwt}from"events";var pRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>cW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),cW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Pg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),cP(e,s);let o=Cu(t,e,r),a=new AbortController,c={};return Iwt(t,o,a),Owt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Pwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Iwt=async(t,e,r)=>{try{await fRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Owt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await fRe(t,"strict:error",{signal:r.signal});n.error=sP(i,e),r.abort()}catch{}},Pwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Cwt(r,"message",{signal:s.signal}))dRe(o),yield c}catch{dRe(o)}finally{s.abort(),lP(e,a),n||Ng(t),i&&await t}},dRe=({error:t})=>{if(t)throw t};var mRe=(t,{ipc:e})=>{Object.assign(t,_Re(t,!1,e))},gRe=()=>{let t=hRe,e=!0,r=hRe.channel!==void 0;return{..._Re(t,e,r),getCancelSignal:bbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},_Re=(t,e,r)=>({sendMessage:gP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:uRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:pRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Nwt}from"child_process";import{PassThrough as kwt,Readable as $wt,Writable as Lwt,Duplex as Dwt}from"stream";var yRe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{X3(n);let a=new Nwt;Mwt(a,n),Object.assign(a,{readable:Uwt,writable:Fwt,duplex:jwt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=zwt(c,o,i);return{subprocess:a,promise:l}},Mwt=(t,e)=>{let r=KT(),n=KT(),i=KT(),s=Array.from({length:e.length-3},KT),o=KT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},KT=()=>{let t=new kwt;return t.end(),t},Uwt=()=>new $wt({read(){}}),Fwt=()=>new Lwt({write(){}}),jwt=()=>new Dwt({read(){},write(){}}),zwt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as SRe,createWriteStream as ERe}from"fs";import{Buffer as qwt}from"buffer";import{Readable as ZT,Writable as Bwt,Duplex as Vwt}from"stream";var TRe=(t,e)=>PP(Hwt,t,e,!1),JT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Iu[t]}.`)},vRe={fileNumber:JT,generator:iW,asyncGenerator:iW,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Vwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Hwt={input:{...vRe,fileUrl:({value:t})=>({stream:SRe(t)}),filePath:({value:{file:t}})=>({stream:SRe(t)}),webStream:({value:t})=>({stream:ZT.fromWeb(t)}),iterable:({value:t})=>({stream:ZT.from(t)}),asyncIterable:({value:t})=>({stream:ZT.from(t)}),string:({value:t})=>({stream:ZT.from(t)}),uint8Array:({value:t})=>({stream:ZT.from(qwt.from(t))})},output:{...vRe,fileUrl:({value:t})=>({stream:ERe(t)}),filePath:({value:{file:t,append:e}})=>({stream:ERe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Bwt.fromWeb(t)}),iterable:JT,asyncIterable:JT,string:JT,uint8Array:JT}};import{on as Gwt,once as bRe}from"events";import{PassThrough as Wwt,getDefaultHighWaterMark as Ywt}from"stream";import{finished as ARe}from"stream/promises";function Zf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)uW(i);let e=t.some(({readableObjectMode:i})=>i),r=Kwt(t,e),n=new lW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Kwt=(t,e)=>{if(t.length===0)return Ywt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},lW=class extends Wwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(uW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Zwt(this,this.#e,this.#s);let r=Qwt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(uW(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},Zwt=async(t,e,r)=>{UP(t,wRe);let n=new AbortController;try{await Promise.race([Jwt(t,n),Xwt(t,e,r,n)])}finally{n.abort(),UP(t,-wRe)}},Jwt=async(t,{signal:e})=>{try{await ARe(t,{signal:e,cleanup:!0})}catch(r){throw xRe(t,r),r}},Xwt=async(t,e,r,{signal:n})=>{for await(let[i]of Gwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},uW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Qwt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{UP(t,RRe);let a=new AbortController;try{await Promise.race([eRt(s,e,a),tRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),rRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),UP(t,-RRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?dW(t):nRt(t))},eRt=async(t,e,{signal:r})=>{try{await t,r.aborted||dW(e)}catch(n){r.aborted||xRe(e,n)}},tRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await ARe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;CRe(o)?i.add(e):IRe(t,o)}},rRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await bRe(t,i,{signal:s}),!t.readable)return bRe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},nRt=t=>{t.writable&&t.end()},xRe=(t,e)=>{CRe(e)?dW(t):IRe(t,e)},CRe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",dW=t=>{(t.readable||t.writable)&&t.destroy()},IRe=(t,e)=>{t.destroyed||(t.once("error",iRt),t.destroy(e))},iRt=()=>{},UP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},wRe=2,RRe=1;import{finished as ORe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),sRt(t,e),oRt(t,e)},sRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await ORe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}fW(e)}},fW=t=>{t.writable&&t.end()},oRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await ORe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}pW(t)}},pW=t=>{t.readable&&t.destroy()};var PRe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Is.has(c)))aRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Is.has(c)))lRt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Zf(s);jg(o,i)}},aRt=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=cRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},cRt=["stdin","stdout","stderr"],lRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;uRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},uRt=(t,{signal:e})=>{ao(t)&&Gf(t,dRt,e)},dRt=2;import{addAbortListener as hRt}from"events";var Jf=[];Jf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Jf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Jf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FP=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",hW=Symbol.for("signal-exit emitter"),mW=globalThis,fRt=Object.defineProperty.bind(Object),gW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(mW[hW])return mW[hW];fRt(mW,hW,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},jP=class{},pRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),_W=class extends jP{onExit(){return()=>{}}load(){}unload(){}},yW=class extends jP{#e=SW.platform==="win32"?"SIGINT":"SIGHUP";#r=new gW;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Jf)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!FP(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Jf)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Jf.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return FP(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&FP(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},SW=globalThis.process,{onExit:NRe,load:$mr,unload:Lmr}=pRt(FP(SW)?new yW(SW):new _W);var kRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=NRe(()=>{t.kill()});hRt(n,()=>{i()})};var LRe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=JO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mRt(r,n,i),{sourceStream:d,sourceError:f}=_Rt(t,l),{options:p,fileDescriptors:h}=pa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},mRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=gRt(t,e,...r),a=aP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},gRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($Re,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||c3(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=zO(r,...n);return{destination:e($Re)(i,s,o),pipeOptions:o}}if(pa.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},$Re=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_Rt=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var MRe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=yRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw EW({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},yRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return pW(t),n;if(e!==void 0)return fW(r),e},EW=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:DRe,escapedCommand:DRe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),DRe="source.pipe(destination)";var URe=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 SRt}from"stream/promises";var FRe=(t,e,r)=>{let n=zP.has(e)?vRt(t,e):ERt(t,e);return Gf(t,bRt,r.signal),Gf(e,wRt,r.signal),TRt(e),n},ERt=(t,e)=>{let r=Zf([t]);return jg(r,e),zP.set(e,r),r},vRt=(t,e)=>{let r=zP.get(e);return r.add(t),r},TRt=async t=>{try{await SRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zP.delete(t)},zP=new WeakMap,bRt=2,wRt=1;import{aborted as RRt}from"util";var jRe=(t,e)=>t===void 0?[]:[ARt(t,e)],ARt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await RRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw EW({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var qP=(t,...e)=>{if(Cr(e[0]))return qP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=LRe(t,...e),i=xRt({...n,destination:r});return i.pipe=qP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},xRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=CRt(t,i);MRe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=FRe(e,s,d);return await Promise.race([URe(u),...jRe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},CRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as LRt}from"timers/promises";import{on as IRt}from"events";import{getDefaultHighWaterMark as ORt}from"stream";var BP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return PRt(e,o),qRe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},PRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},vW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;NRt(e,o,t);let a=t.readableObjectMode&&!s;return qRe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},NRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},qRe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=IRt(t,"data",{signal:e.signal,highWaterMark:zRe,highWatermark:zRe});return kRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},TW=ORt(!0),zRe=TW,kRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=$Rt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Kf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*YT(a)}},$Rt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[kP(t,r,!e),NP(t,i,!n,{})].filter(Boolean);var BRe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=DRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([MRt(t),d]);return}let f=Q3(c,r),p=vW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([URt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},DRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!DP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=vW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await eRe(a,t,r,s)},MRt=async t=>{await LRt(),t.readableFlowing===null&&t.resume()},URt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await bP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await wP(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return VRe(ewe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},bW=async t=>{try{return await t}catch(e){return VRe(e)}},VRe=({bufferedData:t})=>gve(t)?new Uint8Array(t):t;import{finished as FRt}from"stream/promises";var XT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=jRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],FRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||BRt(a,e,r,n)}finally{o.abort()}},jRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&zRt(t,r,n),n},zRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qRt(e,r),n.call(t,...i)}},qRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},BRt=(t,e,r,n)=>{if(!VRt(t,e,r,n))throw t},VRt=(t,e,r,n=!0)=>r.propagating?HRe(t)||VP(t):(r.propagating=!0,wW(r,e)===n?HRe(t):VP(t)),wW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",HRe=t=>t?.code==="EPIPE";var GRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>RW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),RW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=XT(t,e,l);if(wW(l,e)){await u;return}let[d]=await Promise.all([BRe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var WRe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Zf([t,e].filter(Boolean)):void 0,YRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>RW({...HRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:GRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),HRt=({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}},GRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as WRt}from"events";var KRe=t=>Cg(t,"ipc"),ZRe=(t,e)=>{let r=ZO(t);da({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var JRe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=KRe(s),a=kc(e,"ipc"),c=kc(r,"ipc");for await(let l of cW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(twe(t,i,c),i.push(l)),o&&ZRe(l,s);return i},XRe=async(t,e)=>(await Promise.allSettled([t]),e);var QRe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let E=sRe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=GRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=YRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],A=JRe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=YRt(m,t,y),C=KRt(h,y);try{return await Promise.race([Promise.all([{},aRe(E),Promise.all(g),T,A,kbe(t,d),...b,...C]),_,ZRt(t,S),...Cbe(t,s,f,S),...KTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Abe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(g.map(x=>bW(x))),bW(T),XRe(A,w),Promise.allSettled(b),Promise.allSettled(C)])}},YRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:XT(n,i,r)),KRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>uo(s,{checkOpen:!1})&&!ao(s)).map(({type:i,value:s,stream:o=s})=>XT(o,n,e,{isSameDirection:Is.has(i),stopOnExit:i==="native"}))),ZRt=async(t,{signal:e})=>{let[r]=await WRt(t,"error",{signal:e});throw r};var eAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),QT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=fa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},zg=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as JRt}from"stream";import{callbackify as XRt}from"util";import{finished as tAe}from"stream/promises";var AW=async t=>{if(t!==void 0)try{await xW(t)}catch{}},rAe=async t=>{if(t!==void 0)try{await CW(t)}catch{}},xW=async t=>{await tAe(t,{cleanup:!0,readable:!1,writable:!0})},CW=async t=>{await tAe(t,{cleanup:!0,readable:!0,writable:!1})},HP=async(t,e)=>{if(await t,e)throw e},GP=(t,e,r)=>{r&&!VP(r)?t.destroy(r):e&&t.destroy()};var nAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Yi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=IW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=OW(a,o),{read:f,onStdoutDataDone:p}=PW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new JRt({read:f,destroy:XRt(kW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return NW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},IW=(t,e,r)=>{let n=kg(t,e),i=QT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},OW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:TW},PW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=fa(),o=BP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){QRt(this,o,s)},onStdoutDataDone:s}},QRt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},NW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await CW(t),await n,await AW(i),await e,r.readable&&r.push(null)}catch(s){await AW(i),iAe(r,s)}},kW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await zg(r,e)&&(iAe(t,n),await HP(e,n))},iAe=(t,e)=>{GP(t,t.readable,e)};import{Writable as eAt}from"stream";import{callbackify as sAe}from"util";var oAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=$W(t,r,e),o=new eAt({...LW(n,t,i),destroy:sAe(MW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return DW(n,o),o},$W=(t,e,r)=>{let n=aP(t,e),i=QT(r,n,"writableFinal"),s=QT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},LW=(t,e,r)=>({write:tAt.bind(void 0,t),final:sAe(rAt.bind(void 0,t,e,r))}),tAt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rAt=async(t,e,r)=>{await zg(r,e)&&(t.writable&&t.end(),await e)},DW=async(t,e,r)=>{try{await xW(t),e.writable&&e.end()}catch(n){await rAe(r),aAe(e,n)}},MW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await zg(r,e),await zg(n,e)&&(aAe(t,i),await HP(e,i))},aAe=(t,e)=>{GP(t,t.writable,e)};import{Duplex as nAt}from"stream";import{callbackify as iAt}from"util";var cAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Yi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=IW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=$W(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=OW(c,a),{read:_,onStdoutDataDone:S}=PW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new nAt({read:_,...LW(u,t,d),destroy:iAt(sAt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return NW({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),DW(u,E,c),E},sAt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([kW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),MW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var UW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Yi.has(e),o=kg(t,r),a=BP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return oAt(a,o,t)},oAt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var lAe=(t,{encoding:e})=>{let r=eAe();t.readable=nAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=oAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=cAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=UW.bind(void 0,t,e),t[Symbol.asyncIterator]=UW.bind(void 0,t,e,{})};var uAe=(t,e)=>{for(let[r,n]of cAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},aAt=(async()=>{})().constructor.prototype,cAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aAt,t)]);var dAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dAt(t,e,r),{subprocess:f,promise:p}=pAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=qP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),uAe(f,p),pa.set(f,{options:u,fileDescriptors:d}),f},dAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),{file:a,commandArguments:c,options:l}=yP(t,e,r),u=fAt(l),d=TRe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},fAt=({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}},pAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uAt(...SP(t,e,r))}catch(h){return yRe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;lAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];PRe(c,a,l),kRe(c,r,l);let d={},f=fa();c.kill=WTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=WRe(c,r),lAe(c,r),mRe(c,r);let p=hAt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},hAt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await QRe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((g,T)=>Lc(g,e,T)),E=Lc(m,e,"all"),y=mAt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(y,n,e)},mAt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?WT({error:t.error,command:c,escapedCommand:l,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ha,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):xP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var WP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,gAt(n,t[n],i)]));return{...t,...r}},gAt=(t,e,r)=>_At.has(t)&&Cr(e)&&Cr(r)?{...e,...r}:r,_At=new Set(["env",...h3]);var Ou=(t,e,r,n)=>{let i=(o,a,c)=>Ou(o,a,r,c),s=(...o)=>yAt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},yAt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Cr(s))return i(t,WP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=SAt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?lRe(a,c,l):dAe(a,c,l,i)},SAt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Tve(e)?bve(e,r):[e,...r],[o,a,c]=zO(...s),l=WP(WP(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var fAe=({file:t,commandArguments:e})=>hAe(t,e),pAe=({file:t,commandArguments:e})=>({...hAe(t,e),isSync:!0}),hAe=(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]=EAt(t);return{file:r,commandArguments:n}},EAt=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(vAt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},vAt=/ +/g;var mAe=(t,e,r)=>{t.sync=e(TAt,r),t.s=t.sync},gAe=({options:t})=>_Ae(t),TAt=({options:t})=>({..._Ae(t),isSync:!0}),_Ae=t=>({options:{...bAt(t),...t}}),bAt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},yAe={preferLocal:!0};var SAe=Ou(()=>({})),wyr=Ou(()=>({isSync:!0})),EAe=Ou(fAe),Ryr=Ou(pAe),Ayr=Ou(Obe),xyr=Ou(gAe,{},yAe,mAe),{sendMessage:Cyr,getOneMessage:Iyr,getEachMessage:Oyr,getCancelSignal:Pyr}=gRe();import{Transform as wAt}from"stream";var RAt=["NETLIFY_AI_GATEWAY_KEY"];function AAt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...RAt])]}function xAt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function CAt(){let e=AAt().map(r=>process.env[r]).filter(r=>!(!r||xAt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Pi(t){if(typeof t!="string")return t;let e=CAt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(IAt(n),"g");r=r.replace(i,"******")}),r}function IAt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var eb=class extends wAt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Pi(i);n(null,s)}},YP=Symbol("maskedWrite");function vAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[YP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stdout.write=r}if(!process.stderr.write[YP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stderr.write=r}}}var TAe=!1,bAe,FW=t=>{bAe??=t},wAe=t=>{TAe=!0,FW(t)},Cn=()=>TAe,ga=()=>bAe,RAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var tb=null,AAe=t=>(tb&&tb.destroy(),tb=new fo({totalAllowedTime:t}),tb),xAe=()=>tb;var fo=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Cn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await DO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var CAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.190.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.18.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var kAt=PAt(import.meta.url),$At=Dc.dirname(kAt),LAt=NAt(import.meta.url),qg=fe("shell"),jW=new Set,IAe={preferLocal:!0},sr=(t,e,r)=>{let[n,i]=DAt(e,r),s={...IAe,...i},o=SAe(t,n,s);PAe(o,s),$Ae(o);let a=r?.idleTimeout;return a&&a>0&&kAe(o,a),o},OAe=(t,e)=>{let r={...IAe,...e},n=EAe(t,r);return PAe(n,r),$Ae(n),e?.idleTimeout&&e.idleTimeout>0&&kAe(n,e.idleTimeout),n},DAt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},PAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||_a.env.NETLIFY_LOCAL_QUIET==="true")return;if(_a.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new eb).pipe(_a.stdout),t.stderr?.pipe(new eb).pipe(_a.stderr);return}t.stdout?.pipe(_a.stdout),t.stderr?.pipe(_a.stderr)},zW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_a.kill(-t.pid,e),qg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qg.error("Error killing process:",r),!1}},NAe=t=>zW(t,"SIGKILL"),kAe=(t,e)=>{let r=null,n=()=>{qg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing idle process ${t.pid}`),NAe(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)},$Ae=t=>{jW.add(t);let e=xAe();if(e){let r=e.onTimesUp(()=>{qg.log(`Global timer expired, killing process ${t.pid}`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing process ${t.pid} after timeout`),NAe(t))},5e3)});t.on("exit",()=>{jW.delete(t),r()}),t.on("error",()=>{jW.delete(t),r()})}};function ya(t,e){if(!_a.env.NETLIFY_LOCAL_MODE)try{let i=LAt.resolve(CAe.name),s=Dc.dirname(i);for(;s!==Dc.dirname(s);){let o=Dc.dirname(s);if(Dc.basename(o)==="node_modules"){let a=Dc.join(o,".bin",e);if(KP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(_a.env.NODE_PATH){let i=Dc.join(_a.env.NODE_PATH,".bin",e);if(KP.existsSync(i))return i}let r=Dc.join(t,"node_modules",".bin",e);if(KP.existsSync(r))return r;let n=Dc.join($At,"..","node_modules",".bin",e);if(KP.existsSync(n))return n}import yD from"process";import{fileURLToPath as dFt}from"url";import{createRequire as fFt}from"module";import tR from"path";import{readFileSync as pFt}from"fs";var MAt="__netlify__getTracer",UAt="__netlify__shutdownTracers",Tt=(t,e)=>globalThis[MAt]?.(t,e),LAe=async()=>globalThis[UAt]?.();function rb(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as iFt}from"timers/promises";Ne();import Fxt from"process";Ne();var c0t=(t,e)=>{e.recordException(t),e.setStatus({code:Gn.ERROR})};var Fc=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=C0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>I0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=C0e(r,n,i),c=this._tracer.startSpan(e,s,o);return I0e(c,s,a)}};function C0e(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Gt.active(),{opts:n,ctx:i,fn:s}}function I0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:c0t,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ne();var Kg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var vY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=F0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Kg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Kg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=F0e(this._rawAttributes),this._schemaUrl=l0t(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,Kg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ue.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Kg(n)){ue.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=u0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function TY(t,e){return vY.FromAttributeList(Object.entries(t),e)}function F0e(t){return t.map(([e,r])=>Kg(r)?[e,r.catch(n=>{ue.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function l0t(t){if(typeof t=="string"||t===void 0)return t;ue.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function u0t(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ue.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var hb=class{emit(e){}enabled(){return!1}},j0e=new hb;var mb=Symbol.for("io.opentelemetry.js.api.logs"),Zg=globalThis;function z0e(t,e,r){return n=>n===t?e:r}var bY=1;var wY=class{getLogger(e,r,n){return new hb}},yN=new wY;var SN=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):j0e}};var gb=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new SN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:yN}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var EN=class t{constructor(){this._proxyLoggerProvider=new gb}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Zg[mb]?this.getLoggerProvider():(Zg[mb]=z0e(bY,e,yN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Zg[mb])===null||e===void 0?void 0:e.call(Zg,bY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Zg[mb],this._proxyLoggerProvider=new gb}};var q0e=EN.getInstance();function B0e(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 V0e(t){t.forEach(e=>e.disable())}function RY(t){let e=t.tracerProvider||Ot.getTracerProvider(),r=t.meterProvider||pb.getMeterProvider(),n=t.loggerProvider||q0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return B0e(i,e,r,n),()=>{V0e(i)}}Ne();var d0t=Qr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function H0e(t){return t.getValue(d0t)===!0}var Jg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Jg||(Jg={}));Ne();var AY="[_0-9a-z-*/]",f0t=`[a-z]${AY}{0,255}`,p0t=`[a-z0-9]${AY}{0,240}@[a-z]${AY}{0,13}`,h0t=new RegExp(`^(?:${f0t}|${p0t})$`),m0t=/^[ -~]{0,255}[!-~]$/,g0t=/,|=/;function xY(t){return h0t.test(t)}function CY(t){return m0t.test(t)&&!g0t.test(t)}var _0t=32,G0e=512,W0e=",",Y0e="=",vN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!xY(e)||!CY(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>G0e)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=W0e+e),e=`${n[0]}${Y0e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(W0e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Y0e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!xY(a)||!CY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>G0e)&&(r.set(a,c),n=l,r.size>=_0t))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var TN="traceparent",bN="tracestate",y0t="00",S0t="(?!ff)[\\da-f]{2}",E0t="(?![0]{32})[\\da-f]{32}",v0t="(?![0]{16})[\\da-f]{16}",T0t="[\\da-f]{2}",b0t=new RegExp(`^\\s?(${S0t})-(${E0t})-(${v0t})-(${T0t})(-.*)?\\s?$`);function K0e(t){let e=b0t.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ku=class{inject(e,r,n){let i=Ot.getSpanContext(e);if(!i||H0e(e)||!Ni(i))return;let s=`${y0t}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Er.NONE).toString(16)}`;n.set(r,TN,s),i.traceState&&n.set(r,bN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,TN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=K0e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,bN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new vN(typeof c=="string"?c:void 0)}return Ot.setSpanContext(e,o)}fields(){return[TN,bN]}};var wN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var _b=class{_isCalled=!1;_deferred=new wN;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var mk=pn(pK(),1);Ne();var PIe=t=>{throw TypeError(t)},_K=(t,e,r)=>e.has(t)||PIe("Cannot "+r),hk=(t,e,r)=>(_K(t,e,"read from private field"),r?r.call(t):e.get(t)),hK=(t,e,r)=>e.has(t)?PIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),CIe=(t,e,r,n)=>(_K(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Uxt=(t,e,r)=>(_K(t,e,"access private method"),r),IIe="__netlify__getTracer",jxt="__netlify__shutdownTracers",zxt="__nfOTLPTrace",Nb,kb,gK,NIe,qxt=class{constructor(){hK(this,gK),hK(this,Nb),hK(this,kb),CIe(this,Nb,new _b(Uxt(this,gK,NIe),this)),CIe(this,kb,ue.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(hk(this,kb).debug(`export ${t.length.toString()} spans`),hk(this,Nb).isCalled){e({code:Jg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zxt,JSON.stringify(Bxt(t))),e({code:Jg.SUCCESS})}shutdown(){return hk(this,Nb).call()}};Nb=new WeakMap;kb=new WeakMap;gK=new WeakSet;NIe=function(){return hk(this,kb).debug("Shutting down"),Promise.resolve()};function Bxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:pk(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||po.SERVER,startTimeUnixNano:mK(e.startTime),endTimeUnixNano:mK(e.endTime),attributes:pk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:mK(n.time),attributes:pk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:pk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function pk(t){return Object.keys(t).map(e=>kIe(e,t[e]))}function kIe(t,e){return{key:t,value:$Ie(e)}}function $Ie(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($Ie)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>kIe(r,n))}}:{}}function mK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var OIe={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"}},LIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,IIe))return;let e=Fxt.version.slice(1),r=TY({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[Vxt()],i=new mk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ku});let s=t.instrumentations??[];RY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,IIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Fc(Ot.getTracer(a,c)):new Fc(Ot.getTracer(OIe.name,OIe.version))}}),Object.defineProperty(globalThis,jxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Vxt=()=>new mk.SimpleSpanProcessor(new qxt);Ne();var $b=pn(pK(),1);Ne();import*as gk from"diagnostics_channel";var DIe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Gn.ERROR:Gn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Fc?t:new Fc(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){gk.subscribe(t,e);let r=()=>gk.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:po.CLIENT},Gt.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Gn.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var o1e=pn(i1e(),1);var gD=fe("tracing"),s1e=8e3,sFt=5e3,Xw=async(t=sFt)=>{try{await Promise.race([LAe(),iFt(t)])}catch(e){gD.warn("Failed to flush tracers on shutdown",e)}},a1e=async(t,e,r)=>{if(!Tt()){let n=[new $b.SimpleSpanProcessor(new yJ),new $b.SimpleSpanProcessor(new o1e.OTLPTraceExporter({url:r.exporterUrl}))];await LIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new DIe({skipHeaders:!0})]})}return r.traceparent?(li.setGlobalPropagator(new ku),li.extract(Gt.active(),{traceparent:r.traceparent,isRemote:!0})):Gt.active()};function Kt(t,e,r){return gD.log(`\u23F3 TRACE: ${e} starting...`),rb(t,e,r)}var yJ=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";gD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&gD.log(` \u274C Error: ${e.status.message}`)}};function SJ(){return Xe().captureLlmContentEnabled}function c1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function _D(t,e,r){let n={role:t,parts:[{type:"text",content:Pi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var oFt=new Set([te.Task,te.RunCommand,te.Explore,te.FileRead,te.FileWrite,te.Notebook,te.Web,te.Todo,te.Skill,te.Tool,te.Memorize,te.Deployment,te.SiteGeneration]);function l1e(t,e,r,n){if(!t.length)return;let i=Tt();if(!i)return;let s=SJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&oFt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>s1e?`${a.message.slice(0,s1e)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Pi(_)}:{"gen_ai.output.messages":_D("assistant",_)}:{}}}).end(u)})}import{readdir as aFt,rm as cFt}from"fs/promises";import{join as lFt}from"path";async function u1e(t,e=[]){let n=(await aFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>cFt(lFt(t,i),{recursive:!0,force:!0})))}var uFt=300,Qw=t=>Xe().budgetCreditThresholds[t.mode]?.[t.runner]??uFt,eR=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var EJ=t=>{let e=Qw(t);if(!eR(t,e))return"default";let r=Xe();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},d1e=t=>{let e=EJ(t),r=Qw(t);return{budget_eligible:eR(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var hFt=tR.dirname(dFt(import.meta.url)),f1e=fFt(import.meta.url),mFt=tR.resolve(hFt,"scripts/scaffold.js"),gFt="scripts/scaffold.js",_Ft=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,vJ=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},yFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),SFt=t=>{let e=vJ(t);return e==="node"||e.endsWith("/node")},ll=t=>{if(typeof t!="string")return!1;let e=t.match(_Ft)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&yFt(vJ(e[r]));)r+=1;if(r>=e.length||!SFt(e[r]))return!1;let n=e[r+1];return n?vJ(n).includes(gFt):!1},Mp=fe("create_stage"),TJ="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",EFt=`${TJ}
|
|
598
598
|
|
|
599
599
|
Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,vFt=`${TJ}
|
|
600
600
|
|
|
@@ -738,7 +738,7 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
738
738
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
739
739
|
|
|
740
740
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
741
|
-
`);this.baseURL=c.baseURL,this.timeout=c.timeout??p7.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=zJ(c.logLevel,"ClientOptions.logLevel",this)??zJ(_d("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??ED(),Ue(this,YD,O1e,"f"),this._options=c,o&&(this._workloadIdentityAuth=new xD(o,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=s}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return ge([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return F1e(e)}getUserAgent(){return`${this.constructor.name}/JS ${ud}`}defaultIdempotencyKey(){return`stainless-node-retry-${xJ()}`}makeStatusError(e,r,n,i){return vr.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof Re?n:new Re(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new Re(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!H(this,f7,"m",TUe).call(this)&&n||this.baseURL,s=E1e(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(s.searchParams);return(!OJ(o)||!OJ(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(s.search=this.stringifyQuery(r)),s.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new jp(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,s=i.maxRetries??this.maxRetries;r==null&&(r=s),await this.prepareOptions(i);let{req:o,url:a,timeout:c}=await this.buildRequest(i,{retryCount:s-r});await this.prepareRequest(o,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Nr(this).debug(`[${l}] sending request`,dl({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:o.headers})),i.signal?.aborted)throw new Ur;let f=new AbortController,p=await this.fetchWithAuth(a,o,c,f).catch(oR),h=Date.now();if(p instanceof globalThis.Error){let S=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new Ur;let E=sR(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Nr(this).info(`[${l}] connection ${E?"timed out":"failed"} - ${S}`),Nr(this).debug(`[${l}] connection ${E?"timed out":"failed"} (${S})`,dl({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw Nr(this).info(`[${l}] connection ${E?"timed out":"failed"} - error; no more retries left`),Nr(this).debug(`[${l}] connection ${E?"timed out":"failed"} (error; no more retries left)`,dl({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof Up||p instanceof aR?p:E?new ld:new cd({cause:p})}let m=[...p.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,E])=>", "+S+": "+JSON.stringify(E)).join(""),_=`[${l}${u}${m}] ${o.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await kJ(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let S=await this.shouldRetry(p);if(r&&S){let A=`retrying, ${r} attempts remaining`;return await kJ(p.body),Nr(this).info(`${_} - ${A}`),Nr(this).debug(`[${l}] response error (${A})`,dl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let E=S?"error; no more retries left":"error; not retryable";Nr(this).info(`${_} - ${E}`);let y=await p.text().catch(A=>oR(A).message),g=b1e(y),T=g?void 0:y;throw Nr(this).debug(`[${l}] response error (${E})`,dl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:T,durationMs:Date.now()-d})),this.makeStatusError(p.status,g,T,p.headers)}return Nr(this).info(_),Nr(this).debug(`[${l}] response start`,dl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new pR(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${d7}`){let c=await this._workloadIdentityAuth.getToken();o.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:s,method:o,...a}=r||{},c=this._makeAbort(i);s&&s.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let s,o=i?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(s=c)}let a=i?.get("retry-after");if(a&&!s){let c=parseFloat(a);Number.isNaN(c)?s=Date.parse(a)-Date.now():s=c*1e3}if(s===void 0){let c=e.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Ba(s),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let s=r-e,o=Math.min(.5*Math.pow(2,s),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:s,query:o,defaultBaseURL:a}=n,c=this.buildURL(s,o,a);"timeout"in n&&T1e("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let s={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);let o=ge([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...C1e(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(o),o.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:r}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let n=ge([r]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,s=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!s}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:vD(e),isStreamingBody:!0}:typeof e=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e),isStreamingBody:!1}:{...H(this,YD,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};p7=Ge,YD=new WeakMap,f7=new WeakSet,TUe=function(){return this.baseURL!=="https://api.openai.com/v1"};Ge.OpenAI=p7;Ge.DEFAULT_TIMEOUT=6e5;Ge.OpenAIError=Re;Ge.APIError=vr;Ge.APIConnectionError=cd;Ge.APIConnectionTimeoutError=ld;Ge.APIUserAbortError=Ur;Ge.NotFoundError=py;Ge.ConflictError=hy;Ge.RateLimitError=gy;Ge.BadRequestError=uy;Ge.AuthenticationError=dy;Ge.InternalServerError=_y;Ge.PermissionDeniedError=fy;Ge.UnprocessableEntityError=my;Ge.InvalidWebhookSignatureError=qa;Ge.toFile=ID;Ge.Completions=Kp;Ge.Chat=hd;Ge.Embeddings=Jp;Ge.Files=Qp;Ge.Images=nh;Ge.Audio=Wa;Ge.Moderations=sh;Ge.Models=ih;Ge.FineTuning=Lo;Ge.Graders=Td;Ge.VectorStores=Sl;Ge.Webhooks=ch;Ge.Beta=$o;Ge.Batches=Vp;Ge.Uploads=wd;Ge.Responses=_l;Ge.Realtime=gl;Ge.Conversations=Ed;Ge.Evals=vd;Ge.Containers=Sd;Ge.Skills=yl;Ge.Videos=ah;var Fi=fe("runner_codex"),KD="Codex CLI",rS="gpt-5.6-sol";async function azt({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else r?await t.isModelAvailableForProvider("openai",r)||(Fi.log(`Model '${r}' is not available for openai provider, proceeding without model specification`),ee.inc("model.unavailable",1,{provider:"openai"}),n=void 0):!!rS&&await t.isModelAvailableForProvider("openai",rS)?(n=rS,Fi.log(`Using default model: ${rS}`)):rS&&Fi.log(`Default model ${rS} is not available, proceeding without model specification`);return n}var ZD="netlify-ask-db",czt=`default_permissions = "${ZD}"`,lzt=()=>Rd.join(El.env.XDG_CONFIG_HOME??Rd.join(CR.homedir(),".config"),"netlify"),uzt=t=>["",`[permissions.${ZD}]`,'description = "Ask mode: read-only filesystem, network access for database reads"','extends = ":read-only"',"",`[permissions.${ZD}.filesystem]`,'":minimal" = "read"','"/" = "read"',`"${t}" = "write"`,"",`[permissions.${ZD}.network]`,"enabled = true"];function dzt({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");El.env.OPENAI_API_KEY=e,El.env.OPENAI_BASE_URL=r}else if(!El.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function h7({config:t,persistSteps:e,sendSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:s,cwd:o=El.cwd(),abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let{prompt:u}=t,{model:d}=t;dzt({aiGateway:n});let f=await azt({config:t,aiGateway:n,model:d}),p=[],h=[],m=[],_={},S=new Set,E=0,y=0,g,T,w,A,b,C=Mm(t),P=`${El.env.NVM_BIN}/node`,x=Rd.join(CR.homedir(),".codex"),L=Rd.join(x,"config.toml"),O=Rd.join(x,"auth.json");try{await xR.mkdir(x,{recursive:!0});let F={OPENAI_API_KEY:El.env.OPENAI_API_KEY};await xR.writeFile(O,JSON.stringify(F,null,2),"utf-8"),Fi.log("Created Codex auth.json file");let q=El.env.OPENAI_BASE_URL,M=['forced_login_method = "api"'],Q=vu({creditWrapUpTurn:l}),j=Eu(t,{creditWrapUpTurn:l});C&&M.push(czt),q&&M.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${q}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),Q&&M.push(...XEe()),j&&M.push(...QEe(j));let k=[];C&&(k=uzt(lzt()),M.push(...k)),await xR.writeFile(L,`${M.join(`
|
|
741
|
+
`);this.baseURL=c.baseURL,this.timeout=c.timeout??p7.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=zJ(c.logLevel,"ClientOptions.logLevel",this)??zJ(_d("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??ED(),Ue(this,YD,O1e,"f"),this._options=c,o&&(this._workloadIdentityAuth=new xD(o,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=s}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return ge([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return F1e(e)}getUserAgent(){return`${this.constructor.name}/JS ${ud}`}defaultIdempotencyKey(){return`stainless-node-retry-${xJ()}`}makeStatusError(e,r,n,i){return vr.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof Re?n:new Re(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new Re(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!H(this,f7,"m",TUe).call(this)&&n||this.baseURL,s=E1e(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(s.searchParams);return(!OJ(o)||!OJ(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(s.search=this.stringifyQuery(r)),s.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new jp(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,s=i.maxRetries??this.maxRetries;r==null&&(r=s),await this.prepareOptions(i);let{req:o,url:a,timeout:c}=await this.buildRequest(i,{retryCount:s-r});await this.prepareRequest(o,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Nr(this).debug(`[${l}] sending request`,dl({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:o.headers})),i.signal?.aborted)throw new Ur;let f=new AbortController,p=await this.fetchWithAuth(a,o,c,f).catch(oR),h=Date.now();if(p instanceof globalThis.Error){let S=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new Ur;let E=sR(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Nr(this).info(`[${l}] connection ${E?"timed out":"failed"} - ${S}`),Nr(this).debug(`[${l}] connection ${E?"timed out":"failed"} (${S})`,dl({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw Nr(this).info(`[${l}] connection ${E?"timed out":"failed"} - error; no more retries left`),Nr(this).debug(`[${l}] connection ${E?"timed out":"failed"} (error; no more retries left)`,dl({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof Up||p instanceof aR?p:E?new ld:new cd({cause:p})}let m=[...p.headers.entries()].filter(([S])=>S==="x-request-id").map(([S,E])=>", "+S+": "+JSON.stringify(E)).join(""),_=`[${l}${u}${m}] ${o.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await kJ(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let S=await this.shouldRetry(p);if(r&&S){let A=`retrying, ${r} attempts remaining`;return await kJ(p.body),Nr(this).info(`${_} - ${A}`),Nr(this).debug(`[${l}] response error (${A})`,dl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let E=S?"error; no more retries left":"error; not retryable";Nr(this).info(`${_} - ${E}`);let y=await p.text().catch(A=>oR(A).message),g=b1e(y),T=g?void 0:y;throw Nr(this).debug(`[${l}] response error (${E})`,dl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:T,durationMs:Date.now()-d})),this.makeStatusError(p.status,g,T,p.headers)}return Nr(this).info(_),Nr(this).debug(`[${l}] response start`,dl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new pR(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${d7}`){let c=await this._workloadIdentityAuth.getToken();o.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:s,method:o,...a}=r||{},c=this._makeAbort(i);s&&s.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let s,o=i?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(s=c)}let a=i?.get("retry-after");if(a&&!s){let c=parseFloat(a);Number.isNaN(c)?s=Date.parse(a)-Date.now():s=c*1e3}if(s===void 0){let c=e.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Ba(s),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let s=r-e,o=Math.min(.5*Math.pow(2,s),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:s,query:o,defaultBaseURL:a}=n,c=this.buildURL(s,o,a);"timeout"in n&&T1e("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let s={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);let o=ge([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...C1e(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(o),o.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:r}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let n=ge([r]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,s=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!s}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:vD(e),isStreamingBody:!0}:typeof e=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e),isStreamingBody:!1}:{...H(this,YD,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};p7=Ge,YD=new WeakMap,f7=new WeakSet,TUe=function(){return this.baseURL!=="https://api.openai.com/v1"};Ge.OpenAI=p7;Ge.DEFAULT_TIMEOUT=6e5;Ge.OpenAIError=Re;Ge.APIError=vr;Ge.APIConnectionError=cd;Ge.APIConnectionTimeoutError=ld;Ge.APIUserAbortError=Ur;Ge.NotFoundError=py;Ge.ConflictError=hy;Ge.RateLimitError=gy;Ge.BadRequestError=uy;Ge.AuthenticationError=dy;Ge.InternalServerError=_y;Ge.PermissionDeniedError=fy;Ge.UnprocessableEntityError=my;Ge.InvalidWebhookSignatureError=qa;Ge.toFile=ID;Ge.Completions=Kp;Ge.Chat=hd;Ge.Embeddings=Jp;Ge.Files=Qp;Ge.Images=nh;Ge.Audio=Wa;Ge.Moderations=sh;Ge.Models=ih;Ge.FineTuning=Lo;Ge.Graders=Td;Ge.VectorStores=Sl;Ge.Webhooks=ch;Ge.Beta=$o;Ge.Batches=Vp;Ge.Uploads=wd;Ge.Responses=_l;Ge.Realtime=gl;Ge.Conversations=Ed;Ge.Evals=vd;Ge.Containers=Sd;Ge.Skills=yl;Ge.Videos=ah;var Fi=fe("runner_codex"),KD="Codex CLI",rS="gpt-6.1-sol";async function azt({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else r?await t.isModelAvailableForProvider("openai",r)||(Fi.log(`Model '${r}' is not available for openai provider, proceeding without model specification`),ee.inc("model.unavailable",1,{provider:"openai"}),n=void 0):!!rS&&await t.isModelAvailableForProvider("openai",rS)?(n=rS,Fi.log(`Using default model: ${rS}`)):rS&&Fi.log(`Default model ${rS} is not available, proceeding without model specification`);return n}var ZD="netlify-ask-db",czt=`default_permissions = "${ZD}"`,lzt=()=>Rd.join(El.env.XDG_CONFIG_HOME??Rd.join(CR.homedir(),".config"),"netlify"),uzt=t=>["",`[permissions.${ZD}]`,'description = "Ask mode: read-only filesystem, network access for database reads"','extends = ":read-only"',"",`[permissions.${ZD}.filesystem]`,'":minimal" = "read"','"/" = "read"',`"${t}" = "write"`,"",`[permissions.${ZD}.network]`,"enabled = true"];function dzt({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");El.env.OPENAI_API_KEY=e,El.env.OPENAI_BASE_URL=r}else if(!El.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function h7({config:t,persistSteps:e,sendSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:s,cwd:o=El.cwd(),abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let{prompt:u}=t,{model:d}=t;dzt({aiGateway:n});let f=await azt({config:t,aiGateway:n,model:d}),p=[],h=[],m=[],_={},S=new Set,E=0,y=0,g,T,w,A,b,C=Mm(t),P=`${El.env.NVM_BIN}/node`,x=Rd.join(CR.homedir(),".codex"),L=Rd.join(x,"config.toml"),O=Rd.join(x,"auth.json");try{await xR.mkdir(x,{recursive:!0});let F={OPENAI_API_KEY:El.env.OPENAI_API_KEY};await xR.writeFile(O,JSON.stringify(F,null,2),"utf-8"),Fi.log("Created Codex auth.json file");let q=El.env.OPENAI_BASE_URL,M=['forced_login_method = "api"'],Q=vu({creditWrapUpTurn:l}),j=Eu(t,{creditWrapUpTurn:l});C&&M.push(czt),q&&M.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${q}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),Q&&M.push(...XEe()),j&&M.push(...QEe(j));let k=[];C&&(k=uzt(lzt()),M.push(...k)),await xR.writeFile(L,`${M.join(`
|
|
742
742
|
`)}
|
|
743
743
|
`,"utf-8"),Fi.log("Wrote Codex config.toml",...k.length?[k.join(`
|
|
744
744
|
`)]:[])}catch(F){let q=F instanceof Error?F.message:String(F);throw Fi.warn("Failed to setup Codex config and credentials",{error:q}),new Error(`Codex setup failed: ${q}`)}let R=Lm("codex",t.effort);t.effort&&!R&&Fi.log(`Effort '${t.effort}' is not available on ${KD}; using its default`);let I=l?"low":R,N=!!(i&&s),G="mode"in t&&t.mode==="ask",Y=!!C,ce=[ya(o,"codex"),"exec",...G&&!Y?["--sandbox","read-only"]:[],...N?["resume",s]:[],...G?[]:["--yolo"],"--json",...I?["-c",`model_reasoning_effort="${I}"`]:[],...f?["--model",f]:[]].filter(Boolean);Fi.log(`Running ${P} ${ce.join(" ")}`);let ve=sr(P,ce,{all:!0,cwd:o,env:{...El.env},stdin:"pipe",idleTimeout:nc,cancelSignal:a});ve.stdin?.end(u);let xe=Nl(()=>{e?.({steps:p,duration:y}),r?.({steps:h,duration:y}),h=[]},250),Le=(F,q)=>{let M={...F,id:E};E+=1,m.push(M),p.push(M),h.push(M),q||xe.flush(),xe(),q&&xe.flush()},re=f||"default";t.answeredInteraction||Le({title:`Using ${KD} with ${re}`,category:te.Environment},!0);let qe=ozt.createInterface({input:ve.all});qe.on("error",F=>{Fi.error("Readline interface error",{error:F.message,stack:F.stack})}),qe.on("line",F=>{let q;try{q=JSON.parse(F)}catch{Fi.log("Could not parse line",F);return}if(q?.duration_ms&&(y=q.duration_ms),q?.type==="thread.started"&&typeof q?.thread_id=="string"&&(w=q.thread_id,c?.(w)),q?.type==="item.started"&&q?.item?.type==="command_execution")_[q.item.id]=q.item;else if(q?.type==="item.completed"&&q?.item?.type==="command_execution"){let M=q.item,Q=hzt(M);Q&&Le(Q,!0);let j=M.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(j&&!S.has(j)){S.add(j);let k=Go(j);ic(Fi,k),Le({title:`Use ${k}`,category:te.Skill,type:j},!0)}}else if(q?.type==="item.completed"&&q?.item?.type==="reasoning"){let M={title:"Reasoning",message:q.item.text,category:te.Reasoning};Le(M,!0)}else if(q?.type==="item.completed"&&q?.item?.type==="agent_message")g=q.item.text;else if(q?.type==="item.started"&&q?.item?.type==="mcp_tool_call"){let M=q.item,Q=Kge(M.server)&&!b?wg(M.tool,M.arguments,Yge):void 0;Q&&"interaction"in Q?(b=Q.interaction,ve.kill()):Q&&(Fi.warn("Ignoring malformed pause tool input",{toolUseId:M.id,tool:M.tool,issues:Q.issues}),ee.inc(Q.metric,1))}else if(q?.type==="turn.completed"&&q.usage)A={input_tokens:q.usage.input_tokens,output_tokens:q.usage.output_tokens},Tu(A,f?{model:f}:{});else if(q?.type==="turn.failed"&&q?.error?.message)T=q.error.message;else if(q?.type==="local_shell_call"){let M=q;_[M.call_id]=M}else if(q?.type==="local_shell_call_output"){let M=q,Q=_[M.call_id],j=mzt(Q,M);j&&Le(j,!0);let U=(Q?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(U&&!S.has(U)){S.add(U);let W=Go(U);ic(Fi,W),Le({title:`Use ${W}`,category:te.Skill,type:U},!0)}}else q?.type==="message"&&q.role==="assistant"?g=q.content?.map(M=>M.text).join(`
|