@netlify/agent-runner-cli 1.140.0 → 1.140.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +3 -3
- package/dist/bin.js +3 -3
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -501,7 +501,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
501
501
|
`,LF:`
|
|
502
502
|
`,concatBytes:sq},HZe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},VZe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:HZe};import{Buffer as GZe}from"buffer";var Tle=(t,e)=>t?void 0:zZe.bind(void 0,e),zZe=function*(t,e){if(typeof e!="string"&&!cr(e)&&!GZe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},ble=(t,e)=>t?WZe.bind(void 0,e):YZe.bind(void 0,e),WZe=function*(t,e){vle(t,e),yield e},YZe=function*(t,e){if(vle(t,e),typeof e!="string"&&!cr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},vle=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
503
503
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
504
|
-
if (condition) { yield value; }`)};import{Buffer as KZe}from"buffer";import{StringDecoder as JZe}from"string_decoder";var jA=(t,e,r)=>{if(r)return;if(t)return{transform:XZe.bind(void 0,new TextEncoder)};let n=new JZe(e);return{transform:QZe.bind(void 0,n),final:ZZe.bind(void 0,n)}},XZe=function*(t,e){KZe.isBuffer(e)?yield wa(e):typeof e=="string"?yield t.encode(e):yield e},QZe=function*(t,e){yield cr(e)?t.write(e):e},ZZe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as wle}from"util";var oq=wle(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),HA=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=tet}=e[r];for await(let s of n(t))yield*HA(s,e,r+1)},Rle=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*eet(r,Number(e),t)},eet=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*HA(n,r,e+1)},Ale=wle(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),tet=function*(t){yield t};var aq=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},Cle=(t,e)=>[...e.flatMap(r=>[...Tf(r,t,0)]),...nE(t)],Tf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=net}=e[r];for(let s of n(t))yield*Tf(s,e,r+1)},nE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ret(r,Number(e),t)},ret=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Tf(n,r,e+1)},net=function*(t){yield t};var cq=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=Ple(t,o,i),l=Ef(e),u=Ef(r),f=l?oq.bind(void 0,HA,a):aq.bind(void 0,Tf),d=l||u?oq.bind(void 0,Rle,a):aq.bind(void 0,nE),h=l||u?Ale.bind(void 0,a):void 0;return{stream:new set({writableObjectMode:n,writableHighWaterMark:Ole(n),readableObjectMode:s,readableHighWaterMark:Ole(s),transform(m,g,y){f([m,c,0],this,y)},flush(m){d([c],this,m)},destroy:h})}},VA=(t,e,r,n)=>{let s=e.filter(({type:o})=>o==="generator"),i=n?s.reverse():s;for(let{value:o,optionName:a}of i){let c=Ple(o,r,a);t=Cle(c,t)}return t},Ple=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:Tle(n,a)},jA(r,o,n),BA(r,i,n,c),{transform:t,final:e},{transform:ble(s,a)},Ele({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var xle=(t,e)=>{for(let r of iet(t))oet(t,r,e)},iet=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),oet=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${ol[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>aet(a,n));r.input=WS(o)},aet=(t,e)=>{let r=VA(t,e,"utf8",!0);return cet(r),WS(r)},cet=t=>{let e=t.find(r=>typeof r!="string"&&!cr(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 het,appendFileSync as pet}from"fs";var GA=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Up(r,n)&&!ts.has(e)&&uet(n)&&(t.some(({type:s,value:i})=>s==="native"&&fet.has(i))||t.every(({type:s})=>Bs.has(s))),uet=t=>t===1||t===2,fet=new Set(["pipe","overlapped"]),Ile=async(t,e,r,n)=>{for await(let s of t)det(e)||Mle(s,r,n)},Nle=(t,e,r)=>{for(let n of t)Mle(n,e,r)},det=t=>t._readableState.pipes.length>0,Mle=(t,e,r)=>{let n=iA(t);ho({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Lle=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:s})=>{if(e===null)return{output:Array.from({length:3})};let i={},o=new Set([]);return{output:e.map((c,l)=>met({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},met=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:f})=>{if(t===null)return;let d=Dce(t,i,f),h=wa(d),{stdioItems:p,objectMode:m}=e[r],g=get([h],p,c,n),{serializedResult:y,finalResult:T=y}=_et({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});yet({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let S=a[r]?T:void 0;try{return n.error===void 0&&Eet(y,p,s),S}catch(_){return n.error=_,S}},get=(t,e,r,n)=>{try{return VA(t,e,r,!1)}catch(s){return n.error=s,t}},_et=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:WS(t)};let o=Kie(t,r);return n[i]?{serializedResult:o,finalResult:iq(o,!s[i],e)}:{serializedResult:o}},yet=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!GA({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=iq(t,!1,o);try{Nle(a,e,n)}catch(c){r.error??=c}},Eet=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>UA.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?pet(n,t):(r.add(i),het(n,t))}};var Dle=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ca(e,r,"all")]:Array.isArray(e)?[Ca(t,r,"all"),...e]:cr(t)&&cr(e)?pU([t,e]):`${t}${e}`};import{once as lq}from"events";var kle=async(t,e)=>{let[r,n]=await Tet(t);return e.isForcefullyTerminated??=!1,[r,n]},Tet=async t=>{let[e,r]=await Promise.allSettled([lq(t,"spawn"),lq(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$le(t):r.value},$le=async t=>{try{return await lq(t,"exit")}catch{return $le(t)}},Fle=async t=>{let[e,r]=await t;if(!bet(e,r)&&uq(e,r))throw new gi;return[e,r]},bet=(t,e)=>t===void 0&&e===void 0,uq=(t,e)=>t!==0||e!==null;var Ule=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=vet(t,e,r),o=i?.code==="ETIMEDOUT",a=Lce(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},vet=(t,e,r)=>t!==void 0?t:uq(e,r)?new gi:void 0;var qle=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Ret(t,e,r),f=Oet({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Kp(f,c,l)},Ret=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=aA(t,e,r),a=Aet(r),{file:c,commandArguments:l,options:u}=CA(t,e,a);Cet(u);let f=gle(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},Aet=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Cet=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&zA("ipcInput"),t&&zA("ipc: true"),r&&zA("detached: true"),n&&zA("cancelSignal")},zA=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Oet=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Pet({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:f,timedOut:d,isMaxBuffer:h}=Ule(c,r),{output:p,error:m=l}=Lle({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),g=p.map((T,S)=>Ca(T,r,S)),y=Ca(Dle(p,r),r,"all");return Iet({error:m,exitCode:u,signal:f,timedOut:d,isMaxBuffer:h,stdio:g,all:y,options:r,command:n,escapedCommand:s,startTime:a})},Pet=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{xle(i,r);let a=xet(r);return wet(...OA(t,e,a))}catch(a){return Yp({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},xet=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:DA(e)}),Iet=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:s,stdio:i,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?kA({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):rE({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:s,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:i,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as yrt}from"events";import{spawn as Srt}from"child_process";import Gle from"process";import{once as fq,on as Net}from"events";var Ble=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(jp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:TA(t)}),Met({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),Met=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{_A(e,s);let i=il(t,e,r),o=new AbortController;try{return await Promise.race([Let(i,n,o),Det(i,r,o),ket(i,r,o)])}catch(a){throw Hp(t),a}finally{o.abort(),yA(e,s)}},Let=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await fq(t,"message",{signal:r});return n}for await(let[n]of Net(t,"message",{signal:r}))if(e(n))return n},Det=async(t,e,{signal:r})=>{await fq(t,"disconnect",{signal:r}),Cae(e)},ket=async(t,e,{signal:r})=>{let[n]=await fq(t,"strict:error",{signal:r});throw pA(n,e)};import{once as Hle,on as $et}from"events";var Vle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>dq({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),dq=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{jp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:TA(t)}),_A(e,i);let o=il(t,e,r),a=new AbortController,c={};return Fet(t,o,a),Uet({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),qet({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},Fet=async(t,e,r)=>{try{await Hle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Uet=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await Hle(t,"strict:error",{signal:r.signal});n.error=pA(s,e),r.abort()}catch{}},qet=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of $et(r,"message",{signal:i.signal}))jle(o),yield c}catch{jle(o)}finally{i.abort(),yA(e,a),n||Hp(t),s&&await t}},jle=({error:t})=>{if(t)throw t};var zle=(t,{ipc:e})=>{Object.assign(t,Yle(t,!1,e))},Wle=()=>{let t=Gle,e=!0,r=Gle.channel!==void 0;return{...Yle(t,e,r),getCancelSignal:ece.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Yle=(t,e,r)=>({sendMessage:RA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Ble.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Vle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Bet}from"child_process";import{PassThrough as jet,Readable as Het,Writable as Vet,Duplex as Get}from"stream";var Kle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{rq(n);let a=new Bet;zet(a,n),Object.assign(a,{readable:Wet,writable:Yet,duplex:Ket});let c=Yp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=Jet(c,o,s);return{subprocess:a,promise:l}},zet=(t,e)=>{let r=sE(),n=sE(),s=sE(),i=Array.from({length:e.length-3},sE),o=sE(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},sE=()=>{let t=new jet;return t.end(),t},Wet=()=>new Het({read(){}}),Yet=()=>new Vet({write(){}}),Ket=()=>new Get({read(){},write(){}}),Jet=async(t,e,r)=>Kp(t,e,r);import{createReadStream as Jle,createWriteStream as Xle}from"fs";import{Buffer as Xet}from"buffer";import{Readable as iE,Writable as Qet,Duplex as Zet}from"stream";var Zle=(t,e)=>qA(ett,t,e,!1),oE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ol[t]}.`)},Qle={fileNumber:oE,generator:cq,asyncGenerator:cq,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Zet.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},ett={input:{...Qle,fileUrl:({value:t})=>({stream:Jle(t)}),filePath:({value:{file:t}})=>({stream:Jle(t)}),webStream:({value:t})=>({stream:iE.fromWeb(t)}),iterable:({value:t})=>({stream:iE.from(t)}),asyncIterable:({value:t})=>({stream:iE.from(t)}),string:({value:t})=>({stream:iE.from(t)}),uint8Array:({value:t})=>({stream:iE.from(Xet.from(t))})},output:{...Qle,fileUrl:({value:t})=>({stream:Xle(t)}),filePath:({value:{file:t,append:e}})=>({stream:Xle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Qet.fromWeb(t)}),iterable:oE,asyncIterable:oE,string:oE,uint8Array:oE}};import{on as ttt,once as eue}from"events";import{PassThrough as rtt,getDefaultHighWaterMark as ntt}from"stream";import{finished as nue}from"stream/promises";function bf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)pq(s);let e=t.some(({readableObjectMode:s})=>s),r=stt(t,e),n=new hq({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var stt=(t,e)=>{if(t.length===0)return ntt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},hq=class extends rtt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(pq(e),this.#e.has(e))return;this.#e.add(e),this.#n??=itt(this,this.#e,this.#i);let r=ctt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(pq(e),!this.#e.has(e))return!1;let r=this.#s.get(e);return r===void 0?!1:(this.#s.delete(e),e.unpipe(this),await r,!0)}},itt=async(t,e,r)=>{WA(t,tue);let n=new AbortController;try{await Promise.race([ott(t,n),att(t,e,r,n)])}finally{n.abort(),WA(t,-tue)}},ott=async(t,{signal:e})=>{try{await nue(t,{signal:e,cleanup:!0})}catch(r){throw sue(t,r),r}},att=async(t,e,r,{signal:n})=>{for await(let[s]of ttt(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},pq=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ctt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{WA(t,rue);let a=new AbortController;try{await Promise.race([ltt(i,e,a),utt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),ftt({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),WA(t,-rue)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?mq(t):dtt(t))},ltt=async(t,e,{signal:r})=>{try{await t,r.aborted||mq(e)}catch(n){r.aborted||sue(e,n)}},utt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await nue(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;iue(o)?s.add(e):oue(t,o)}},ftt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await eue(t,s,{signal:i}),!t.readable)return eue(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},dtt=t=>{t.writable&&t.end()},sue=(t,e)=>{iue(e)?mq(t):oue(t,e)},iue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",mq=t=>{(t.readable||t.writable)&&t.destroy()},oue=(t,e)=>{t.destroyed||(t.once("error",htt),t.destroy(e))},htt=()=>{},WA=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},tue=2,rue=1;import{finished as aue}from"stream/promises";var Xp=(t,e)=>{t.pipe(e),ptt(t,e),mtt(t,e)},ptt=async(t,e)=>{if(!(mi(t)||mi(e))){try{await aue(t,{cleanup:!0,readable:!0,writable:!1})}catch{}gq(e)}},gq=t=>{t.writable&&t.end()},mtt=async(t,e)=>{if(!(mi(t)||mi(e))){try{await aue(e,{cleanup:!0,readable:!1,writable:!0})}catch{}_q(t)}},_q=t=>{t.readable&&t.destroy()};var cue=(t,e,r)=>{let n=new Map;for(let[s,{stdioItems:i,direction:o}]of Object.entries(e)){for(let{stream:a}of i.filter(({type:c})=>Bs.has(c)))gtt(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!Bs.has(c)))ytt({subprocess:t,stream:a,direction:o,fdNumber:s,pipeGroups:n,controller:r})}for(let[s,i]of n.entries()){let o=i.length===1?i[0]:bf(i);Xp(o,s)}},gtt=(t,e,r,n)=>{r==="output"?Xp(t.stdio[n],e):Xp(e,t.stdio[n]);let s=_tt[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},_tt=["stdin","stdout","stderr"],ytt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;Stt(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},Stt=(t,{signal:e})=>{mi(t)&&yf(t,Ett,e)},Ett=2;import{addAbortListener as vtt}from"events";var vf=[];vf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&vf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&vf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var YA=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",yq=Symbol.for("signal-exit emitter"),Sq=globalThis,Ttt=Object.defineProperty.bind(Object),Eq=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Sq[yq])return Sq[yq];Ttt(Sq,yq,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},KA=class{},btt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Tq=class extends KA{onExit(){return()=>{}}load(){}unload(){}},bq=class extends KA{#e=vq.platform==="win32"?"SIGINT":"SIGHUP";#r=new Eq;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of vf)this.#s[r]=()=>{let n=this.#t.listeners(r),{count:s}=this.#r,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#i=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!YA(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 vf)try{let r=this.#s[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,vf.forEach(e=>{let r=this.#s[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.#i,this.#r.count-=1)}#a(e){return YA(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#i.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&YA(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let s=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),s}else return n.call(this.#t,e,...r)}},vq=globalThis.process,{onExit:lue,load:gzt,unload:_zt}=btt(YA(vq)?new bq(vq):new Tq);var uue=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=lue(()=>{t.kill()});vtt(n,()=>{s()})};var due=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=oA(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=wtt(r,n,s),{sourceStream:f,sourceError:d}=Att(t,l),{options:h,fileDescriptors:p}=mo.get(t);return{sourcePromise:e,sourceStream:f,sourceOptions:h,sourceError:d,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},wtt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=Rtt(t,e,...r),a=gA(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},Rtt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(fue,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||dU(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[s,i,o]=JR(r,...n);return{destination:e(fue)(s,i,o),pipeOptions:o}}if(mo.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}`)},fue=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Att=(t,e)=>{try{return{sourceStream:Vp(t,e)}}catch(r){return{sourceError:r}}};var pue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=Ctt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw wq({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},Ctt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return _q(t),n;if(e!==void 0)return gq(r),e},wq=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Yp({error:t,command:hue,escapedCommand:hue,fileDescriptors:e,options:r,startTime:n,isSync:!1}),hue="source.pipe(destination)";var mue=async t=>{let[{status:e,reason:r,value:n=r},{status:s,reason:i,value:o=i}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),s==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as Ott}from"stream/promises";var gue=(t,e,r)=>{let n=JA.has(e)?xtt(t,e):Ptt(t,e);return yf(t,Ntt,r.signal),yf(e,Mtt,r.signal),Itt(e),n},Ptt=(t,e)=>{let r=bf([t]);return Xp(r,e),JA.set(e,r),r},xtt=(t,e)=>{let r=JA.get(e);return r.add(t),r},Itt=async t=>{try{await Ott(t,{cleanup:!0,readable:!1,writable:!0})}catch{}JA.delete(t)},JA=new WeakMap,Ntt=2,Mtt=1;import{aborted as Ltt}from"util";var _ue=(t,e)=>t===void 0?[]:[Dtt(t,e)],Dtt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await Ltt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw wq({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var XA=(t,...e)=>{if(Jt(e[0]))return XA.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=due(t,...e),s=ktt({...n,destination:r});return s.pipe=XA.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},ktt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=$tt(t,s);pue({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let f=new AbortController;try{let d=gue(e,i,f);return await Promise.race([mue(u),..._ue(a,{sourceStream:e,mergedStream:d,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{f.abort()}},$tt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Vtt}from"timers/promises";import{on as Ftt}from"events";import{getDefaultHighWaterMark as Utt}from"stream";var QA=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return qtt(e,o),Sue({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},qtt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Rq=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;Btt(e,o,t);let a=t.readableObjectMode&&!i;return Sue({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Btt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Sue=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=Ftt(t,"data",{signal:e.signal,highWaterMark:yue,highWatermark:yue});return jtt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},Aq=Utt(!0),yue=Aq,jtt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Htt({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*Tf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*nE(a)}},Htt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[jA(t,r,!e),BA(t,s,!n,{})].filter(Boolean);var Eue=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let f=Gtt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([ztt(t),f]);return}let d=nq(c,r),h=Rq({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:d,allMixed:a}),[p]=await Promise.all([Wtt({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),f]);return p},Gtt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!GA({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=Rq({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await Ile(a,t,r,i)},ztt=async t=>{await Vtt(),t.readableFlowing===null&&t.resume()},Wtt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await NA(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await MA(r,{maxBuffer:i})):await Wp(r,{maxBuffer:i})}catch(a){return Tue(Ice({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},Cq=async t=>{try{return await t}catch(e){return Tue(e)}},Tue=({bufferedData:t})=>Wie(t)?new Uint8Array(t):t;import{finished as Ytt}from"stream/promises";var aE=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Ktt(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Ytt(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Qtt(a,e,r,n)}finally{o.abort()}},Ktt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Jtt(t,r,n),n},Jtt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Xtt(e,r),n.call(t,...s)}},Xtt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Qtt=(t,e,r,n)=>{if(!Ztt(t,e,r,n))throw t},Ztt=(t,e,r,n=!0)=>r.propagating?bue(t)||ZA(t):(r.propagating=!0,Oq(r,e)===n?bue(t):ZA(t)),Oq=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ZA=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",bue=t=>t?.code==="EPIPE";var vue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>Pq({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),Pq=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=aE(t,e,l);if(Oq(l,e)){await u;return}let[f]=await Promise.all([Eue({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return f};var wue=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?bf([t,e].filter(Boolean)):void 0,Rue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>Pq({...ert(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:trt(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),ert=({stdout:t,stderr:e,all:r},[,n,s])=>{let i=n||s;return i?n?s?{stream:r,buffer:i}:{stream:t,buffer:i}:{stream:e,buffer:i}:{stream:r,buffer:i}},trt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as rrt}from"events";var Aue=t=>Up(t,"ipc"),Cue=(t,e)=>{let r=iA(t);ho({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Oue=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=Aue(i),a=Ra(e,"ipc"),c=Ra(r,"ipc");for await(let l of dq({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Nce(t,s,c),s.push(l)),o&&Cue(l,i);return s},Pue=async(t,e)=>(await Promise.allSettled([t]),e);var xue=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:f},context:d,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:g,controller:y})=>{let T=kle(t,d),S={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:T,propagating:!1},_=vue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),A=Rue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),P=[],C=Oue({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:h}),R=nrt(m,t,S),O=srt(p,S);try{return await Promise.race([Promise.all([{},Fle(T),Promise.all(_),A,C,uce(t,f),...R,...O]),g,irt(t,y),...ice(t,i,d,y),...Aae({subprocess:t,cancelSignal:o,gracefulCancel:a,context:d,controller:y}),...nce({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:d,controller:y})])}catch(w){return d.terminationReason??="other",Promise.all([{error:w},T,Promise.all(_.map(b=>Cq(b))),Cq(A),Pue(C,P),Promise.allSettled(R),Promise.allSettled(O)])}},nrt=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:aE(n,s,r)),srt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>yi(i,{checkOpen:!1})&&!mi(i)).map(({type:s,value:i,stream:o=i})=>aE(o,n,e,{isSameDirection:Bs.has(s),stopOnExit:s==="native"}))),irt=async(t,{signal:e})=>{let[r]=await rrt(t,"error",{signal:e});throw r};var Iue=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),cE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=po();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Qp=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 ort}from"stream";import{callbackify as art}from"util";import{finished as Nue}from"stream/promises";var xq=async t=>{if(t!==void 0)try{await Iq(t)}catch{}},Mue=async t=>{if(t!==void 0)try{await Nq(t)}catch{}},Iq=async t=>{await Nue(t,{cleanup:!0,readable:!1,writable:!0})},Nq=async t=>{await Nue(t,{cleanup:!0,readable:!0,writable:!1})},eC=async(t,e)=>{if(await t,e)throw e},tC=(t,e,r)=>{r&&!ZA(r)?t.destroy(r):e&&t.destroy()};var Lue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||ts.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Mq(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:f}=Lq(a,o),{read:d,onStdoutDataDone:h}=Dq({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new ort({read:d,destroy:art($q.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:f,objectMode:u,encoding:l});return kq({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},Mq=(t,e,r)=>{let n=Vp(t,e),s=cE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},Lq=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:Aq},Dq=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=po(),o=QA({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){crt(this,o,i)},onStdoutDataDone:i}},crt=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},kq=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await Nq(t),await n,await xq(s),await e,r.readable&&r.push(null)}catch(i){await xq(s),Due(r,i)}},$q=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qp(r,e)&&(Due(t,n),await eC(e,n))},Due=(t,e)=>{tC(t,t.readable,e)};import{Writable as lrt}from"stream";import{callbackify as kue}from"util";var $ue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=Fq(t,r,e),o=new lrt({...Uq(n,t,s),destroy:kue(Bq.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return qq(n,o),o},Fq=(t,e,r)=>{let n=gA(t,e),s=cE(r,n,"writableFinal"),i=cE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},Uq=(t,e,r)=>({write:urt.bind(void 0,t),final:kue(frt.bind(void 0,t,e,r))}),urt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},frt=async(t,e,r)=>{await Qp(r,e)&&(t.writable&&t.end(),await e)},qq=async(t,e,r)=>{try{await Iq(t),e.writable&&e.end()}catch(n){await Mue(r),Fue(e,n)}},Bq=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Qp(r,e),await Qp(n,e)&&(Fue(t,s),await eC(e,s))},Fue=(t,e)=>{tC(t,t.writable,e)};import{Duplex as drt}from"stream";import{callbackify as hrt}from"util";var Uue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||ts.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Mq(t,n,e),{subprocessStdin:u,waitWritableFinal:f,waitWritableDestroy:d}=Fq(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=Lq(c,a),{read:g,onStdoutDataDone:y}=Dq({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),T=new drt({read:g,...Uq(u,t,f),destroy:hrt(prt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:f,waitWritableDestroy:d})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return kq({subprocessStdout:c,onStdoutDataDone:y,readable:T,subprocess:t,subprocessStdin:u}),qq(u,T,c),T},prt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([$q({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),Bq({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var jq=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||ts.has(e),o=Vp(t,r),a=QA({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return mrt(a,o,t)},mrt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var que=(t,{encoding:e})=>{let r=Iue();t.readable=Lue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$ue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Uue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=jq.bind(void 0,t,e),t[Symbol.asyncIterator]=jq.bind(void 0,t,e,{})};var Bue=(t,e)=>{for(let[r,n]of _rt){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},grt=(async()=>{})().constructor.prototype,_rt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(grt,t)]);var jue=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:f}=Ert(t,e,r),{subprocess:d,promise:h}=brt({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:f});return d.pipe=XA.bind(void 0,{source:d,sourcePromise:h,boundOptions:{},createNested:n}),Bue(d,h),mo.set(d,{options:u,fileDescriptors:f}),d},Ert=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=aA(t,e,r),{file:a,commandArguments:c,options:l}=CA(t,e,r),u=Trt(l),f=Zle(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},Trt=({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}},brt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Srt(...OA(t,e,r))}catch(p){return Kle({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;yrt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];cue(c,a,l),uue(c,r,l);let f={},d=po();c.kill=wae.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:d,context:f,controller:l}),c.all=wue(c,r),que(c,r),zle(c,r);let h=vrt({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:f,onInternalError:d,controller:l});return{subprocess:c,promise:h}},vrt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[f,[d,h],p,m,g]=await xue({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let y=p.map((_,A)=>Ca(_,e,A)),T=Ca(m,e,"all"),S=wrt({errorInfo:f,exitCode:d,signal:h,stdio:y,all:T,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Kp(S,n,e)},wrt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?rE({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 go,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):kA({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var rC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,Rrt(n,t[n],s)]));return{...t,...r}},Rrt=(t,e,r)=>Art.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,Art=new Set(["env",...yU]);var al=(t,e,r,n)=>{let s=(o,a,c)=>al(o,a,r,c),i=(...o)=>Crt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Crt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(Jt(i))return s(t,rC(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=Ort({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?qle(a,c,l):jue(a,c,l,s)},Ort=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=Zie(e)?eoe(e,r):[e,...r],[o,a,c]=JR(...i),l=rC(rC(n,s),c),{file:u=o,commandArguments:f=a,options:d=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:f,options:d,isSync:h}};var Hue=({file:t,commandArguments:e})=>Gue(t,e),Vue=({file:t,commandArguments:e})=>({...Gue(t,e),isSync:!0}),Gue=(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]=Prt(t);return{file:r,commandArguments:n}},Prt=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(xrt)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},xrt=/ +/g;var zue=(t,e,r)=>{t.sync=e(Irt,r),t.s=t.sync},Wue=({options:t})=>Yue(t),Irt=({options:t})=>({...Yue(t),isSync:!0}),Yue=t=>({options:{...Nrt(t),...t}}),Nrt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Kue={preferLocal:!0};var Jue=al(()=>({})),oWt=al(()=>({isSync:!0})),Xue=al(Hue),aWt=al(Vue),cWt=al(ace),lWt=al(Wue,{},Kue,zue),{sendMessage:uWt,getOneMessage:fWt,getEachMessage:dWt,getCancelSignal:hWt}=Wle();import{Transform as Mrt}from"stream";var Lrt=["NETLIFY_AI_GATEWAY_KEY"];function Drt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...Lrt])]}function krt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function $rt(){let e=Drt().map(r=>process.env[r]).filter(r=>!(!r||krt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function js(t){if(typeof t!="string")return t;let e=$rt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let s=new RegExp(Frt(n),"g");r=r.replace(s,"******")}),r}function Frt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var lE=class extends Mrt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let s=e.toString(),i=js(s);n(null,i)}},nC=Symbol("maskedWrite");function Que(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[nC]){let e=process.stdout.write.bind(process.stdout),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[nC]=!0,process.stdout.write=r}if(!process.stderr.write[nC]){let e=process.stderr.write.bind(process.stderr),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[nC]=!0,process.stderr.write=r}}}var Zue=!1,efe=()=>{Zue=!0},Fn=()=>Zue;var uE=null,tfe=t=>(uE&&uE.destroy(),uE=new Oa({totalAllowedTime:t}),uE),rfe=()=>uE;var Oa=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&Fn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let i=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,f)=>{o=setTimeout(()=>{f(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await YR({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Oe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),i(),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 nfe={name:"@netlify/agent-runner-cli",type:"module",version:"1.140.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:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.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.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0"}};var jrt=qrt(import.meta.url),Hrt=Pa.dirname(jrt),Vrt=Brt(import.meta.url),Zp=Te("shell"),Hq=new Set,sfe={preferLocal:!0},rs=(t,e,r)=>{let[n,s]=Grt(e,r),i={...sfe,...s},o=Jue(t,n,i);ofe(o,i),lfe(o);let a=r?.idleTimeout;return a&&a>0&&cfe(o,a),o},ife=(t,e)=>{let r={...sfe,...e},n=Xue(t,r);return ofe(n,r),lfe(n),e?.idleTimeout&&e.idleTimeout>0&&cfe(n,e.idleTimeout),n},Grt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ofe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(xa.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new lE).pipe(xa.stdout),t.stderr?.pipe(new lE).pipe(xa.stderr);return}t.stdout?.pipe(xa.stdout),t.stderr?.pipe(xa.stderr)},Vq=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(xa.kill(-t.pid,e),Zp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Zp.error("Error killing process:",r),!1}},afe=t=>Vq(t,"SIGKILL"),cfe=(t,e)=>{let r=null,n=()=>{Zp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Vq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zp.log(`Force killing idle process ${t.pid}`),afe(t))},5e3)},s=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};s(),t.stdout?.on("data",s),t.stderr?.on("data",s);let i=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",i),t.on("error",i)},lfe=t=>{Hq.add(t);let e=rfe();if(e){let r=e.onTimesUp(()=>{Zp.log(`Global timer expired, killing process ${t.pid}`),Vq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zp.log(`Force killing process ${t.pid} after timeout`),afe(t))},5e3)});t.on("exit",()=>{Hq.delete(t),r()}),t.on("error",()=>{Hq.delete(t),r()})}};function cl(t,e){if(!xa.env.NETLIFY_LOCAL_MODE)try{let s=Vrt.resolve(nfe.name),i=Pa.dirname(s);for(;i!==Pa.dirname(i);){let o=Pa.dirname(i);if(Pa.basename(o)==="node_modules"){let a=Pa.join(o,".bin",e);if(sC.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(xa.env.NODE_PATH){let s=Pa.join(xa.env.NODE_PATH,".bin",e);if(sC.existsSync(s))return s}let r=Pa.join(t,"node_modules",".bin",e);if(sC.existsSync(r))return r;let n=Pa.join(Hrt,"..","node_modules",".bin",e);if(sC.existsSync(n))return n}import cI from"process";import{fileURLToPath as Mgt}from"url";import{createRequire as Lgt}from"module";import lI from"path";var zrt="__netlify__getTracer",Wrt="__netlify__shutdownTracers",Ze=(t,e)=>globalThis[zrt]?.(t,e),ufe=async()=>globalThis[Wrt]?.();function wf(t,e,r,n,s){let i=typeof n=="function"?n:typeof r=="function"?r:s;if(!i)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,i):i()}import{setTimeout as Ogt}from"timers/promises";import Hst from"process";var ffe=typeof globalThis=="object"?globalThis:global;var Ia="1.9.0";var dfe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Yrt(t){var e=new Set([t]),r=new Set,n=t.match(dfe);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(c){return c===t};function i(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(dfe);if(!l)return i(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||s.major!==u.major?i(c):s.major===0?s.minor===u.minor&&s.patch<=u.patch?o(c):i(c):s.minor<=u.minor?o(c):i(c)}}var hfe=Yrt(Ia);var Krt=Ia.split(".")[0],fE=Symbol.for("opentelemetry.js.api."+Krt),dE=ffe;function ll(t,e,r,n){var s;n===void 0&&(n=!1);var i=dE[fE]=(s=dE[fE])!==null&&s!==void 0?s:{version:Ia};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==Ia){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+Ia);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Ia+"."),!0}function Si(t){var e,r,n=(e=dE[fE])===null||e===void 0?void 0:e.version;if(!(!n||!hfe(n)))return(r=dE[fE])===null||r===void 0?void 0:r[t]}function ul(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Ia+".");var r=dE[fE];r&&delete r[t]}var Jrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Xrt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},pfe=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("verbose",this._namespace,e)},t})();function hE(t,e,r){var n=Si("diag");if(n)return r.unshift(e),n[t].apply(n,Xrt([],Jrt(r),!1))}var yn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(yn||(yn={}));function mfe(t,e){t<yn.NONE?t=yn.NONE:t>yn.ALL&&(t=yn.ALL),e=e||{};function r(n,s){var i=e[n];return typeof i=="function"&&t>=s?i.bind(e):function(){}}return{error:r("error",yn.ERROR),warn:r("warn",yn.WARN),info:r("info",yn.INFO),debug:r("debug",yn.DEBUG),verbose:r("verbose",yn.VERBOSE)}}var Qrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Zrt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},ent="diag",ns=(function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var a=Si("diag");if(a)return a[s].apply(a,Zrt([],Qrt(i),!1))}}var r=this,n=function(s,i){var o,a,c;if(i===void 0&&(i={logLevel:yn.INFO}),s===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof i=="number"&&(i={logLevel:i});var u=Si("diag"),f=mfe((a=i.logLevel)!==null&&a!==void 0?a:yn.INFO,s);if(u&&!i.suppressOverrideMessage){var d=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+d),f.warn("Current logger will overwrite one already registered from "+d)}return ll("diag",f,r,!0)};r.setLogger=n,r.disable=function(){ul(ent,r)},r.createComponentLogger=function(s){return new pfe(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var tnt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},rnt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},gfe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=tnt(e,2),n=r[0],s=r[1];return[n,s]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var i=new t(this._entries);try{for(var o=rnt(n),a=o.next();!a.done;a=o.next()){var c=a.value;i._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t})();var rYt=ns.instance();function _fe(t){return t===void 0&&(t={}),new gfe(new Map(Object.entries(t)))}function iC(t){return Symbol.for(t)}var nnt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var i=new t(r._currentContext);return i._currentContext.set(n,s),i},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t})(),yfe=new nnt;var Sfe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Efe={set:function(t,e,r){t!=null&&(t[e]=r)}};var snt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},int=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Tfe=(function(){function t(){}return t.prototype.active=function(){return yfe},t.prototype.with=function(e,r,n){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return r.call.apply(r,int([n],snt(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var ont=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},ant=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Gq="context",cnt=new Tfe,fl=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ll(Gq,e,ns.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,ant([e,r,n],ont(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Si(Gq)||cnt},t.prototype.disable=function(){this._getContextManager().disable(),ul(Gq,ns.instance())},t})();var oC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(oC||(oC={}));var zq="0000000000000000",Wq="00000000000000000000000000000000",bfe={traceId:Wq,spanId:zq,traceFlags:oC.NONE};var dl=(function(){function t(e){e===void 0&&(e=bfe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var Yq=iC("OpenTelemetry Context Key SPAN");function aC(t){return t.getValue(Yq)||void 0}function vfe(){return aC(fl.getInstance().active())}function pE(t,e){return t.setValue(Yq,e)}function wfe(t){return t.deleteValue(Yq)}function Rfe(t,e){return pE(t,new dl(e))}function cC(t){var e;return(e=aC(t))===null||e===void 0?void 0:e.spanContext()}var lnt=/^([0-9a-f]{32})$/i,unt=/^[0-9a-f]{16}$/i;function fnt(t){return lnt.test(t)&&t!==Wq}function dnt(t){return unt.test(t)&&t!==zq}function lC(t){return fnt(t.traceId)&&dnt(t.spanId)}function Afe(t){return new dl(t)}var Kq=fl.getInstance(),uC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=Kq.active());var s=!!r?.root;if(s)return new dl;var i=n&&cC(n);return hnt(i)&&lC(i)?new dl(i):new dl},t.prototype.startActiveSpan=function(e,r,n,s){var i,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(i=r,a=n):(i=r,o=n,a=s);var c=o??Kq.active(),l=this.startSpan(e,i,c),u=pE(c,l);return Kq.with(u,a,void 0,l)}},t})();function hnt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var pnt=new uC,Cfe=(function(){function t(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,s){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):pnt},t})();var Ofe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new uC},t})();var mnt=new Ofe,Jq=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var s;return(s=this.getDelegateTracer(e,r,n))!==null&&s!==void 0?s:new Cfe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:mnt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,r,n)},t})();var hl;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(hl||(hl={}));var yo;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(yo||(yo={}));var Na=fl.getInstance();var Xq=ns.instance();var Pfe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var Qq=iC("OpenTelemetry Baggage Key");function Zq(t){return t.getValue(Qq)||void 0}function xfe(){return Zq(fl.getInstance().active())}function Ife(t,e){return t.setValue(Qq,e)}function Nfe(t){return t.deleteValue(Qq)}var eB="propagation",gnt=new Pfe,Mfe=(function(){function t(){this.createBaggage=_fe,this.getBaggage=Zq,this.getActiveBaggage=xfe,this.setBaggage=Ife,this.deleteBaggage=Nfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ll(eB,e,ns.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=Efe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=Sfe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ul(eB,ns.instance())},t.prototype._getGlobalPropagator=function(){return Si(eB)||gnt},t})();var mE=Mfe.getInstance();var tB="trace",Lfe=(function(){function t(){this._proxyTracerProvider=new Jq,this.wrapSpanContext=Afe,this.isSpanContextValid=lC,this.deleteSpan=wfe,this.getSpan=aC,this.getActiveSpan=vfe,this.getSpanContext=cC,this.setSpan=pE,this.setSpanContext=Rfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=ll(tB,this._proxyTracerProvider,ns.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return Si(tB)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){ul(tB,ns.instance()),this._proxyTracerProvider=new Jq},t})();var gE=Lfe.getInstance();var ynt=function(t,e){e.recordException(t),e.setStatus({code:yo.ERROR})};var Rf=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,s){var i=Dfe(r,n,s),o=i.opts,a=i.ctx,c=i.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return kfe(l,o,c)})},t.prototype.withSpan=function(e,r,n,s){var i=Dfe(r,n,s),o=i.opts,a=i.ctx,c=i.fn,l=this._tracer.startSpan(e,o,a);return kfe(l,o,c)},t})();function Dfe(t,e,r){var n,s,i;return!e&&!r?i=t:r?(n=t,s=e,i=r):(n=t,i=e),n=n??{},s=s??Na.active(),{opts:n,ctx:s,fn:i}}function kfe(t,e,r){var n,s=(n=e.onException)!==null&&n!==void 0?n:ynt,i=function(a){throw s(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},i):(t.end(),o)}catch(a){throw i(a)}}QB();He();var BE=class{emit(e){}enabled(){return!1}},Khe=new BE;var jE=Symbol.for("io.opentelemetry.js.api.logs"),lm=globalThis;function Jhe(t,e,r){return n=>n===t?e:r}var ZB=1;var ej=class{getLogger(e,r,n){return new BE}},tO=new ej;var rO=class{constructor(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}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):Khe}};var HE=class{getLogger(e,r,n){var s;return(s=this._getDelegateLogger(e,r,n))!==null&&s!==void 0?s:new rO(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:tO}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getLogger(e,r,n)}};var nO=class t{constructor(){this._proxyLoggerProvider=new HE}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return lm[jE]?this.getLoggerProvider():(lm[jE]=Jhe(ZB,e,tO),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=lm[jE])===null||e===void 0?void 0:e.call(lm,ZB))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete lm[jE],this._proxyLoggerProvider=new HE}};var Xhe=nO.getInstance();function Qhe(t,e,r,n){for(let s=0,i=t.length;s<i;s++){let o=t[s];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function Zhe(t){t.forEach(e=>e.disable())}function tj(t){let e=t.tracerProvider||lr.getTracerProvider(),r=t.meterProvider||CE.getMeterProvider(),n=t.loggerProvider||Xhe.getLoggerProvider(),s=t.instrumentations?.flat()??[];return Qhe(s,e,r,n),()=>{Zhe(s)}}Vt();var RO=fn(_j(),1);Vt();var Npe=t=>{throw TypeError(t)},Tj=(t,e,r)=>e.has(t)||Npe("Cannot "+r),wO=(t,e,r)=>(Tj(t,e,"read from private field"),r?r.call(t):e.get(t)),yj=(t,e,r)=>e.has(t)?Npe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Ppe=(t,e,r,n)=>(Tj(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),jst=(t,e,r)=>(Tj(t,e,"access private method"),r),xpe="__netlify__getTracer",Vst="__netlify__shutdownTracers",Gst="__nfOTLPTrace",GE,zE,Ej,Mpe,zst=class{constructor(){yj(this,Ej),yj(this,GE),yj(this,zE),Ppe(this,GE,new Ro(jst(this,Ej,Mpe),this)),Ppe(this,zE,Xq.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(wO(this,zE).debug(`export ${t.length.toString()} spans`),wO(this,GE).isCalled){e({code:It.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Gst,JSON.stringify(Wst(t))),e({code:It.SUCCESS})}shutdown(){return wO(this,GE).call()}};GE=new WeakMap;zE=new WeakMap;Ej=new WeakSet;Mpe=function(){return wO(this,zE).debug("Shutting down"),Promise.resolve()};function Wst(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:vO(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||hl.SERVER,startTimeUnixNano:Sj(e.startTime),endTimeUnixNano:Sj(e.endTime),attributes:vO(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Sj(n.time),attributes:vO(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:vO(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function vO(t){return Object.keys(t).map(e=>Lpe(e,t[e]))}function Lpe(t,e){return{key:t,value:Dpe(e)}}function Dpe(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(Dpe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>Lpe(r,n))}}:{}}function Sj(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var Ipe={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},kpe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,xpe))return;let e=Hst.version.slice(1),r=eO({"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??[Yst()],s=new RO.NodeTracerProvider({resource:r,spanProcessors:n});s.register({propagator:new $a});let i=t.instrumentations??[];tj({instrumentations:i,tracerProvider:s}),Object.defineProperty(globalThis,xpe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Rf(gE.getTracer(a,c)):new Rf(gE.getTracer(Ipe.name,Ipe.version))}}),Object.defineProperty(globalThis,Vst,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await s.shutdown()})},Yst=()=>new RO.SimpleSpanProcessor(new zst);Vt();var WE=fn(_j(),1);import*as AO from"diagnostics_channel";var $pe=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?yo.ERROR:yo.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],s=this.config.redactHeaders??[],i=n.some(a=>r.includes(a.toString())),o={};if(i)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(d=>typeof d=="string"?d==u:d.test(u)))continue;let f=`http.${t}.header.${u}`;s===!0||s.some(d=>typeof d=="string"?d==u:d.test(u))?o[f]="REDACTED":o[f]=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 Rf?t:new Rf(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){AO.subscribe(t,e);let r=()=>AO.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(s=>typeof s=="string"?r.href.startsWith(s):s.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:hl.CLIENT},Na.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:yo.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 KTe=fn(WTe(),1);var oI=Te("tracing"),YTe=8e3,Pgt=5e3,ob=async(t=Pgt)=>{try{await Promise.race([ufe(),Ogt(t)])}catch(e){oI.warn("Failed to flush tracers on shutdown",e)}},JTe=async(t,e,r)=>{if(!Ze()){let n=[new WE.SimpleSpanProcessor(new iz),new WE.SimpleSpanProcessor(new KTe.OTLPTraceExporter({url:r.exporterUrl}))];await kpe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new $pe({skipHeaders:!0})]})}return r.traceparent?(mE.setGlobalPropagator(new $a),mE.extract(Na.active(),{traceparent:r.traceparent,isRemote:!0})):Na.active()};function yt(t,e,r){return oI.log(`\u23F3 TRACE: ${e} starting...`),wf(t,e,r)}var iz=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,s=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?s.push(`${a}=${c.toFixed(2)}ms`):s.push(`${a}=${c}`);let i=e.status?.code===2?"\u274C":"\u2705",o=s.length>0?` [${s.join(", ")}]`:"";oI.log(`${i} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&oI.log(` \u274C Error: ${e.status.message}`)}};function oz(){return process.env.AGENT_RUNNER_CAPTURE_LLM_CONTENT!=="false"}function XTe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t}function aI(t,e,r){let n={role:t,parts:[{type:"text",content:js(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function QTe(t,e,r,n){if(!t.length)return;let s=Ze();if(!s)return;let i=oz(),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),f=a.title||a.type||`step-${a.id??c}`,d=a.type==="tool_use"||a.type==="tool_result",h=a.message?a.message.length>YTe?`${a.message.slice(0,YTe)}\u2026`:a.message:void 0;s.startSpan(f,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":f,"gen_ai.operation.name":d?"execute_tool":"chat",...d?{"gen_ai.tool.name":f}:{},"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}:{},...i&&h?d?{"gen_ai.tool.call.result":js(h)}:{"gen_ai.output.messages":aI("assistant",h)}:{}}}).end(u)})}import{readdir as xgt,rm as Igt}from"fs/promises";import{join as Ngt}from"path";async function ZTe(t,e=[]){let n=(await xgt(t)).filter(s=>!e.includes(s));await Promise.all(n.map(s=>Igt(Ngt(t,s),{recursive:!0,force:!0})))}var Dgt=lI.dirname(Mgt(import.meta.url)),ebe=Lgt(import.meta.url),kgt=lI.resolve(Dgt,"scripts/scaffold.js"),$gt="scripts/scaffold.js",Fgt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,az=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},Ugt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),qgt=t=>{let e=az(t);return e==="node"||e.endsWith("/node")},cd=t=>{if(typeof t!="string")return!1;let e=t.match(Fgt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&Ugt(az(e[r]));)r+=1;if(r>=e.length||!qgt(e[r]))return!1;let n=e[r+1];return n?az(n).includes($gt):!1},ab=Te("create_stage"),Bgt="After completing the user's request:\n- Add a README.md to the project root describing what the project is, the key technologies used, and how to run it locally.\n- Add an AGENTS.md to the project root describing the project architecture, key directories, coding conventions, and any non-obvious decisions. This file is read by AI agents in future sessions to understand the project.\n\nDo 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.\n\nCommands 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.",jgt="./.netlify-cache",Hgt=({cwd:t=cI.cwd()}={})=>{let e=cI.env.NVM_BIN?`${cI.env.NVM_BIN}/node`:"node",r;try{let n=ebe.resolve("@netlify/ts-cli/package.json"),s=lI.dirname(n),i=ebe("@netlify/ts-cli/package.json");r=lI.join(s,i.bin)}catch{r=cl(t,"ts-cli")}return{nodeCmd:e,tsCliPath:r}},Vgt=t=>{let e;try{if(!t)throw new Error("empty response");e=JSON.parse(t)}catch(r){return ab.error("Failed to parse template list from ts-cli",{raw:t,error:r.message}),Oe.inc("context.degraded",1,{component:"templates"}),[]}return e.filter(r=>r.type==="example").map(r=>{let{type:n,...s}=r;return s})},Ggt=({templates:t,nodeCmd:e,scaffoldScriptPath:r})=>{let n=JSON.stringify(t.map(({id:i,name:o,description:a})=>({id:i,name:o,description:a})),null,2);return["You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",t.length>0?`## Available Templates
|
|
504
|
+
if (condition) { yield value; }`)};import{Buffer as KZe}from"buffer";import{StringDecoder as JZe}from"string_decoder";var jA=(t,e,r)=>{if(r)return;if(t)return{transform:XZe.bind(void 0,new TextEncoder)};let n=new JZe(e);return{transform:QZe.bind(void 0,n),final:ZZe.bind(void 0,n)}},XZe=function*(t,e){KZe.isBuffer(e)?yield wa(e):typeof e=="string"?yield t.encode(e):yield e},QZe=function*(t,e){yield cr(e)?t.write(e):e},ZZe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as wle}from"util";var oq=wle(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),HA=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=tet}=e[r];for await(let s of n(t))yield*HA(s,e,r+1)},Rle=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*eet(r,Number(e),t)},eet=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*HA(n,r,e+1)},Ale=wle(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),tet=function*(t){yield t};var aq=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},Cle=(t,e)=>[...e.flatMap(r=>[...Tf(r,t,0)]),...nE(t)],Tf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=net}=e[r];for(let s of n(t))yield*Tf(s,e,r+1)},nE=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*ret(r,Number(e),t)},ret=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Tf(n,r,e+1)},net=function*(t){yield t};var cq=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=Ple(t,o,i),l=Ef(e),u=Ef(r),f=l?oq.bind(void 0,HA,a):aq.bind(void 0,Tf),d=l||u?oq.bind(void 0,Rle,a):aq.bind(void 0,nE),h=l||u?Ale.bind(void 0,a):void 0;return{stream:new set({writableObjectMode:n,writableHighWaterMark:Ole(n),readableObjectMode:s,readableHighWaterMark:Ole(s),transform(m,g,y){f([m,c,0],this,y)},flush(m){d([c],this,m)},destroy:h})}},VA=(t,e,r,n)=>{let s=e.filter(({type:o})=>o==="generator"),i=n?s.reverse():s;for(let{value:o,optionName:a}of i){let c=Ple(o,r,a);t=Cle(c,t)}return t},Ple=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:Tle(n,a)},jA(r,o,n),BA(r,i,n,c),{transform:t,final:e},{transform:ble(s,a)},Ele({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var xle=(t,e)=>{for(let r of iet(t))oet(t,r,e)},iet=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),oet=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${ol[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>aet(a,n));r.input=WS(o)},aet=(t,e)=>{let r=VA(t,e,"utf8",!0);return cet(r),WS(r)},cet=t=>{let e=t.find(r=>typeof r!="string"&&!cr(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 het,appendFileSync as pet}from"fs";var GA=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Up(r,n)&&!ts.has(e)&&uet(n)&&(t.some(({type:s,value:i})=>s==="native"&&fet.has(i))||t.every(({type:s})=>Bs.has(s))),uet=t=>t===1||t===2,fet=new Set(["pipe","overlapped"]),Ile=async(t,e,r,n)=>{for await(let s of t)det(e)||Mle(s,r,n)},Nle=(t,e,r)=>{for(let n of t)Mle(n,e,r)},det=t=>t._readableState.pipes.length>0,Mle=(t,e,r)=>{let n=iA(t);ho({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Lle=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:s})=>{if(e===null)return{output:Array.from({length:3})};let i={},o=new Set([]);return{output:e.map((c,l)=>met({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},met=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:f})=>{if(t===null)return;let d=Dce(t,i,f),h=wa(d),{stdioItems:p,objectMode:m}=e[r],g=get([h],p,c,n),{serializedResult:y,finalResult:T=y}=_et({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});yet({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let S=a[r]?T:void 0;try{return n.error===void 0&&Eet(y,p,s),S}catch(_){return n.error=_,S}},get=(t,e,r,n)=>{try{return VA(t,e,r,!1)}catch(s){return n.error=s,t}},_et=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:WS(t)};let o=Kie(t,r);return n[i]?{serializedResult:o,finalResult:iq(o,!s[i],e)}:{serializedResult:o}},yet=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!GA({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=iq(t,!1,o);try{Nle(a,e,n)}catch(c){r.error??=c}},Eet=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>UA.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?pet(n,t):(r.add(i),het(n,t))}};var Dle=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ca(e,r,"all")]:Array.isArray(e)?[Ca(t,r,"all"),...e]:cr(t)&&cr(e)?pU([t,e]):`${t}${e}`};import{once as lq}from"events";var kle=async(t,e)=>{let[r,n]=await Tet(t);return e.isForcefullyTerminated??=!1,[r,n]},Tet=async t=>{let[e,r]=await Promise.allSettled([lq(t,"spawn"),lq(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$le(t):r.value},$le=async t=>{try{return await lq(t,"exit")}catch{return $le(t)}},Fle=async t=>{let[e,r]=await t;if(!bet(e,r)&&uq(e,r))throw new gi;return[e,r]},bet=(t,e)=>t===void 0&&e===void 0,uq=(t,e)=>t!==0||e!==null;var Ule=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=vet(t,e,r),o=i?.code==="ETIMEDOUT",a=Lce(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},vet=(t,e,r)=>t!==void 0?t:uq(e,r)?new gi:void 0;var qle=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Ret(t,e,r),f=Oet({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Kp(f,c,l)},Ret=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=aA(t,e,r),a=Aet(r),{file:c,commandArguments:l,options:u}=CA(t,e,a);Cet(u);let f=gle(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},Aet=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Cet=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&zA("ipcInput"),t&&zA("ipc: true"),r&&zA("detached: true"),n&&zA("cancelSignal")},zA=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Oet=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Pet({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:f,timedOut:d,isMaxBuffer:h}=Ule(c,r),{output:p,error:m=l}=Lle({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),g=p.map((T,S)=>Ca(T,r,S)),y=Ca(Dle(p,r),r,"all");return Iet({error:m,exitCode:u,signal:f,timedOut:d,isMaxBuffer:h,stdio:g,all:y,options:r,command:n,escapedCommand:s,startTime:a})},Pet=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{xle(i,r);let a=xet(r);return wet(...OA(t,e,a))}catch(a){return Yp({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},xet=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:DA(e)}),Iet=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:s,stdio:i,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?kA({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):rE({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:s,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:i,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as yrt}from"events";import{spawn as Srt}from"child_process";import Gle from"process";import{once as fq,on as Net}from"events";var Ble=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(jp({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:TA(t)}),Met({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),Met=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{_A(e,s);let i=il(t,e,r),o=new AbortController;try{return await Promise.race([Let(i,n,o),Det(i,r,o),ket(i,r,o)])}catch(a){throw Hp(t),a}finally{o.abort(),yA(e,s)}},Let=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await fq(t,"message",{signal:r});return n}for await(let[n]of Net(t,"message",{signal:r}))if(e(n))return n},Det=async(t,e,{signal:r})=>{await fq(t,"disconnect",{signal:r}),Cae(e)},ket=async(t,e,{signal:r})=>{let[n]=await fq(t,"strict:error",{signal:r});throw pA(n,e)};import{once as Hle,on as $et}from"events";var Vle=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>dq({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),dq=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{jp({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:TA(t)}),_A(e,i);let o=il(t,e,r),a=new AbortController,c={};return Fet(t,o,a),Uet({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),qet({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},Fet=async(t,e,r)=>{try{await Hle(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Uet=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await Hle(t,"strict:error",{signal:r.signal});n.error=pA(s,e),r.abort()}catch{}},qet=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of $et(r,"message",{signal:i.signal}))jle(o),yield c}catch{jle(o)}finally{i.abort(),yA(e,a),n||Hp(t),s&&await t}},jle=({error:t})=>{if(t)throw t};var zle=(t,{ipc:e})=>{Object.assign(t,Yle(t,!1,e))},Wle=()=>{let t=Gle,e=!0,r=Gle.channel!==void 0;return{...Yle(t,e,r),getCancelSignal:ece.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Yle=(t,e,r)=>({sendMessage:RA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Ble.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Vle.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Bet}from"child_process";import{PassThrough as jet,Readable as Het,Writable as Vet,Duplex as Get}from"stream";var Kle=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{rq(n);let a=new Bet;zet(a,n),Object.assign(a,{readable:Wet,writable:Yet,duplex:Ket});let c=Yp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=Jet(c,o,s);return{subprocess:a,promise:l}},zet=(t,e)=>{let r=sE(),n=sE(),s=sE(),i=Array.from({length:e.length-3},sE),o=sE(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},sE=()=>{let t=new jet;return t.end(),t},Wet=()=>new Het({read(){}}),Yet=()=>new Vet({write(){}}),Ket=()=>new Get({read(){},write(){}}),Jet=async(t,e,r)=>Kp(t,e,r);import{createReadStream as Jle,createWriteStream as Xle}from"fs";import{Buffer as Xet}from"buffer";import{Readable as iE,Writable as Qet,Duplex as Zet}from"stream";var Zle=(t,e)=>qA(ett,t,e,!1),oE=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ol[t]}.`)},Qle={fileNumber:oE,generator:cq,asyncGenerator:cq,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Zet.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},ett={input:{...Qle,fileUrl:({value:t})=>({stream:Jle(t)}),filePath:({value:{file:t}})=>({stream:Jle(t)}),webStream:({value:t})=>({stream:iE.fromWeb(t)}),iterable:({value:t})=>({stream:iE.from(t)}),asyncIterable:({value:t})=>({stream:iE.from(t)}),string:({value:t})=>({stream:iE.from(t)}),uint8Array:({value:t})=>({stream:iE.from(Xet.from(t))})},output:{...Qle,fileUrl:({value:t})=>({stream:Xle(t)}),filePath:({value:{file:t,append:e}})=>({stream:Xle(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Qet.fromWeb(t)}),iterable:oE,asyncIterable:oE,string:oE,uint8Array:oE}};import{on as ttt,once as eue}from"events";import{PassThrough as rtt,getDefaultHighWaterMark as ntt}from"stream";import{finished as nue}from"stream/promises";function bf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)pq(s);let e=t.some(({readableObjectMode:s})=>s),r=stt(t,e),n=new hq({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var stt=(t,e)=>{if(t.length===0)return ntt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},hq=class extends rtt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(pq(e),this.#e.has(e))return;this.#e.add(e),this.#n??=itt(this,this.#e,this.#i);let r=ctt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(pq(e),!this.#e.has(e))return!1;let r=this.#s.get(e);return r===void 0?!1:(this.#s.delete(e),e.unpipe(this),await r,!0)}},itt=async(t,e,r)=>{WA(t,tue);let n=new AbortController;try{await Promise.race([ott(t,n),att(t,e,r,n)])}finally{n.abort(),WA(t,-tue)}},ott=async(t,{signal:e})=>{try{await nue(t,{signal:e,cleanup:!0})}catch(r){throw sue(t,r),r}},att=async(t,e,r,{signal:n})=>{for await(let[s]of ttt(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},pq=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ctt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{WA(t,rue);let a=new AbortController;try{await Promise.race([ltt(i,e,a),utt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),ftt({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),WA(t,-rue)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?mq(t):dtt(t))},ltt=async(t,e,{signal:r})=>{try{await t,r.aborted||mq(e)}catch(n){r.aborted||sue(e,n)}},utt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await nue(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;iue(o)?s.add(e):oue(t,o)}},ftt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await eue(t,s,{signal:i}),!t.readable)return eue(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},dtt=t=>{t.writable&&t.end()},sue=(t,e)=>{iue(e)?mq(t):oue(t,e)},iue=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",mq=t=>{(t.readable||t.writable)&&t.destroy()},oue=(t,e)=>{t.destroyed||(t.once("error",htt),t.destroy(e))},htt=()=>{},WA=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},tue=2,rue=1;import{finished as aue}from"stream/promises";var Xp=(t,e)=>{t.pipe(e),ptt(t,e),mtt(t,e)},ptt=async(t,e)=>{if(!(mi(t)||mi(e))){try{await aue(t,{cleanup:!0,readable:!0,writable:!1})}catch{}gq(e)}},gq=t=>{t.writable&&t.end()},mtt=async(t,e)=>{if(!(mi(t)||mi(e))){try{await aue(e,{cleanup:!0,readable:!1,writable:!0})}catch{}_q(t)}},_q=t=>{t.readable&&t.destroy()};var cue=(t,e,r)=>{let n=new Map;for(let[s,{stdioItems:i,direction:o}]of Object.entries(e)){for(let{stream:a}of i.filter(({type:c})=>Bs.has(c)))gtt(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!Bs.has(c)))ytt({subprocess:t,stream:a,direction:o,fdNumber:s,pipeGroups:n,controller:r})}for(let[s,i]of n.entries()){let o=i.length===1?i[0]:bf(i);Xp(o,s)}},gtt=(t,e,r,n)=>{r==="output"?Xp(t.stdio[n],e):Xp(e,t.stdio[n]);let s=_tt[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},_tt=["stdin","stdout","stderr"],ytt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;Stt(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},Stt=(t,{signal:e})=>{mi(t)&&yf(t,Ett,e)},Ett=2;import{addAbortListener as vtt}from"events";var vf=[];vf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&vf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&vf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var YA=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",yq=Symbol.for("signal-exit emitter"),Sq=globalThis,Ttt=Object.defineProperty.bind(Object),Eq=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Sq[yq])return Sq[yq];Ttt(Sq,yq,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},KA=class{},btt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Tq=class extends KA{onExit(){return()=>{}}load(){}unload(){}},bq=class extends KA{#e=vq.platform==="win32"?"SIGINT":"SIGHUP";#r=new Eq;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of vf)this.#s[r]=()=>{let n=this.#t.listeners(r),{count:s}=this.#r,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#i=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!YA(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 vf)try{let r=this.#s[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,vf.forEach(e=>{let r=this.#s[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.#i,this.#r.count-=1)}#a(e){return YA(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#i.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&YA(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let s=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),s}else return n.call(this.#t,e,...r)}},vq=globalThis.process,{onExit:lue,load:gzt,unload:_zt}=btt(YA(vq)?new bq(vq):new Tq);var uue=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=lue(()=>{t.kill()});vtt(n,()=>{s()})};var due=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=oA(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=wtt(r,n,s),{sourceStream:f,sourceError:d}=Att(t,l),{options:h,fileDescriptors:p}=mo.get(t);return{sourcePromise:e,sourceStream:f,sourceOptions:h,sourceError:d,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},wtt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=Rtt(t,e,...r),a=gA(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},Rtt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(fue,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||dU(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[s,i,o]=JR(r,...n);return{destination:e(fue)(s,i,o),pipeOptions:o}}if(mo.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}`)},fue=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Att=(t,e)=>{try{return{sourceStream:Vp(t,e)}}catch(r){return{sourceError:r}}};var pue=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=Ctt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw wq({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},Ctt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return _q(t),n;if(e!==void 0)return gq(r),e},wq=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Yp({error:t,command:hue,escapedCommand:hue,fileDescriptors:e,options:r,startTime:n,isSync:!1}),hue="source.pipe(destination)";var mue=async t=>{let[{status:e,reason:r,value:n=r},{status:s,reason:i,value:o=i}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),s==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as Ott}from"stream/promises";var gue=(t,e,r)=>{let n=JA.has(e)?xtt(t,e):Ptt(t,e);return yf(t,Ntt,r.signal),yf(e,Mtt,r.signal),Itt(e),n},Ptt=(t,e)=>{let r=bf([t]);return Xp(r,e),JA.set(e,r),r},xtt=(t,e)=>{let r=JA.get(e);return r.add(t),r},Itt=async t=>{try{await Ott(t,{cleanup:!0,readable:!1,writable:!0})}catch{}JA.delete(t)},JA=new WeakMap,Ntt=2,Mtt=1;import{aborted as Ltt}from"util";var _ue=(t,e)=>t===void 0?[]:[Dtt(t,e)],Dtt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await Ltt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw wq({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var XA=(t,...e)=>{if(Jt(e[0]))return XA.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=due(t,...e),s=ktt({...n,destination:r});return s.pipe=XA.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},ktt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=$tt(t,s);pue({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let f=new AbortController;try{let d=gue(e,i,f);return await Promise.race([mue(u),..._ue(a,{sourceStream:e,mergedStream:d,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{f.abort()}},$tt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Vtt}from"timers/promises";import{on as Ftt}from"events";import{getDefaultHighWaterMark as Utt}from"stream";var QA=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return qtt(e,o),Sue({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},qtt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},Rq=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;Btt(e,o,t);let a=t.readableObjectMode&&!i;return Sue({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},Btt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Sue=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=Ftt(t,"data",{signal:e.signal,highWaterMark:yue,highWatermark:yue});return jtt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},Aq=Utt(!0),yue=Aq,jtt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=Htt({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*Tf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*nE(a)}},Htt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[jA(t,r,!e),BA(t,s,!n,{})].filter(Boolean);var Eue=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let f=Gtt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([ztt(t),f]);return}let d=nq(c,r),h=Rq({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:d,allMixed:a}),[p]=await Promise.all([Wtt({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),f]);return p},Gtt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!GA({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=Rq({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await Ile(a,t,r,i)},ztt=async t=>{await Vtt(),t.readableFlowing===null&&t.resume()},Wtt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await NA(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await MA(r,{maxBuffer:i})):await Wp(r,{maxBuffer:i})}catch(a){return Tue(Ice({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},Cq=async t=>{try{return await t}catch(e){return Tue(e)}},Tue=({bufferedData:t})=>Wie(t)?new Uint8Array(t):t;import{finished as Ytt}from"stream/promises";var aE=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Ktt(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],Ytt(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Qtt(a,e,r,n)}finally{o.abort()}},Ktt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Jtt(t,r,n),n},Jtt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{Xtt(e,r),n.call(t,...s)}},Xtt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Qtt=(t,e,r,n)=>{if(!Ztt(t,e,r,n))throw t},Ztt=(t,e,r,n=!0)=>r.propagating?bue(t)||ZA(t):(r.propagating=!0,Oq(r,e)===n?bue(t):ZA(t)),Oq=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",ZA=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",bue=t=>t?.code==="EPIPE";var vue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>Pq({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),Pq=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=aE(t,e,l);if(Oq(l,e)){await u;return}let[f]=await Promise.all([Eue({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return f};var wue=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?bf([t,e].filter(Boolean)):void 0,Rue=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>Pq({...ert(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:trt(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),ert=({stdout:t,stderr:e,all:r},[,n,s])=>{let i=n||s;return i?n?s?{stream:r,buffer:i}:{stream:t,buffer:i}:{stream:e,buffer:i}:{stream:r,buffer:i}},trt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as rrt}from"events";var Aue=t=>Up(t,"ipc"),Cue=(t,e)=>{let r=iA(t);ho({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Oue=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=Aue(i),a=Ra(e,"ipc"),c=Ra(r,"ipc");for await(let l of dq({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Nce(t,s,c),s.push(l)),o&&Cue(l,i);return s},Pue=async(t,e)=>(await Promise.allSettled([t]),e);var xue=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:f},context:d,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:g,controller:y})=>{let T=kle(t,d),S={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:T,propagating:!1},_=vue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),A=Rue({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:S}),P=[],C=Oue({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:h}),R=nrt(m,t,S),O=srt(p,S);try{return await Promise.race([Promise.all([{},Fle(T),Promise.all(_),A,C,uce(t,f),...R,...O]),g,irt(t,y),...ice(t,i,d,y),...Aae({subprocess:t,cancelSignal:o,gracefulCancel:a,context:d,controller:y}),...nce({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:d,controller:y})])}catch(w){return d.terminationReason??="other",Promise.all([{error:w},T,Promise.all(_.map(b=>Cq(b))),Cq(A),Pue(C,P),Promise.allSettled(R),Promise.allSettled(O)])}},nrt=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:aE(n,s,r)),srt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>yi(i,{checkOpen:!1})&&!mi(i)).map(({type:s,value:i,stream:o=i})=>aE(o,n,e,{isSameDirection:Bs.has(s),stopOnExit:s==="native"}))),irt=async(t,{signal:e})=>{let[r]=await rrt(t,"error",{signal:e});throw r};var Iue=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),cE=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=po();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},Qp=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 ort}from"stream";import{callbackify as art}from"util";import{finished as Nue}from"stream/promises";var xq=async t=>{if(t!==void 0)try{await Iq(t)}catch{}},Mue=async t=>{if(t!==void 0)try{await Nq(t)}catch{}},Iq=async t=>{await Nue(t,{cleanup:!0,readable:!1,writable:!0})},Nq=async t=>{await Nue(t,{cleanup:!0,readable:!0,writable:!1})},eC=async(t,e)=>{if(await t,e)throw e},tC=(t,e,r)=>{r&&!ZA(r)?t.destroy(r):e&&t.destroy()};var Lue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||ts.has(r),{subprocessStdout:a,waitReadableDestroy:c}=Mq(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:f}=Lq(a,o),{read:d,onStdoutDataDone:h}=Dq({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new ort({read:d,destroy:art($q.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:f,objectMode:u,encoding:l});return kq({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},Mq=(t,e,r)=>{let n=Vp(t,e),s=cE(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},Lq=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:Aq},Dq=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=po(),o=QA({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){crt(this,o,i)},onStdoutDataDone:i}},crt=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},kq=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await Nq(t),await n,await xq(s),await e,r.readable&&r.push(null)}catch(i){await xq(s),Due(r,i)}},$q=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qp(r,e)&&(Due(t,n),await eC(e,n))},Due=(t,e)=>{tC(t,t.readable,e)};import{Writable as lrt}from"stream";import{callbackify as kue}from"util";var $ue=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=Fq(t,r,e),o=new lrt({...Uq(n,t,s),destroy:kue(Bq.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return qq(n,o),o},Fq=(t,e,r)=>{let n=gA(t,e),s=cE(r,n,"writableFinal"),i=cE(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},Uq=(t,e,r)=>({write:urt.bind(void 0,t),final:kue(frt.bind(void 0,t,e,r))}),urt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},frt=async(t,e,r)=>{await Qp(r,e)&&(t.writable&&t.end(),await e)},qq=async(t,e,r)=>{try{await Iq(t),e.writable&&e.end()}catch(n){await Mue(r),Fue(e,n)}},Bq=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await Qp(r,e),await Qp(n,e)&&(Fue(t,s),await eC(e,s))},Fue=(t,e)=>{tC(t,t.writable,e)};import{Duplex as drt}from"stream";import{callbackify as hrt}from"util";var Uue=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||ts.has(r),{subprocessStdout:c,waitReadableDestroy:l}=Mq(t,n,e),{subprocessStdin:u,waitWritableFinal:f,waitWritableDestroy:d}=Fq(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=Lq(c,a),{read:g,onStdoutDataDone:y}=Dq({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),T=new drt({read:g,...Uq(u,t,f),destroy:hrt(prt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:f,waitWritableDestroy:d})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return kq({subprocessStdout:c,onStdoutDataDone:y,readable:T,subprocess:t,subprocessStdin:u}),qq(u,T,c),T},prt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([$q({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),Bq({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var jq=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||ts.has(e),o=Vp(t,r),a=QA({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return mrt(a,o,t)},mrt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var que=(t,{encoding:e})=>{let r=Iue();t.readable=Lue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$ue.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Uue.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=jq.bind(void 0,t,e),t[Symbol.asyncIterator]=jq.bind(void 0,t,e,{})};var Bue=(t,e)=>{for(let[r,n]of _rt){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},grt=(async()=>{})().constructor.prototype,_rt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(grt,t)]);var jue=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:f}=Ert(t,e,r),{subprocess:d,promise:h}=brt({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:f});return d.pipe=XA.bind(void 0,{source:d,sourcePromise:h,boundOptions:{},createNested:n}),Bue(d,h),mo.set(d,{options:u,fileDescriptors:f}),d},Ert=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=aA(t,e,r),{file:a,commandArguments:c,options:l}=CA(t,e,r),u=Trt(l),f=Zle(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:f}},Trt=({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}},brt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=Srt(...OA(t,e,r))}catch(p){return Kle({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;yrt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];cue(c,a,l),uue(c,r,l);let f={},d=po();c.kill=wae.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:d,context:f,controller:l}),c.all=wue(c,r),que(c,r),zle(c,r);let h=vrt({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:f,onInternalError:d,controller:l});return{subprocess:c,promise:h}},vrt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[f,[d,h],p,m,g]=await xue({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let y=p.map((_,A)=>Ca(_,e,A)),T=Ca(m,e,"all"),S=wrt({errorInfo:f,exitCode:d,signal:h,stdio:y,all:T,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Kp(S,n,e)},wrt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?rE({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 go,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):kA({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var rC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,Rrt(n,t[n],s)]));return{...t,...r}},Rrt=(t,e,r)=>Art.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,Art=new Set(["env",...yU]);var al=(t,e,r,n)=>{let s=(o,a,c)=>al(o,a,r,c),i=(...o)=>Crt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Crt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(Jt(i))return s(t,rC(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=Ort({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?qle(a,c,l):jue(a,c,l,s)},Ort=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=Zie(e)?eoe(e,r):[e,...r],[o,a,c]=JR(...i),l=rC(rC(n,s),c),{file:u=o,commandArguments:f=a,options:d=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:f,options:d,isSync:h}};var Hue=({file:t,commandArguments:e})=>Gue(t,e),Vue=({file:t,commandArguments:e})=>({...Gue(t,e),isSync:!0}),Gue=(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]=Prt(t);return{file:r,commandArguments:n}},Prt=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(xrt)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},xrt=/ +/g;var zue=(t,e,r)=>{t.sync=e(Irt,r),t.s=t.sync},Wue=({options:t})=>Yue(t),Irt=({options:t})=>({...Yue(t),isSync:!0}),Yue=t=>({options:{...Nrt(t),...t}}),Nrt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Kue={preferLocal:!0};var Jue=al(()=>({})),oWt=al(()=>({isSync:!0})),Xue=al(Hue),aWt=al(Vue),cWt=al(ace),lWt=al(Wue,{},Kue,zue),{sendMessage:uWt,getOneMessage:fWt,getEachMessage:dWt,getCancelSignal:hWt}=Wle();import{Transform as Mrt}from"stream";var Lrt=["NETLIFY_AI_GATEWAY_KEY"];function Drt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...Lrt])]}function krt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function $rt(){let e=Drt().map(r=>process.env[r]).filter(r=>!(!r||krt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function js(t){if(typeof t!="string")return t;let e=$rt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let s=new RegExp(Frt(n),"g");r=r.replace(s,"******")}),r}function Frt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var lE=class extends Mrt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let s=e.toString(),i=js(s);n(null,i)}},nC=Symbol("maskedWrite");function Que(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[nC]){let e=process.stdout.write.bind(process.stdout),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[nC]=!0,process.stdout.write=r}if(!process.stderr.write[nC]){let e=process.stderr.write.bind(process.stderr),r=function(n,s,i){let o=typeof n=="string"?js(n):n;return typeof s=="function"?e(o,s):e(o,s,i)};r[nC]=!0,process.stderr.write=r}}}var Zue=!1,efe=()=>{Zue=!0},Fn=()=>Zue;var uE=null,tfe=t=>(uE&&uE.destroy(),uE=new Oa({totalAllowedTime:t}),uE),rfe=()=>uE;var Oa=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&Fn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let i=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,f)=>{o=setTimeout(()=>{f(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await YR({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Oe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),i(),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 nfe={name:"@netlify/agent-runner-cli",type:"module",version:"1.140.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.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.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0"}};var jrt=qrt(import.meta.url),Hrt=Pa.dirname(jrt),Vrt=Brt(import.meta.url),Zp=Te("shell"),Hq=new Set,sfe={preferLocal:!0},rs=(t,e,r)=>{let[n,s]=Grt(e,r),i={...sfe,...s},o=Jue(t,n,i);ofe(o,i),lfe(o);let a=r?.idleTimeout;return a&&a>0&&cfe(o,a),o},ife=(t,e)=>{let r={...sfe,...e},n=Xue(t,r);return ofe(n,r),lfe(n),e?.idleTimeout&&e.idleTimeout>0&&cfe(n,e.idleTimeout),n},Grt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ofe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(xa.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new lE).pipe(xa.stdout),t.stderr?.pipe(new lE).pipe(xa.stderr);return}t.stdout?.pipe(xa.stdout),t.stderr?.pipe(xa.stderr)},Vq=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(xa.kill(-t.pid,e),Zp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Zp.error("Error killing process:",r),!1}},afe=t=>Vq(t,"SIGKILL"),cfe=(t,e)=>{let r=null,n=()=>{Zp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),Vq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zp.log(`Force killing idle process ${t.pid}`),afe(t))},5e3)},s=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};s(),t.stdout?.on("data",s),t.stderr?.on("data",s);let i=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",i),t.on("error",i)},lfe=t=>{Hq.add(t);let e=rfe();if(e){let r=e.onTimesUp(()=>{Zp.log(`Global timer expired, killing process ${t.pid}`),Vq(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Zp.log(`Force killing process ${t.pid} after timeout`),afe(t))},5e3)});t.on("exit",()=>{Hq.delete(t),r()}),t.on("error",()=>{Hq.delete(t),r()})}};function cl(t,e){if(!xa.env.NETLIFY_LOCAL_MODE)try{let s=Vrt.resolve(nfe.name),i=Pa.dirname(s);for(;i!==Pa.dirname(i);){let o=Pa.dirname(i);if(Pa.basename(o)==="node_modules"){let a=Pa.join(o,".bin",e);if(sC.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(xa.env.NODE_PATH){let s=Pa.join(xa.env.NODE_PATH,".bin",e);if(sC.existsSync(s))return s}let r=Pa.join(t,"node_modules",".bin",e);if(sC.existsSync(r))return r;let n=Pa.join(Hrt,"..","node_modules",".bin",e);if(sC.existsSync(n))return n}import cI from"process";import{fileURLToPath as Mgt}from"url";import{createRequire as Lgt}from"module";import lI from"path";var zrt="__netlify__getTracer",Wrt="__netlify__shutdownTracers",Ze=(t,e)=>globalThis[zrt]?.(t,e),ufe=async()=>globalThis[Wrt]?.();function wf(t,e,r,n,s){let i=typeof n=="function"?n:typeof r=="function"?r:s;if(!i)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,i):i()}import{setTimeout as Ogt}from"timers/promises";import Hst from"process";var ffe=typeof globalThis=="object"?globalThis:global;var Ia="1.9.0";var dfe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Yrt(t){var e=new Set([t]),r=new Set,n=t.match(dfe);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(c){return c===t};function i(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(dfe);if(!l)return i(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||s.major!==u.major?i(c):s.major===0?s.minor===u.minor&&s.patch<=u.patch?o(c):i(c):s.minor<=u.minor?o(c):i(c)}}var hfe=Yrt(Ia);var Krt=Ia.split(".")[0],fE=Symbol.for("opentelemetry.js.api."+Krt),dE=ffe;function ll(t,e,r,n){var s;n===void 0&&(n=!1);var i=dE[fE]=(s=dE[fE])!==null&&s!==void 0?s:{version:Ia};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==Ia){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+Ia);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Ia+"."),!0}function Si(t){var e,r,n=(e=dE[fE])===null||e===void 0?void 0:e.version;if(!(!n||!hfe(n)))return(r=dE[fE])===null||r===void 0?void 0:r[t]}function ul(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Ia+".");var r=dE[fE];r&&delete r[t]}var Jrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Xrt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},pfe=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return hE("verbose",this._namespace,e)},t})();function hE(t,e,r){var n=Si("diag");if(n)return r.unshift(e),n[t].apply(n,Xrt([],Jrt(r),!1))}var yn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(yn||(yn={}));function mfe(t,e){t<yn.NONE?t=yn.NONE:t>yn.ALL&&(t=yn.ALL),e=e||{};function r(n,s){var i=e[n];return typeof i=="function"&&t>=s?i.bind(e):function(){}}return{error:r("error",yn.ERROR),warn:r("warn",yn.WARN),info:r("info",yn.INFO),debug:r("debug",yn.DEBUG),verbose:r("verbose",yn.VERBOSE)}}var Qrt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},Zrt=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},ent="diag",ns=(function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var a=Si("diag");if(a)return a[s].apply(a,Zrt([],Qrt(i),!1))}}var r=this,n=function(s,i){var o,a,c;if(i===void 0&&(i={logLevel:yn.INFO}),s===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof i=="number"&&(i={logLevel:i});var u=Si("diag"),f=mfe((a=i.logLevel)!==null&&a!==void 0?a:yn.INFO,s);if(u&&!i.suppressOverrideMessage){var d=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+d),f.warn("Current logger will overwrite one already registered from "+d)}return ll("diag",f,r,!0)};r.setLogger=n,r.disable=function(){ul(ent,r)},r.createComponentLogger=function(s){return new pfe(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var tnt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},rnt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},gfe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=tnt(e,2),n=r[0],s=r[1];return[n,s]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var i=new t(this._entries);try{for(var o=rnt(n),a=o.next();!a.done;a=o.next()){var c=a.value;i._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t})();var rYt=ns.instance();function _fe(t){return t===void 0&&(t={}),new gfe(new Map(Object.entries(t)))}function iC(t){return Symbol.for(t)}var nnt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var i=new t(r._currentContext);return i._currentContext.set(n,s),i},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t})(),yfe=new nnt;var Sfe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Efe={set:function(t,e,r){t!=null&&(t[e]=r)}};var snt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},int=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Tfe=(function(){function t(){}return t.prototype.active=function(){return yfe},t.prototype.with=function(e,r,n){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return r.call.apply(r,int([n],snt(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var ont=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},ant=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Gq="context",cnt=new Tfe,fl=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ll(Gq,e,ns.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,ant([e,r,n],ont(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Si(Gq)||cnt},t.prototype.disable=function(){this._getContextManager().disable(),ul(Gq,ns.instance())},t})();var oC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(oC||(oC={}));var zq="0000000000000000",Wq="00000000000000000000000000000000",bfe={traceId:Wq,spanId:zq,traceFlags:oC.NONE};var dl=(function(){function t(e){e===void 0&&(e=bfe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var Yq=iC("OpenTelemetry Context Key SPAN");function aC(t){return t.getValue(Yq)||void 0}function vfe(){return aC(fl.getInstance().active())}function pE(t,e){return t.setValue(Yq,e)}function wfe(t){return t.deleteValue(Yq)}function Rfe(t,e){return pE(t,new dl(e))}function cC(t){var e;return(e=aC(t))===null||e===void 0?void 0:e.spanContext()}var lnt=/^([0-9a-f]{32})$/i,unt=/^[0-9a-f]{16}$/i;function fnt(t){return lnt.test(t)&&t!==Wq}function dnt(t){return unt.test(t)&&t!==zq}function lC(t){return fnt(t.traceId)&&dnt(t.spanId)}function Afe(t){return new dl(t)}var Kq=fl.getInstance(),uC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=Kq.active());var s=!!r?.root;if(s)return new dl;var i=n&&cC(n);return hnt(i)&&lC(i)?new dl(i):new dl},t.prototype.startActiveSpan=function(e,r,n,s){var i,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(i=r,a=n):(i=r,o=n,a=s);var c=o??Kq.active(),l=this.startSpan(e,i,c),u=pE(c,l);return Kq.with(u,a,void 0,l)}},t})();function hnt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var pnt=new uC,Cfe=(function(){function t(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,s){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):pnt},t})();var Ofe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new uC},t})();var mnt=new Ofe,Jq=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var s;return(s=this.getDelegateTracer(e,r,n))!==null&&s!==void 0?s:new Cfe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:mnt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,r,n)},t})();var hl;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(hl||(hl={}));var yo;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(yo||(yo={}));var Na=fl.getInstance();var Xq=ns.instance();var Pfe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var Qq=iC("OpenTelemetry Baggage Key");function Zq(t){return t.getValue(Qq)||void 0}function xfe(){return Zq(fl.getInstance().active())}function Ife(t,e){return t.setValue(Qq,e)}function Nfe(t){return t.deleteValue(Qq)}var eB="propagation",gnt=new Pfe,Mfe=(function(){function t(){this.createBaggage=_fe,this.getBaggage=Zq,this.getActiveBaggage=xfe,this.setBaggage=Ife,this.deleteBaggage=Nfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ll(eB,e,ns.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=Efe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=Sfe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ul(eB,ns.instance())},t.prototype._getGlobalPropagator=function(){return Si(eB)||gnt},t})();var mE=Mfe.getInstance();var tB="trace",Lfe=(function(){function t(){this._proxyTracerProvider=new Jq,this.wrapSpanContext=Afe,this.isSpanContextValid=lC,this.deleteSpan=wfe,this.getSpan=aC,this.getActiveSpan=vfe,this.getSpanContext=cC,this.setSpan=pE,this.setSpanContext=Rfe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=ll(tB,this._proxyTracerProvider,ns.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return Si(tB)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){ul(tB,ns.instance()),this._proxyTracerProvider=new Jq},t})();var gE=Lfe.getInstance();var ynt=function(t,e){e.recordException(t),e.setStatus({code:yo.ERROR})};var Rf=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,s){var i=Dfe(r,n,s),o=i.opts,a=i.ctx,c=i.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return kfe(l,o,c)})},t.prototype.withSpan=function(e,r,n,s){var i=Dfe(r,n,s),o=i.opts,a=i.ctx,c=i.fn,l=this._tracer.startSpan(e,o,a);return kfe(l,o,c)},t})();function Dfe(t,e,r){var n,s,i;return!e&&!r?i=t:r?(n=t,s=e,i=r):(n=t,i=e),n=n??{},s=s??Na.active(),{opts:n,ctx:s,fn:i}}function kfe(t,e,r){var n,s=(n=e.onException)!==null&&n!==void 0?n:ynt,i=function(a){throw s(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},i):(t.end(),o)}catch(a){throw i(a)}}QB();He();var BE=class{emit(e){}enabled(){return!1}},Khe=new BE;var jE=Symbol.for("io.opentelemetry.js.api.logs"),lm=globalThis;function Jhe(t,e,r){return n=>n===t?e:r}var ZB=1;var ej=class{getLogger(e,r,n){return new BE}},tO=new ej;var rO=class{constructor(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}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):Khe}};var HE=class{getLogger(e,r,n){var s;return(s=this._getDelegateLogger(e,r,n))!==null&&s!==void 0?s:new rO(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:tO}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getLogger(e,r,n)}};var nO=class t{constructor(){this._proxyLoggerProvider=new HE}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return lm[jE]?this.getLoggerProvider():(lm[jE]=Jhe(ZB,e,tO),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=lm[jE])===null||e===void 0?void 0:e.call(lm,ZB))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete lm[jE],this._proxyLoggerProvider=new HE}};var Xhe=nO.getInstance();function Qhe(t,e,r,n){for(let s=0,i=t.length;s<i;s++){let o=t[s];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function Zhe(t){t.forEach(e=>e.disable())}function tj(t){let e=t.tracerProvider||lr.getTracerProvider(),r=t.meterProvider||CE.getMeterProvider(),n=t.loggerProvider||Xhe.getLoggerProvider(),s=t.instrumentations?.flat()??[];return Qhe(s,e,r,n),()=>{Zhe(s)}}Vt();var RO=fn(_j(),1);Vt();var Npe=t=>{throw TypeError(t)},Tj=(t,e,r)=>e.has(t)||Npe("Cannot "+r),wO=(t,e,r)=>(Tj(t,e,"read from private field"),r?r.call(t):e.get(t)),yj=(t,e,r)=>e.has(t)?Npe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Ppe=(t,e,r,n)=>(Tj(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),jst=(t,e,r)=>(Tj(t,e,"access private method"),r),xpe="__netlify__getTracer",Vst="__netlify__shutdownTracers",Gst="__nfOTLPTrace",GE,zE,Ej,Mpe,zst=class{constructor(){yj(this,Ej),yj(this,GE),yj(this,zE),Ppe(this,GE,new Ro(jst(this,Ej,Mpe),this)),Ppe(this,zE,Xq.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(wO(this,zE).debug(`export ${t.length.toString()} spans`),wO(this,GE).isCalled){e({code:It.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(Gst,JSON.stringify(Wst(t))),e({code:It.SUCCESS})}shutdown(){return wO(this,GE).call()}};GE=new WeakMap;zE=new WeakMap;Ej=new WeakSet;Mpe=function(){return wO(this,zE).debug("Shutting down"),Promise.resolve()};function Wst(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:vO(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||hl.SERVER,startTimeUnixNano:Sj(e.startTime),endTimeUnixNano:Sj(e.endTime),attributes:vO(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Sj(n.time),attributes:vO(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:vO(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function vO(t){return Object.keys(t).map(e=>Lpe(e,t[e]))}function Lpe(t,e){return{key:t,value:Dpe(e)}}function Dpe(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(Dpe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>Lpe(r,n))}}:{}}function Sj(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var Ipe={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},kpe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,xpe))return;let e=Hst.version.slice(1),r=eO({"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??[Yst()],s=new RO.NodeTracerProvider({resource:r,spanProcessors:n});s.register({propagator:new $a});let i=t.instrumentations??[];tj({instrumentations:i,tracerProvider:s}),Object.defineProperty(globalThis,xpe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Rf(gE.getTracer(a,c)):new Rf(gE.getTracer(Ipe.name,Ipe.version))}}),Object.defineProperty(globalThis,Vst,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await s.shutdown()})},Yst=()=>new RO.SimpleSpanProcessor(new zst);Vt();var WE=fn(_j(),1);import*as AO from"diagnostics_channel";var $pe=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?yo.ERROR:yo.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],s=this.config.redactHeaders??[],i=n.some(a=>r.includes(a.toString())),o={};if(i)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(d=>typeof d=="string"?d==u:d.test(u)))continue;let f=`http.${t}.header.${u}`;s===!0||s.some(d=>typeof d=="string"?d==u:d.test(u))?o[f]="REDACTED":o[f]=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 Rf?t:new Rf(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){AO.subscribe(t,e);let r=()=>AO.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(s=>typeof s=="string"?r.href.startsWith(s):s.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:hl.CLIENT},Na.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:yo.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 KTe=fn(WTe(),1);var oI=Te("tracing"),YTe=8e3,Pgt=5e3,ob=async(t=Pgt)=>{try{await Promise.race([ufe(),Ogt(t)])}catch(e){oI.warn("Failed to flush tracers on shutdown",e)}},JTe=async(t,e,r)=>{if(!Ze()){let n=[new WE.SimpleSpanProcessor(new iz),new WE.SimpleSpanProcessor(new KTe.OTLPTraceExporter({url:r.exporterUrl}))];await kpe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new $pe({skipHeaders:!0})]})}return r.traceparent?(mE.setGlobalPropagator(new $a),mE.extract(Na.active(),{traceparent:r.traceparent,isRemote:!0})):Na.active()};function yt(t,e,r){return oI.log(`\u23F3 TRACE: ${e} starting...`),wf(t,e,r)}var iz=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,s=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?s.push(`${a}=${c.toFixed(2)}ms`):s.push(`${a}=${c}`);let i=e.status?.code===2?"\u274C":"\u2705",o=s.length>0?` [${s.join(", ")}]`:"";oI.log(`${i} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&oI.log(` \u274C Error: ${e.status.message}`)}};function oz(){return process.env.AGENT_RUNNER_CAPTURE_LLM_CONTENT!=="false"}function XTe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t}function aI(t,e,r){let n={role:t,parts:[{type:"text",content:js(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function QTe(t,e,r,n){if(!t.length)return;let s=Ze();if(!s)return;let i=oz(),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),f=a.title||a.type||`step-${a.id??c}`,d=a.type==="tool_use"||a.type==="tool_result",h=a.message?a.message.length>YTe?`${a.message.slice(0,YTe)}\u2026`:a.message:void 0;s.startSpan(f,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":f,"gen_ai.operation.name":d?"execute_tool":"chat",...d?{"gen_ai.tool.name":f}:{},"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}:{},...i&&h?d?{"gen_ai.tool.call.result":js(h)}:{"gen_ai.output.messages":aI("assistant",h)}:{}}}).end(u)})}import{readdir as xgt,rm as Igt}from"fs/promises";import{join as Ngt}from"path";async function ZTe(t,e=[]){let n=(await xgt(t)).filter(s=>!e.includes(s));await Promise.all(n.map(s=>Igt(Ngt(t,s),{recursive:!0,force:!0})))}var Dgt=lI.dirname(Mgt(import.meta.url)),ebe=Lgt(import.meta.url),kgt=lI.resolve(Dgt,"scripts/scaffold.js"),$gt="scripts/scaffold.js",Fgt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,az=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},Ugt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),qgt=t=>{let e=az(t);return e==="node"||e.endsWith("/node")},cd=t=>{if(typeof t!="string")return!1;let e=t.match(Fgt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&Ugt(az(e[r]));)r+=1;if(r>=e.length||!qgt(e[r]))return!1;let n=e[r+1];return n?az(n).includes($gt):!1},ab=Te("create_stage"),Bgt="After completing the user's request:\n- Add a README.md to the project root describing what the project is, the key technologies used, and how to run it locally.\n- Add an AGENTS.md to the project root describing the project architecture, key directories, coding conventions, and any non-obvious decisions. This file is read by AI agents in future sessions to understand the project.\n\nDo 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.\n\nCommands 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.",jgt="./.netlify-cache",Hgt=({cwd:t=cI.cwd()}={})=>{let e=cI.env.NVM_BIN?`${cI.env.NVM_BIN}/node`:"node",r;try{let n=ebe.resolve("@netlify/ts-cli/package.json"),s=lI.dirname(n),i=ebe("@netlify/ts-cli/package.json");r=lI.join(s,i.bin)}catch{r=cl(t,"ts-cli")}return{nodeCmd:e,tsCliPath:r}},Vgt=t=>{let e;try{if(!t)throw new Error("empty response");e=JSON.parse(t)}catch(r){return ab.error("Failed to parse template list from ts-cli",{raw:t,error:r.message}),Oe.inc("context.degraded",1,{component:"templates"}),[]}return e.filter(r=>r.type==="example").map(r=>{let{type:n,...s}=r;return s})},Ggt=({templates:t,nodeCmd:e,scaffoldScriptPath:r})=>{let n=JSON.stringify(t.map(({id:i,name:o,description:a})=>({id:i,name:o,description:a})),null,2);return["You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",t.length>0?`## Available Templates
|
|
505
505
|
|
|
506
506
|
Start with one of the following templates by using the Bash command below, unless there's a strong reason to start from scratch based on the users prompt.
|
|
507
507
|
|
|
@@ -548,9 +548,9 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
548
548
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
549
549
|
|
|
550
550
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
551
|
-
`);this.baseURL=c.baseURL,this.timeout=c.timeout??Kz.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=vz(c.logLevel,"ClientOptions.logLevel",this)??vz(Jl("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??dI(),Ce(this,qI,Ebe,"f"),this._options=c,o&&(this._workloadIdentityAuth=new SI(o,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=s,this.webhookSecret=i}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 ne([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return Pbe(e)}getUserAgent(){return`${this.constructor.name}/JS ${Hl}`}defaultIdempotencyKey(){return`stainless-node-retry-${lz()}`}makeStatusError(e,r,n,s){return Gt.generate(e,r,n,s)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof _e?n:new _e(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new _e(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let s=!H(this,Yz,"m",dve).call(this)&&n||this.baseURL,i=ube(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(i.searchParams);return(!dz(o)||!dz(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(i.search=this.stringifyQuery(r)),i.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(s=>({method:e,path:r,...s})))}request(e,r=null){return new fd(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let s=await e,i=s.maxRetries??this.maxRetries;r==null&&(r=i),await this.prepareOptions(s);let{req:o,url:a,timeout:c}=await this.buildRequest(s,{retryCount:i-r});await this.prepareRequest(o,{url:a,options:s});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,f=Date.now();if(Zt(this).debug(`[${l}] sending request`,sc({retryOfRequestLogID:n,method:s.method,url:a,options:s,headers:o.headers})),s.signal?.aborted)throw new sr;let d=new AbortController,h=await this.fetchWithAuth(a,o,c,d).catch(fb),p=Date.now();if(h instanceof globalThis.Error){let y=`retrying, ${r} attempts remaining`;if(s.signal?.aborted)throw new sr;let T=ub(h)||/timed? ?out/i.test(String(h)+("cause"in h?String(h.cause):""));if(r)return Zt(this).info(`[${l}] connection ${T?"timed out":"failed"} - ${y}`),Zt(this).debug(`[${l}] connection ${T?"timed out":"failed"} (${y})`,sc({retryOfRequestLogID:n,url:a,durationMs:p-f,message:h.message})),this.retryRequest(s,r,n??l);throw Zt(this).info(`[${l}] connection ${T?"timed out":"failed"} - error; no more retries left`),Zt(this).debug(`[${l}] connection ${T?"timed out":"failed"} (error; no more retries left)`,sc({retryOfRequestLogID:n,url:a,durationMs:p-f,message:h.message})),h instanceof ld||h instanceof db?h:T?new jl:new Bl({cause:h})}let m=[...h.headers.entries()].filter(([y])=>y==="x-request-id").map(([y,T])=>", "+y+": "+JSON.stringify(T)).join(""),g=`[${l}${u}${m}] ${o.method} ${a} ${h.ok?"succeeded":"failed"} with status ${h.status} in ${p-f}ms`;if(!h.ok){if(h.status===401&&this._workloadIdentityAuth&&!s.__metadata?.hasStreamingBody&&!s.__metadata?.workloadIdentityTokenRefreshed)return await mz(h.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...s,__metadata:{...s.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let y=await this.shouldRetry(h);if(r&&y){let C=`retrying, ${r} attempts remaining`;return await mz(h.body),Zt(this).info(`${g} - ${C}`),Zt(this).debug(`[${l}] response error (${C})`,sc({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,durationMs:p-f})),this.retryRequest(s,r,n??l,h.headers)}let T=y?"error; no more retries left":"error; not retryable";Zt(this).info(`${g} - ${T}`);let S=await h.text().catch(C=>fb(C).message),_=hbe(S),A=_?void 0:S;throw Zt(this).debug(`[${l}] response error (${T})`,sc({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,message:A,durationMs:Date.now()-f})),this.makeStatusError(h.status,_,A,h.headers)}return Zt(this).info(g),Zt(this).debug(`[${l}] response start`,sc({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,durationMs:p-f})),{response:h,options:s,controller:d,requestLogID:l,retryOfRequestLogID:n,startTime:f}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(s=>({method:"get",path:e,...s})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new yb(this,n,e)}async fetchWithAuth(e,r,n,s){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${Wz}`){let c=await this._workloadIdentityAuth.getToken();o.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,s)}async fetchWithTimeout(e,r,n,s){let{signal:i,method:o,...a}=r||{},c=this._makeAbort(s);i&&i.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,f={signal:s.signal,...u?{duplex:"half"}:{},method:"GET",...a};o&&(f.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,f)}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,s){let i,o=s?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(i=c)}let a=s?.get("retry-after");if(a&&!i){let c=parseFloat(a);Number.isNaN(c)?i=Date.parse(a)-Date.now():i=c*1e3}if(i===void 0){let c=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Vo(i),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let i=r-e,o=Math.min(.5*Math.pow(2,i),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:s,path:i,query:o,defaultBaseURL:a}=n,c=this.buildURL(i,o,a);"timeout"in n&&dbe("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:f}=this.buildBody({options:n});f&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let d=await this.buildHeaders({options:e,method:s,bodyHeaders:l,retryCount:r});return{req:{method:s,headers:d,...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:s}){let i={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let o=ne([i,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...ybe(),"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=ne([r]),s=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,i=!s&&(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||s?{bodyHeaders:void 0,body:e,isStreamingBody:!i}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:hI(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,qI,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};Kz=Ne,qI=new WeakMap,Yz=new WeakSet,dve=function(){return this.baseURL!=="https://api.openai.com/v1"};Ne.OpenAI=Kz;Ne.DEFAULT_TIMEOUT=6e5;Ne.OpenAIError=_e;Ne.APIError=Gt;Ne.APIConnectionError=Bl;Ne.APIConnectionTimeoutError=jl;Ne.APIUserAbortError=sr;Ne.NotFoundError=ug;Ne.ConflictError=fg;Ne.RateLimitError=hg;Ne.BadRequestError=ag;Ne.AuthenticationError=cg;Ne.InternalServerError=pg;Ne.PermissionDeniedError=lg;Ne.UnprocessableEntityError=dg;Ne.InvalidWebhookSignatureError=Ho;Ne.toFile=TI;Ne.Completions=Ed;Ne.Chat=Wl;Ne.Embeddings=bd;Ne.Files=wd;Ne.Images=Od;Ne.Audio=Yo;Ne.Moderations=xd;Ne.Models=Pd;Ne.FineTuning=ji;Ne.Graders=tu;Ne.VectorStores=dc;Ne.Webhooks=Md;Ne.Beta=Bi;Ne.Batches=md;Ne.Uploads=nu;Ne.Responses=uc;Ne.Realtime=lc;Ne.Conversations=Zl;Ne.Evals=eu;Ne.Containers=Ql;Ne.Skills=fc;Ne.Videos=Nd;var Vn=Te("runner_codex"),Jz="Codex CLI",Zg="gpt-5.6",vyt=({catchError:t,runCmd:e,error:r,result:n,runnerName:s})=>(Vn.log(`${s} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(Vn.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(Vn.log("Setting result to undefined because no valid result was captured"),{error:r||`${s} failed`,result:void 0}));async function hve({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let s=e.modelVersionOverrides?.codex?.[e.accountType];if(s){if(!await t.isModelAvailableForProvider("openai",s))throw new Error(`Model override '${s}' is not available for openai provider`);n=s}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!Zg&&await t.isModelAvailableForProvider("openai",Zg)?(n=Zg,Vn.log(`Using default model: ${Zg}`)):Zg&&Vn.log(`Default model ${Zg} is not available, proceeding without model specification`);return n}function pve({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");su.env.OPENAI_API_KEY=e,su.env.OPENAI_BASE_URL=r}else if(!su.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function Xz({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:s,continueSession:i,priorAgentSessionId:o,cwd:a=su.cwd()}){let{prompt:c}=t,{model:l}=t;pve({aiGateway:s});let u=await hve({config:t,aiGateway:s,model:l}),f=[],d=[],h=[],p={},m=new Set,g=0,y=0,T,S,_,A=`${su.env.NVM_BIN}/node`,P=e_.join(BI.homedir(),".codex"),C=e_.join(P,"config.toml"),R=e_.join(P,"auth.json");try{await Nb.mkdir(P,{recursive:!0});let G={OPENAI_API_KEY:su.env.OPENAI_API_KEY};await Nb.writeFile(R,JSON.stringify(G,null,2),"utf-8"),Vn.log("Created Codex auth.json file");let V=su.env.OPENAI_BASE_URL,Z=['forced_login_method = "api"'];V&&Z.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${V}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),await Nb.writeFile(C,`${Z.join(`
|
|
551
|
+
`);this.baseURL=c.baseURL,this.timeout=c.timeout??Kz.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=vz(c.logLevel,"ClientOptions.logLevel",this)??vz(Jl("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??dI(),Ce(this,qI,Ebe,"f"),this._options=c,o&&(this._workloadIdentityAuth=new SI(o,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=s,this.webhookSecret=i}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 ne([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return Pbe(e)}getUserAgent(){return`${this.constructor.name}/JS ${Hl}`}defaultIdempotencyKey(){return`stainless-node-retry-${lz()}`}makeStatusError(e,r,n,s){return Gt.generate(e,r,n,s)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof _e?n:new _e(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new _e(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let s=!H(this,Yz,"m",dve).call(this)&&n||this.baseURL,i=ube(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(i.searchParams);return(!dz(o)||!dz(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(i.search=this.stringifyQuery(r)),i.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(s=>({method:e,path:r,...s})))}request(e,r=null){return new fd(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let s=await e,i=s.maxRetries??this.maxRetries;r==null&&(r=i),await this.prepareOptions(s);let{req:o,url:a,timeout:c}=await this.buildRequest(s,{retryCount:i-r});await this.prepareRequest(o,{url:a,options:s});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,f=Date.now();if(Zt(this).debug(`[${l}] sending request`,sc({retryOfRequestLogID:n,method:s.method,url:a,options:s,headers:o.headers})),s.signal?.aborted)throw new sr;let d=new AbortController,h=await this.fetchWithAuth(a,o,c,d).catch(fb),p=Date.now();if(h instanceof globalThis.Error){let y=`retrying, ${r} attempts remaining`;if(s.signal?.aborted)throw new sr;let T=ub(h)||/timed? ?out/i.test(String(h)+("cause"in h?String(h.cause):""));if(r)return Zt(this).info(`[${l}] connection ${T?"timed out":"failed"} - ${y}`),Zt(this).debug(`[${l}] connection ${T?"timed out":"failed"} (${y})`,sc({retryOfRequestLogID:n,url:a,durationMs:p-f,message:h.message})),this.retryRequest(s,r,n??l);throw Zt(this).info(`[${l}] connection ${T?"timed out":"failed"} - error; no more retries left`),Zt(this).debug(`[${l}] connection ${T?"timed out":"failed"} (error; no more retries left)`,sc({retryOfRequestLogID:n,url:a,durationMs:p-f,message:h.message})),h instanceof ld||h instanceof db?h:T?new jl:new Bl({cause:h})}let m=[...h.headers.entries()].filter(([y])=>y==="x-request-id").map(([y,T])=>", "+y+": "+JSON.stringify(T)).join(""),g=`[${l}${u}${m}] ${o.method} ${a} ${h.ok?"succeeded":"failed"} with status ${h.status} in ${p-f}ms`;if(!h.ok){if(h.status===401&&this._workloadIdentityAuth&&!s.__metadata?.hasStreamingBody&&!s.__metadata?.workloadIdentityTokenRefreshed)return await mz(h.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...s,__metadata:{...s.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let y=await this.shouldRetry(h);if(r&&y){let C=`retrying, ${r} attempts remaining`;return await mz(h.body),Zt(this).info(`${g} - ${C}`),Zt(this).debug(`[${l}] response error (${C})`,sc({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,durationMs:p-f})),this.retryRequest(s,r,n??l,h.headers)}let T=y?"error; no more retries left":"error; not retryable";Zt(this).info(`${g} - ${T}`);let S=await h.text().catch(C=>fb(C).message),_=hbe(S),A=_?void 0:S;throw Zt(this).debug(`[${l}] response error (${T})`,sc({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,message:A,durationMs:Date.now()-f})),this.makeStatusError(h.status,_,A,h.headers)}return Zt(this).info(g),Zt(this).debug(`[${l}] response start`,sc({retryOfRequestLogID:n,url:h.url,status:h.status,headers:h.headers,durationMs:p-f})),{response:h,options:s,controller:d,requestLogID:l,retryOfRequestLogID:n,startTime:f}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(s=>({method:"get",path:e,...s})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new yb(this,n,e)}async fetchWithAuth(e,r,n,s){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${Wz}`){let c=await this._workloadIdentityAuth.getToken();o.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,s)}async fetchWithTimeout(e,r,n,s){let{signal:i,method:o,...a}=r||{},c=this._makeAbort(s);i&&i.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,f={signal:s.signal,...u?{duplex:"half"}:{},method:"GET",...a};o&&(f.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,f)}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,s){let i,o=s?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(i=c)}let a=s?.get("retry-after");if(a&&!i){let c=parseFloat(a);Number.isNaN(c)?i=Date.parse(a)-Date.now():i=c*1e3}if(i===void 0){let c=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Vo(i),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let i=r-e,o=Math.min(.5*Math.pow(2,i),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:s,path:i,query:o,defaultBaseURL:a}=n,c=this.buildURL(i,o,a);"timeout"in n&&dbe("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:f}=this.buildBody({options:n});f&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let d=await this.buildHeaders({options:e,method:s,bodyHeaders:l,retryCount:r});return{req:{method:s,headers:d,...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:s}){let i={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let o=ne([i,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...ybe(),"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=ne([r]),s=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,i=!s&&(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||s?{bodyHeaders:void 0,body:e,isStreamingBody:!i}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:hI(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,qI,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};Kz=Ne,qI=new WeakMap,Yz=new WeakSet,dve=function(){return this.baseURL!=="https://api.openai.com/v1"};Ne.OpenAI=Kz;Ne.DEFAULT_TIMEOUT=6e5;Ne.OpenAIError=_e;Ne.APIError=Gt;Ne.APIConnectionError=Bl;Ne.APIConnectionTimeoutError=jl;Ne.APIUserAbortError=sr;Ne.NotFoundError=ug;Ne.ConflictError=fg;Ne.RateLimitError=hg;Ne.BadRequestError=ag;Ne.AuthenticationError=cg;Ne.InternalServerError=pg;Ne.PermissionDeniedError=lg;Ne.UnprocessableEntityError=dg;Ne.InvalidWebhookSignatureError=Ho;Ne.toFile=TI;Ne.Completions=Ed;Ne.Chat=Wl;Ne.Embeddings=bd;Ne.Files=wd;Ne.Images=Od;Ne.Audio=Yo;Ne.Moderations=xd;Ne.Models=Pd;Ne.FineTuning=ji;Ne.Graders=tu;Ne.VectorStores=dc;Ne.Webhooks=Md;Ne.Beta=Bi;Ne.Batches=md;Ne.Uploads=nu;Ne.Responses=uc;Ne.Realtime=lc;Ne.Conversations=Zl;Ne.Evals=eu;Ne.Containers=Ql;Ne.Skills=fc;Ne.Videos=Nd;var Vn=Te("runner_codex"),Jz="Codex CLI",Zg="gpt-5.6-sol",vyt=({catchError:t,runCmd:e,error:r,result:n,runnerName:s})=>(Vn.log(`${s} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(Vn.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(Vn.log("Setting result to undefined because no valid result was captured"),{error:r||`${s} failed`,result:void 0}));async function hve({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let s=e.modelVersionOverrides?.codex?.[e.accountType];if(s){if(!await t.isModelAvailableForProvider("openai",s))throw new Error(`Model override '${s}' is not available for openai provider`);n=s}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!Zg&&await t.isModelAvailableForProvider("openai",Zg)?(n=Zg,Vn.log(`Using default model: ${Zg}`)):Zg&&Vn.log(`Default model ${Zg} is not available, proceeding without model specification`);return n}function pve({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");su.env.OPENAI_API_KEY=e,su.env.OPENAI_BASE_URL=r}else if(!su.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function Xz({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:s,continueSession:i,priorAgentSessionId:o,cwd:a=su.cwd()}){let{prompt:c}=t,{model:l}=t;pve({aiGateway:s});let u=await hve({config:t,aiGateway:s,model:l}),f=[],d=[],h=[],p={},m=new Set,g=0,y=0,T,S,_,A=`${su.env.NVM_BIN}/node`,P=e_.join(BI.homedir(),".codex"),C=e_.join(P,"config.toml"),R=e_.join(P,"auth.json");try{await Nb.mkdir(P,{recursive:!0});let G={OPENAI_API_KEY:su.env.OPENAI_API_KEY};await Nb.writeFile(R,JSON.stringify(G,null,2),"utf-8"),Vn.log("Created Codex auth.json file");let V=su.env.OPENAI_BASE_URL,Z=['forced_login_method = "api"'];V&&Z.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${V}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),await Nb.writeFile(C,`${Z.join(`
|
|
552
552
|
`)}
|
|
553
|
-
`,"utf-8"),Vn.log("Wrote Codex config.toml")}catch(G){let V=G instanceof Error?G.message:String(G);throw Vn.warn("Failed to setup Codex config and credentials",{error:V}),new Error(`Codex setup failed: ${V}`)}let O=u==="gpt-5.6",w=!!(i&&o),b="mode"in t&&t.mode==="ask",L=[cl(a,"codex"),"exec",...b?["--sandbox","read-only"]:[],...w?["resume",o]:[],...b?[]:["--yolo"],"--json",...O?["-c",'model_reasoning_effort="low"']:[],...u?["--model",u]:[]].filter(Boolean);Vn.log(`Running ${A} ${L.join(" ")}`);let I=e.utils.run(A,L,{all:!0,cwd:a,env:{...su.env},stdin:"pipe",idleTimeout:wu});I.stdin?.end(c);let v=Xd(()=>{r?.({steps:f,duration:y}),n?.({steps:d,duration:y}),d=[]},250),x=(G,V)=>{let Z={...G,id:g};g+=1,h.push(Z),f.push(Z),d.push(Z),V||v.flush(),v(),V&&v.flush()};x({title:`Using ${Jz} with ${u||"default"}`,category:ce.Environment},!0);let k=byt.createInterface({input:I.all});return k.on("error",G=>{Vn.error("Readline interface error",{error:G.message,stack:G.stack})}),k.on("line",G=>{let V;try{V=JSON.parse(G)}catch{Vn.log("Could not parse line",G);return}if(V?.duration_ms&&(y=V.duration_ms),V?.type==="thread.started"&&typeof V?.thread_id=="string"&&(_=V.thread_id),V?.type==="item.started"&&V?.item?.type==="command_execution")p[V.item.id]=V.item;else if(V?.type==="item.completed"&&V?.item?.type==="command_execution"){let Z=V.item,ue=Ayt(Z);ue&&x(ue,!0);let me=Z.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(me&&!m.has(me)){m.add(me);let Q=wc(me);Cu(Vn,Q),x({title:`Use ${Q}`,category:ce.Skill,type:me},!0)}}else if(V?.type==="item.completed"&&V?.item?.type==="reasoning"){let Z={title:"Reasoning",message:V.item.text,category:ce.Reasoning};x(Z,!0)}else if(V?.type==="item.completed"&&V?.item?.type==="agent_message")T=V.item.text;else if(V?.type==="local_shell_call"){let Z=V;p[Z.call_id]=Z}else if(V?.type==="local_shell_call_output"){let Z=V,ue=p[Z.call_id],me=Cyt(ue,Z);me&&x(me,!0);let X=(ue?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(X&&!m.has(X)){m.add(X);let oe=wc(X);Cu(Vn,oe),x({title:`Use ${oe}`,category:ce.Skill,type:X},!0)}}else V?.type==="message"&&V.role==="assistant"?T=V.content?.map(Z=>Z.text).join(`
|
|
553
|
+
`,"utf-8"),Vn.log("Wrote Codex config.toml")}catch(G){let V=G instanceof Error?G.message:String(G);throw Vn.warn("Failed to setup Codex config and credentials",{error:V}),new Error(`Codex setup failed: ${V}`)}let O=u==="gpt-5.6-sol",w=!!(i&&o),b="mode"in t&&t.mode==="ask",L=[cl(a,"codex"),"exec",...b?["--sandbox","read-only"]:[],...w?["resume",o]:[],...b?[]:["--yolo"],"--json",...O?["-c",'model_reasoning_effort="low"']:[],...u?["--model",u]:[]].filter(Boolean);Vn.log(`Running ${A} ${L.join(" ")}`);let I=e.utils.run(A,L,{all:!0,cwd:a,env:{...su.env},stdin:"pipe",idleTimeout:wu});I.stdin?.end(c);let v=Xd(()=>{r?.({steps:f,duration:y}),n?.({steps:d,duration:y}),d=[]},250),x=(G,V)=>{let Z={...G,id:g};g+=1,h.push(Z),f.push(Z),d.push(Z),V||v.flush(),v(),V&&v.flush()};x({title:`Using ${Jz} with ${u||"default"}`,category:ce.Environment},!0);let k=byt.createInterface({input:I.all});return k.on("error",G=>{Vn.error("Readline interface error",{error:G.message,stack:G.stack})}),k.on("line",G=>{let V;try{V=JSON.parse(G)}catch{Vn.log("Could not parse line",G);return}if(V?.duration_ms&&(y=V.duration_ms),V?.type==="thread.started"&&typeof V?.thread_id=="string"&&(_=V.thread_id),V?.type==="item.started"&&V?.item?.type==="command_execution")p[V.item.id]=V.item;else if(V?.type==="item.completed"&&V?.item?.type==="command_execution"){let Z=V.item,ue=Ayt(Z);ue&&x(ue,!0);let me=Z.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(me&&!m.has(me)){m.add(me);let Q=wc(me);Cu(Vn,Q),x({title:`Use ${Q}`,category:ce.Skill,type:me},!0)}}else if(V?.type==="item.completed"&&V?.item?.type==="reasoning"){let Z={title:"Reasoning",message:V.item.text,category:ce.Reasoning};x(Z,!0)}else if(V?.type==="item.completed"&&V?.item?.type==="agent_message")T=V.item.text;else if(V?.type==="local_shell_call"){let Z=V;p[Z.call_id]=Z}else if(V?.type==="local_shell_call_output"){let Z=V,ue=p[Z.call_id],me=Cyt(ue,Z);me&&x(me,!0);let X=(ue?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(X&&!m.has(X)){m.add(X);let oe=wc(X);Cu(Vn,oe),x({title:`Use ${oe}`,category:ce.Skill,type:X},!0)}}else V?.type==="message"&&V.role==="assistant"?T=V.content?.map(Z=>Z.text).join(`
|
|
554
554
|
`):V?.type==="message"&&V.role==="system"&&(S=V.content?.map(Z=>Z.text).join(`
|
|
555
555
|
`))}),await I.catch(G=>{let V=vyt({catchError:G,runCmd:I,error:S,result:T,runnerName:"Codex"});S=V.error,T=V.result}),k.close(),v.flush(),{steps:h,duration:y,result:await Mp({initialResult:T,agentName:Jz,hasError:!!S}),error:Lp({error:S,agentName:Jz}),isRetryableError:Dp(S),isProviderUnavailableError:kp(S),resolvedModel:u,effort:O?"low":"high",agentSessionId:_}}var mve=async()=>{let t=e_.join(BI.homedir(),".codex");await Nb.rm(t,{recursive:!0,force:!0});let e=e_.join(BI.homedir(),".agents","skills");await Nb.rm(e,{recursive:!0,force:!0})},gve={baseDir:e_.join(BI.homedir(),".codex"),include:["sessions"]},wyt=new Set(["bash","-lc"]),Ryt=/^sed\s+-n\s+(?:'[^']*'|"[^"]*"|\S+)\s+(\S+)\s*$/,_ve=t=>{if(cd(t))return{title:"Generating the site",category:ce.SiteGeneration};let e=t.match(Ryt);return e?{title:`Reading \`${e[1]}\``,category:ce.FileRead}:{title:`Running \`${t}\``,category:ce.RunCommand}},Ayt=t=>{if(!t||t.type!=="command_execution")return null;let e=t.command;e=e.replace(/^(\/usr\/bin\/)?bash -lc ['"]/,"").replace(/['"]$/,"");let{command:r,heredocContent:n}=CM(e),{title:s,category:i}=_ve(r),o=t.aggregated_output?.trim();return n?o=`\`\`\`
|
|
556
556
|
${n}
|